I somehow can't get my for loop inside of a function to print elements in an array. could someone point out why javascript is not allowing the iteration to occur and only printing the first element?
const data1 = [17, 21, 23];
function printForecast(array) {
for (let i = 0; i < array.length; i++) {
let dayVsDays = i <= 1 ? 'day' : 'days'
return `The temp is ${array[i]}ºC in ${[i+1]} ${dayVsDays}`;
}
}
console.log(printForecast(data1))