How do I pick the first value of rowVal of the first object (I want to print 42.00).
dataTest.rows = [{
"rowHeader": "",
"rowDesc": ["Gene Name"],
"rowVal": [
["42.00", "57.00", "45.00", "48.00", "52.00", "47.00", "39.00", "38.00", "35.00"]
]
}, {
"rowHeader": "",
"rowDesc": ["Gene Source"],
"rowVal": [
["38.00", "50.00", "39.00", "41.00", "45.00", "40.00", "34.00", "33.00", "29.00"]
]
}];
I tried:
console.log(dataTest.rows[0].rowVal[0]);
but it returns all the numbers in the array of rowVal of the first object?
console.log(dataTest.rows[0].rowVal[0][0]);rowValis an array of arrays, not an array of primitives: you're selecting a sub-array, not a string inside the sub-array. Go down one more level to access the first element:console.log(dataTest.rows[0].rowVal[0][0]);console.log(dataTest.rows[0].rowVal[0][0]);You were so close. Note the extra[0]rowValis an array with an array as the first value. Note the[[