34) What JavaScript object and method is used to write HTML to the web page?

a. document.println()

b. document.writeln()

c. window.write()

d. window.print()

35) How many DOM nodes are created from the paragraph?

Feed the dog.

a. None

b. One for the p element

c. One for the p element and one for the paragraph text

d. One for the p element, one for the paragraph text, and one for the whitespace within the paragraph text

36) Which statement changes the Pinterest link to a YouTube link?




DOM example

 

 Pinterest
 

 

a. para.href = “https://www.youtube.com/”;

b. link.href = “https://www.youtube.com/”;

c. para.innerHTML = “https://www.youtube.com/”;

d. link.innerHTML = “https://www.youtube.com/”;

37) What is the preferred way to register an event handler that allows multiple handlers for the same event?

a. myButton.addEventListener(“click”, clickHandler);

b. myButton.onclick = clickHandler;

c.

d.

38) An event that occurs when someone enters their name in an input field is a(n) _____ event.

a. click

b. load

c. input

d. submit

39) On a given keypress event, the event object’s _____ property is used to access the object where the keypress event occurred.

a. event

b. click

c. target

d. element

40) The _____ is required to cancel the interval:

let timerId = setInterval(repeatMe, 1000);

a. clearInterval(repeatMe)

b. clearInterval(timerId)

c. stopInterval(timerId)

d. setTimeout(timerId)

41) What code would be used to call a function called repeat every 3 seconds?

a. setTimeout(repeat, 3)

b. setInterval(repeat, 3000);

c. setInterval(repeat, 3);

d. setTimeout(repeat, 3000)

42) How many times isshowMe()called when the following code is executed?

let timerId = setTimeout(showMe, 3000);
 

function showMe() {
 let div1 = document.getElementById(“div1”);
 div1.style.display = “block”;
 alert(“called”);
 let timerId = setTimeout(showMe, 3000);
}

a. indefinitely

b. 1

c. 2

d. 3

43) In the following JSON, the datatype associated with friends is _____.

{“friends”: [{ “name”:”Bobby”}, {“name”:”Celia”},{“name”:”Judy”}]}

a. string

b. object

c. array

d. char

44) How is the age field accessed after the following is executed:

let obj = JSON.parse(‘{“name”:”Bobby”, “age”:20}’);

a. this.age

b. age

c. obj.age

d. obj.name.age

45) What doesstringify()return?

JSON.stringify({“friends”: [{ “name”:”Bobby”}, {“name”:”Celia”},{“name”:”Judy”}]});

a. single string

b. string array

c. JSON object

d. undefined

46) A(n) _____ allows older browsers to function with newer features by providing missing functionality.

a. trifill

b. backfill

c. polyfill

d. altfill

47) A polyfill is engineered to:

a. Use JavaScript to implement a feature whenever possible

b. Replace HTML to implement a feature after checking if a feature exists

c. Use JavaScript to implement a feature after checking if a feature exists

d. Use Ajax to implement a feature whenever possible

48) The _____ website shows what features are supported by major browsers and frequency of use.

a. W3C

b. Tiobe

c. CanIUse

d. W3Schools

49) Which strings match the regex?

let words = [“dapper”, “paper”, “cat”, “flack”];
let re = /pa|ac/;

a. dapper, paper

b. paper, flack

c. flack, cat

d. dapper, flack

50) Which regular expression matches only the words burp, dirt, and right?

let randomWords = [“burp”, “try”, “dirt”, “right”];

a. let re = /[a-i]/

b. let re = /[e-i]/

c. let re = /[i-u]/

d. let re = /[r]/

51) Which string inwordNumsmatches the regex?

let wordNums = [“blahblah!!”, “yea”, “N()P3”, “H!”];
let re = /waS!/;

a. blahblah!!

b. yea

c. N()P3

d. H!

52) Which line of code instantiates Adele and the album 21?

function PlayList(artist, album) {
 this.artist = artist;
 this.album = album;
};

a. Adele.PlayList = (“Adele”, “21”);

b. Adele = new PlayList(“Adele”, “21”);

c. Adele new PlayList = (“Adele”, “21”);

d. Adele = PlayList (“Adele”, “21”);

53) Which line of code creates a prototype method for PlayList called showCollection?

function PlayList(artist, album) {
 this.artist = artist;
 this.album = album;
};

a. PlayList.prototype.showCollection = function() {
 console.log(“My playlist so far: ” + this.artist + ” : ” + this.album);
};

b. prototype.PlayList.showCollection = function() {
 console.log(“My playlist so far: ” + this.artist + ” : ” + this.album);
};

c. this.prototype.showCollection = function() {
 console.log(“My playlist so far: ” + this.artist + ” : ” + this.album);
};

d. PlayList.showCollection.prototype = function() {
 console.log(“My playlist so far: ” + this.artist + ” : ” + this.album);
};

54) In strict mode, _____ variables must be declared.

a. most

b. some

c. all

d. no

55) Which function is in strict mode?

a. function abc123() {
 “restrict”;
}

b. function abc123() {
 “use strict”;
}

c. function abc123() {
 “strict”;
}

d. function abc123() {
 “strict mode”;
}

56) http://www.google.com and https://www.google.com are _____.

a. different origins

b. the same

c. data sharers

d. web storage objects

57) Which line of code deletes all data fromlocalStorage?

a. localStorage.clear();

b. localStorage.delete();

c. localStorage.remove();

d. localStorage.clearAll();

58) What does this line of code do?

localStorage.removeItem(“name”);

a. Removes the “name” key and associated value from storage

b. Removes the “name” key from storage

c. Removes all values from storage

d. Deletes a local variable named “name”