# Basic JavaScript - Selecting from Many Options with Switch Statements

**URL:** <https://forum.freecodecamp.org/t/basic-javascript-selecting-from-many-options-with-switch-statements/601434>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [March 29, 2023, 6:38pm UTC](https://forum.freecodecamp.org/t/basic-javascript-selecting-from-many-options-with-switch-statements/601434 "2023-03-29T18:38:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim-la](https://avatars.discourse-cdn.com/v4/letter/t/49beb7/32.png) [@tim-la](https://forum.freecodecamp.org/u/tim-la)\
**Post date:** [March 29, 2023, 6:38pm UTC](https://forum.freecodecamp.org/t/basic-javascript-selecting-from-many-options-with-switch-statements/601434/1 "2023-03-29T18:38:33Z")

</div>

**Tell us what’s happening:**  
the error I get is:

```auto
caseInSwitch(1)

```

should have a value of the string

```auto
alpha

```

```auto
caseInSwitch(2)

```

should have a value of the string

```auto
beta

```

```auto
caseInSwitch(3)

```

should have a value of the string

```auto
gamma

```

```auto
caseInSwitch(4)

```

should have a value of the string

```auto
delta

```

but when I test at the bottom with 1-4, I get these answers as strings.

**Your code so far**

```javascript
function caseInSwitch(val) {
  let answer = "";
  // Only change code below this line
  switch(val){
    case 1:
      console.log("alpha");
      break;
    case 2:
      console.log("beta");
      break;
    case 3:
      console.log("gamma");
      break
    case 4:
    console.log("delta");
    break;
  }
  // Only change code above this line
  return answer;
}

caseInSwitch(1);

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0`

**Challenge:** Basic JavaScript - Selecting from Many Options with Switch Statements

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [March 29, 2023, 6:41pm UTC](https://forum.freecodecamp.org/t/basic-javascript-selecting-from-many-options-with-switch-statements/601434/2 "2023-03-29T18:41:37Z")

</div>

You aren’t changing the value stored in the `answer` variable

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [September 28, 2023, 6:42am UTC](https://forum.freecodecamp.org/t/basic-javascript-selecting-from-many-options-with-switch-statements/601434/3 "2023-09-28T06:42:28Z")

</div>

Closed on September 28, 2023, 6:42am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
