I got the exact given value when I logged the variable to the console, don’t know why I’m still getting an error message.
Your code so far
function isLeapYear() {
if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0){
return `${year} is a leap year`
}else{
return `${year} is not a leap year`
}
};
let year = 2024;
let result = isLeapYear(year);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Challenge Information:
Build a Leap Year Calculator - Build a Leap Year Calculator
function isLeapYear(year) {
if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0){
return \`${year} is a leap year\`
}else{
return \`${year} is not a leap year\`
}
}
let year = 2024;
let result = isLeapYear(year);
console.log(result);
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.