I am supposed to finish the provided function 'climb' shown below. Using the built-in local variable arguments, within the function climb.
This is what the function is 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."
Has to pass 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 provided function:
function climb(){
//CODE HERE - DO NOT TOUCH THE CODE ABOVE!
}
This is what I am trying and it doesn't work:
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.";
}
}