Welcome to the Treehouse Community
Looking to learn something new?
Why did I not get an error when I forgot to declare each variable?
I didn't exactly write a ad-lib style story, but I got the idea.
below is the entirety of what I wrote:
console.log ("Your Script started"); yourName = prompt("What's your Name?"); console.log ("Yes prompt 1"); yourAdjective = prompt("Pick an Adjective"); yourSentence = "Hey, " + yourName + ". You've got an "+ yourAdjective +" name. Jerk."; document.write (yourSentence); console.log ("Your Script Ended");
Elise Kain54,392 Points
Hi Alexander - When you forget the "var", "let" or "const" keyword to declare variables, they are still created but are automatically put in the "global" scope (so they are accessible anywhere). This is not a best practice, so it should be avoided whenever possible. However, since it "works", the Chrome Dev Tools did not give you an error.