Pagina de inicio
/
Tecnología
/
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

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

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

Solución

avatar
Mayraprofessionell · Tutor durante 6 años
expert verifiedVerificación de expertos
4.0 (240 votos)

Responder

The given code will not run correctly due to syntax errors. The correct syntax for a while loop in JavaScript is:<br /><br />```javascript<br />let i = 0;<br />while (i < 10) {<br /> console.log("hello");<br />}<br />```<br /><br />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.
Haz clic para calificar: