I revisited the Array topic in part 5 of the JS module after being stuck during the Luhn Credit Card challenge and encountered the ‘issue’ on line 9 of my code. When the program is ran: it outputs “[ ]” onto the console instead of ‘Yup’ and yet when i call on the array again on line 10, the item on that index is now actually ‘Yup’. I’d like to know why this is, thank you in advance for your time!
const newArr = [1,2,3,4,‘hi’];
var array = [1,2,3,4,5,6];
var val = newArr[newArr.length - 1];
console.log(newArr.splice((newArr.length - 1), 0, ‘Yup’)); //output is [ ]??? Why though?