Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!