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
ἔρως
ἔρως4w ago
have you tried to press f12?
No description
ἔρως
ἔρως4w ago
also, on line 21, you're grabbing the input that you've grabbed on line 1
Yido
Yido4w ago
this does not happen in my console tho
No description
ἔρως
ἔρως4w ago
i don't know what you typed there
Yido
Yido4w ago
where
ἔρως
ἔρως4w ago
into the console
Yido
Yido4w ago
i did not type anything into the console its the code that did this
ἔρως
ἔρως4w ago
then you forgot to copy-paste something
Yido
Yido4w ago
just checked it and yes you were right 😭 https://codepen.io/SirYido/pen/VwOzroq
SirYido
CodePen
VwOzroq
...
ἔρως
ἔρως4w 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
Yido4w ago
but i did not use for loop i used if
ἔρως
ἔρως4w 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
Yido4w ago
oh i get it now thank you
ἔρως
ἔρως4w ago
you're welcome
Want results from more Discord servers?
Add your server
More Posts