you are adding the biggest number to your answer array at the index of i;
arrays are designed to add continuous values so instead of using the index to add the biggest element to answer array use the push method as
answer.push(biggestNumber);
here’s my simple solution to this problem
function largestOfFour(arr) {
let newarr=;
for(let i=0;i < arr.length ; i++){
let largest=arr[i].reduce((acc,val)=>{
if(val > acc){
acc = val;
}
return acc;
});
newarr.push(largest);
}
return newarr;
}
to get the most out of the free code camp challenges I recommend executing the challenges first in our local environment because this will help you think thoroughly over the problem and you can try your mistakes yourself by debugging.