JavaScript Tutorial For Beginners #17 - For Loops

preview_player
Показать описание
An easier way to iterate through a loop is via the for loop, which we'll talk about in this JavaScript tutorial. A for loop does exactly the same thing as a while loop, but it has the advantage of organizing it's components more locally and neater.

As always, if you have any questions, fire ahead with them below :).

========== JavaScript for Beginners Playlist ==========

========== CSS for Beginners Playlist ==========

========== HTML for Beginners Playlist ==========

========== The Net Ninja ============

========== Social Links ==========

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

I found that thinking of them like this helps: A 'for loop' states a specific amount... for this many times; a 'while loop... while this is happening... not a specific amount'

vincecaruso
Автор

These vids really suit my ( early stages ) learning style. No queries yet but so good to be able to go over these points without taking up too much time.

bobcocksedge
Автор

Thank you so much for this I really appreciate the time and effort you put into these vids.

raphaelboateng-amponsah
Автор

You do need 'var' keyword for 'for' loop variable, otherwise you create a global variable which remains while page lives. Let alone cases when you recursively call a function containing 'for' loop. And if you use ECMA6 then 'let' variable is even better for 'for' loop.

mikhailbisserov
Автор

your videos are so easy to understand. Can you please do an example of how to create the game hangman using JS? Or other games?

adb
Автор

Can you add another video showing different problems utilizing the for loop?

evanman
Автор

Great tutorials lads. Nothing better than showing 'actual examples' like looping through links, then just going over the fundamentals.

davidmchale
Автор

The string "this is link number" is misleading isn't it? The code doesn't really display the link. The for loop only use the length of the links variable to display it 6 times. It has nothing to do with the content inside the <a> tags. You writing the code that way, as a beginner I was thinking the script get those elements and stores in a variable, then display them in console.

joshjakkrit
Автор

hi there, great videos, really learning alot from your playlist of this series. Just a quick question, you dont seem to be using var to declare the new variables within the for loops, the code still seems to work, so just wanted to confirm, is var not required within the for loop or is it good practice to use it. e.g. you did:

- for (age = 5; age < 10; age++) however should i be doing:
- for (var age = 5; age < 10; age++) instead.

Thanks again.

sagshah
Автор

everything's better explained in british accent

pablobiedma
Автор

dude good work! for your links example there is a possibility that the JS executes before the HTML completes loading so you might want to handle that

prab
Автор

You speak a bit too fast but at the same time it is the best explanation ever
Thank you!

rendezvousss
Автор

I have a question that has been bugging me for some time now. If I wanted to use the variable i inside the loop, to let's say push an 'input to the alert' into an array of objects, how would I go about that?

shawnzain
Автор

What would be a typical usage case where a "for" loop would be preferable to using a "while" loop, other than to reduce clutter? Thanks again for the great content!

seanearnest
Автор

I gave each element an id assignment because the console read an error for getElementByTagname The console logged 5 links and printed out.

lonw.
Автор

When I put '"links.length" nothing shows up on my screen, but the moment I change it into a number; the loops show up. lol?

brocklesnarufcchamp
Автор

Thanks sirrr...amazing explanation.. 👏

sahiraahamed
Автор

thank you for all the info man... btw what type of text editor is that? look amazing!

alimansour
Автор

I need help. Do you know how to turn off errors that are showing in brackets (probably new version) in js files on some codes which are absolutely correct. I just done the same code that is in the videos but those red circle errors keep showing on some codes.

GameNon-Quitters
Автор

I started the while loop without age++, my PC is working well but the debugging has been crashed. when I started the debugging I get at the deprecated debugger for chrome, and i am no longer can start debugging in VS. Is there any solution for my problem?

ammarobeid
join shbcf.ru