Here you go:
// data format modification
// create single object
dataMod = Object.fromEntries(data.map(d => [d.Countries, d[yearString]]))
The problem in your code was that you wrote d.yearString
instead of d[yearString]
. I’ve also simplified the code a bit.