Multiple errors displayed in console











up vote
-1
down vote

favorite












I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.



Here is my HTML



<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>


This is index.js errors are included in comments



function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};









share|improve this question






















  • If the code works fine but the tests don't pass, maybe the tests are wrong.....
    – peeebeee
    Nov 8 at 11:16










  • Well it's working tho... what's the problem?!
    – Islam Elshobokshy
    Nov 8 at 11:22










  • What are the errors in the console?
    – Djave
    Nov 8 at 11:24










  • Djave I have included them in the comments for index.js
    – Anusha
    Nov 8 at 11:25






  • 1




    So for the 'space in parens' error, did you try if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.
    – peeebeee
    Nov 8 at 12:25















up vote
-1
down vote

favorite












I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.



Here is my HTML



<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>


This is index.js errors are included in comments



function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};









share|improve this question






















  • If the code works fine but the tests don't pass, maybe the tests are wrong.....
    – peeebeee
    Nov 8 at 11:16










  • Well it's working tho... what's the problem?!
    – Islam Elshobokshy
    Nov 8 at 11:22










  • What are the errors in the console?
    – Djave
    Nov 8 at 11:24










  • Djave I have included them in the comments for index.js
    – Anusha
    Nov 8 at 11:25






  • 1




    So for the 'space in parens' error, did you try if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.
    – peeebeee
    Nov 8 at 12:25













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.



Here is my HTML



<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>


This is index.js errors are included in comments



function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};









share|improve this question













I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.



Here is my HTML



<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>


This is index.js errors are included in comments



function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};






jquery login






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 11:10









Anusha

4029




4029












  • If the code works fine but the tests don't pass, maybe the tests are wrong.....
    – peeebeee
    Nov 8 at 11:16










  • Well it's working tho... what's the problem?!
    – Islam Elshobokshy
    Nov 8 at 11:22










  • What are the errors in the console?
    – Djave
    Nov 8 at 11:24










  • Djave I have included them in the comments for index.js
    – Anusha
    Nov 8 at 11:25






  • 1




    So for the 'space in parens' error, did you try if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.
    – peeebeee
    Nov 8 at 12:25


















  • If the code works fine but the tests don't pass, maybe the tests are wrong.....
    – peeebeee
    Nov 8 at 11:16










  • Well it's working tho... what's the problem?!
    – Islam Elshobokshy
    Nov 8 at 11:22










  • What are the errors in the console?
    – Djave
    Nov 8 at 11:24










  • Djave I have included them in the comments for index.js
    – Anusha
    Nov 8 at 11:25






  • 1




    So for the 'space in parens' error, did you try if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.
    – peeebeee
    Nov 8 at 12:25
















If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16




If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16












Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22




Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22












What are the errors in the console?
– Djave
Nov 8 at 11:24




What are the errors in the console?
– Djave
Nov 8 at 11:24












Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25




Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25




1




1




So for the 'space in parens' error, did you try if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.
– peeebeee
Nov 8 at 12:25




So for the 'space in parens' error, did you try if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.
– peeebeee
Nov 8 at 12:25

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206555%2fmultiple-errors-displayed-in-console%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206555%2fmultiple-errors-displayed-in-console%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Landwehr

Reims

Schenkenzell