Practice Makes Perfect: Correct code getting error, HELP!


#1

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

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

Oops, try again.
It looks like your greeter method prints to the console instead of using return.

#2

Figured it out, It was because I had some commented out code that was apparently effecting it


#3

def greeter(name)
return "hello "+ name +" "
end

def by_three?(n)
if n % 3 == 0
return "True"
else
return "False"
end
end

puts greeter("abcd")
puts by_three?(45)

I get the same error


#4

How about that:

name = "hi"
def greeter(name)
return "Greetings "+name
end

number = 7

def by_three? (number)
number % 3 == 0
end

It is a lot easier!


#5

def greeter(name)
return ("greeting"+name)
end
def by_three?(number)
(number %3 ==0)?(return true): (return false)
end
greeter("abc")
by_three?(30)

that answer!