Created
August 22, 2017 13:10
-
-
Save swaraj89/ed5d85b58e54e3d0194c465885fa514b to your computer and use it in GitHub Desktop.
Write a program to print a sequence from 0,1,2,3,....n,n-1,n-2.....0 in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSeries(limit){ | |
var series = ""; | |
var counter = 1; | |
for(var i=1; i>0; i+=counter){ | |
if(i==limit){ | |
counter= -1; | |
} | |
series += (i + " "); | |
}; | |
return series; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment