CGS Exam 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What line is needed so that SuperHeroPet property inherits from SuperHero? SuperHeroPet.prototype = Object.create(SuperHero.prototype):

SuperHeroPet.prototype.constructor = SuperHeroPet;

How is a restful web service API called?

Using a URL and parameters

Which event is triggered when there has been successful connection?

WebSocket.onopen

When is closure created in the following code? function closureDemo() { let message = "In the name of the moon...."; let displayMessage = function() { console.log(message); }; displayMessage(); } closureDemo();

When displaymessage is declared as an inner function

What is output to the console? let myPhrase = "Are you talking to me?"; console.log(myPhrase.split("a"));

["Are you t", "lking to me?"]

In the following JSON the datatype associated with friends is____ {"friends": [{ "name":"Bobby

array

Which date method changes the time from 12 noon to 4pm? let changeTime = new Date(2020, 5, 2, 12);

changeTime.setHours(16);

Which method was used to create the text below? Hello

fillText();

How many times is showMe() called when the following code is executed? let timerId = setTimeout (showMe, 3000); function showMe() { let div1 = document.getElementById("div1");

indefinitely

The _____ method can be used to check for the presence of a required character in an input field

indexOf()

_______ loops never stop executing

infinite

Complete the code where (50, 50) is the starting point of the line and (50, 100) is where the line ends.

moveTo, LineTo

A promise object's state may change if the promise is _______

pending

What types of data can Ajax transmit?

plain text HTML, XML, and JSON

Which context method moves the canvas origin?

translate();

_____ is a WebSocket handshake requesting a change from HTTP to WebSocket protocol.

upgrade

What default object is used when no object prefix is utilized to access a property or call a method (example: alert method)?

window

Which line of code sets gold flakes as the secret ingredient? function Dessert(name)

chocolateMoney.setSecretIngredient("gold flakes");

Which block of code has the correct static method syntax?

class StaticExample { static methodExample() { return "this is a static method example.": } }

parseFloat () is used with ______ numbers

decimal

What is the last number output by the loop? i = 5 while (i >= 0) { console.log(i); i--; }

0

Math.floor(Math.random() * 4); will produce random numbers between_____

0 and 3

What is rainbow's data type?

Array

The ____ website shows what features are supported by major browsers and frequency of use

CanIUse

What is output to the console when the following code runs in a browser? var withVar = "Global declared with var"; let withLet = "Global declared with let"; console.log(withVar);

Global declared with var Global declared with let Global declared with var undefined

what does the following code snippet output to the console? let names = ["Mike", "Belinda",]; for

Mike Belinda Jonny Sophie

IfparseInt () cannot return a number, _____ is returned.

NaN

How many DOM nodes are created from the paragraph? Feed the dog.

One for the p element and one for the paragraph text

Which line of code creates a prototype method for PlayList called showCollection function PlayList(artist, album) { this.artist = artist; this.album = album; };

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

What is the final output? let quote = "Talk and they will listen."; quote = quote.replace("talk", "Speak"); quote = quote.replace("they", "I"); quote = quote.replace("Listen", "be heard");

Talk and I will listen

What will the web page contain after running the Javascript?

The paragraph is: Paragraph with class

What is output? function findError() { try { let message1 = "No errors here"; message2; } catch (error) { console.log("There is an error"); } } findError(); console.log("Done searching");

There is an error Done searching

Why is a key sometimes needed to access a third party web based API?

To obtain a key developer must agree to restrictions on data received

which error is thrown by this code block? let num = 13; console.log(num());

TypeError

A polyfill is engineered to

Use Javascript to implement a feature after checking if a feature exists

which string inwordNumsmatches the regex let wordNums = ["blahblah!!", "yea", "N()P3", "H!"]; let re = /\wa\S!/;

blahblah!!

What is the correct format for calling the function and using 1 and 2 as arguments? function multiplyNums (a, b) { return a * b: }

call multiplyNums (1, 2);

Which code segment changes the year to 2020? let changeYear = new Date (2020, 6, 20);

changeYear.setFullYear(2021);

The _____ is required to cancel the interval: let timerID = setInterval(repeatMe, 1000):

clearInterval(timerId)

What is the correct format for logging "My Favorite food is pizza"?

console.log ("My Favorite food is " + favFood + ".")

Which declaration is a constant for minimum wage?

const MIN_WAGE - 10;

Which document object method should be used to create a text string for inserting into a paragraph?

createTextNode()

Fill in the blank to eliminate the owner property from the pokemon object. let pokemon = { name: "Eevee", color: "brown", evolution: "Jolteon", owner: "Ash" }; _______ pokemon.owner;

delete

Which of the following methods sets the text color in a div element to green? let div = document.querySelector("div");

div.style.setProperty("color", "green");

In the following example, how is the head element accessed from a DOM?

document.documentElement.children[0]

Assuming the following <div id="divl" ><p id="p1">Click Me</p> You clicked on the p element you clicked on the div element

document.getElementByID("p1") .addEventListener("click", function() { alert("You clicked on the p element."); }); document.getElementByID("divl") .addEventListener("click",function() { alert("You clicked on the div element."); });

Which code segment removes the class "myClass" from the element <span id ="myId" class="myClass"> </span>

document.querySelect("#myId").classList.remove("myClass");

Which if-else statement correctly conveys the following information? If Age is at least 16, "You can learn to drive." is output.

if (age >= 16) { console.log("You can learn to drive."); } else { console.log("You need to wait a little longer."); }

Which line of code constructs Guam as an instance of AirportCode? class AirportCode { constructor (location, code) { this. location = location; this.code = code;

let Guam = new AirportCode("Guam", "GUM");

what expression iterates over all the animals properties? let animals = { "cat": 1, "dog"; 1, "fish": 3, "hamster": 2 }; for (______) { console.log(animal + " count = " + animals[animal]); }

let animal in animals

Which array is correctly structured?

let countries = ["England", "Brazil", "Cuba"];

what code converts divideNums(a, b) into an arrow function? function divideNums (a, b) { return b / a; }

let divideNums = (a, b) => b / a;

Which Variable declaration format is correct?

let favBand - "Linkin Park";

Which code snippet uses an anonymous function?

let subNum = function(a, b) { return b - a; }

Which statement changes the Pinterest link to a Youtube link?

link.href = "https://www.youtube.com/";

Which statement removes the first item in the following list? <ol id="list"> <li>one</li> <li>two</li> <li>three</li> </ol>

list = document.getElementsByTagName("ol") [0]; list.removeChild(list.childNodes[0]);

Given the following code, re.test() returns true for which string? let odWords = ["body", "mood", "Food", "bode"]; let re = /od$/g; odWords.foreach(function

mood

An ____ allows older browsers to functions with newer features by providing missing functionality

polyfill

What stylesheet method changes the color of an element with classname "myclass" to green?

stylesheet.insertRule(".myclass { color: green }");

Which script tag attribute causes the browser the process the JavaScript after the page web is completely loaded?

test

("title":"Rocky", "rating":"PG", "year":1976"]

this.response

What is missing to complete the following code segment let places = { woods: "Guam", beach: "PR", mountains: "Switzerland" }; try { console.log(places.rainforest); ____"There might be an error"; } catch (error) { console.log(error); } _____{ console.log(error); } ______ console.log(places); }

throw, finally

what attribute of an input element can be validated when text is entered on a webpage?

value

x = 4 ** 4 is the same as

x - 4 * 4 * 4 * 4

In JavaScript, 5 + "5" evaluates to a _______

string

which return statement is correct if the return value is "I will make an apple and blueberry pie."? let fruitPie = function (a, b) { return ____; }

"I will make an " + a + " and " + b + " pie."

What does the span's style attribute method getPropertyValue("color") return? <span style ="color: blue">Test</span>

"blue"

What Javascript object and method is used to write HTML to the web page?

document.writeln()

which function correctly sorts the values in a descending order? let nums = [10, 2, 15, 25, 40, 55, 5];

nums.sort(function (a, b) { return b - a; });

How is the age field accessed after the following is executed let obj = JSON.parse('("name":"Bobby", "age";

obj.age

What XMLHttpRequest method must be used to send a POST request to the server?

open()

What strings match the regex? let words = ["dapper", "paper", "cat", "flack"];

paper flack

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

setInterval (repeat, 3000);

What does stringify ()return? JSON.stringify{{"friends": [{ "name";"Bobby"},{"name";"Celia"},{"name":"Judy")]]);

single string

Which variables are scoped to the entire function given? function addStrings() { let str1 = "This string 1."; if (str1 == "") { let str2 = str1 + " This is string 2."; console.log(str2): } let str3 = "This is string 3."; console.log(str1 + " " + str3): }

str1 and str3

Complete the inheritance here class AnimePet extends AnimeCharacter { _____(name, owner, show) { ______(name, show); this.owner = owner; } }

super, this

let weather = "storm"; _____ (weather) { case "rainy": message = "It is raining."; break; case "cloudy"; message = "There is a chance it will rain."; break; case "thunder"; message = "There is a storm out there."; break: default: message - "It is sunny."; } console.log(message);

switch it is sunny.

On a given keypress event, the events objects ___ property is used to access the object where the keypress event occured.

target

What type of data can be expected from a third party RESTful web API

JSON or XML

Which method changes 10.2 to 11?

Math.ceil(10.2);

CallingbankWithdraw(100);outputs_____ and returns _____. function bankWithdraw(amount) { let currentBalance = 500; let remaining = currentBalance; if (currentBalance >= amount) { let remaining = currentBalance = amount; console.log("$" + remaining); } return remaining; }

$400, 500

How would message to be written as a template literal? let message = petName + " want a " + petSnack + "?";

'${petName} want a ${petSnack}?';

Which compound assignment operator assigns number with 9? let numbers - 3; numbers _______3;

*=

In JavaScript, multiple lines are commented out using

/* */

What does nums.indexOf(10) return? let nums = [4, 8, 10, 6, 2];

0

What is the value of the missing startAngle for the semicircle below? context.arc(50, 100, 50, _____, Math>PI true

0

What is output force? const functionArray = new Array (3); for (let i = 0; i < 3; i++) { let times3 = i * 3; functionsArray[i] = function() { console.log(times3); }; } for (let functionToCall of functionsArray) { functionsToCall(); }

0 3 6

What is the date? let day = new Date(2020, 9, 30);

Fri Oct 30 2020 03:00:00 GMT-0400 (Eastern Daylight Time)

What is output to the console? num - 5; console.log(num > 10 ? "Iron Man" : "Hulk");

Hulk

How does the unshift() method change the following array? let colors = ["red", "orange", "yellow"]; colors.unshift("blue");

Adds Blue to beginning of array

Which line of code instantiates Adele and the album 21? function PlayList(artist, album) { this.artist = artist; this.album = album; };

Adele = new PlayList ("Adele", "21");

When is the HTTP request sent in an Ajex transaction?

After calling send

What does this line of code do? localStorage.removeItem("name");

Removes the "name" key from storage

_____ produces a string in response to a successful WebSocket handshake request.

Sec-WebSocket-accept

The CSS rule input:invalid______

does not require JavaScript to validate

What is the order of the arguments passed to Promise.then()?

fulfilled, rejected

Which function is in strict mode?

function abc123() { "use strict"; }

which getter method is correct?

get planetName() { return "This is " + this.planetName + "."; }

the variable magic is a _______. function findPower (strength, potion) { magic = strength + potion; return magic; } findPower(50, 75); console.log(magic);

global variable

An example of a falsy value is ________

if ("")

Which loop executes once before the condition is tested?

Do-while

abSumis what type of function? function multipleNums(x, y) { return x * y; } function findSum(a, b) { let abSum = function() { return a + b; } return abSum(); }

inner

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

input

What is output to the console? let re = /i.+e/; result = re.exec("Moana is better than Frozen."); if (result === null) { console.log("No match"); } else { console.log(result[0]); }

is better than Froze

which regular expression matches only the words burp dirt and right? let randomWords = ["burp", "try", "dirt", "right"];

let re = /[a-i]/

How is a web socket instantiated?

let socket = new WebSocket("ws://example.com"8080");

The variable findCost can have _____. function musicTix (people, price) { var findCost = people * price; return findCost; }

local scope

What line of codes deletes all data from localStorage?

localStorage.clear();

What line completes the code below so that the output is the secret? console.log(localStorage.getItem("theKe"));

localStorage.setItem("theKey", "the secret");

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

myButton.addEventListener("click", clickHandler);

What is the proper way to set valid to true if the number is valid, false otherwise? function checkNumber() { let number = numberWidget.value; number = number.trim(); valid=; )

number.length === 10 && !isNan(number)

let numbers = positiveNumsOnly{[1, 0, -5, -96, 41, -99, -7]);

numbers.filter(isItPositive)

which statement changes the puppy object's name from Daisy to Darth? let puppy = { name: "Daisy", breed: "husky", color: "black" };

puppy.name = "Darth";

What is output by the following code? let message ="I choose you!"; console.log(message.charAt (6));

s

Which statement evaluates to true? let score - 10;

score == "10"

Which code defines a setter for the breed property, such that assigning to person 1.breedsetsperson1.pet? let person1 = { firstName: "Sophie", lastName: "Hernandez", age: 25, pet: "", _______ };

set breed(value) { this.breed = pet; }

What does stringify() return? JSON.stringify(["friends"; [{ "name":"Bobby", "age":20}, {"name":"Celia","age":30} {"name";"Judy","age":21}]: ["friends","age"]);

string with no names

misspelled variables in strict mode _______

throw an exception

Using the code snippet below, which numbers will output to the console? for (i = 10; i >= 0; i -= 2) { console.log(i); }

10,8,6,4,2,0

What is output to the console? let population = new Map(); population.set("San Juan", 0.3); population.set("Tokyo", 9.3); population.set("beijing", 20.5); population.set("San Juan", 0.7); population.delete("Tokyo"); console.log(population.size);

2

What is output for Math.pow(4,4);?

256

What is the red square's new (x, y) coordinates, width, and height? context.scale(2, 3);

50,135,140,210

What is the output? const functionsArray - new Array(3); for (var i = 0;

6 6 6

How many pixels away from the top of the canvas is the rectangle?

85px

the rectangle is rotated ______ context.rotate(Math.PI / 2 ); context.fillStyle = "green";

90 degrees

When will the animation stop? let x = 0; window.requestAnimationFrame(drawFrame); function drawFrame() {

When x = 350

When would the functiondidNotWork be called if the promise is fulfilled? tryMe2,then(itWorked).catch (didNotWork);

WhendidNotWork()throws an exception

____ is an object used to communicate with the server

XMLHttpRequest

A variable declared with let has _____

block scope

In strict mode, ______ variables must be declared

all

complete the missing code below _____ function hello () ( return message = ______ Promise.resolve("Good night"); ); hello().then(alert);

async,await

sessionStorage stores ____ but localStorage stores _________

data that persists until the browser or tab is closed, data indefinitely

http://www.google.com and https://www.google.com are

different origins


Set pelajaran terkait

ACCT 2020 Chapter 6 Smartbook Review

View Set

int mgnt 5.0 (manging arcross culture)

View Set

(Gillesania)TRIGONOMETRY SETS 10, 11

View Set

CompTIA A+ 1102 exam Practice Test 11

View Set

MKTG 380 -- Safavi -- WWU -- FINAL ASSIGNMENTS

View Set

Functional Assessment and Behavior Intervention Plans

View Set

Anna's Ultimate Exam Practice Test

View Set

Health Promotion of Infants (2 days to 1 year)

View Set