const z = [
[
"Almond",
54
],
[
"Oats",
75
],
[
"Raisins",
undefined
]
]
let temp=[];
z.map((item, index) => {
temp.push(item);
if (item[item.length - 1] === undefined) {
temp[index][1] = 'Not available'
}
});
console.log(temp)
console.log(z);
I'm changing the undefined
entry to 'Not available' by creating another array.
I'm not able to understand my z
array is changing along with temp
.