Tell us what’s happening:
Weirdest thing is happening. When I’m logging the result of arr, it’s completely ignoring splice…
arr.splice(1,3)
// logs [2,1] - the last two elements.
When I use the same code and assign the value to a new variable I get the correct result.
let newArr = arr.splice(1,3)
// logs [4,5,1]
Is this an extension issue, have others seen this before?
Note regardles of whether I delete the line let newArr, I still do not get the correct result in arr…
Your code so far
const arr = [2, 4, 5, 1, 7, 5, 2, 1];
// Only change code below this line
let newArr = arr.splice(1,3)
arr.splice(1,3)
// Only change code above this line
console.log(arr);
console.log(newArr)
/*
.splice(index, numberOfItemsToDelete)
*/
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Challenge: Basic Data Structures - Remove Items Using splice()
Link to the challenge: