Essentially I am creating object's key (year) using for-loop.
However, I would like to have it that the first key of the object will be the initial
key I manually created.
However, it ends up being pushed all the way to the last.
I have the following code:
const VEHICLE_YEARS = () => {
const vehicleYears = {}
vehicleYears['initial'] = 'Choose One'
const startYear = 2013
const endYear = new Date().getFullYear()
for (let year = startYear; year <= endYear; year++) {
vehicleYears[year] = year
}
return vehicleYears
}
VEHICLE_YEARS()
it sends up like this:
{
'2013': 2013,
'2014': 2014,
'2015': 2015,
'2016': 2016,
'2017': 2017,
initial: 'Select One'
}