Skip to content

Instantly share code, notes, and snippets.

@schan90
Last active April 21, 2017 06:03
Show Gist options
  • Select an option

  • Save schan90/46548162fa39de76ecfe236099a3d265 to your computer and use it in GitHub Desktop.

Select an option

Save schan90/46548162fa39de76ecfe236099a3d265 to your computer and use it in GitHub Desktop.
cs-monkeyCount
//var userInput = prompt("Enter a number:");
var userInput = 7;
function monkeyCount(n) {
var result = '[';
for(var i=1; i<=n; i+=1){
if(i!=n) {
result += (i+", ");
console.log(i);
}
else if(i=n){
result += i+']';
}
}
return result;
}
console.log(monkeyCount(userInput));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment