const dataArray = [ { id: 1, odds: 1.28, }, { id: 15, odds: 2.52, } ]; const convertedData = dataArray.reduce((result, obj) => { result[obj.id.toString()] = { ...obj }; return result; }, {}); console.log(convertedData);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter