What's Wrong with this javaScript code?

  • Hi everyone. What do you think I am missing out on this code?

    @function ont(question,answer){
    var r=level;
    if(r == 0){
    first= Math.floor(Math.random()*19+1);
    second= Math.floor(Math.random()*19+1);
    return question;
    return answer;

    The purpose of the code above is to return the question and answer to be used as a property of a qml file named object

    property string answer: Logic.ont();
    Text {
    id: query
    text: qsTr(" "+Logic.ont())


    As you will notice, the question will be displayed as a text while the answer will be a property of that object. while the questions seems to be displayed properly. im having a problem about the answer. i cant verify the correct answer and i dont know what went wrong

    can you help me guys? thanks

  • Moderators

    You are using 2 return statements... function will end after the first one. The second one (line 9.) will never get returned.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.