Section 1

Preview this deck

The _____ method creates a new array by passing the original array items to the callback function, which returns the equivalent value of the array items. a. array.every(callback [, thisArg]) b. array.map(callback [, thisArg]) c. array.some(callback [, thisArg]) d. array.find(callback [, thisArg])

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (48)

Section 1

(48 cards)

The _____ method creates a new array by passing the original array items to the callback function, which returns the equivalent value of the array items. a. array.every(callback [, thisArg]) b. array.map(callback [, thisArg]) c. array.some(callback [, thisArg]) d. array.find(callback [, thisArg])

Front

array.map(callback [, thisArg])

Back

Identify a method that extracts array items that match a specified condition. a. sort() b. filter() c. splice() d. reverse()

Front

filter()

Back

Identify the output of the following code. var x = [3, 45, 1234, 24]; x.sort(); a. 1234, 24, 3, 45 b. 3, 24, 45, 1234 c. 1234, 45, 24, 3 d. 1234, 24, 45

Front

1234, 24, 3, 45

Back

Identify the syntax of the while loop. a. while (continue) { commands } b. while (start) { commands } c. while [start;stop] { commands } d. while [update;continue] { commands }

Front

while (continue) { commands }

Back

Front

Back

Identify the structure of an if statement a. if (condition) { commands } b. if { }(condition) c. if { commands } d. if { } (condition){ commands

Front

if (condition) { commands }

Back

Which of the following methods is used to determine the day of the week on which a month starts? a. calDay; b. day.calDay() c. find.Day; d. getDay()

Front

getDay()

Back

The _____ method diminishes array from the last element by keeping only those items that return a value of true from the callback function. a. array.every(callback [, thisArg]) b. array.map(callback [, thisArg]) c. array.reduceRight(callback [, thisArg]) d. array.findIndex(callback [, thisArg])

Front

array.reduceRight(callback [, thisArg])

Back

Identify a method that decreases array by keeping only those items that return a value of true from the callback function. a. array.every(callback [, thisArg]) b. array.map(callback [, thisArg]) c. array.reduce(callback [, thisArg]) d. array.find(callback [, thisArg])

Front

array.reduce(callback [, thisArg])

Back

The _____ operator tests whether two items are equal in value and have the same data type. a. = = b. = = = c. = d. !=

Front

= = =

Back

Which of the following examples tests whether x is equal to 5 or y is equal to 8? a. (x === 5) && (y === 8) b. (x === 5) : (y === 8) c. (x === 5) || (y === 8) d. (x === 5) / (y === 8)

Front

(x === 5) || (y === 8)

Back

What is the output of the following code? var x = [4, 7, 11]; x.forEach(stepUp); function stepUp(value, i, arr) { arr[i] = value + 1; } a. 4, 7, 11 b. 3, 7, 11 c. 5, 8, 12 d. 8, 14, 22

Front

5, 8, 12

Back

Melissa, a computer science engineering student, is learning the basics of programming by exploring arrays. She learns about different array methods. She wishes to learn more on inserting and deleting array items. She creates monthName array to extract only the three spring months—March, April, and May—from a calendar. Melissa wants to extract the spring months and store them in the monthName array. Identify a method Melissa should choose to perform this task. a. springMonths = monthName.slice(2, 5); b. springMonths = monthName.splice(2, 3); c. springMonths = monthName.slice(3, 5); d. springMonths = monthName.splice(5, 3);

Front

springMonths = monthName.slice(2, 5);

Back

Gregor, a software developer, is developing a calendar application. He has to use several if conditional statements to ensure that the calendar displays the exact number of days present in each month of each year. He creates a dayCount array to keep track of the number of days in each month. Gregor wants to ensure February contains 29 days only in the year 2020 as it is a leap year. Which of the following should Gregor use to set the value in the dayCount array? a. if (thisYear === 2020) { dayCount[1] = 29; } b. if (dayCount=29) { 2020; } c. if { thisYear = 2020; dayCount[1] == 29; } d. if { dayCount=29 && this year=2020; }

Front

if (thisYear === 2020) { dayCount[1] = 29; }

Back

Identify a method that inserts new items at the front of an array. a. reverse() b. unshift() c. assert() d. sort()

Front

unshift()

Back

Numeric data can be sorted by creating a(n) _____ function that contrasts the values of two adjacent array items. a. sum b. iteration c. assert d. compare

Front

compare

Back

Which of the following statements is used to terminate any program loop or conditional statement? a. for b. while c. pass d. break

Front

break

Back

Identify a method that is used to create a subarray. a. concat() b. slice() c. assert() d. sort()

Front

slice()

Back

Which of the following methods creates a new array populated with the elements of array that return a value of true from the callback function? a. array.every(callback [, thisArg]) b. array.filter(callback [, thisArg]) c. array.some(callback [, thisArg]) d. array.find(callback [, thisArg])

Front

array.filter(callback [, thisArg])

Back

Gregor, a software developer, is developing a calendar application. He has to use several if conditional statements to ensure that the calendar displays the exact number of days present in each month of each year. He creates a dayCount array to keep track of the number of days in each month. Gregor wants to create a condition to ensure that all the years divisible by 4 should contain 29 days in February. Which of the following statements should he use? a. if (thisYear % 4 === 0) { dayCount[1] = 29; } b. if (this year/4 === 0) { dayCount[2] = 29; } c. if (this year*4==0) { dayCount[1] = 29 } d. if (thisYear % 4 <= 29) { dayCount[2] = 29; }

Front

if (thisYear % 4 === 0) { dayCount[1] = 29; }

Back

Melissa, a computer science engineering student, is learning the basics of programming by exploring arrays. She learns about different array methods. She wishes to learn more on inserting and deleting array items. She creates monthName array to extract only the three spring months—March, April, and May—from a calendar. Melissa wants to insert abbreviations of spring months into the monthName array. Which of the following methods should she use? a. monthName.reverse(5, 3, "Mar", "Apr", "May"); b. monthName.sort(2, 3, "Mar", "Apr", "May"); c. monthName.join(5, 3, "Mar", "Apr", "May"); d. monthName.splice(2, 3, "Mar", "Apr", "May");

Front

monthName.splice(2, 3, "Mar", "Apr", "May");

Back

Identify a method that tests whether the condition returned by the callback function holds for all items in an array. a. array.every(callback [, thisArg]) b. array.filter(callback [, thisArg]) c. array.some(callback [, thisArg]) d. array.find(callback [, thisArg])

Front

array.every(callback [, thisArg])

Back

What is the output of the following code? for(var i = 5; i > 0; i--) a. i = 4, 3, 2, 1, 0 b. i = 5, 4, 3, 2, 1 c. i = 0, 1, 2, 3, 4 d. i = 1, 2, 3, 4, 5

Front

i = 5, 4, 3, 2, 1

Back

What is the output of the following code? var scores = [92, 68, 83, 95, 91, 65, 77]; var highScores = scores.filter(gradeA); function gradeA(value) { return value > 90; } a. [92, 95, 91] b. [96, 97, 98] c. [68, 83, 65, 77] d. [91, 92, 65, 68, 77, 83]

Front

[92, 95, 91]

Back

A _____, which employs the first-in-first-out (FIFO) principle in which the first item added to the data list is the first removed, is similar to a stack. a. frame b. bitmap c. queue d. binary tree

Front

queue

Back

Identify a true statement of array.some(callback [, thisArg]) method. a. It tests whether the condition returned by the callback function holds for at least one item in array. b. It returns the value of the first element in the array that passes a test in the callback function. c. It tests whether the condition returned by the callback function holds for all items in array. d. It returns the index of the first element in the array that passes a test in the callback function.

Front

It tests whether the condition returned by the callback function holds for at least one item in array.

Back

Identify a compare function that sorts numeric values in ascending order. a. function ascending(a, b) { return a - b; } b. function ascending(b, a) { return a; } c. function ascending(a, b) { return b - a; } d. function ascending(b, a) { return b; }

Front

function ascending(a, b) { return a - b; }

Back

For array data that should be treated as a queue, the _____ method is used, which is similar to the pop() method except that it removes the first array item and not the last. a. reverse() b. shift() c. assert() d. sort()

Front

shift()

Back

The _____ method performs an action similar to the forEach() method except that the function it calls returns a value that can be used to match the contents of an existing array into a new array. a. sort() b. map() c. splice() d. find()

Front

map()

Back

What is the output of the following code? var sum = 0; var x = [1, 3, 7, 11]; x.forEach(sumArray); function sumArray(value) { sum += value; } a. 0 b. 231 c. 11 d. 22

Front

22

Back

Identify the syntax of the statement label. a. label = {statements} b. statement!(label) c. label: statements d. statements.label

Front

label: statements

Back

Identify the expression in which the initial value of the day variable will be set to match the first day of the calendar month. a. var day = Date(calDate(), calDate.getDay(), 1); b. var day = new Day(calDate.getDD(), calDate.getMM(),calDate.getYY(),1); c. var day = new Day(calDay.getFullMonth(), calDay.getDate(), 1); d. var day = new Date(calDate.getFullYear(), calDate.getMonth(), 1);

Front

var day = new Date(calDate.getFullYear(), calDate.getMonth(), 1);

Back

Melissa, a computer science engineering student, is learning the basics of programming by exploring arrays. She learns about different array methods. She wishes to learn more on inserting and deleting array items. She creates monthName array to extract only the three spring months—March, April, and May—from a calendar. Melissa wants to remove spring months from the monthName array. Which of the following methods should Melissa use? a. springMonths = monthName.slice(2, 5); b. springMonths = monthName.splice(2, 3); c. springMonths = monthName.slice(3, 5); d. springMonths = monthName.splice(5, 3);

Front

springMonths = monthName.splice(2, 3);

Back

Identify the general syntax of the do/while loop. a. do (continue) { commands } while (continue){ commands } b. while (continue) { commands } do (continue){ commands } c. while { commands } do (continue); d. do { commands } while (continue);

Front

do { commands } while (continue);

Back

Identify the general syntax of the forEach method. a. array.forEach [, thisArg]() { commands } b. array.forEach(callback [, thisArg]) c. array.forEach (value){ commands } d. array.forEach(callback [value])

Front

array.forEach(callback [, thisArg])

Back

Identify the expression used to reference array values. a. array() b. array[i] c. array{array1,array2,...} d. array::values

Front

array[i]

Back

The _____ statement stops processing the commands in the current iteration of the loop and proceeds to the next iteration instead of stopping the program loop altogether. a. switch b. else c. continue d. pass

Front

continue

Back

Identify the general structure for accessing each value from an array using a for loop. a. for (i < array; i++) { commands involving array[i] } b. for (var i = 0; i++; i < array.length) { commands involving array(i) } c. for (var i = 0; i++) { commands involving array(i) } d. for (var i = 0; i < array.length; i++) { commands involving array[i] }

Front

for (var i = 0; i < array.length; i++) { commands involving array[i] }

Back

Which of the following functions increases the value of each item in an array by 1? a. sum() b. AddArray() c. StepUp() d. ceil()

Front

StepUp()

Back

What is the output of the following code? for (var i = 0; i <= 360; i+=60) a. i = 0, 60, 120, 180, 240, 360 b. i = 360, 240, 180, 120, 60, 0 c. i = 60, 120, 240, 480, 960 d. i = 600, 300, 240, 180, 120, 60

Front

i = 0, 60, 120, 180, 240, 360

Back

A(n) _____ is a collection of values organized under a single name. a. index b. heap c. array d. tuple

Front

array

Back

What is the output of the following code? var x = ["a", "b", "c"]; x.push("d", "e"); x.pop(); x.pop(); a. x = ["a", "b", "c"] b. x = ["a", "b", "d", "e"] c. x = ["d", "e"] d. x = ["c", "d", "e"]

Front

x = ["a", "b", "c"]

Back

Which of the following values will the expression 15 % 4 return? a. 1 b. 11 c. 3 d. 60

Front

3

Back

Identify a compare function that sorts numeric values in descending order. a. function descending(a, b) { return a - b; } b. function descending(b, a) { return b; } c. function descending(a, b) { return b - a; } d. function descending(b, a) { return a; }

Front

function descending(a, b) { return b - a; }

Back

The _____ loop tests the condition to continue the loop right after the latest command block is run. a. do/while b. while c. for d. forEach

Front

do/while

Back

Identify the general structure of a for loop. a. for (start;continue;update) { commands } b. for (start;update) { commands } c. for (start;stop) { commands } d. for (start;stop;continue) { commands }

Front

for (start;continue;update) { commands }

Back

Which of the following determines the current size of an array? a. array(length) b. array[length] c. array.length d. array::length

Front

array.length

Back

Identify a true statement of array.find(callback [, thisArg]) method. a. It tests whether the condition returned by the callback function holds for at least one item in array. b. It returns the value of the first element in the array that passes a test in the callback function. c. It tests whether the condition returned by the callback function holds for all items in array. d. It returns the index of the first element in the array that passes a test in the callback function.

Front

It returns the value of the first element in the array that passes a test in the callback function.

Back