Let's try creating a simple if and else statement that checks the score.
If the score is more than 80, let's print 'Congratulations!'
. Else, print 'It's ok, try harder next round.'
First, we have to initialise the score. You can give the score of 40 or any value that you want to check.
let score = 40;
if (score >= 80){
console.log("Congratulations!!!");
}
else
console.log("It's ok, try harder next round.");
🎉 Now, you have created a if and else statement successfully! Try the exercise below!
If i'm hungry, I want the application to print "I'm hungry!!!Feed me now!!!!"
. If i'm not, i want it to print "I'm not hungry"
.
Want Answer? Press me!
let hungry = false;
if (hungry){ //hungry === true
console.log("I'm hungry!!!Feed me now!!!!");
}
else
console.log("I'm not hungry");