The Countdown Clock
EasyAcc. 98.7%
+15 XP 5
Counting Down
Usually, for loops count upwards. But by changing the starting point and using a decrement operation, you can walk backward through time.
The Assignment
Your function receives a parameter named startValue.
- Write a
forloop that initializes a variableito exactly the value ofstartValue. - The loop should continue as long as
iis greater than or equal to 1. - Move the value of
idownward by 1 in each step. - Inside the loop, print the current value of
i.
01EXAMPLE 1
Input
startValue = 10Output
10
9
...
1Explanation: Counts down from 10 to 1.
02EXAMPLE 2
Input
startValue = 3Output
3
2
1Explanation: Counts down from 3 to 1.
Constraints
- Use a standard for loop.
- Print each number on a new line.
LoopsFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
startValue10
Expected Output
10 9 8 7 6 5 4 3 2 1
Click RUN to test your solution