Skip to content
Advertisement

Print out the numbers from the for loop

The Return type is void

No input parameters

Print out the numbers calculated results separated by a space using current number add the next number from 0 to (a+b).

An example would be if the numbers for the for loop are 0,1,2,3,4,5,6 then it would add 0+1, 1+2, 2+3, 3+4, 4+5, 5+6 and print out those values just like 0,1,2,3,4,5,6.

I honestly have no clue how to do this so I’m not going to lie about it so can someone help me code it and explain or just help me with it.

JavaScript

Advertisement

Answer

I believe this should do the trick:

JavaScript

Test case (array):

JavaScript

Outputs:

JavaScript

Note: The array size does not matter.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement