Skip to content

Instantly share code, notes, and snippets.

@swaraj89
Created August 22, 2017 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swaraj89/ed5d85b58e54e3d0194c465885fa514b to your computer and use it in GitHub Desktop.
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
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