# Selecting from many options with Switch Statements (Not understood)

**URL:** <https://forum.freecodecamp.org/t/selecting-from-many-options-with-switch-statements-not-understood/156205>\
**Category:** General\
**Created:** [October 31, 2017, 2:39pm UTC](https://forum.freecodecamp.org/t/selecting-from-many-options-with-switch-statements-not-understood/156205 "2017-10-31T14:39:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mittalyashu77](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mittalyashu77](https://forum.freecodecamp.org/u/mittalyashu77)\
**Post date:** [October 31, 2017, 2:39pm UTC](https://forum.freecodecamp.org/t/selecting-from-many-options-with-switch-statements-not-understood/156205/1 "2017-10-31T14:39:15Z")

</div>

**Tell us what’s happening:**

**Your code so far**

```auto
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  
  switch (val) {
    case "alpha":
      break;
    case "beta":
      break;
    case "gamma":
      break;
    case "delta":
      break;
  }
  
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/selecting-from-many-options-with-switch-statements](https://www.freecodecamp.org/challenges/selecting-from-many-options-with-switch-statements)

---

<div class="post-metadata">

**Author:** ![v-lai](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/v-lai/32/65024_2.png) [@v-lai](https://forum.freecodecamp.org/u/v-lai)\
**Post date:** [October 31, 2017, 5:11pm UTC](https://forum.freecodecamp.org/t/selecting-from-many-options-with-switch-statements-not-understood/156205/2 "2017-10-31T17:11:22Z")

</div>

> **[switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)**
>
> The switch statement evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case, as well as statements in cases that follow the matching case.

since you are using `val` as the switching case, you want to make sure that `answer` is changed depending on what `val` is. so looking at the input in this case, `val` would be `1`. When `val` is `1`, `answer` should be `alpha`, and so on with the values and answers on the left sidebar of the problem.

---

<div class="post-metadata">

**Author:** ![mittalyashu77](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mittalyashu77](https://forum.freecodecamp.org/u/mittalyashu77)\
**Post date:** [October 31, 2017, 6:03pm UTC](https://forum.freecodecamp.org/t/selecting-from-many-options-with-switch-statements-not-understood/156205/3 "2017-10-31T18:03:40Z")

</div>

Ya. I got the solution.

Actually, I didn’t saw the variable answer.  
That’s why I didn’t understand, how to make the value equal.

When I posted this question, after 30 minutes. I noticed the variable answer 🤣

Sorry, for posting this silly question.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:35pm UTC](https://forum.freecodecamp.org/t/selecting-from-many-options-with-switch-statements-not-understood/156205/4 "2021-01-17T20:35:49Z")

</div>

Closed on January 17, 2021, 8:35pm UTC


