Your main issue is a syntax error - if you look in the browsers developer tools console, you should see an error message
SyntaxError: expected expression, got ':'
That's what firefox says, but other browsers may issue a different message, but the message should point to the line with the issue
The other issue, once you fix that, is that your code will alert for any year divisible by 4 only - if it's not divisible by 4, no alert happens at all
tidying your code, you'll see why
function myfunc() {
var a = prompt("Enter the year?");
if (a % 4 == 0) {
if (a % 100 == 0) {
if (a % 400 == 0) {
window.alert("it is a leap year");
} else {
window.alert("it is not a leap year");
}
} else {
window.alert("it is a leap year");
}
} // you would need an else here for a % 4 !== 0
}
So, your code would end up
function myfunc() {
var a = prompt("Enter the year?");
if (a % 4 == 0) {
if (a % 100 == 0) {
if (a % 400 == 0) {
window.alert("it is a leap year");
} else {
window.alert("it is not a leap year");
}
} else {
window.alert("it is a leap year");
}
} else {
window.alert("it is a leap year");
}
}
That's all very well, but you've got four alerts, when really you only need two
So, create another variable that will be true or false, depending on if the entered value is a leap year or not
function myfunc() {
var a = prompt("Enter the year?");
var isLeap = (a % 4 === 0) && ((a % 100 !== 0) || (a % 400 === 0));
if (isLeap) {
window.alert("it is a leap year");
} else {
window.alert("it is not a leap year");
}
}