Skip to main content
Participant
November 8, 2022
Answered

Animate Code - "and"

  • November 8, 2022
  • 1 reply
  • 128 views

Hi there.

I am looking for guidance on how to inset a "and" function into my code in Animate.

I am a student at [removed by moderator] and need this information for a project. 

A simple google search returned no results.

Here is my code: (The text in red is the focused code where i need the and function)


var randomNumber = Math.floor(Math.random() * 10) + 1;
var Highchoice = false;
this.Rnumber.text = "";
this.message.text = "Guess how high or low the number will be!";
var _this = this;

function chooseNumber() {
randomNumber = Math.floor(Math.random() * 10) + 1;
_this.Rnumber.text = randomNumber;
}

function checkNumber(){
if(randomNumber>5){
_this.message.text = "more than 5";
} else if (randomNumber<5){
_this.message.text = "less than 5";
}
}
chooseNumber();


function riwr(){
if(randomNumber>5) 
}


_this.chooser.on('click', function () {
chooseNumber();
checkNumber();

});

_this.HigherThan5.on('click', function (){
Highchoice = true;
console.log(Highchoice);
})
_this.LowerThan5.on('click', function (){
Highchoice = false;
})

*/

    This topic has been closed for replies.
    Correct answer kglad

    it's not clear what the other criteria is for that "and", but here are a few examplesL

     

    function riwr(){
    if(randomNumber>5 && Highchoice){

    // do something randomNumber is >5 AND Highchoice is true


    }

     

    or

     

    function riwr(){
    if(randomNumber>5 && !Highchoice){

    // do something randomNumber is >5 AND Highchoice is false


    }

     

    or

     

    function riwr(){
    if(randomNumber>5 && randomNumber<10){

    // do something randomNumber is between 5 and 10


    }

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    November 9, 2022

    it's not clear what the other criteria is for that "and", but here are a few examplesL

     

    function riwr(){
    if(randomNumber>5 && Highchoice){

    // do something randomNumber is >5 AND Highchoice is true


    }

     

    or

     

    function riwr(){
    if(randomNumber>5 && !Highchoice){

    // do something randomNumber is >5 AND Highchoice is false


    }

     

    or

     

    function riwr(){
    if(randomNumber>5 && randomNumber<10){

    // do something randomNumber is between 5 and 10


    }