Yes, you are definitely right that forEach() will help you here. Inside the forEach() callback, you’ve got the array item and its index value made available.
One problem is that the array values inside forEach() are not “live”, meaning that if you change the value with something like item = newValue, it won’t work.
The item is only a copy of the item in the array, rather than the actual item in the array, if that makes sense? So instead, you’ll have to create the new value for the array item, and then copy it back to the actual array with something like myArray[index] = newValue.
I am still having issue finding the solution. I have tried an assortment of solutions, all of which have not produced the desired outcome. The best of what I have put together follow:
let last = myArray.pop();
myArray = myArray.push(‘Fei Long’, ‘Balrog’);
for (let 1 = 0; i < myArray.length; i++) {
let breaker = myArray[i].split(’,’);
let name = breaekr[0];
let index = breaker[2];
let finalArray = name + ‘-’ + index;
let list = finalArray.toString;
}
AND THIS TO TEST:
let last = myArray.pop();
myArray = myArray.push(‘Fei Long’, ‘Balrog’);