Using JavaScript and JSON in Django | Week 1

Course Name: Django for Everybody

Sub-course: Using JavaScript and JSON in Django

Course Link: Django for Everybody

Sub-course Link: Django Features and Libraries

These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


JavaScript

Q1. Where does the following JavaScript code execute?

  • In the database server
  • On the network
  • In the browser
  • In the web server

Answer: In the browser


Q2. What happens when JavaScript runs the alert() function?

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

Answer: JavaScript execution is paused and a dialog box pops up


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


Q3. Which of the following is NOT a way to include JavaScript in an HTML document?

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

Answer: By including the code the <?javascript and ?> tags


Q4. In the following code, what does the “return false” accomplish?

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

Answer: It keeps the browser from following the href attribute when “Click Me” is clicked


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


Q5. What happens in a normal end user’s browser when there is a JavaScript error?

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

Answer: Nothing except perhaps a small red error icon that is barely noticeable


Q6. Where can a developer find which line in a web page of JavaScript file is causing a syntax error?

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

Answer: In the developer console in the browser


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


Q7. 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 browser console and pauses JavaScript execution
  • Puts the message in the Django console log
  • Sends the message to console.log.com

Answer: Puts the message in the browser developer console and continues JavaScript execution


Q8. Which of the following is not a valid comment in JavaScript?

  • // This is a comment
  • /* This is a comment */
  • # This is comment
See also  Web Application Technologies and Django | Week 1

Answer: # This is comment


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


Q9. Which of the following is not a valid JavaScript variable name?

  • $data
  • $_data
  • _data
  • 3peat

Answer: 3peat


Q10. What is the difference between strings with single quotes and double quotes in JavaScript?

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

Answer: There is no difference


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


Q11. What does the following JavaScript print out?
toys = [‘bat’, ‘ball’, ‘whistle’, ‘puzzle’, ‘doll’]; console.log(toys[1]);

  • whistle
  • bat
  • ball
  • doll
  • puzzle

Answer: ball


Q12. What value ends up in the variable x when the JavaScript below is executed?
x = 27 % 2;

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

Answer: 1


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


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

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

Answer: The values being compared are the same without any type conversion


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


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

  • Declare the variable globally before the function definition in the code
  • Use the keyword “var” to declare the variable in the function
  • Use the keyword “global” to declare the variable in the function
  • Use the keyword “global” when declaring the variable outside the function
See also  Django Features and Libraries | Week 1

Answer: Declare the variable globally before the function definition in the code


These are Using JavaScript and JSON in Django Week 1 Answers Coursera Quiz


More Weeks of this course: Click Here

More Coursera Courses: http://progiez.com/coursera


Using JavaScript and JSON in Django Week 1 Answers