I am working with some HRV data that I have stored in Arrays in Nodejs. However, whenever I want to acces a value stored in said array it appears as "undefined". The array that I'd like to read is generated by this code:
let rr_data = [456,782,365,234,783,456,987,456,782,365,234,783,456,987,456,782,365,234,783,456,987]
let t = []
rr_data.reduce((current, next, i) => {
return t[i] = current + next
})
When I now console log "t" (console.table(t)) it appears like this:

However, whenever I try acccesing one element by itself for example console.log(t.at(0)) or console.log(t[0]) it shows up as "undefined". Why does that happen and how can I prevent it?
Thank you for your help!
return t[i] = current + nextis supposed to be doing?reducewith an initial value. So the first element (index 0) is taken as the initial value andreducestarts at index 1. You could’ve added something likeconsole.log({ current, next, i });in the callback to help you understand what’s going on.456for the first element oft(just the value ofrr_data[0]unchanged) and one of which gives you1238for the first value (the result of addingrr_data[0]andrr_data[1]).