Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // What might go wrong with the following code
  2. let inputs = [1, 2, 3, 4, 5, 6, 7]
  3. let filtered = [];
  4.  
  5. inputs.forEach((curInput, i) => {
  6.   if (curInput % 2) {
  7.      inputs[i] = curInput * 4
  8.   }else{
  9.      inputs.splice(i, 1)
  10.      filtered.push(curInput);
  11.   }
  12. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement