Using JavaScript and JSON in Django | Week 3

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 3 Answers Coursera Quiz


JavaScript and the Browser

Q1. What does the following JavaScript accomplish?

  • Ascertain if the document is ready to load
  • Clear the browser window so drawing can start in the upper left hand corner
  • Enable the retrieval of data in the JSON format
  • Register a function that will be called when the HTML document is completely loaded

Answer: Register a function that will be called when the HTML document is completely loaded


Q2. What portion of the DOM (Document Object Model) will be affected by the following JavaScript statement:

  • All elements in the DOM
  • All tags with a class atribute of “para”
  • A tag with an id atribute of “para”
  • A tag with a class atribute of “para”

Answer: A tag with an id atribute of “para”


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


Q3. What does the following JavaScript code do?

  • Replace all the HTML on the page
  • Write HTML into the “under construction” DOM
  • Replace the contents of all p tags in the DOM
  • Scroll the window to the bottom of all content

Answer: Write HTML into the “under construction” DOM


Q4. Which of the following lines will call the function “myFunc” five seconds in the future.

  • setTimeout(myFunc, 5);
  • setTimeout(‘myFunc’, 5);
  • setTimeout(myFunc, 5000);
  • setTimeout(myFunc(), 5000);

Answer: setTimeout(myFunc, 5000);


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

See also  Django Features and Libraries | Week 5

Q5. When do we see a scroll bar in a browser?

  • When the ‘EnableScroll’ event is active
  • When the window is larger than the DOM
  • When the DOM is too large to fit in the window
  • When the window height is increased

Answer: When the DOM is too large to fit in the window


Q6. Which of the following JavaScript statements will hide spiner.gif in this HTML?

  • $(“.chatcontent”).toggle();
  • document.getElementById(“chatcontent”).style.display = ‘none’
  • document.getElementById(“chatcontent”).hide();
  • document.getElementById(“#chatcontent”).hide();
  • $(“#chatcontent”).hide();

Answer: document.getElementById(“chatcontent”).style.display = ‘none’


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


Q7. What does document.createElement() do?

  • Clear the contents of a div from AJAX
  • Start the server session for the current browser tab
  • Create a new element / tag that is not connected to the document
  • Open a blank window in a new browser tab

Answer: Create a new element / tag that is not connected to the document


Q8. The ‘onclick=’ attribute is effectively a shotcut to which of these methods?

  • addClickHandler()
  • document.ready()
  • addEventListener()
  • document.onClick()

Answer: addEventListener()


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


Q9. When using fetch(), what is the purpose of the .then() method?

  • Trigger code after the form POST completes successfully
  • Stop DOM display updates from happening until the URL is retrieved
  • Register code to be execute when the fetch promise is completed
  • Release the memory that was allocated using malloc()

Answer: Register code to be execute when the fetch promise is completed


Q10. Which is the better way to retrieve data in JavaScript – promises / then or async / await?

  • None of the above – using input() is the best practice in JavaScript
  • It depends and there are a lot of different opinions
  • Async / await
  • Promises
See also  Django Features and Libraries | Week 6

Answer: It depends and there are a lot of different opinions


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


More Weeks of this course: Click Here

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


Using JavaScript and JSON in Django Week 3 Answers