Methods, Blocks and Sorting Exercise 8/19


#1

Hi! I would appreciate your help in pointing out the problem in my code. I read other posts related to this exercise and tried the solution but it didn't work. It kept stating "It looks like your greeter method prints to the console instead of using return". Below is my code:

def greeter(name)
return name
end

input = greeter("edmund")
puts input

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

input = by_three?(9)
puts input


#2

Don't use
input = greeter("edmund")
puts input

its printing your "edmund" not getting returned by method.

use this:
def greeter(name)
return "Welcome" + name + "."
end
greeter(" your name")


#3

Thanks for the answer :smile: rajpurohit01


#4

Welcome bud. :wink: i also stucked in same issue when i was doing this course.


#5

Sharing my full code :slight_smile: thanks for this!

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

p greeter(“mark”)

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

p by_three?(9)
p by_three?(10)
p by_three?(3)