settingsAccountsettings
Menusettings

Q: Print Numbers from 1 to N

+9 votes

You are given a number N. Create a program that loops through all of the numbers from 1 to N and prints them. N will always be positive.

Examples:

 

Input

Output

 

Input

Output

5

1

2

3

4

5

 

2

1

2

 

asked in JavaScript category by user Jolie Ann

1 Answer

+1 vote
 
Best answer

Here's the answer:

function printNumbers(args) {
  let input = args[0];
  for (var i = 1; i <= input; i++) {
    console.log(i);
  }
}
answered by user matthew44
edited by user golearnweb
...