0
Need help!!! :)
What is the output of this code? document.vvrite("S"); for(var i =1; i <=4; i++) { if(i%2 === 0) { document.vvrite("l"); }else { document.write("o"); } } document.vvrite("earn");
3 Answers
+ 15
Joshua there's nothing bad if someone want to understand how a quiz works, if Ionut wanted just to know the answer he could check the "View Correct Answer", that's not the case!
Output is "Sololearn"
1) Code prints "Solo" at the beginning of the script
2) When i % 2 == 0 it prints "l", when i % 2 == 1 it prints "o", in a for loop from 1 to 4 we'll have:
1 % 2 = 1 = "o"
2 % 2 = 0 = "l"
3 % 2 = 1 = "o"
4 % 2 = 0 = "l"
... Now we have: "Solol".
3) The code prints "earn", we'll have:
"Solol" + "earn" = "Sololearn".
+ 6
good Expln @Maz
- 2
sololearn