Find 1st January is being a Sunday between 2014 and 2050
CODE:
function findIfJanuary(yearstart, yearend) {
var rez = [];
for (var year = yearstart; year <= yearend; year++) {
var data = new Date(year, 0, 1);
if (data.getDay() === 0) {
rez.push(year);
}
}
return rez;
}
function evFindJanuary() {
var ekran = document.querySelector("#ekran
var vlez1 = document.querySelector("input[name=vlez1]").value;
var vlez2 = document.querySelector("input[name=vlez2]").value;
if (!vlez1.trim()) {
ekran.innerHTML = "Vnesi pocetna Godina";
return;
}
if (!vlez2.trim()) {
ekran.innerHTML = "Vnesi zavrsna Godina";
return;
}
var rezz = findIfJanuary(vlez1, vlez2);
for (var i = 0; i < rezz.length; i++) {
ekran.innerHTML += "first january is on sunday in " + rezz[i] + " year" + " ";
}
}