Challenge: Print Numbers from 5 to 9
Task
Let's implement a while loop that outputs numbers from 5 to 9 to the console.
123456let a = 5; ___ (a ___ ___) { console.log(___); ___++; };
The output should be:
5
6
7
8
9
- Set the condition to a
<= 9
ora < 10
. - Include the variable
a
within theconsole.log()
function. - Increment the value of
a
inside the loop.
123456let a = 5; while (a <= 9) { console.log(a); a++; }
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 5. Capítulo 3
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Suggested prompts:
Can you explain how the while loop works in this example?
What would happen if we changed the starting value of 'a'?
Can you show how to do the same with a for loop?
Awesome!
Completion rate improved to 2.33
Challenge: Print Numbers from 5 to 9
Deslize para mostrar o menu
Task
Let's implement a while loop that outputs numbers from 5 to 9 to the console.
123456let a = 5; ___ (a ___ ___) { console.log(___); ___++; };
The output should be:
5
6
7
8
9
- Set the condition to a
<= 9
ora < 10
. - Include the variable
a
within theconsole.log()
function. - Increment the value of
a
inside the loop.
123456let a = 5; while (a <= 9) { console.log(a); a++; }
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 5. Capítulo 3