This snippet should print the number of days in a month specified through user input. However, each day is logged twice to the console, regardless which month is chosen:
"Day:", 1
"Day:", 1
"Day:", 2
"Day:", 2
var month = prompt("enter which month of the year 1 to 12", 6);
for (var days = 1; days <= 31; days++) {
if ((month == 4 || month == 6 || month == 9 || month == 11) && days == 31) continue
console.log('Day:', days);
if (month == 2 && days == 28) break
console.log('Day:', days);
}
console.log()
are always executed.if ((month == 4 || month == 6 || month == 9 || month == 11) && days == 31) { console.log('Day:', days); continue; } else if (month == 2 && days == 28) { console.log('Day:', days); break; }