title: can't pass challenge if code not optimized further
body: <p>I can't pass this coding challenge: Code Challenge: <a href="https://www.codewars.com/kata/550f22f4d758534c1100025a/train/javascript" rel="nofollow noreferrer">https://www.codewars.com/kata/550f22f4d758534c1100025a/train/javascript</a></p>
  <p>because my code is <em>TOO SLOW</em>. I'm not sure which part of my code is causing the problem. That's why I need help to optimize it.</p>
  <pre><code>function dirReduc(arr){
    if (arr.length === 0 || arr.length === 1) return [];
    let lengthTracker = arr.length;
    for (let i = 0; i &lt; arr.length; i++) { 
    if (lengthTracker &gt; arr.length) {
      lengthTracker = arr.length;
      i = 0;
    }
      switch(arr[i]) {
    case &quot;NORTH&quot;:
   arr[i-1] === &quot;SOUTH&quot;? arr.splice(i-1,2) : 
   arr[i+1] === &quot;SOUTH&quot;? arr.splice(i,2) : null
    break;
    case &quot;SOUTH&quot;:
   arr[i-1] === &quot;NORTH&quot;? arr.splice(i-1,2) : 
   arr[i+1] === &quot;NORTH&quot;? arr.splice(i,2) : null
      break;
    case &quot;EAST&quot;:
   arr[i-1] === &quot;WEST&quot;? arr.splice(i-1,2) : 
   arr[i+1] === &quot;WEST&quot;? arr.splice(i,2) : null
      break;
    case &quot;WEST&quot;:
   arr[i-1] === &quot;EAST&quot;? arr.splice(i-1,2) : 
   arr[i+1] === &quot;EAST&quot;? arr.splice(i,2) : null
      break;
  }
  i===arr.length-1? i=0:null
    }
   return arr;
  }
  </code></pre>