I've been trying to create a loop that will increase the temperature by 10 degrees every 2 minutes. However, I'm struggling to figure out how to stop the temperature at 120 degrees after 16 minutes. Any suggestions on how to solve this issue?
var temp = 30,
min = 0;
console.log("Cooking started at " + temp + " deg");
for (min = 0; min <= 25; min++) {
if (min % 2 === 0) {
temp += 10;
console.log("Minutes passed: " + min +
", we are cooking at " + temp + " deg");
}
if (min % 2 !== 0 && min === 25) {
console.log("Total minutes of cooking is 25 min");
}
}
The expected output should be as follows:
Cooking started at 30 deg
Minutes passed: 0, we are cooking at 40 deg
Minutes passed: 2, we are cooking at 50 deg
Minutes passed: 4, we are cooking at 60 deg
Minutes passed: 6, we are cooking at 70 deg
Minutes passed: 8, we are cooking at 80 deg
Minutes passed: 10, we are cooking at 90 deg
Minutes passed: 12, we are cooking at 100 deg
Minutes passed: 14, we are cooking at 110 deg
Minutes passed: 16, we are cooking at 120 deg
Minutes passed: 18, we are cooking at 120 deg
Minutes passed: 20, we are cooking at 120 deg
Minutes passed: 22, we are cooking at 120 deg
Minutes passed: 24, we are cooking at 120 deg
Total minutes of cooking is 25 min