Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

write an if statement that displays \ok\ if userage is between 10 and 2…

Question

write an if statement that displays \ok\ if userage is between 10 and 20 inclusive.
1 let userage = 12; // your code will be tested with multiple values, not just 12.
2
3 / your solution goes here /
4

Explanation:

Step1: Check if userAge is greater than or equal to 10

Use the condition userAge >= 10

Step2: Check if userAge is less than or equal to 20

Use the condition userAge <= 20

Step3: Combine the two conditions with a logical AND

Use && to combine the two conditions. So the full if statement is if (userAge >= 10 && userAge <= 20) { console.log("OK"); }

Answer:

if (userAge >= 10 && userAge <= 20) { console.log("OK"); }