This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by akersmaanew
almost 9 years

I have no idea what is wrong and the hint is no help.

Here is what I was asked to do: 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.

Here is what I wrote def greeter(name) return “Hello to” + [name] + “.” end

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

greeter(marie)

What did I do wrong? ?????

thanks

Answer 558254e19113cb010b000017

0 votes

Permalink

It seems like string “name” in [], try to put it into ().

points
Submitted by Andromedium
almost 9 years

1 comments

melger almost 9 years

by_three is supposed to return “true” if it’s divisible by 3, not return the number divisible by 3. Needs to be an if/else statement. Stuck on that myself though.

Answer 55a675d99376766f4300018a

0 votes

Permalink

Use this code.

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

def by_three?(number)
if number%3 == 0
return true
else
return false
end
end
points
Submitted by Archisman Dinda
over 8 years