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
14 Replies
have you tried to press f12?
also, on line 21, you're grabbing the input that you've grabbed on line 1
this does not happen in my console tho
i don't know what you typed there
where
into the console
i did not type anything into the console its the code that did this
then you forgot to copy-paste something
just checked it and yes you were right 😭 https://codepen.io/SirYido/pen/VwOzroq
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
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'
but i did not use
for
loop
i used if
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 codeoh i get it now
thank you
you're welcome