Created
June 9, 2017 23:06
-
-
Save anonymous/6892fde97d13472df2f62378b23c655f to your computer and use it in GitHub Desktop.
fizzBuzzDrillJS2 created by dtstanley - https://repl.it/Ieut/9
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
function fizzBuzz(countTo) { | |
console.log("initial countTo = ", countTo); | |
var newCountTo = []; | |
for (var i =0; i< countTo.length; i++){ | |
//compare countTo[i] to 15 and chg countTo[i] to fizzBuzz | |
if (countTo[i]%3 ==0 && countTo[i]%5 ==0){ | |
newCountTo[i] = 'fizzbuzz'; | |
} | |
//compare countTo[i] to 5 and chg countTo[i] to buzz | |
else if (countTo[i]%5 ==0){ | |
newCountTo[i] = 'buzz'; | |
} | |
//compare countTo[i] to 3 and chg countTo[i] to fizz | |
else if (countTo[i]%3 ==0){ | |
newCountTo[i] = 'fizz'; | |
} | |
else { | |
newCountTo[i] = countTo[i]; | |
} | |
console.log("looped countTo = ", countTo[i]); | |
console.log("looped newCountTo = ", newCountTo); | |
} | |
return newCountTo; | |
} | |
fizzBuzz([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment