I am still very new to javascript so I apologize if this is annoying. So I have this really odd problem that I am unfamiliar with and trying to solve. I am to finish the function 'climb' which I have listed below. I am required to use the built-in local variable arguments, within the function climb. I can NOT alter the function to take in parameters, the purpose of this exercise is to use the local arguments variable within the function scope. Any help is greatly appreciated! Thanks in advance.
This is what the function has to do:
If there is a string at arguments[0] but arguments[1] is falsy, return "On belay?".
If there is a string at arguments[0], and true at arguments[1],
return "Climbing!"
Otherwise, return "Let's set up the belay rope before we climb."
It also has to pass all of these tests:
should be a function that does not have built-in parameters
should return "Let's set up the belay rope before we climb." if called as climb()
should return "Climbing!" if called with climb("Benny", true)
should return "Climbing!" if called with climb("any string here", true)
should return "On belay?" if called with climb("Benny", false)
should return "On belay?" if called with climb("any string here")
Here is the start of the function I am provided with:
function climb(){
//CODE HERE - DO NOT TOUCH THE CODE ABOVE!
}
Here is what I am trying:
function climb(){
//CODE HERE - DO NOT TOUCH THE CODE ABOVE!
if(arguments[0]){
if(arguments[1]==false){
return "On belay?";
} else {
return "Climbing!";
}
} else {
return "Let's set up the belay rope before we climb.";
}
}
This passes all the tests except for this one:
should return "On belay?" if called with climb("any string here")