Defining 2 Methods


#1

Please help. There was no clear example of this code.

Define two methods in the editor:

A greeter method that takes a single string parameter, name, and returns a string greeting that person. (Make sure to use return and don't use print or puts.)
A by_three? method that takes a single integer parameter, number, and returns true if that number is evenly divisible by three and false if not.

This is my code below:

def greeter(name)
return "Hello"
end

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


#2

Hi this part

if !(number % 3 == 0)
return false
end

Why dont you use a else statement like that

else 
    return false

And you should add a end to close the Method by_three?


#3

the first part of the code is not working. How do you add a greeter code again?


#4

The greeter should be like that

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

And then you should call greeter like that

greeter("type your name here")

#5

thank you. the notes didn't give an example like this.


#6

def by_three?(number)
(number % 3).zero?
end


#7