Can someone give me/explain me the correct syntax to define till 2 sub-levels in the present code?
the array is : answer["gps-location"][0].constellation = []
I would like to add under this level : nsat
I tried without success with : answer["gps-location"][0].constellation.nsat = elements[0].substr(54,3)
let c;
answer["gps-location"] = [{}]
if (answer.flag === "A") {
let degreesN = Number(elements[0].substr(13,2))
let minutesN = Number(elements[0].substr(15,7))
let ns = elements[0].substr(22,1)
let degreesE = Number(elements[0].substr(23,3))
let minutesE = Number(elements[0].substr(26,7))
let ew = elements[0].substr(33,1)
answer["gps-location"][0].latitude = degreesN + minutesN/60
if (ns === "S") answer.latitude = -answer.latitude
answer["gps-location"][0].longitude = degreesE + minutesE/60
if (ew === "W") answer.longitude = -answer.longitude
}
answer["gps-location"][0].speed = elements[0].substr(34,5)
answer["gps-location"][0].bearing = elements[0].substr(45,6)
answer["gps-location"][0].constellation = []
answer["gps-location"][0].constellation.nsat = elements[0].substr(54,3)