VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
For Loops - Beau teaches JavaScript

For Loops - Beau teaches JavaScript

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
For loops are one of the most common ways to repeat things in JavaScript. Code: - http://codepen.io/beaucarnes/pen/YZyWxY?editors=0012 More info: - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for Beau Carnes on
Date: 2022-03-14

Comments and reviews: 8


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

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

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

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

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

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

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

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






Other channel videos