can anyone help me understand why this code doesn't work? Don't know where I'm going wrong.
let ratings = ["8.8", "8.6", "9.0", "8.3"];
ratings.forEach(rating => {
return parseFloat(rating)}
);
I just get undefined.
can anyone help me understand why this code doesn't work? Don't know where I'm going wrong.
let ratings = ["8.8", "8.6", "9.0", "8.3"];
ratings.forEach(rating => {
return parseFloat(rating)}
);
I just get undefined.
Your program is not working since your forEach()
is not storing the result anywhere. And it would be better to use
Array.map() in this case :
:
let ratings = ["8.8", "8.6", "9.0", "8.3"];
ratings = ratings.map(a=> parseFloat(a));
console.log(ratings);