Javascript Function Parameter

Hello.

I don’t know a lot about coding. When I faced this challenge “Selecting from Many Options with Switch StatementsPassed” on Basic Javascript curriculm, I was taken aback.

function caseInSwitch(val) {
var answer = “”;
// Only change code below this line

// Only change code above this line
return answer;
}

caseInSwitch(1);

How come the local variable answer returns the parameter val without assignment? I am not aruging it’s wrong. My beginner’s brain doesn’t understand how this works without assigning val to answer.
I would have written this below if this challenge required the full code.

var answer = val;

the challenge link

You don’t have provided the challenge link, so I do not have well in mind the context of this challenge, but I don’t think that val is already the answer, you need to use val in some way, and probably depending on the value of val you need to determine the value of answer

1 Like

Hello. Here is the link below.

yeah, my explanation above was correct

1 Like