Input not dissappearing

Was trying to make the input dissappear when the counter hit 0 but it doesnt work and nothing happens with it https://codepen.io/SirYido/pen/VwOzroq
SirYido
CodePen
VwOzroq
...
14 Replies
ἔρως
ἔρως7mo ago
have you tried to press f12?
No description
ἔρως
ἔρως7mo ago
also, on line 21, you're grabbing the input that you've grabbed on line 1
Yido
YidoOP7mo ago
this does not happen in my console tho
No description
ἔρως
ἔρως7mo ago
i don't know what you typed there
Yido
YidoOP7mo ago
where
ἔρως
ἔρως7mo ago
into the console
Yido
YidoOP7mo ago
i did not type anything into the console its the code that did this
ἔρως
ἔρως7mo ago
then you forgot to copy-paste something
Yido
YidoOP7mo ago
just checked it and yes you were right 😭 https://codepen.io/SirYido/pen/VwOzroq
SirYido
CodePen
VwOzroq
...
ἔρως
ἔρως7mo ago
you know what would be a lot easier? a css animation your logic is wrong first, you check if it isn't equal to 0 if it isn't 0, it loops then you check if it is higher than 0 if it is, then it decrements the rest is dead code because it never gets executed if it is 1, then it decrements to 0, which will stop the loop also, you're doing a for loop on a while, which is extremely unreadable
for(let i = 20; i; i--) {
await wait(1000);
counterElement.innerText = i;
}

inpt.style.display = 'none';
for(let i = 20; i; i--) {
await wait(1000);
counterElement.innerText = i;
}

inpt.style.display = 'none';
this should do the same thing you also have .style.display = none; and the variable none doesn't exist, but i presume you wanted to set it to 'none'
Yido
YidoOP7mo ago
but i did not use for loop i used if
ἔρως
ἔρως7mo ago
you didn't you wrote the code of a for loop spread all over breaking down this: for(let i = 20; i; i--) { - for -> line 13 - the while loop - let i = 20 -> line 2 - the weird thing of you reading text of an input for some reason - i -> line 13 - counter != 0 - i-- -> line 17 - counter -= 1; so, you did what the for loop does, but it's all over the code
Yido
YidoOP7mo ago
oh i get it now thank you
ἔρως
ἔρως7mo ago
you're welcome
Want results from more Discord servers?
Add your server