🔥 0
0 XP
Lv.1 Beginner
FAQ
Log In
Home
JavaScript
Getting Started with JavaScript
For Loops
Sum 1 to N
1
2
3
4
5
6
7
8
9
10
Your task
Lesson: Looping with For
Exercise 4 · Chapter: For Loops
Required
+50 XP
Sum 1 to N
Read a number N, then print the sum of all numbers from 1 to N.
Example:
Input:
5
Output:
15
Need a hint?
3 available · costs 5 XP each
Reveal hint (-5 XP)
javascript
Reset
Run
Submit
9
1
Output
Run your code to see the output here.
Previous · Exercise
Fix the Range
Exercise 4 of 10
Next · Exercise
Letter Counter