
For Loops - Beau teaches JavaScript
video description
Date: 2022-03-14
Related videos
Comments and reviews: 8
Max
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!
reply
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!
reply
Neenus
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
reply
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
reply
ouf
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;
reply
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;
reply
Eklavya
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?
reply
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?
reply
Garrett
Does anyone ever give an example of for loops that actually ends up on a web page, and not just -console.log-? I'm at my wits end. -document.write- and -console.log- are of no use to me.
reply
Does anyone ever give an example of for loops that actually ends up on a web page, and not just -console.log-? I'm at my wits end. -document.write- and -console.log- are of no use to me.
reply
Izaak
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
reply
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
reply
goldensleeves
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
reply
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
reply
Daniel
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
reply
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
reply
Add a review, comment















