Course Content
Introduction to JavaScript
Introduction to JavaScript
3. Performing Operations in JavaScript
Understanding Assignment OperatorsMathematical Operations in JavaScriptAssignment Operators in JavaScriptIncrement and Decrement OperatorsChallenge: Variable Operations PracticeComparison Operators in JavaScriptLogical Operators ExplainedChallenge: Compare Variables in JavaScriptConcatenating Strings in JavaScriptChallenge: Build Sentences with JavaScript
4. Controlling Program Flow with Conditional Statements
5. Looping Through Data in JavaScript
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(___); };
The output should be:
python
- 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 fromΒ0
Β toΒ4
Β (5 loop iterations: 0, 1, 2, 3, 4). - Include the increment operation (
++
) for theΒi
Β counter. - Place theΒ
tiger
Β variable inside theΒconsole.log()
Β function.
let tiger = "Tiger"; for (let i = 0; i < 5; i++) { console.log(tiger); };
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 5