i'm trying to make a function where you input a year, and the output return the centure that year is from. I got most of down, but somewhere in the logic i'm missing something and i'm not getting the correct values for when the year is, i.e. 2000 (20th century, and i get 21st)
My JS:
function centuryFromYear(year) {
if (year <= 100) {
console.log("um")
return year * 0 + 1
} else if (year > 100 && year <= 1000) {
console.log("dois")
var kek = year / 100
var lul = Math.floor(kek)
} else if (year > 1001) {
console.log("tres")
var kek = year / 100
var lul = Math.floor(kek)
return (lul + 1)
}
}