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

157
Vistas
How do I modify my for loop to iterate x amount of time on character length?

How should I modify my for loop so that the document.querySelector('.answer').style.marginTop = "-1rem"; iterates x amount of times? currently, it is not working, even though I change the value of I to a different number, nothing happens.

It will only happen once and that is because of the if (display.length >= 21)

function buttonPress(numbers) {

    let input = document.querySelector('.answer').innerText.split('\n').join('')+numbers
    let display = document.querySelector('.answer').innerHTML = input
    console.log(input)
  
    if (display.length >= 21) {

      for (let i = 0; i > display.length; i++) {
        document.querySelector('.answer').style.marginTop = "-1rem";
      }
    }
  }

Expected result output of screen behaviour with for loop:

|---------------|
|111111111111111|
|111111111111111|
|111111111111111|
|111111111111111|
|---------------|
about 4 years ago · Juan Pablo Isaza
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