Skip to content
Advertisement

javascript object modification add key for the object [closed]

I need to add year, month, day for my object. This is my current string array

JavaScript

I need to convert this as below

JavaScript

How i do this conversion. thank you

Advertisement

Answer

Just split() the date into components, map() the strings to numbers using parseInt(), and create an object:

JavaScript
Advertisement