Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fc4ff93

Browse files
Update FizzBuzz objective and logic
1 parent 0a7e14b commit fc4ff93

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎1_Fizz-Buzz/index.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Classic Fizz-Buzz
2-
// Write a function that takes in a number and will return "Fizz" if it's divisible by 3, "Buzz" if divisible by 5, or "Fizz-Buzz" if divisible by 15
2+
// Write a function that takes in a number and will return "Fizz" if it's divisible by 3, "Buzz" if divisible by 5, or "Fizz-Buzz" if divisible by both
33

44
const fizzBuzz = num => {
5-
if (num % 15 === 0) {
5+
if (num % 3===0&&num%5 === 0) {
66
return 'Fizz-Buzz'
77
} else if (num % 3 === 0) {
88
return 'Fizz'
@@ -22,7 +22,7 @@ console.log(fizzBuzz(4))
2222
// or using a Ternary expression
2323

2424
const fizzBuzzTernary = num => {
25-
return num % 15 === 0
25+
return num % 3===0&&num%5 === 0
2626
? 'Fizz-Buzz'
2727
: num % 3 === 0
2828
? 'Fizz'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /