6

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.

Jill
  • 79
  • 1
  • 1
  • 7

6 Answers6

3

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.

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205
0

Some browsers (IE) will crash if the developer tools (F12) are not open: How can I use console logging in Internet Explorer?

Community
  • 1
  • 1
ElGavilan
  • 5,747
  • 16
  • 24
  • 35
  • It's true, but it's not the cause of the problem above (I didn't vote, but just saying, that's probably it) – tymeJV Nov 04 '13 at 15:09
  • "once I answer "yes" or "no," everything stops." – ElGavilan Nov 04 '13 at 15:10
  • It's already been established in the comments that the browser is Chrome. – JJJ Nov 04 '13 at 15:10
  • 1
    It hadn't been at the time this answer was given – Quentin Nov 04 '13 at 15:11
  • 1
    Thank you for answering (I didn't down vote you). :) I didn't receive e-mail notifications for these additional answers (even in my spam), so I apologize that I didn't answer sooner about the browser. – Jill Nov 04 '13 at 15:11
  • And my answer was posted before those comments were made. – ElGavilan Nov 04 '13 at 15:11
  • "[..]I am using Chrome.[..] – Jill 6 mins ago" vs "answered 5 mins ago". And the answer is still wrong, regardless of when the information came in. – JJJ Nov 04 '13 at 15:12
  • 1
    It takes people time to write answers. The comment almost certainly wasn't displayed when as the answer was composed. The answer is a plausible one. – Quentin Nov 04 '13 at 15:23
0

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.

shriniwas_ayyer
  • 121
  • 1
  • 1
  • 4
0

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.

view image

  • This feature also exists in other browsers. There are also other values that this dropdown can be set to and hide `console.log()` output. Make sure that your browser is displaying the console outputs you need. – andrewgu Aug 09 '17 at 06:29
0

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.")
}
Aqeel
  • 31
  • 6
0

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.")
}
Aqeel
  • 31
  • 6