Skip to content

Instantly share code, notes, and snippets.

@silveimar
Created December 14, 2017 01:43
Show Gist options
  • Save silveimar/8fc2557d01b6dc547a0b1a7efbc0b131 to your computer and use it in GitHub Desktop.
Save silveimar/8fc2557d01b6dc547a0b1a7efbc0b131 to your computer and use it in GitHub Desktop.
//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