QUESTION IMAGE
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
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.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
30 or more