I was working on the below javascript code, could someone explain why below code output is undefined?
Given a year, find the date of the 256th day of that year according to the official Russian calendar during that year.
Then print it in the format dd.mm.yyyy.
function solve(year) {
if (year < 1700 || year > 2700) {
return false;
} else if (year >= 1700 && year <= 1917) {
if (year % 4 === 0) {
var days = [31, 29, 31, 30, 31, 30, 31, 31];
calculate(days)
`enter code here`
}
var days = [31, 28, 31, 30, 31, 30, 31, 31];
calculate(days)
} else if (year > 1918 && year <= 2700) {
if (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) {
var days = [31, 29, 31, 30, 31, 30, 31, 31];
calculate(days)
}
var days = [31, 28, 31, 30, 31, 30, 31, 31];
calculate(days)
} else if (year === 1918) {
var days = [31, 15, 31, 30, 31, 30, 31, 31];
calculate(days)
}
function calculate(days) {
var daysOfSep = 256 - days.reduce(function(accumulator, currentValue) {
return accumulator + currentValue
}, 0)
return `${daysOfSep}.09.${year}`
}
}
console.log(solve(1918))