Skip to content

Instantly share code, notes, and snippets.

@Craigson
Created February 10, 2015 22:40
Show Gist options
  • Select an option

  • Save Craigson/16ff50fbd5c5afa0ded8 to your computer and use it in GitHub Desktop.

Select an option

Save Craigson/16ff50fbd5c5afa0ded8 to your computer and use it in GitHub Desktop.
Code snippet for HackerSchool application - Written in Javascript
/*
Written by Craig Pickard for HackerSchool Application for Summer Batch 1, 2015
Language: Javascript
This code prints out integers 1-100 (inclusive), replacing every integer value that's divisible by 3 with the string "Crackle",
every integer that's divisible by 5 with the word "Pop", and every integer that's divisible by both 3 and 5 with
the string "CracklePop".
*/
var snapList = [];
for (var i = 1; i < 101; i++){
if (i%3 == 0 && i%5==0){
snapList.push("CracklePop");
} else if (i%3 == 0){
snapList.push("Crackle");
} else if (i%5 == 0){
snapList.push("Pop");
} else {
snapList.push(i);
}
}
console.log(snapList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment