"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
Mannix9mo ago
you can only have one else statement you probably want another else if for that confirm
Yido
YidoOP9mo 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
YidoOP9mo ago
No description
lko
lko9mo 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
YidoOP9mo ago
stop when the user clicks cancel and not going on a endless loop of keep asking until the user enters a name
lko
lko9mo ago
then you can leave the else empty
Yido
YidoOP9mo ago
nope not working
lko
lko9mo 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
YidoOP9mo ago
oh so i have to get rid of it to stop the loop
lko
lko9mo ago
Yep But why are you using prompt() btw? Isnt a normal form better?
Yido
YidoOP9mo ago
normal form? i just started learning javascript from the start
lko
lko9mo ago
Do you know html?
Yido
YidoOP9mo ago
yeah ı do
lko
lko9mo ago
Yeah I meant <form>
Yido
YidoOP9mo 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
lko9mo ago
I'm not sure you can That's probably why people use forms
SvenSplynter
SvenSplynter9mo 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