Instructions for cloning down this repository to an IDE (coding environment):
- Above the list of files, click on the
Code
button. - Copy the URL of the repository.
- If you are using Repl.it:
- Select the
+ Create Repl
button on the top left corner of the web page. - In the pop up window, select the
Import from GitHub
button - Paste the GitHub URL and click on the button
Import from GitHub
.
- Select the
Note: If you are coding along with the video, we suggest you open the video in a window on the left and your code in a window on the right. This method of coding along is called "split screen".
Javascript can be used to make mathematical tasks much less... well... mathy. In this lab, you will use for
loops to compute some math challenges without having to add hundreds of numbers by hand.
Loops in javascript allow us to automate processes that would be tedious and exhausting otherwise.
For example: Without loops, printing 100 different numbers would take 100 lines of code. With loops, we can do it in 3 lines of code. More impressively, we can bump that number up to 10,000, or even into the millions and billions without having to add extra lines of code!
Open up the loops.js file, and try to complete each of the for
loop challenges described there (written as javascript comments). Run the code after each new loop you write to see if your code works as intended. Before moving on to the next challenge, make sure to comment out all previous code. Many of the challenges can be done in at least two ways, and some can be done in ad many as 10 ways! As long as your output meets the criteria for each challenge, you're doing a great job!
Need a challenge? There are stretch activities built right into this lab!
Not sure where to start? Take a look at the example below...
Example: Code a for
loop that prints every number from 0 to 2.
for(let i = 0; i <= 2; i++) {
console.log(i)
}