I have an array of objects:
let cars = [
{
"color": "purple",
"type": "minivan",
"registration": new Date('2017-01-03'),
"capacity": 7
},
{
"color": "red",
"type": "station wagon",
"registration": new Date('2018-03-03'),
"capacity": 5
},
{
...
},
...
]
the object with purple color is in 0 index and the object with red color in 1 index. How can I change the object with red color to be in 0 index and purple in 1 using only their index, not attributes?