Kristen Kerchhoff1,895 Points
Methods working locally but in online editor
When I run the methods in this file locally the correct numbers are returned.
However when I run this in the online editor as part of a challenge task it returns "wrong number of arguments (given 0, expected 2)"
Could someone please advise what the correct format should look like?
def three(length, width) return length + width end def five(length, width) return length - width end puts three(1, 2) puts five(7, 2)
Jason AndersTreehouse Moderator 143,733 Points
While the code above is correct in syntax, it is not what the Challenge is asking for. I'm not sure where you are getting the code from, but instructions for Code Challenges need to be followed exactly or the task will fail with a
You are getting that error because there are supposed to be no arguments for the methods, but you have two in both. The instructions simply say to:
Define a method named three that returns the number 3. Also define a method named five that returns the number 5.
The instructions say nothing about calculations or even calling the methods, nor do they say anything about arguments.
A good rule to remember is: "If the instructions don't ask for it... don't do it."
I feel you just really over thought this one. The methods just needs to be simplified:
def three() return 3 end def five() return 5 end
Other than that... Nice work on the method syntax! :)