Skip to content
Advertisement

How to write the program that prints out all positive integers between 1 and given number , alternating between the two ends of the range?

The program should work as follow:

JavaScript

My code doesn’t do the same. I think there is should be the 2nd loop, but I don’t really understand how can I do it. Could you possibly give me a hint or advice to solve this task. Thanks. My code looks like this:

JavaScript

Advertisement

Answer

This should work:

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