How to convert primitive array into object array with key and value?

Please elaborate on the reasons why