I have an exercise in javascript in which I have to display a sentence like “17° in 1 day… 21° in 2 days…” from an array. I know I’ve done the exercise correctly, my code is similar to the correction and yet my console still shows me undefined… :
const data1 = [17, 21, 23];
const printForecast = function(arr) {
let str = '';
for (let i = 0; i < arr.lenght; i++) {
str += `${arr[i]}° in ${i + 1} days...`;
}
console.log(str);
};
printForecast(data1);
If anyone has an idea.
Thanks in advance
I try to obtain a certain string in my console but I actually get undefined