I'm trying to convert the array and put "Day" in front of every month I have in my objects list, so I can use it to create a chart on React Native with Victory Native.
Here's my array:
const months = ["08/31/2022", "09/01/2022", "08/31/2022", "08/31/2022", "08/31/2022", "08/31/2022"]
And I need my final input to be:
{"Day": "08/31/2022"},{"Day": "09/01/2022"}, {"Day": "08/31/2022"}, {"Day": "08/31/2022"}, {"Day": "08/31/2022"}, {"Day": "08/31/2022"}
Here's my code:
var hash = {};
for (var i = 0; i < months.length; i++)
hash['Day'] = months[i];
console.log(hash)
My current output is:
{"Day": "08/31/2022"}
As you can see it just prints out 1 object.
Any help will be much appreciated from the bottom of my heart!