Final Exam Flashcards
Concerning web development, MDN is an acronym for:
Mozilla Developer Network
Which of the following is NOT an integrated development environment (IDE)?
Git Bash
To begin using git with a project, the first command you should issue is:
git init
Which developer tool stores your project in an online code repository and allows you to share it with others?
GitHub
You can use git inside of Visual Studio Code
True
Which developer tool tracks each change to your project on your computer?
git
What option should always be included with the command git commit?
-m
The command line interface for git is called:
Git Bash
In the Visual Studio Code file tree, a file that has a U beside it indicates it has been uploaded by git.
false
After adding your file changes to your git repository with git add, what is the next step git requires?
git commit
Using the .slice() method, complete the following code so that it returns the last 4 characters of whatever value myString holds.
myString.slice(_____);
-4
What type of data will the following line of code return?
“taco cat”.indexOf(‘taco’, 1) !== -1;
boolean
Choose the result of:
“humpty” + 3 + 2 + “dumpty”;
humpty32dumpty
If I declare a variable like this:
let myInt;
It automatically has a value of zero.
false
let myName = “Dave”;
The letter “e” has an index position of 3.
true
Choose the result of:
2 + 3 + “foot” + “ball”;
5football
let myInt = 0;
myInt++;
The variable myInt is now equal to zero because zero plus zero is still zero.
false
I need to generate a random number between 1 and 50. Help me by filling in the blank to complete the equation.
_______(Math.random() * 50) + 1;
Math.floor
Javascript variables are named using ________.
camelCase
I need to return the remainder of 13 divided by 5. Which operator achieves the result I need?
%
Which statement in a for loop is required?
Select the best answer.
None - all for loop statements are optional.
Please fill-in the blank to complete the for loop below so it will execute the loop once for each letter in any name the user enters:
var myName = ‘any-name-entered’; //do not take this string literally - It should work for Dave or Harold or Sue or whoever enters their name.
for(var x = 0; x < ____; x++) { \ case-sensitive - no spaces please
console.log(myName[x]);
}
myName.length
You cannot have over five ELSE IF statements in your IF statement
false
It is easy to create an endless loop by mistake.
What should we add to the code block of the loop below to prevent it from being an endless loop?
Select ALL answers that will work (together if necessary) to prevent the loop from being an endless loop.
var x = 1;
while(x > 0) {
console.log(x);
}
A break statement
x++
An IF statement to check if x > 50
Select the answer that best completes this sentence:
A for loop has _____ optional parts (aka expressions and aka statements - depending on the source you read).
three
An IF, ELSE IF statement must end with an ELSE to execute if none of the previous conditions were true.
false
Fill-in the blank to complete the following ternary statement. Case-sensitive. No spaces please.
shipState !== “KS” __console.log(‘No Sales Tax.’) : console.log(“We need to add sales tax.’);
?
switch(cityName) {
case “Denver”:
console.log(‘MST’);
_____;
default:
console.log(‘CST’);
}
break
I need to construct an IF statement that checks if the value of x is divisible by 2.
Select the best answer to complete the IF statement with the desired outcome.
if(_____) {
console.log(x + ‘ is divisible by 2.’);
} else {
console.log(x + ‘ is NOT divisible by 2.’);
}
x % 2 === 0
An IF statement must include an ELSE to execute if the IF condition is false.
false
Variables created in the global scope may be used inside of a local scope.
true
const age = 30;
{
const isEven = (number) => {
return number % 2 === 0;
};
console.log(isEven(age));
}
Is the above valid code that will execute without an error?
true
In our Javascript file, we define the function called timesTen() below:
function timesTen(number) {
return number * 10;
}
Now we call the function in our file like this:
timesTen(5);
What output is in the console? Pick the best answer.
Nothing. The code does not attempt to send any output to the console.
Fill-in the blank to complete the function definition. Case-sensitive - no spaces please.
______multiply(a, b) {
return a * b);
}
function
What type of data will this function return when called on the variable myNum?
function overOneHundred(number) {
return number > 100;
}
var myNum = 50;
boolean
Built-in Browser functions are referred to as ______.
methods
When we know we will receive a value from a function, you could also say the function will ______ a value.
Select the best answer.
return
What is wrong with this function definition?
const myFirstName = “Dave”;
const myLastName = “Gray”;
function myFullName(first, last) {
return myFirstName + “ “ + myLastName;
}
Inside the function definition, you need to refer to the parameterswith the parameter names first and last instead of using specific variable names.
const sum = (num1, num2) => {
return num1 + num2;
}
console.log(sum(10));
What is output to the console?
NaN
const squared = function (number) {
return number * number;
}
How do you call this function with a parameter of 10?
squared(10);
const myCars = [“Camaro”, “Hummer”, “Mustang”, “Tesla”];
I want to replace the array element holding the string value “Tesla” with an array element holding the string value “Gremlin”.
Please complete the following line of code to help me achieve the desired result:
myCares.splice(________);
3, 1, “Gremlin”
let myDog = “Tyson”;
myDog = myDog.split(“”);
myDog = myDog.join();
console.log(myDog);
What is output to the console?
T,y,s,o,n
const myGuitars = [“Les Paul”, “Strat”, “SG”, “Tele”];
I want to log the element of the array that holds the “SG” string value to the console.
What goes in the blank to complete the line of code:
console.log(______);
myGuitars[2]
const myArray = [“Pepperoni”, 12.99, [“parmesanpackets”, “pepper packets”], [“napkins”, “paper plates”]];
How many dimensions is myArray?
2
Select ALL that can be stored in an array.
number
boolean
array
string
const myGuitars = [‘Strat’, ‘Les Paul’, ‘Tele’, ‘Explorer’, ‘Wolfgang’];
I execute the following line of code:
delete myGuitars[0];
What is the value of myGuitars[0] now?
undefined
I want to add the value “Gibson Explorer” to the end of an array.
Which method do I use?
.push()
const myTreble = [“Vocals”, “Guitar”];
const myBass = [“Bass”, “Drums”];
Complete the following line of code with the method that combines the above arrays into one new array named myBand:
const myBand = myTreble._____(myBass);
concat
const myArray = [“Supreme”, 16.99, [“parmesan packets”, “pepper packets”, “napkins”], “delivery”];
Which answer holds the string value “pepper packets”?
myArray[2][1]
const myData = [‘Dava’, ‘23’, ‘true’];
What type of data is in index position 1?
string
If I want to return the value of an object property, I must reference the ________ using dot or bracket notation.
key
const { name, major, gpa } = student;
Utilizing destructuring, I have just defined _________.
three variables from the properties within the student object.
To programmatically access the property value of an object with an iterator variable, you must use _______ notation.
bracket
We can add new properties and methods to Child objects, and they will also have access to the properties and methods they inherit from their Parent objects.
true
A function stored in an object is referred to as a ________.
method
If you want to add new properties or methods to an object, you must define the object with the keyword let.
false
const myDegreeMap = {
semester: {
spring21 : {
classes: [‘sociology’, ‘math’, ‘programming’]
}
}
};
Given the above object, how do I access the value “programming”?
myDegreeMap.semester.spring21.class[2];
function myRide({ make, model, year }) {
console.log(I drive a ${year} ${make} ${model}.
);
}
I have an object named myCar with multiple properties including make, model, and year.
How do I call the above function?
myRide(myCar);
We can access object properties with __________. Select ALL that apply.
dot notation
bracket notation
const guitars = {make: ‘Gibson’, model: ‘Les Paul’};
This is an example of creating a Javascript object with ________.
an Object literal
In the video for JavaScript Classes, they are compared to a “blueprint” or _________ for creating objects.
template
As a naming convention, what symbol has traditionally indicated a JavaScript property should be considered private?
_ (underscore)
Which symbol indicates a private field declaration within a class?
#
What keyword must be used when referring to properties in a class constructor?
this
Using a Factory Function to create objects allows the objects to have __________.
private properties and privatemethods
To construct a subclass based on a parent class, what keyword must be used in the declaration of the subclass?
extends
Identify the static JSON method:
stringify
When receiving JSON, which JSON method converts the string data back into an object?
parse()
To inherit the properties of a parent class, what keyword must be invoked in a subclass constructor?
super
Instead of retrieving an object property value with dot notation, it is best practice to add a ________ method that retrieves the value.
getter
try {
throw new Error(‘This is a customerror.’);
}
catch(e) {
console.error(${e.name}: ${e.message}
);
}
//In the code above, what does e represent? Select ALL that apply.
the catchID
a parameter for the Catch block of code
the error object we created in the Try block of code
We can create blocks of code for error handling… especially when working with user input.
Select ALL the code block names we use for error handling:
Catch
Try
Finally
When we want our code to create an error, we use this keyword:
throw
Select ALL the Javascript error types that were discussed in our class video:
TypeError
ReferenceError
SyntaxError
What keyword can we put in our code to pause its execution and instantly launch the developer console?
debugger
Select the properties of an Error object instance. (standard and non-standard according to MDN are both valid here)
message
name
stack
Which panel in Chrome DevTools allows you to debug JavaScript?
Sources
Errors may only be displayed in the console with console.error()
false
When debugging, Chrome DevToolsoffers many different types of _________.
breakpoints
The first step in debugging your code is to _____________.
reproduce the bug
I have a div with an id attribute of “divOne”. It is inside the body element.
I create a new div like this: var newDiv = document.createElement(‘div’);
I want to add my newDiv to the document AFTER divOne. Which line of code achieves my goal?
document.vody.appendChild(newDiv);
I create a div element on my page. Inside the div element, I create a paragraph element.
When discussing the relationship of the div element to the paragraph element, the div is referred to as the ________of the paragraph.
parent
Select ALL of the things found within the Document Object Model (no partial credit):
nodes
whitespace
attributes
elements
Which method will select only one element from the DOM?
document.getElementById()
There are 5 paragraphs in the DOM. I need to change the text color of the 2nd paragraph to white.
Which line of code will achieve my goal?
document.getElementsByTagName(‘p’)[1].style.color = ‘white’;
I have created a paragraph with javascript. I still need to create the text to go in it.
Which method do I use to create the text?
document.createTextNode()
The HTML Document Object Model is often referred to as _________.
a tree
The textContent property of an HTML element may contain HTML markup.
false
I need to select every other div element inside a section element with the id attribute of “view1”.
document.querySelector(‘#view1 div:nth-of-type(2n)’)
I need to select ALL of the paragraph elements int he DOM. Which method or methods will let me do this? (Select ALL that apply)
document.getElementsByTagName(‘p’)
document.querySelectorAll(‘p’)
The addEventListener has 3 parameters: the event to lister for, the function to call, and optionall, the ________.
useCapture
Look at the following line of code:
document.element.addEventListener(‘click’, function(event) {console.log(event.target)};
We are listening for the click event. When a click occurs, it calls the anonymous function. What is the event.target referring to?
Whichever element initially triggered the click event.
Before calling an initApp() function, it is good practice to listen for the DOMContentLoaded event OR the ________ event of the document so we know the DOM elements we want to select exist.
readystatechange
Which type of storage array may still be retrieved after we close our browser and then revisit the web app at another time?
localStorage
I am adding a click event listener to a div. The div is a child of the body element.
The body element already has a click event. If I click on the div, the click event of the body will also occur.
Help me complete this code by filling the blank (exact match, case-sensitive) to prevent the click event of the body from firing.
document.myDiv.addEventListener(‘click’, function(e){
e._______________;
console.log(‘I hope you get it!’);
});
stopPropagation()
When anevent triggers on the element that creates the event, and then moves outward to trigger the same event on a container element, it is called event _______.
bubbling
I have created a function named doTheStuff. Select the line of code that calls doTheStuff with a click event listener when the button is clicked:
button.addEventListener(“click”, doTheStuff, false);
I have an HTML form. I want to apply form validation via JavaScript instead of letting the form submit right away. To keep this from happening, JavaScript lets me apply _________ to the submit event.
preventDefault()
We use event listeners instead of putting JavaScript inline in our HTML elements. This separation of concerns is a principle of _________.
Unobtrusive JavaScript
Look at the following line of code:
document.elem.addEventListener(‘click’,function(magic){console.log(‘abracadabra’)};
What does “magic” refer to?
the event object
Which Section 508 requirement makes sure the coding of a website, software, operating systems, etc. is compatible with assistive technologies?
technical
The ______________specification adds the ability to modify and enhance the semantic meaning of elements in the DOM.
WAI-ARIA
The accessibility audit feature in Chrome Dev Tools is powered by ___________.
Lighthouse
Section 508 compliance is required for all organizations that provide goods or services
true
You can enable a screen reader in Chrome using the ______ extension
ChromeVox
Landmark elements are important for screen reader navigation. Select ALL of the landmark elements that help create “hot spots” on a web page.
nav
header
main
SelectALL of the ways you can provide alternative text with ARIA
aria-labelledby
aria-label
To be legally compliant with Section 508, a web site must meet how many “main” requirements?
3
The _________ guidelines are organized around the POUR principles.
Web Content Accessibility
Semantic HTML improves A11y
true
Every function must be imported on a separate line.
false
Select ALL higher order functions that return new arrays.
filter()
map()
users.forEach(user => { console.log(user.id)});
The above code__________.
logs the user id property of every user object contained in the users array
I receive user data in JSON format. I need to exclude all users under the age of 21.
What higher order function will I likely use to achieve this goal?
filter()
I have a module with three functions: add(), subtract(), and multiply().
I want to import all three functions.
Select all of the correct statement to accomplish this.
__import * as Calculator from “./myFile.js”;
__import { add} from “./myFile.js”;
import { subtract } from “./myFile.js”;
import { multiply } from “./myFile.js”;
__import { add, subtract, multiply } from “./myFile.js”;
users.forEach(user => { console.log(user.id) });
In the above code, what is the word user referring to?
An element in the users array.
A module may have more than one default export.
false
I receive user data in JSON format that has a field containing each user’s average monthly purchase amount. I need to create a new array from this data containing an annual purchase projection for each user by multiplying their average monthly purchase by 12.
What higher order function will I most likely use to achieve this goal?
map()
I receive user data in JSON format. I need to add all of the user ages together for a sum total as the first step for calculating an average age.
What higher order function will I likely use to achieve this goal?
reduce()
A module is required to have a default export.
false
If I attempt to return the value of a fetch() call immediately without using a thenable or the await keyword, what will I receive?
A pending promise.
By telling the receiving API what type of data we expect returned, we may receive different data. Where do we put this information in our fetch() call?
In the Accept property of the headers object.
When using Fetch to request data, the optional second parameter Fetch accepts is a __________.
object
When using Fetch to request data, the first parameter Fetch accepts is usually a ______________.
URL
The http POST method sends parameters in the API endpoint URL.
false
You may await the resolution of more than one promise within an async function.
true
Promises have how many possible states?
3
Functions must be defined with the await keyword to use async within.
false
The .json() method of the body mixin returns a _________
promise
A callback is a ____________ that is passed to a function as a parameter.
function