Reputation: 59
I am new to JS. Today I was trying to practice a little of what I've learned, and I can't get my console log to print anything. My "good morning" alert works, as well as my initial prompt question, but once I answer "yes" or "no," everything stops. Here is my code:
alert("Good morning!");
var hireMe = prompt("Are you here because you're interested in hiring me?");
if (hireMe === "yes") {
console.log("You've just made my day. Carry on.")
}
else {
console.log("Well, I hope you're at least thinking about it.")
}
Thanks.
Upvotes: 5
Views: 17445
Reputation: 71
Take a look at your ' if ' statement. It does work with three but it's better to use double equals. Your code will be:
if (hireMe == "yes") {
console.log("You've just made my day. Carry on.")
}
else {
console.log("Well, I hope you're at least thinking about it.")
}
Upvotes: 0
Reputation: 71
Take a look at your ' if ' statement. It does work with three but it's better to use double equals. Your code will be:
alert("Good morning!");
var hireMe = prompt("Are you here because you're interested in hiring me?");
if (hireMe == "yes") {
console.log("You've just made my day. Carry on.")
}
else {
console.log("Well, I hope you're at least thinking about it.")
}
Upvotes: 0
Reputation: 1
In chrome, sometimes the content that can be displayed on the console, can be changed to "Hide All". To view the necessary content, select the appropriate fields in the drop down.
Upvotes: 0
Reputation: 161
IE unfortunately has this dependency where the console object gets created only when you open it (F12). So console.log tries to call the log method for the object console, and if that object is not yet created, it results in an error.
Upvotes: 0
Reputation: 943099
I don't see any console window appear at all. It's as if no more code is written beyond the prompt
console.log
will write to the console.
It will not cause the console window to open if it isn't already open.
You have to open your browser's console (the Developer Tools since you are using Chrome) manually.
Upvotes: 3
Reputation: 6894
Some browsers (IE) will crash if the developer tools (F12) are not open: How can I use console logging in Internet Explorer?
Upvotes: 0