Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Which method of the Document interface retrieves an array of all the elements

ID: 3724419 • Letter: 1

Question

1.Which method of the Document interface retrieves an array of all the elements of the specified type?

a. getElementByTagName ()

b.getElementByClassName ()

c.getElementByName ()

d.getElementById ()

2.To avoid potential errors caused by using variables that are not properly declared, you should?

a.make all variables global

b.use strict mode

c.make sure you always assign values to your variables

d.make all variables local

3.When you test an application with Chrome’s developer tools and a breakpoint is reached, you can click:

a. the Step Into button to execute the current statement and move to the next statement

b. the Step Over button to skip execution of the next statement

c.the Step Out button to continue normal execution of the application

d.the Continue button to continue stepping through the statements

4.What will be displayed in the user's browser after the following code executes if the user enters 87 at the prompt?

"use strict"

var getInfo = function() {

grade = parseInt(prompt("What's your score on the test?"));

var newGrade = getResult(grade);

alert("Your grade, curved, is " + newGrade);

};

var getResult = function(grade) {

var newGrade = grade + 5;

return (newGrade);

};

a.an alert will display: Your grade, curved, is 92

b.an alert will display: Your grade, curved, is NaN

c.nothing will display; grade is an undeclared variable

d.nothing will display; newGrade cannot be declared twice

5.Given HTML that includes the element

<p id = "ship">shipping cost goes here</p>

what will the following code do if the user enters 100 at the prompt?

var getInfo = function() {

var cost = parseFloat(prompt("How much does the item cost?"));

var ship = cost * .06;

document.getElementById("ship").innerHTML="Shipping: $" + ship.toFixed(2);

};

a.It will calculate the value of the ship variable, but the <p> element will remain unchanged

b.It will display "shipping cost goes here Shipping: $6.00" in the <p> element

c.It will display NaN in the <p> element because the starting text in this element is not a number

d.It will replace the text in the <p> element with "Shipping: $6.00"

6.What event occurs when the user selects a new item from a select list?

a. change

b.select

c.dblclick

d.click

7.What does the following code do?

var userName = $("user").firstChild.nodeValue;

a. It puts the value of the userName variable into the HTML element with "user" as its id attribute

b.It replaces the text of an HTML element with "userName" as its id attribute with value "user"

c.It sets the text of an HTML element with "user" as its id attribute

d.It puts the text of an HTML element with "user" as its id attribute into the userName varieable

8.What method would you use to remove the focus from a control?

a. value()

b. focus()

c. remove()

d. blur()

9.To trace the execution of a JavaScript application so you can view the results when the application ends, you would?

a.insert alert() method calls at key points in the code

b.insert source.write() method calls at key points in the code

c.insert console,log() method calls at key points in the code

d.set breakpoints at key points in the code

10How would you rewrite the statement that follows that uses the DOM Core specification to use the DOM HTML specification?

imageElement.getAttribute(src);

a.imageElement.setAttribute(src);

b. var newImage = img.src;

c.imageElement.src;

d.imageElement.img.src;

11.Prior to ECMAScript 5, what would happen if you declared a variable named firstName and then later refered to it as firstname?

a. Firstname would be treated as a new local variable

b. Firstname would be treated as a new global variable

c.The JavaScript engine would throw an arror

d. The JavaScript enggine would automatically correct the error

Explanation / Answer

1.Which method of the Document interface retrieves an array of all the elements of the specified type?
Answer :
c. getElementsByTagName()

Explanation :
The getElementsByTagName() method returns a node list. A node list is an array of nodes.

x = xmlDoc.getElementsByTagName("title");

The <title> elements in x can be accessed by index number. To access the third <title> you can write::

y = x[2];

Note: The index starts at 0.

2.To avoid potential errors caused by using variables that are not properly declared, you should?
Answer :
d. make all variables local

Example :

// global scope
var a = 1;

function two(a) {
// local scope
alert(a); // alerts the given argument, not the global value of '1'
}

// local scope again
function three() {
var a = 3;
alert(a); // alerts '3'
}

Explanation : it's use only locally then sure To avoid potential errors which caused by global scope

3.When you test an application with Chrome’s developer tools and a breakpoint is reached, you can click:
Answer :
a. the Step Into button to execute the current statement and move to the next statement


4.What will be displayed in the user's browser after the following code executes if the user enters 87 at the prompt?
Answer :
a.an alert will display: Your grade, curved, is 92

Note : According to chegg policy i have solve first 4 question Here.

Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote