Олимпиада для котов - мой варик


#1

function getYears(start,end,num){
var year = [];
while(start <= end){
arr = String(start).split(’’).reduce((accumulator, currentValue) => {
accumulator = Number(currentValue) + Number(accumulator);
return accumulator
}
)
if(arr === num){
year.push(start)
}
start++
}
return year
}

console.log(getYears(2000,2020,4))