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|
|---------------|