-1
const birthYear = 2002;
let century;
if (birthYear <= 2000) 
    let century = 20;
} else {
    let century = 21;
}
console.log(century);

So the problem is when i run the code console says "undefined". I wanna know what is the problem. (I'm new at coding and all this stuff, so, please help. Thanks in advance)

1 Answers1

-2

here answer

const birthYear = 2002;
let century;
if (birthYear <= 2000) {

   century = 20
} else {
    century = 21
}
console.log(century)
Tushar
  • 126
  • 13