I am trying to populate an array with numbers starting from 2016, ending at current year.
My method looks like this
generateYears () {
const currentDate = new Date();
let y = 2016;
console.log(currentDate.getFullYear());
for (y = 2016; y <= currentDate.getFullYear(); y++) {
this.testYears.push(y);
}
console.log(this.testYears);
}
and testYears was declared with
testYears: number[];
I have tried to declare it any[] but got same error.
What should I do?