Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Console Tigers with Loops | Looping Through Data in JavaScript
Introduction to JavaScript

book
Challenge: Console Tigers with Loops

Task

Implement a for loop that outputs the word "Tiger" exactly 5 times.

let tiger = "___";

___ (let ___ = 0; i < ___; ___) {
console.log(___);
};
12345
let tiger = "___"; ___ (let ___ = 0; i < ___; ___) { console.log(___); };
copy

The output should be:

python
Tiger
Tiger
Tiger
Tiger
Tiger
  1. Begin by assigning the value "Tiger" to the variable tiger.

  2. Utilize the for keyword to create the loop.

  3. Initialize the counter variable i.

  4. Set the range for the counter i to go from 0 to 4 (5 loop iterations: 0, 1, 2, 3, 4).

  5. Include the increment operation (++) for the i counter.

  6. Place the tiger variable inside the console.log() function.

let tiger = "Tiger";

for (let i = 0; i < 5; i++) {
console.log(tiger);
};
12345
let tiger = "Tiger"; for (let i = 0; i < 5; i++) { console.log(tiger); };
copy

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 5. Capítulo 5

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt