I have this code
console.log({Stats:Object.fromEntries(['score','count','w','l','d'].map(s=>[s,teamsToPlay[0][s]]))})
//Stats: { score:123 count:22 w:12 l:10 d:0 }
How can I extract value/number of each entry?
I tried
const d = ({Stats:Object.fromEntries(['d'].map(s=>[s,teamsToPlay[0][s]]))}).match(/\d+/);
but it gives
{(intermediate value)}.match is not a function
This is not the best solution but it worked for me:
var swin = {Stats: Object.fromEntries(['w'].map(s => [s, teamsToPlay[0][s]]))};
var scount = {Stats: Object.fromEntries(['count'].map(s => [s, teamsToPlay[0][s]]))};
swin = JSON.stringify(swin);
scount = JSON.stringify(scount);
swin = swin.match(/\d+/);
scount = scount.match(/\d+/);