Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

what text will be output by the program? var score = 0 score = score + …

Question

what text will be output by the program?

var score = 0
score = score + 10
score = score + 10
score = score + 10
if( score < 10 ){
console.log( \less than 10\ );
} else if ( score < 20 ) {
console.log( \less than 20\ );
} else if ( score < 30 ) {
console.log( \less than 30\ );
} else {
console.log( \30 or more\ );
}

less than 30
30 or more
less than 10
less than 20

Explanation:

Step1: Calculate the value of score

Initially, score = 0.
Then, score = score + 10 (three times).
So, score=0 + 10+10 + 10=30.

Step2: Evaluate the if - else if - else conditions

Check if(score < 10): \(30<10\) is false.
Check else if(score < 20): \(30<20\) is false.
Check else if(score < 30): \(30<30\) is false.
Since all previous conditions are false, execute the else block.

Answer:

30 or more