Created
December 14, 2017 01:43
-
-
Save silveimar/8fc2557d01b6dc547a0b1a7efbc0b131 to your computer and use it in GitHub Desktop.
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
//NodeJS | |
function printNumbers(){ | |
for (number = 1; number <= 100; number++) { | |
const result = getStringToPrint(number) | |
console.log(result); | |
}; | |
} | |
function getStringToPrint(number){ | |
let stringResult = number; | |
divisibleBy3 = number % 3; | |
divisibleBy5 = number % 5; | |
if(divisibleBy3 === 0 && divisibleBy5 != 0){ | |
stringResult = 'Crackle'; | |
} | |
else if(divisibleBy5 === 0 && divisibleBy3 != 0){ | |
stringResult = 'Pop'; | |
} | |
else if(divisibleBy3 === 0 && divisibleBy5 === 0){ | |
stringResult = 'CracklePop'; | |
} | |
return stringResult; | |
} | |
printNumbers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment