Reputation: 23
The javascript file(sript1) doesn't load when i open the test page and they are in the same folder.(I am using sublime text).
The test page
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Test</h1>
<script src="script1.js"></script>
</body>
</html>
The script1.js page
var database = [
{
username:"boss",
password:"super"
}
];
var newFeed = [
{
username="Bob",
timeline="whatsssupp"
},
{
username="Sally",
timeline="cooooool"
}
];
var userNamePrompt= prompt("What is your username");
var passwordPropmt=prompt("Whats your password");
Upvotes: 2
Views: 155
Reputation: 1240
Most likely your JS file is loaded (and running), but it contains errors so it doesn't show the prompts as you expected it to. You are using =
instead of :
when assigning a value to an object (newFeed).
Test whether fixing your code works for you, like so:
var database = [
{
username: "boss",
password: "super"
}
];
var newFeed = [
{
username:"Bob",
timeline:"whatsssupp"
},
{
username:"Sally",
timeline:"cooooool"
}
];
var userNamePrompt = prompt("What is your username");
var passwordPropmt = prompt("Whats your password");
In the case that it didn't fix your issue, then it could be one of the following:
Whatever the reason might be, most browsers nowadays have something called 'Developer Tools' which can be opened using the F12 hotkey. Then you will be able to see in the console if JavaScript code goes wrong:
Firefox: https://developer.mozilla.org/en-US/docs/Tools
Chrome: https://developers.google.com/web/tools/chrome-devtools/
IE: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/hh968260(v=vs.85)
EDGE: https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide
THAT error will tell you exactly what is going wrong with your setup. Hope it helps!
Upvotes: 4