'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|
|---------------|
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
