title: JS, doubling the element of an array and check if the next element of the current element that is doubling is equal to the previous element
body: <p>I need help to solve this exercise:
  An array is given and composed of
  whole numbers. Write a function which takes it
  as a parameter this array and modifies it by doubling the values. If the previous value and
  next value of the current value that is doubling are
  equal, change the value of the next element to
  0. In other words :
  doubling the element of an array and check if the next element(not doublet yet) of the current element that is doubling is equal to the previous element and if so change the next element to 0.
  The given array is:
  [0, 2, 5, 4, 1, 0, 3, 3, 6, 7];</p>
  <pre><code>const nums = [0, 2, 5, 4, 10, 3, 3, 6, 7];
  
  const double = function (arr) {
    for (let i = 0; i &lt; arr.length; i++) {
      arr[i] *= 2;
      console.log(arr[i]);
      if ((arr[i - 1] = arr[i + 1])) {
        arr[i + 1] = 0;
      }
    }
    return arr;
  };
  console.log(double(nums));
  </code></pre>