Task of Challenge #01/54
Print numbers from 1 to 10 with a for-loop
.
Solution
Explanation
We just need to print out ten numbers to the console prompt. A for-loop
is the perfect tool for this job! We create a loop with a running index of i
with the starting value of 1.
The loop will stop once i
reaches the value of 11, so when i
equals 10, the loop will execute the last execution because we created the condition of i <= 10
.
The running index will be increased by 1 every iteration. i++
is the corresponding statement for that. It is the short form for i = i+1
.
Inside the loop we got our statement of console.log(i);
which prints out, whatever is inside the brace, to the console window.
Follow me on Instagram and don’t miss the latest Challenge!
https://www.instagram.com/arnold.code/
Gather more Knowledge about JavaScript?
Here are two pre-picked and high quality Medium articles for you.
Quick 3-Minute Guide for the Monday Morning about https://t.co/thEjiQhZR6() @JS_PlainEnglish https://t.co/thEjiQhZR6() https://t.co/Fg4ky3xvn9 #javascript #learning #coding #Frontend #Developer #programmer #Guide #tutorial #Fastlane #QuickHits #easyaccess #learntocode
— ArnoldCode (@ArnoldAbrahamP1) March 29, 2021
Document object model Free DOM Guide for everyone!https://t.co/yjO6OMy3uy#HTML #html5 #htmlcss #htmlcode #htmlemail #htmlcoding #medium #tutorial #Tutorials #WritingCommunity #webdesign #website #web #webdesigner #webdevelopment #WebDeveloper #code #coder #CodersTeach #coder
— ArnoldCode (@ArnoldAbrahamP1) December 23, 2020