Created
April 11, 2020 12:40
-
-
Save nicokosi/ebf6a3ba15d6f5b422435b78c93cf117 to your computer and use it in GitHub Desktop.
FizzBuzz en javaScript https://cyber-dojo.org/kata/edit/EXa7qp
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
'use strict'; | |
module.exports = { | |
answer | |
}; | |
function answer(number) { | |
if (number % 15 === 0) { | |
return "FizzBuzz"; | |
} | |
if (number % 5 === 0) { | |
return "Buzz"; | |
} | |
if (number % 3 === 0) { | |
return "Fizz"; | |
} | |
return number; | |
} |
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
'use strict'; | |
const hiker = require('./hiker.js'); | |
const assert = require('assert'); | |
assert.equal(hiker.answer(1), 1); | |
assert.equal(hiker.answer(3), "Fizz"); | |
assert.equal(hiker.answer(5), "Buzz"); | |
assert.equal(hiker.answer(15), "FizzBuzz"); | |
// - - - - - - - - - - - - - - - - - - - - - - | |
const greenTrafficLightPattern = function() { | |
return 'All tests passed'; | |
}; | |
console.log(greenTrafficLightPattern()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment