Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution for FizzBuzz #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ GEM

PLATFORMS
ruby
x64-mingw-ucrt

DEPENDENCIES
rspec (~> 3.0.0.beta2)

BUNDLED WITH
2.4.10
13 changes: 9 additions & 4 deletions lib/fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class SuperFizzBuzz

def run(input)

#Implement your code here

if (input % 3 == 0 and input % 5 == 0)
"FizzBuzz"
elsif input % 5 == 0
"Buzz"
elsif input % 3 == 0
"Fizz"
else input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We put the body of the else clause on its own line.

Suggested change
else input
else
input
if var.check?
  the_truthy_thing
else
  the_falsey_thing
end

end
end

end

#You don't necessarily need to execute this script to complete this challenge, but how would you "run" this method (pun intended) so that it printed a value to the terminal?
#
#puts SuperFizzBuzz.new.run()
#HINT: it's an instance method.
7 changes: 4 additions & 3 deletions spec/fizzbuzz_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
end

it "returns 'Buzz' when my input is divisible by 5" do
#implement your test here
expect(script.run(5)).to eq "Buzz"
end

it "returns 'FizzBuzz' when input is divisible by 3 & 5" do
#implement your test here
expect(script.run(15)).to eq "FizzBuzz"
end

it "returns the input number when input isn't divisible by 3, 5, or both" do
#implement your test here
expect(script.run(16)).to eq 16
expect(script.run(7)).to eq 7
end
end