title: JavaScript - Multiplying Even Indexed Array Elements by 2 and Odd Indexed by 3
body: <p>I've been trying to write code that multiplies even indexed elements of an array by 2 and odd indexed elements by 3.</p>
  <p>I have the following numbers stored in the variable number, which represents an array of numbers</p>
  <pre><code>numbers = [1,7,9,21,32,77];
  Even Indexed Numbers - 1,9,32
  Odd Indexed Numbers - 7, 21, 77
  </code></pre>
  <p>Please keep in mind that arrays are Zero Indexed, which means the numbering starts at 0. In which case, the 0-Indexed element is actually 1, and the 1-Indexed element is 7.</p>
  <p>This is what I expected the output to be</p>
  <pre><code>[2,21,18,63,64,231]
  </code></pre>
  <p>Unfortunately, I got this output</p>
  <pre><code>[2,14,17,42,64,154]
  </code></pre>
  <p>Here is the code for my method</p>
  <pre><code>numbers = numbers.map(function(x) {
    n = 0;
    while (n &lt; numbers.length) {
      if (n % 2 == 0) {
        return x * 2;
      }
      else {
       return x * 3;
      }
      n++;
    }});
  return numbers;
  </code></pre>
  <p>Here I created a while loop, that executes code for every iteration of the variable n. For every value of the variable n, I'm checking if n is even, which is used by the code n % 2 == 0. While it's true that 0 % 2 == 0 it's not true that 1 % 2 == 0. I'm incrementing n at the end of the while loop, so I don't understand why I received the output I did.</p>
  <p>Any help will be appreciated.</p>