title: Switch case in a JavaScript function
body: <p>I have a function that needs to pick out the color of a fruit and I have opted for a <em>switch</em> case statement. The problem is I'm not sure how to get the result out of the statement. Maybe I should get an <em>if</em>/<em>else</em>-statement instead?</p>
  <p>Here is the code:</p>
  <pre><code>function fruitColor(fruit) {
      switch(color) {
          case &quot;apple&quot; : green;
              break;
          case &quot;banana&quot; : yellow;
              break;
          case &quot;kiwi&quot; : green;
              break;
          case &quot;plum&quot; : red;
              break;
      }
  }
  
  var result = fruitColor(plum);
  </code></pre>
  <p>I can't get the result and I'm not sure if I need a 'return' value or something like that.</p>