i have an array as , i need to remove the empty values and replace it with zeros.
i have achieved this much . when i checked the array length is 8 but it shows 2 elements only. What is the best method to replace it with zeros.
var a = [];
a[3] = 5
a[5] = 15
console.log(a.length) // 6
console.log(a) // [empty,empty,empty,5,empty,15]
how can i make the output as [0,0,0,5,0,15]
// tried this way didn't worked
a.map(o => o !== null ? o : 0)