Created
November 29, 2017 15:51
-
-
Save DestinyLuong/a6bcde91e05803dc5ef40124bfb28d94 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=a6bcde91e05803dc5ef40124bfb28d94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My first If/Else statment</title> | |
</head> | |
<body> | |
<h1></h1> | |
<input id="username" placeholder="username"> | |
<input id="password" placeholder="password"> | |
<button> Submit</button> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"],"hiddenUIComponents":["editor.css"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//On lines below, complete the missing code. Your goal is to use a conditional statement to check the password. | |
// If username correct and password correct | |
// -> "Welcome!!" | |
// If username correct and password incorrect | |
// -> "Incorrect Password" | |
// If username incorrect | |
// -> "Can not find username" | |
// Otherwise | |
// -> "Invalid Entry" | |
var username = "ScriptEd"; | |
var password = "IL0veC0de"; | |
var first = $("#username").val(); | |
var second = $("#password").val(); | |
$("button").click(function(){ | |
if( first === username && second === password){ | |
$("#body").append("Welcome!!!"); | |
} else if(first !== username && second === password){ | |
$("#body").append("Can not find username"); | |
} else if(first === username && second !== password){ | |
$("#body").append("Can not find password"); | |
} else { | |
$("#body").append("Invalid Entry"); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment