Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

JavaScript Loops Explained: for Loops, while Loops & Off-by-One Errors | JavaScript Tutorial #5

Video information, playback and saved actions.

JavaScript Loops Explained: for Loops, while Loops & Off-by-One Errors | JavaScript Tutorial #5

Description: Stop copying and pasting! Loops let your code repeat itself, and they're one of the most powerful tools in programming 🚀

In this video, you'll learn:
✅ Why we need loops
✅ How a for loop works: start, condition, update
✅ What i++ and i-- mean
✅ The off-by-one error (less than vs less than or equal) and how to avoid it
✅ How to count down with a loop
✅ How to build a multiplication table in 3 lines of code
✅ The % remainder symbol, and how to find even numbers
✅ How while loops work, and how to avoid infinite loops
✅ How to build a star rating on a real web page with a loop

🎯 Your challenge:
Write a for loop that prints the 5 times table, from 5 x 1 to 5 x 10. Then try changing it to your favorite number!

▶️ Next episode: JavaScript Arrays, store many values in one variable

⏱️ Chapters:
0:00 Intro
0:11 The problem: copy and paste
0:24 What is a loop?
0:35 Build a for loop, piece by piece
1:05 It ran five times!
1:15 Using i inside the loop
1:29 What happens inside a loop
1:44 The off-by-one error
1:57 Counting down
2:12 A multiplication table
2:32 The % remainder and even numbers
2:54 The while loop
3:12 Careful: infinite loops
3:24 A star rating on a real page
3:53 Recap
4:20 Your challenge and what's next

🔔 Subscribe and follow BentHub for more coding tutorials, made simple.
Understand programming. Code with confidence.

#JavaScript #LearnJavaScript #LearnToCode #WebDevelopment #JavaScriptTutorial #CodingForBeginners #BentHub Close description
      
Videos related to "JavaScript Loops Explained: for Loops, while Loops & Off-by-One Errors | JavaScript Tutorial #5"