I am trying to create an object that looks something like this:
{
'2017': 2017,
'2016': 2016,
'2015': 2015,
'2014': 2014
}
But for whatever reason, it keeps outputting me ascending order instead:
const EXAMPLE = () => {
const exampleObj = {}
for (let year = 2017; year >= 2014; year--) {
exampleObj[year] = year
}
return exampleObj
}
let example = EXAMPLE()
console.log(example)
Is it possible to achieve of what I desire in Javacript? I would choose Map
but in my application, I need an object to render a certain component