JavaScript, jQuery, and JSON Coursera Quiz Answers

All Weeks JavaScript, jQuery, and JSON Coursera Quiz Answers

In this course, we’ll look at the JavaScript language, and how it supports the Object-Oriented pattern, with a focus on the unique aspect of how JavaScript approaches OO. We’ll explore a brief introduction to the jQuery library, which is widely used to do in-browser manipulation of the Document Object Model (DOM) and event handling.

You’ll also learn more about JavaScript Object Notation (JSON), which is commonly used as a syntax to exchange data between code running on the server (i.e. in PHP) and code running in the browser (JavaScript/jQuery).

It is assumed that learners have already taken the Building Web Applications and Building Database Applications in PHP courses in this specialization.

Enroll on Coursera

JavaScript, jQuery, and JSON Week 01 Quiz Answers

Quiz : JavaScript

Q1. 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 database server
  • In the browser
  • In the network
  • In the web server

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

  • 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
  • JavaScript pops up a dialog box and execution continues until the </alert> tag is encountered

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

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

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

<a href="js-01.htm" onclick="alert('Hi'); return false;">Click Me</a>
  • It is necessary to insure that the onclick code is at least two lines of code
  • 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 keeps the browser from following the href attribute when “Click Me” is clicked

Q5. 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 (;)
  • JavaScript prints a traceback indicating the line in error
  • 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?

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

Q7. What does the following JavaScript do?

console.log("This is a message");
  • Puts the message in the PHP console log
  • Puts the message in the browser console and pauses JavaScript execution
  • Puts the message in the browser developer console and continues JavaScript execution
  • Sends the message to console.log.com

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

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

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

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

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

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

Q11. What does the following JavaScript print out?

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

Q12. What value ends up in the variable x when the JavaScript below is executed?

x = 27 % 2;
  • 2
  • 0
  • 54
  • 13.5
  • 27
  • 1

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

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

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

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

JavaScript, jQuery, and JSON Week 02 Quiz Answers

Quiz : JavaScript Objects

Q1. Which of the following is a template that defines the shape of an object that is created?

  • Method
  • Message
  • Inheritance
  • Instance
  • Class

Q2. Which of the following describes a feature which we would expect from a programming language that supported first class functions?

  • The ability to have a variable number of parameters when calling a function
  • The ability to define a function and assign the function to a variable
  • The ability for a function not to return a value (i.e. void functions)
  • The ability to omit parameters and have the omitted parameters default to a value
  • The ability to return a value from a function

Q3. What is the keyword / predefined variable that is used in a JavaScript class definition to refer to the “current instance” of the class?

  • $this
  • _self
  • self
  • me
  • this

Q4. What do these two statements in JavaScript accomplish?

data.stuff = "hello"; 
data['stuff'] = "hello";
  • The second statement is a syntax error in JavaScript
  • These two statements accomplish the same thing
  • The first statement creates an object and the second creates a dictionary
  • The first statement is a syntax error in JavaScript

Q5. How is the constructor defined in JavaScript class compared to how the constructor is defined in a PHP class?

  • The PHP constructor method is called __construct() and the JavaScript constructor method is called construct()
  • A PHP constructor is a method named __construct() and a JavaScript constructor is code in the outer function definition
  • The PHP and JavaScript constructor patterns are the same
  • JavaScript does not support the notion of running a “constructor” when objects are created.

JavaScript, jQuery, and JSON Week 03 Quiz Answers

Quiz : JQuery & JSON

Q1. What is the purpose of the following JQuery ready() call?

$(document).ready(function(){
 window.console && console.log('Hello JQuery..');
});
  • Register a function that will be called when the HTML document is completely loaded
  • Clear the browser window so drawing can start in the upper left hand corner
  • Ascertain if the document is ready to load
  • Enable the retrieval of data in the JSON format

Q2. What portion of the DOM (Document Object Model) will be affected by the following JQuery statement:1$('#para').css('background-color', 'red');

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

Q3. What does the following JQuery code do

1$('#spinner').toggle();
  • Call the global JavaScript function toggle with the spinner tag as its parameter
  • Hide or show the contents of a tag with the id attribute of “spinner”
  • Indicate that page loading has completed
  • Switch the spinner.gif with the image spinner_toggle.gif

Q4. What will the following JQuery code select from the given HTML?

<p id="p">two
  <input type="text" name="one" value="three" title="four">
  <input type="text" name="five" class="p" value="p">
</p>
<script>
$('#p').find('input[name="one"]').val();
</script>
 
  • one
  • three
  • four
  • two
  • five

Q5. Which of the following is not a primitive type supported in JSON?

  • url
  • boolean
  • string
  • integer
  • array

Q6. In the following JSON, how would you print the value “six”?

data = {'one':'two', 'three': 4,
  'five' : [ 'six', 'seven' ],
  'eight' : { 'nine' : 10, 'ten' : 11  }
}
  • alert(data.five[0])
  • alert(data.eight.nine)
  • alert(five)
  • alert(data[‘six’])
  • alert(five.six)

Q7. What would the following JavaScript print out?


data = {'one':'two', 'three': 4,
  'five' : [ 'six', 'seven' ],
  'eight' : { 'nine' : 10, 'ten' : 11  }
};
alert(data.eight.nine);
  • six
  • nine
  • 10
  • seven
  • 11

Q8. In the following code, what would you expect in the variable named “data”?

$.getJSON('json.php', function(data) {
    $("#back").html(data.first);
    window.console && console.log(data);
 });
  • A string that is the entire HTTP response of the output from the script json.php
  • All of the tags from the DOM with a class attribute of “back”
  • The tag in the DOM that has an id attribute of “first”
  • Either a JavaScript object or list depending on the returned output of the script json.php

Q9. Which of the following JQuery statements will hide spinner.gif in this HTML?

<div id="chatcontent">
 <img src="spinner.gif" alt="Loading..."/>
</div>
  • $(“spinner.gif”).suppress();
  • $(“spinner.gif”).alt \= \-1;
  • $(“img>spinner.gif”).hide();
  • $(“#chatcontent”).hide();
  • $(“.chatcontent”).off();

Q10. What does the PHP function json_encode() do ?

  • Encodes the less\-than and greater\-than characters to make a string safe for JSON
  • Takes a PHP object or list and serializes it into a JSON string representation
  • Reads a JSON string representation and converts it to a PHP object or list
  • Encodes all non\-printing characters with their hexadeciamal equivalents
JavaScript, jQuery, and JSON Coursera Course Review:

In our experience, we suggest you enroll in the JavaScript, jQuery, and JSON courses and gain some new skills from Professionals completely free and we assure you will be worth it.

JavaScript, jQuery, and JSON course is available on Coursera for free, if you are stuck anywhere between quiz or graded assessment quiz, just visit Networking Funda to get JavaScript, jQuery, and JSON Coursera Quiz Answers.

Conclusion:

I hope these JavaScript, jQuery, and JSON Coursera Quiz Answers would be useful for you to learn something new from this Course. If it helped you then don’t forget to bookmark our site for more Coursera Quiz Answers.

This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.

Keep Learning!

Get All Course Quiz Answers of Web Applications for Everybody Specialization

Building Web Applications in PHP Coursera Quiz Answers

Introduction to Structured Query Language (SQL) Quiz Answers

Building Database Applications in PHP Coursera Quiz Answers

JavaScript, jQuery, and JSON Coursera Quiz Answers

Leave a Reply

error: Content is protected !!