"declaration or statement excepted." problem

when i put an another else statement after a another else statement i get this issue. whats causing this and how can i fix it?
No description
17 Replies
Mannix
Mannix8mo ago
you can only have one else statement you probably want another else if for that confirm
Yido
YidoOP8mo ago
but if i use else if im also gonna have to put an condition too and i dont know what to put as a condition im just trying to make the prompt stop asking on a loop when i click cancel
Yido
YidoOP8mo ago
No description
lko
lko8mo ago
@Yido So you want to do that - if there's no name, the function starts again - otherwise the name is empty, alert and then starts the function again - otherwise the name is not empty, asks for confirm else? what does it have to do?
Yido
YidoOP8mo ago
stop when the user clicks cancel and not going on a endless loop of keep asking until the user enters a name
lko
lko8mo ago
then you can leave the else empty
Yido
YidoOP8mo ago
nope not working
lko
lko8mo ago
It's going in a loop because you said if (name === null) clicked() so if he wants to cancel, the name is null so it starts clicked() same thing with name === ""
Yido
YidoOP8mo ago
oh so i have to get rid of it to stop the loop
lko
lko8mo ago
Yep But why are you using prompt() btw? Isnt a normal form better?
Yido
YidoOP8mo ago
normal form? i just started learning javascript from the start
lko
lko8mo ago
Do you know html?
Yido
YidoOP8mo ago
yeah ı do
lko
lko8mo ago
Yeah I meant <form>
Yido
YidoOP8mo ago
oooh that i actually dont know why i didnt used that, prompt seemed better since i wanted to learn javascript also its in the tutorial and the documentry anyways so if i delete the null part and the name == "" then how is it supposed to stop the user when a empty value is entered
lko
lko8mo ago
I'm not sure you can That's probably why people use forms
SvenSplynter
SvenSplynter8mo ago
This is why cancel returns null and and an empty input returns "". So stop when receiving null and tell the user the field can't be empty when receiving "".
Want results from more Discord servers?
Add your server