All Coursera Quiz Answers

JavaScript jQuery and JSON Week 1 Practice Quiz Answer

In this article i am gone to share Coursera Course: JavaScript jQuery and JSON Week 1 Practice Quiz Answer with you..

JavaScript jQuery and JSON Week 1 Practice Quiz Answer


Also visit this link:  JavaScript jQuery and JSON Week 3 Practice Quiz Answer


 

Question 1)
Where does the following JavaScript code execute?

<p>One Paragraph</p> 
<script type="text/javascript">
document.write("<p>Hello World</p>")
</script> 
<p>Second Paragraph</p>
  • In the network
  • In the browser
  • In the database server
  • In the web server

Question 2)
What happens when JavaScript runs the alert() function?

  • JavaScript pops up a dialog box and execution continues until the </alert> tag is encountered
  • JavaScript checks to see if there are any unprocessed events
  • JavaScript execution is paused and a dialog box pops up
  • A message is sent back to the PHP code to be logged on the server

Question 3)
Which of the following is not a way to include JavaScript in an HTML document?

  • By including the code between <script> and </script> tags
  • By including a file containing JavaScript using a  tag
  • By including the code the <?javascript and ?> tags
  • On a tag using an attribute like onclick=””

Question 4)
In the following code, what does the “return false” accomplish?

<a href=”js-01.htm” onclick=”alert(‘Hi’); return false;”>Click Me</a>

  • It keeps the browser from following the href attribute when “Click Me” is clicked
  • It is necessary to insure that the onclick code is at least two lines of code
  • It suppresses the pop up dialog that asks “Are you sure you want to navigate away from this page?”
  • It sets the default for the alert() dialog box

Question 5)
What happens in a normal end-user’s browser when there is a JavaScript error?

  • JavaScript logs the error to the PHP error log
  • JavaScript skips the line in error and continues executing after the next semicolon (;)
  • Nothing except perhaps a small red error icon that is barely noticeable
  • JavaScript prints a traceback indicating the line in error

Question 6)
Where can a developer find which line in a web page of JavaScript file is causing a syntax error?

  • By looking at a file on the hard disk of the system where the browser is running
  • Do a “View Source” to see the HTML source code
  • In the developer console in the browser
  • In the PHP error log

Question 7)
What does the following JavaScript do?

console.log(“This is a message”);

  • Puts the message in the browser developer console and continues JavaScript execution
  • Puts the message in the PHP console log
  • Puts the message in the browser console and pauses JavaScript execution
  • Sends the message to console.log.com

Question 8)
Which of the following is not a valid comment in JavaScript?

  • // This is a comment
  • # This is a comment
  • /* This is a comment */

Question 9)
Which of the following is not a valid JavaScript variable name?

  • $_data
  • $_DATA
  • 3peat
  • _data
  • $data

Question 10)
What is the difference between strings with single quotes and double quotes in JavaScript?

  • There is no difference
  • Double quotes strings cannot be used in JavaScript
  • Single quoted strings do not treat n as a newline
  • Double quoted strings so variable substitution for variables that start with dollar sign ($)

Question 11)
What does the following JavaScript print out?

toys = [‘bat’, ‘ball’, ‘whistle’, ‘puzzle’, ‘doll’];
console.log(toys[1]);

  • puzzle
  • whistle
  • doll
  • ball
  • bat

Question 12)
What value ends up in the variable x when the JavaScript below is executed?

x = 27 % 2;

  • 54
  • 13.5
  • 0
  • 27
  • 1
  • 2

Question 13)
What is the meaning of the “triple equals” operator (===) in JavaScript?

  • Both sides of the triple equals operator are converted to boolean before comparison
  • Both sides of the triple equals operator are converted to integers before comparison
  • Both sides of the triple equals operator are converted to string before comparison
  • That the values being compared are the same without any type conversion

Question 14)
How do you indicate that a variable reference within a JavaScript function is a global (i.e. not local) variable?

  • Use the keyword “global” when declaring the variable outside the function
  • Use the keyword “global” to declare the variable in the function
  • Use the keyword “var” to declare the variable in the function
  • Nothing, simply declare the variable globally before the function definition in the code