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

275
Vistas
How to append to an array every minute on every reload of page in Javascript?

I have a HTML code which is taking stock price which is updating every 1 minute ( on reload of page ). I want to make a graph out of the stock price. For this I would want to make an array in the morning and then as and when prices are updated every minute, the array is updated too. How can I do it? I tried to use local storage but just unable to get the desired results.

vwap_ltp_percentage is the variable here which I am getting every minute and which I want to append to an array

    vwap_ltp_array = Array()
    vwap_ltp_array.push(vwap_ltp_percentage)
    console.log(vwap_ltp_array)
    if (localStorage.getItem('test') == null) {
        localStorage.setItem('test',[])
    }
    else {
        localStorage.setItem('test',[])
    }
    localStorage.setItem("test", JSON.stringify(vwap_ltp_array))
    console.log(localStorage)

ge)

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

0

In your case, you are always starting with an empty array, the if...else construct is not doing anything... Instead, you need to construct the initial array from the storage if an entry exists there.

    var testString = localStorage.getItem('test');
    vwap_ltp_array = testString ? JSON.parse(testString) : []
    vwap_ltp_array.push(vwap_ltp_percentage)
    localStorage.setItem("test", JSON.stringify(vwap_ltp_array))
    console.log(localStorage)
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