I am using csv-parse in node.js (sync api) to parse a csv into a js object. Everything is working great except I'm having a lot of trouble accessing the first key value pair.
If I console log the resulting object I get
//object scorecard
{
'PlayerName': 'Par',
CourseName: 'Lismore Park Wanaka',
LayoutName: 'Mid 2020 (New Hole Numbering)',
Date: '01-07-21 12:44',
Total: '55',
'+/-': '',
Hole1: '3',
Hole2: '3',
Hole3: '3',
Hole4: '3',
Hole5: '3',
Hole6: '3',
Hole7: '3',
Hole8: '3',
Hole9: '4',
Hole10: '3',
Hole11: '3',
Hole12: '3',
Hole13: '3',
Hole14: '3',
Hole15: '3',
Hole16: '3',
Hole17: '3',
Hole18: '3'
}
Trying to access PlayerName I get undefined, I'm assuming because PlayerName is in quotes (this object is made by csv-parse). scorecard.PlayerName and scorecard['PlayerName'] don't work. However, if I use..
let keys = Object.getOwnPropertyNames(scorecard)
console.log(scorecard[keys[0]])
I do get the desired result of Par.