For Loops - Beau teaches JavaScript

preview_player
Показать описание
For loops are one of the most common ways to repeat things in JavaScript.

Code:
More info:

⭐JavaScript Playlists⭐

-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

Рекомендации по теме
Комментарии
Автор

The nested array part makes me wanna dropkick a toddler.

FreelanceFadi
Автор

Loops are used to access arrays using the index of its elements.

Nested arrays needs nested loops as a result.
1st loop to access the outer array &
2nd loop to access the inner one.
var arr = [0, 2, [3, 2], 7];
arr[0] = 0;
arr[1] = 2;
arr[2] = [3, 2];
arr[2][0] = 3;
arr[2][1] = 2;
arr[3] = 7;

oufcena
Автор

Thank you very much for this. I was struggling to get a good understanding of this section in Code Academy but you've broken it down in a way that's given me a lightbulb moment

izaakchater
Автор

always forget this for loop.
thanks for the
keep doing !

Paltibenlaish
Автор

Thank you so much! This one had my head spinning.

nicolejsaunders
Автор

What a beautiful thing to say! "Use your code for good!" WOW!!!

cinammondream
Автор

thanks for the easy explanation, just learning how to program, couldn't grasp the for loop until this video.

Sage
Автор

Thanks Beau, I needed a break; to fix my for loop… many thanks 😊

fabriciohlgn
Автор

Thank You for sharing the knowledge. I really like Your videos, because You touch the topic a little bit deeper than just very very basics. I really start to understand stuff because of You. Your tutorials are highly appreciated. Liked and subscribed, my man.

veetoutas
Автор

Very good explanation, real teacher value here.

janosvegh
Автор

I am confused just because I feel like the first for loop for variable i could be sufficient to display the whole array. Is there a reason there is a second for loop?

Urmomsstockings
Автор

My output seems to be overlapping while debugging in Chrome Browser Dev tool. I found the bug when I used the tab '\t' between nested loop. Anyone has idea why the chrome is behaving that way?

eklavyasharma
Автор

Great video! It's very confusing how i++ happens AFTER each loop but it's placed at the beginning. Your video helped me see that was true. Thank you

goldensleeves
Автор

Great explanation thank you ... can I just ask is that jsfiddle that you are using?? if yes how did you show the console?? I'm new to all of this and I'm trying to do this so I can test my javascript while learning but I can't figure out how to show the console ... so far I've been using the console in developer tools in Chrome

neenus
Автор

Thanks Beau, awesome tutorial! Just 1 question: I don't understand the output flow of 'console.log(arr[ i ] [ j ])'.
I tried to output the log of 'console.log(arr[ j ])', the result was like :
(2) [1, 2]
(2) [3, 4]
(2) [1, 2]
(2) [3, 4]
(2) [1, 2]
(2) [3, 4]

and also tried 'console.log(arr[ i ])', it was like:
(2) [1, 2]
(2) [1, 2]
(2) [3, 4]
(2) [3, 4]
(2) [5, 6]
(2) [5, 6]

why does it always output 6 times? why on the first example, the loop didn't find the array [5, 6]?
Thanks for your great tutorial again!

vmax
Автор

About the first example, why would you add an if statement which is totally opposite of the initial condition? Why not just say from the beginnin i<3 in the for condition?

danielstoicamusic
Автор

nice.. which text editor are you using that comes with a console?

cyrilmacauley
Автор

What is the practical appilcation to this? I mostly get it and how it works wouldn't know what to do with it though...

Fishfood
Автор

what if the variable just holds one number?

orion.
Автор

how do you increment by two when looping thru an array?

zachferell