Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0') -- when all objects are not-undefined

Working on data visualization with d3.js. I'm quite a novice in javascript, but I come here trying to get to the root of my issue.

I'm trying to plot some movie-based data, in which every data point is the string data type. Therefore, I have to convert dates to the Date data type, and Movie Ratings to Number or Float data type for d3 to plot the data properly, else there's an error.

Pretty much, the data is stored in an array, which holds 11 other arrays, one for each movie critic, in which each movie critic array holds 237 objects for each movie watched that year, in which each object looks like

    {
    "key": "Derek",
    "Date": "2019-01-25T05:00:00.000Z",
    "value": 5,
    "Movie": "The Butterfly Effect",
    "Pickedby": "Dan"
} 

Where key is the movie critic, and Pickedby is the person who picked the movie.

Here is the code I'm using to convert a date like 1/25/2019 into "2019-01-25T05:00:00.000Z" and am trying to convert the value item (from a string) into a Number, or Floating Point Number. (Some ratings can be like 3.5, 6.5, etc.)

for (let j = 0; j < series.length; j++) {
    for (let i = 0; i <series[j].length; i++){

      series[j][i].Date = new Date(series[j][i].Date)
      series[j][i].value = Number(series[i][j].value)
    
    }
}

The date conversion line of code works as expected. However, converting the value item into a Number or Float is causing Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0') error to arise.

The thing is, all of the value items data through the entire array is a string. There isn't an undefined issue. Sure, some values are (x's) or some other alphabetical character, but that should be converted to NaN at least, and it is for some.

Any thoughts on why this error could be arising, given the information I have provided? I can always probably provide more detail.

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It looks like a typo was made in the code, where you are not accessing the correct value in the cast to Number.

Instead of:

series[j][i].value = Number(series[i][j].value)

it should be:

series[j][i].value = Number(series[j][i].value)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda