Created
February 10, 2015 22:40
-
-
Save Craigson/16ff50fbd5c5afa0ded8 to your computer and use it in GitHub Desktop.
Code snippet for HackerSchool application - Written in Javascript
This file contains hidden or 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
| /* | |
| 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