#1

Hi, I've made the exercise, and got a right answer (I think) but this is the message
"Oops, try again.
It looks like your method returns for an input of -20, when it should return 400."

Here you have the excercise and my code. Where's the problem?

Write a method, square, that takes a number as an argument and implicitly returns the square of that number.

def square(n)
puts n * n
end

square(5)

#2

They're asking to return the square, not print it, that may be what causes your issue.

#3

leave out the puts and it still works but with a green pass.

#4

It works for me, it is correct.

#5

def square(n)
n ** 2
end

#6

This works also----> My one - liner

def square(n) n ** 2 end

#7

Hi!
Indicating whether our method of square(n) holds true or not works as well.

def square(n)
n * n == square(n)? "True" : "False"
end

Cheers!

#8

Thank you, this fixed my problem! However, why does puts need to be left out? Wouldn't it work with it too?

#9

It could be like
def square(n)
n**2
end
square(7)
or
def square(n)
n*n
end
square(7)

#10

I have no idea. It is probably a bug or something.