+ 1

What's the problem

I want to make like only alert for the specific person who enters the username correctly. Can anyone help me with it? https://code.sololearn.com/WEHQtVXp4Gtq/?ref=app

12th Sep 2017, 9:19 AM
Blugon
Blugon - avatar
7 Respostas
+ 5
Code you wrote: var welcome = prompt("Please enter your username with small letters:") if (prompt == "Blugon"); { txt = "Welcome there"; } else { txt = "Sorry,wrong username"; } if (prompt == "Blugon"); { txt = "I got something for you" } explaining: line 2 and line 7: you put a semicolon after the bracket, and you check the word inputed in prompt without using the variable name. line 3, line 5, line 8: you wrote txt to output the text when the statement checked without declare what is the txt name, use alert or document.write instead of writing like this or just declaring the txt name in a variable. see the fixed code below fixed code: var welcome = prompt("Please enter your username with small letters:") if (welcome == "blugon") { alert("Welcome there"); } else { alert("Sorry,wrong username"); } hope it help.
12th Sep 2017, 9:34 AM
Amethyst Animion
Amethyst Animion - avatar
12th Sep 2017, 9:27 AM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 4
var welcome = prompt("Please enter your username with small letters:") if ([[welcome]] == "Blugon") { txt = "Welcome there. I got something for you "; } else { txt = "Sorry,wrong username"; } alert(txt)
12th Sep 2017, 9:34 AM
Akbar Khalilzadeh
Akbar Khalilzadeh - avatar
+ 2
Thanks for everyone's help..i appreciate them
12th Sep 2017, 10:09 AM
Blugon
Blugon - avatar
+ 1
delete the ";" after if (prompt == "Blugon")
12th Sep 2017, 9:26 AM
zakaria kasmi
zakaria kasmi - avatar
+ 1
var welcome = prompt("Please enter your username with small letters:") if (prompt == "Blugon") { alert("Welcome there"); } else { alert("Sorry wrong username"); } if (prompt == "Blugon"){ alert("I got something for you"); };
12th Sep 2017, 9:30 AM
zakaria kasmi
zakaria kasmi - avatar
0
You need to look at where ";" are needed.. You had some in the wrong place eg "If (condition) ;{result}" should be "if (condition) {result}" . Furthermore each assignment eg, "x=y" should terminate with a semicolon ";" like so "x=y;"
12th Sep 2017, 10:11 AM
josh mizzi
josh mizzi - avatar