Created
November 29, 2017 04:18
-
-
Save LtAstros/bf24843b8fe3b77e22c0b060cf9e46d1 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=bf24843b8fe3b77e22c0b060cf9e46d1
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" type="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"; | |
$("button").click(function(){ | |
var user = $("#username").val(); | |
var pass = $("#password").val(); | |
if (user === username && pass === password) { | |
$("button").text("Welcome!!"); | |
} else if (user !== username && pass === password) { | |
$("button").text("Can not find username"); | |
} else if (user === username && pass !== password) { | |
$("button").text("incorrect password"); | |
} else { | |
$("button").text("Invalid Entry"); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment