What is wrong with my code? 8/19 question


#1

def greeter(name)
return "Hello, #{name}!"
end

output = greeter("Darmian!")
puts output

def by_three(number)
return number % 3 == 0
if true
else false
end
end

by_three(4)

basically, it says "Did you define your by_three? method?". But I've defined it, and it returns false in this case. First part with greeter also works. What is wrong, help, please!


#2

by_three is different from by_three?.

Also, you should get rid of this line:

puts output

#3

I hope this helps

if true
else false
end

The if statement %3 == 0 already has a true or false value.

There really is no need for ?. I don't know why the tutorial recommends this.

If you do use a ? like name? then you will need to call name? at the end. This is why the code is throwing an error

3.

Solution is below

A # below indicates a comment to ruby

Hope this helps!

def greeter(name)
return "Hello" + " " + name #Sorry this is the Jscript style. Your code here is also fine.
end

def by_three(number)
return number % 3 == 0 # This returns true or false. Remember == means "check if left is equal to right"
#return true if left is the same as right.
end

greeter("Ashley!") # Starts greeter with an input of "Ashley"
by_three(4) # Starts by_three with an integer input of 4