Oh man, I’m not rly good at explaining that kind of stuff.
Look at the top of your code. You have var answer = ""
in there. By that, you create a variable called answer
and assign ""
(an empty string, don’t focus on this part for now).
A variable is kind of a storage box for a value. By assigning the value to the variable answer
you kind of take that value and put it into a box labeled answer
. Now, you can access that value using that particular label. For example, you can write return answer;
at the end of your function. This way, your functions output will be a value assigned to answer
.
So far so good?
Now, you can reassign the value of your variable pretty much at any time. You do it the same way you assign initially, using =
operator. Thats what you are supposed to do in this exercise. You need to change the value assigned to answer
, depending of what kind of value (1, 2, 3, 4) you were provided.
So, you have two bugs in your code. First, you are not using the assign operator where you need to.
Second, you put "N"
at the end of your return statement, I’m not rly sure what for.
facepalm Of course, I try to be too fast.
caseInSwitch is just a name for your function. You could have actually named it iLikeBananas
, would work the same way. What you need to do (along with what i have written up there) is tell Javascript that you want to use this special functionality that is switch
. In order to do it, you need to use a template that @PortableStick gave you, and place it inside your function (which is currently named caseInSwitch).