Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. What's Wrong with this javaScript code?

What's Wrong with this javaScript code?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lexan
    wrote on last edited by
    #1

    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);
    answer=first+second;
    question=first+"+"+second;
    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

    object.qml
    @Image{
    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

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved