Problemas
How many times will the following program print "hello"? let i=0: while(i< 10) f console.log("hello"); 10 11 9 This code will loop infinitely
Roztwór
Mayra
professionell · Tutor durante 6 años
4
(240 Votos)
Respuesta
The given code will not run correctly due to syntax errors. The correct syntax for a while loop in JavaScript is:```javascriptlet i = 0;while (i < 10) { console.log("hello");}```In this corrected code, the while loop will execute as long as `i` is less than 10. The loop will print "hello" 10 times, and then the loop will exit when `i` becomes 10. Therefore, the correct answer is 10.