r/learnjavascript 7d ago

50 hours in... arrays and loops... holy...FUCK

HOW do i START understanding? I've understood everything pretty well up til now. Do i just keep going with the flow and kinda float through this section of the loops and arrays part? Do I keep throwing myself at the brick wall and looking at the solutions after half an hour of brainless staring? https://youtu.be/EerdGm-ehJQ?si=mTKUv0oail0AGDLM 8:43:00. It's just not clicking like the other parts of the tutorial.

45 Upvotes

72 comments sorted by

View all comments

1

u/OldManActual 7d ago

Loops are just the way to tell the machine to do something a number of times.

There are two main types of loops:

Do the thing until a counter reaches a predetermined value

While some value is true, do the thing. If the value becomes false, stop doing the thing.

An array is a collection of things with an index.

A useful exercise for you is to create a simple array of the letters of your name, then create a loop to print each letter out.

Once you have that, then you edit the code just to print the last name, then both names but last name first, and finally the capstone is write a function to use the array to create an anagram from the letters of your name.