All Coursera Quiz Answers

JavaScript jQuery and JSON Week 3 Practice Quiz Answer

Hello Friends in this article i am gone to share JavaScript jQuery and JSON Week 3 Practice Quiz Answer with you..

JavaScript jQuery and JSON Week 3 Practice Quiz Answer


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


 

JQuery

Question 1) What is the purpose of the following JQuery ready() call?

$(document).ready(function(){
 window.console && console.log(‘Hello JQuery..’);
});

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

 

Question 2) What portion of the DOM (Document Object Model) will be affected by the following JQuery statement:

$(‘#para’).css(‘background-color’, ‘red’);

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

 

Question 3) What does the following JQuery code do?

$(‘#spinner’).toggle();

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

 

Question 4) 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>

  • three
  • five
  • one
  • two
  • four

 

Question 5) Which of the following is not a primitive type supported in JSON?

  • integer
  • boolean
  • url
  • string
  • array

 

Question 6) 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(five.six)
  • alert(data.eight.nine)
  • alert(five)
  • alert(data[‘six’])

 

Question 7) What would the following JavaScript print out?

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

  • 10
  • 11
  • nine
  • seven
  • six

 

Question 8) 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);
 });

  • The tag in the DOM that has an id attribute of “first”
  • A string that is the entire HTTP response of the output from the script json.php
  • Either a JavaScript object or list depending on the returned output of the script json.php
  • All of the tags from the DOM with a class attribute of “back”

 

Question 9) 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”).alt = -1;
  • $(“spinner.gif”).suppress();
  • $(“#chatcontent”).hide();
  • $(“img>spinner.gif”).hide();
  • $(“.chatcontent”).off();

 

Question 10) What does the PHP function json_encode() do ?

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