Pagina de inicio
/
Tecnología
/
6. What will be displayed in the console when the following program runs? var count =8 while (count Im 5 ) ( console. log(count); count=count +2; A. 0246 B. 024 C. 246 D. The program will result in an infinite loop

Problemas

6. What will be displayed in the console when the following program runs?
var count =8
while (count Im 5 ) (
console. log(count);
count=count +2;
A. 0246
B. 024
C. 246
D. The program will result in an infinite loop

6. What will be displayed in the console when the following program runs? var count =8 while (count Im 5 ) ( console. log(count); count=count +2; A. 0246 B. 024 C. 246 D. The program will result in an infinite loop

Solución

avatar
Miguelveterano · Tutor durante 9 años
expert verifiedVerificación de expertos
4.0 (265 votos)

Responder

The correct answer is B. The numbers displayed in the console will be 8, 10.

Explicar

## Step 1<br />The given program is a simple while loop in JavaScript. The loop will continue to execute as long as the condition inside the parentheses is true.<br /><br />## Step 2<br />The variable 'count' is initially set to 8. The condition inside the parentheses is 'count < 5'. This means the loop will continue to execute as long as 'count' is less than 5.<br /><br />## Step 3<br />The loop will execute once, printing the current value of 'count', which is 8. Then, the 'count' variable is incremented by 2, making it 10.<br /><br />## Step 4<br />The condition 'count < 5' is now false, as 10 is not less than 5. Therefore, the loop will stop executing.
Haz clic para calificar: