Title: Quiz Week 1 Basics Quiz
Course: Fall 2023 - WEBD 164 (41934) > Section: Week 1 (Aug 21) The JavaScript Syntax, Hello World

Q: Which window object method  would I use to show the user a message?
- window.prompt()
- window.confirm()
- window.alert()
- window.message()
A: window.alert()
If right: Yes, the alert's only purpose is to show the user a message.
If wrong: The alert is the only window object that shows the user a message only.

Q: What window object method will return a Boolean when the user submits it?
- window.prompt()
- window.confirm()
- window.message
- window.alert()
A: window.confirm()
If right: Window.confirm allows the user to send either a yes (true) or no (false) to the browser where it can be accessed using JavaScript.

Q: Which window object method allows the user to enter data that can be used in JavaScript?
- window.prompt()
- window.message()
- window.confirm()
- window.alert()
A: window.prompt()
If right: window.prompt will output a text box where a user can enter data.
If wrong: window.prompt will output a text box where a user can enter data.

Q: Javascript is _________ and is not compiled the way Java is.
A: interpreted
Feedback: parsed
If right: Yes, JavaScript looks at the code line by line.
If wrong: No, JavaScript is interpreted

Q: Which of the following options could I use to see what values a variable called "someData" is holding?
- alert(someData);
- typeof(someData);
- console.log(someData);
- document.write(someData);
A: alert(someData);; console.log(someData);; document.write(someData);
If right: Excellent. This question is not very easy.
If wrong: Typeof only outputs the type of data held by the variable

Q: Which of the following would throw an error in JavaScript
- window.alert("some text");
- var someText = "This is a String;
- document.GetElementById("myspeech");
- document.write("This is my web page");
A: var someText = "This is a String;
If right: Nice work! All quotes must be closed in a statement.
If wrong: All quotes must be closed in a statement.

Q: All Javascript must be placed inside the head tags of your html page
- True
- False
A: False
If right: Yes, it can really be anywhere as long as it has access to the elements it controls.
If wrong: JavaScript can really be anywhere as long as it has access to the elements it controls.

Q: What would the following line output?

document.write(5 + "2");
- 52
- 7
- 5 + 2
- It would throw an error
A: 52
If right: 52 is correct!
If wrong: The second value is a string, so 52.

Q: Why do we put html comments around our javascript?
- To let HTML know that there is JavaScript there.
- To tell the browsers that there is no HTML inside the comments.
- To hide the code in case JavaScript is turned off in the browser's settings
- To make our code run faster
A: To hide the code in case JavaScript is turned off in the browser's settings
If right: Exactly, we want to hide our code from the user if JavaScript is turned off.
If wrong: If JavaScript is turned off, the browser will render the code as text. The comments are therefore necessary to hide the code.