8. Practice Makes Perfect (Methods, Blocks, & Sorting)


#1

Hello,

Can anyone please help? This code is for "8. Practice Makes Perfect" (Methods, Blocks, & Sorting).

In the console, I can get the by_three? part to print, but the greeter part doesn't.

Thank you!

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

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

greeter("Ecchan")
by_three?(4)

#2

You're not printing anything. You are simply returning, you should still print the results. The reason that it is printing by_three correctly, is that Codecademy evaluates and prints the last statement for debugging purposes.


#3

Sorry, I meant "return." Then, is it okay that the console did not display "Hi, Ecchan!" and only "false?"


#4

For checking how some methods run in the console you can create a new variable which is equal to an array of called methods with different arguments:

new_var = [greeter("Ecchan"), by_three?(4)] # Will give your result of two methods to the console

#5

Great, thanks for your input and help.