In a hypothetical scenario where there are 30 days in a month, temperatures ranging randomly between 7 and 16°C are assigned to each day. Below is the code snippet used:
let arrMonth = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30
]
let temperature = Math.floor(Math.random() * (16 - 7 + 1)) + 7;
for (let i = 0; i < arrMont.length; ++i) {
arrMonth[i] = temperature;
console.log(arrMonth[i]);
}
The issue reported is that only the temperature for the last day is displayed. Can you spot the mistake I made?
Output on the console:
30: 11