Challenge: Console Tigers with Loops
Task
Implement a for
loop that outputs the word "Tiger" exactly 5 times.
9
1
2
3
4
5
let tiger = "___";
___ (let ___ = 0; i < ___; ___) {
console.log(___);
};
12345let tiger = "___"; ___ (let ___ = 0; i < ___; ___) { console.log(___); };
The output should be:
python912345TigerTigerTigerTigerTiger
Begin by assigning the value "Tiger" to the variable
tiger
.Utilize the
for
keyword to create the loop.Initialize the counter variable
i
.Set the range for the counter
i
to go from0
to4
(5 loop iterations: 0, 1, 2, 3, 4).Include the increment operation (
++
) for thei
counter.Place the
tiger
variable inside theconsole.log()
function.
9
1
2
3
4
5
let tiger = "Tiger";
for (let i = 0; i < 5; i++) {
console.log(tiger);
};
12345let tiger = "Tiger"; for (let i = 0; i < 5; i++) { console.log(tiger); };
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 5. Capítulo 5
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla