I have read and tried everything I can think of. The other pages that look identical with calling the function onclick work fine. I have tried all I know and read extensively with no avail.
<html>
<head>
<title>Password</title>
</head>
<body>
<div id="output"></div>
<input id="playername" placeholder = "Username" /> <br>
<input id="password" placeholder = "Enter Password"/>
<button onclick="test()">Are you correct?</button>
<script src="pword.js"></script>
</body>
JS:
function test() {
let output = document.querySelector("#output");
let playername = document.querySelector("#playername");
let password = document.querySelector("#password");
if output.value === ("username") && password.value === ("Pa$$w0rd") {
console.log("CORRECT!");
} else {
console.log("Incorrect, try again");
}
}
ifstatement in yourtest()function is incorrect; it's missing the parentheses around the expression.