I'm facing a hard time understanding arrays. I have two of them, which I want to pick one and populate null elements with the other array elements. I currently have the below:
var arr1 = [1,2,3,4]
var arr2 = [null, 99, null, null]
arr2.map((item) => {
if (item == null) {
arr2 = arr1.splice(item, 1)
}
})
console.log(arr2)
// is outputing [3]. Expected is 1, 99, 3, 4
I'm using splice as I see it as the most close method I can use to accomplish my goal. Also, .map is used but not a requirement.
I'll happy visit any related/already answered question, but since English is not my main language, I couldn't find any related question.