JavaScript Flashcards

1
Q

all algorithm are made with 3 parts, what are they?

A

variable, conditionals, and loops. how to save, decide, and repeat.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a script?

A

is a series of instructions a computer can follow step-by-step

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how should you start writing a script?

A

start with the big picture of what you want to achieve and break down into smaller steps.

  1. define the goal
  2. design the script
  3. code each step
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are 2 ways to design a script

A

p. 18
1. tasks (flowchart)
2. steps (list)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

flowchart keys

A

generic step (rectangle)
event (hexogon 6 sides)
input or output (slanted rectangle)
decision (diamond)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of variables?

A

to store values. easier to call upon the information and easier to reuse for future.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you declare a variable?

A

variable-keyword variable-name;

var name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you initialize (assign a value to) a variable?

A
variable-keyword variable-name = value;
var word = "word";
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What characters are allowed in variable names?

A

lower and capital letters, $, _, and numbers, but cannot start.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

var is what scope variable keyword

A

function scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is let and const variable keyword function

A

block scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does it mean to say that variable names are “case sensitive”?

A

score and Score are different

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of a string?

A

for text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of a number?

A

to calculate and measure stuff, financial stuff.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of a boolean?

A

for decision making

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the = operator mean in JavaScript?

A

assignment operator, it assigns/store the value to the variable. value will correlate with the variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the = operator mean in JavaScript?

A

assignment operator, it assigns the value to the variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do you update the value of a variable?

A

with an assignment operator, no need for keyword. variable = value
name = “yay”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the difference between null and undefined?

A

undefined is never assigned by a user/programmer, it is a result that only the browser/javascript will give.

null is a value and is assigned and meant to on purpose.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Why is it a good habit to include “labels” when you log values to the browser console?

A

to see what that console log is for and easier to read/know when coming back to it later. makes it clear.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Give five examples of JavaScript primitives.

A

number, string, boolean, null, undefined.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

example of uniary operator

A

typeof

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What data type is returned by an arithmetic operation?

A

number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is string concatenation?

A

adding 2 or more strings to make it into one string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What purpose(s) does the + plus operator serve in JavaScript?

A

it can add 2 numbers, can add two strings into one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What data type is returned by comparing two values ( less than, greater than, ===, etc)?

A

boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What does the += “plus-equals” operator do?

A

shorthand for adding the variable with an additional value and the result of that get the new value for the variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What are objects used for?

A

to group together a set of variable and functions to create a model of something that are related.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What are object properties?

A

they are variable. properties tells us about the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Describe object literal notation.

A

it is to create an object. object is in curly braces and the object gets stored in a variable

keyword-variable variable = {
property: key value,
property: key value,
method: key(function-name) value(function)
};
*in object, functions are known as methods
variables are known as property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How do you remove a property from an object?

A

with delete operator

delete object.property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What are the two ways to get or update the value of a property?

A

with a dot notation or the bracket notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

how do you read vehicle[‘color’]?

A

vehicle at string color

[] usually read as at

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

what is delete?

A

delete operator

Ex. delete pet.name . delete operator is being used on name property of pet object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What are arrays used for?

A

used when working with a list or a set of values that are related to each other. full view of that category

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Describe array literal notation.

A

with an open bracket and closing bracket [ ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

How are arrays different from “plain” objects?

A

array: number index, know how many data there are, can add data by using method, numerical order
object: property names, cannot know how many property/method there are, can add by using assignment operator, not a numerical order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What number represents the first index of an array?

A

[0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What is the length property of an array?

A

it gives the result of how many values are in an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

How do you calculate the last index of an array?

A

length - 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What is a function in JavaScript?

A

reusable tool that give directions on what to do/process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Describe the parts of a function definition.

A
function keyword with the function name(optional) parameters list(s) (optional) opening a function code block {
what to process or the optional return statment
closing a function code block }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Describe the parts of a function call.

A

the function’s name with the arguments(optional if more than one-separated with commas)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

function call needs only the funtion name and parentheses, arguments are optional. function definition is basically structuring the function so that it can be used when called. it has what is to be processed once called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What is the difference between a parameter and an argument?

A

arguments are the data we are asking to use as an input from a function call.
parameters are the data that is unknown until the function is called with arguments. we take to use it inside the function: a placeholder.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Why are function parameters useful?

A

it can take on the values of the arguments that were passed to be used in the function. ability to have utibility. provides a functionality of same process but with different data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

What two effects does a return statement have on the behavior of a function?

A

it will exit the function, codes after the return statment will not executed.
it will produce a value in place of the function call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

What is the purpose of a loop?

A

to have a condition of iterate trough a number of times. to repeat functionality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

What is the purpose of a condition expression in a loop?

A

to make a stop condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

What does “iteration” mean in the context of loops?

A

number of time it repeats the code block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

When does the condition expression of a while loop get evaluated?

A

in the beginning, before it executes the while loop code block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

When does the initialization expression of a for loop get evaluated?

A

only once in the beggining before executing the for loop code block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

When does the condition expression of a for loop get evaluated?

A

on the first time, it will execute after the initialization and, everytime before it executes the code block, but after the final expression on every iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

When does the final expression of a for loop get evaluated?

A

before the condition and after the code block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

What does the ++ increment operator do?

A

it increaments a number by one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

How do you iterate through the keys of an object?

A

by using for…in loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Why do we log things to the console?

A

to make sure it does what you are expecting to do. To keep track and know what the ouput is coming out as expected.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

What is a “model”?

A

representation of something

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Which “document” is being referred to in the phrase Document Object Model?

A

html document

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What is the word “object” referring to in the phrase Document Object Model?

A

list of properties and values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

DOM

A

Document Object Model, javascript object that is modeling html document contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

What is a DOM Tree?

A

collection of all the information that conveys one content, children, text content, elements,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

Give two examples of document methods that retrieve a single element from the DOM.

A

getElementById, querySelector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

querySelectorAll, getElementsByClassName, getElementsByTagName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

Why might you want to assign the return value of a DOM query to a variable?

A

easier to access or to call

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

What console method allows you to inspect the properties of a DOM element object?

A

dir method. console.dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

Why would a tag need to be placed at the bottom of the HTML content instead of at the top?

A

because the document flow, the load order, it will load from top to bottom. it will not have the info to load if script is above since it didn’t load all the body.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

What does document.querySelector() take as its argument and what does it return?

A

takes a string css select, and will return the first element from top to bot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

What does document.querySelectorAll() take as its argument and what does it return?

A

takes the string and will return all the elements in that string, in NodeList.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

what is NodeList

A

array-like object, can’t easily add content like the array.push, push method will not word since NodeList is not a true array. can use like array.

71
Q

What is the purpose of events and event handling?

A

the purpose of events is to process how to take action when user interacts with the HTML web page.
event handling 3 steps to trigger JS codes.
1. select the element
2. what even will trigger the response (specify event)
3. execute the code. (call code)

purpose, to be aware of when the action happens, handling allows us to do something when it occures

72
Q

Are all possible parameters required to use a JavaScript method or function?

A

no

73
Q

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

addEventListener

74
Q

What is a callback function?

A

a function passed into another function as argument.

75
Q

What object is passed into an event listener callback when the event fires?

A

event object. when event occurs, JS will create an object of that event.

76
Q

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

it is what the event is targeting. place where the even occured from, originated. log out event.target, or MDN

77
Q

What is the difference between these two snippets of code?

element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())

A

handleClick => call back function. name of the function to call, passing the function as an argument/parameter to the addEventListener() method

handleClick() => it will just call the function without there is no argument/parameter. not a call back function. will call the function loads

78
Q

What is the className property of element objects?

A

property containing the value of p

79
Q

How do you update the CSS class attribute of an element using JavaScript?

A

with className, elementObject.className = value

80
Q

What is the textContent property of element objects?

A

property containing the text of element

81
Q

How do you update the text within an element using JavaScript?

A

assignment operator

82
Q

Is the event parameter of an event listener callback always useful?

A

not always useful, if we know what exact element we want to change.

83
Q

Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?

A

complicated. to be readily available in a form we understand

84
Q

What event is fired when a user places their cursor in a form control?

A

focus

85
Q

What event is fired when a user’s cursor leaves a form control?

A

blur

86
Q

What event is fired as a user changes the value of a form control?

A

input

87
Q

What event is fired when a user clicks the “submit” button within a ?

A

submit, for the form, the addevent should be submit

88
Q

What does the event.preventDefault() method do?

A

prevents the default action to be taken.

89
Q

What does submitting a form without event.preventDefault() do?

A

it reloads the page, and data input will be lost.

90
Q

What property of a form element object contains all of the form’s controls.

A

elements, every form element has elements

91
Q

What property of a form control object gets and sets its value?

A

value of form control element

92
Q

What is one risk of writing a lot of code without checking to see if it works so far?

A

potential risk is that the code from the beginning might be wrong.

93
Q

What is an advantage of having your console open when writing a JavaScript program?`

A

you can check your work in real time

94
Q

Does the document.createElement() method insert a new element into the page?

A

no, it only creates the access to DOM

95
Q

How do you add an element as a child to another element?

A

appendChild
called on parent and the argument is child
parent.appendChild(child)

96
Q

What do you pass as the arguments to the element.setAttribute() method?

A

string with the attribute and the value

97
Q

What steps do you need to take in order to insert a new element into the page?

A

createElement, setAttribute and or add textContent, appendChild, if we have something we want to append to is already on the DOM, use querySelector.

98
Q

What is the textContent property of an element object for?

A

adding/changing text to Node or retrieve the current text value.

99
Q

Name two ways to set the class attribute of a DOM element.

A

setAttribute(), className()

100
Q

What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?

A

reuse and able to remember easily

101
Q

What is the event.target?

A

the element that the event is targeting. property that is a reference to the event that is fired from.
where event originated from

102
Q

Why is it possible to listen for events on one element that actually happen its descendent elements?

A

since we query to DOM of the parent, due to event bubbling.

103
Q

What DOM element property tells you what type of element it is?

A

tagName <= should use for when targeting element, nodeName <= use for text name?

104
Q

What does the element.closest() method take as its argument and what does it return?

A

argument is CSS selector, and return closest ancester.

querySelector looks inward decendents whereas closest looks outward ancestor.

105
Q

How can you remove an element from the DOM?

A

remove method, on the object for the DOM element you want to remove

106
Q

If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?

A

add to nearest parent/ancestor

107
Q

What is the event.target?

A

where the event is originated from,

108
Q

What is the affect of setting an element to display: none?

A

it removes the display of the element with that property pair.
gets removed from document flow

109
Q

What does the element.matches() method take as an argument and what does it return?

A

takes CSS Selector in a string as an argument and returns boolean, true/false. if it matches the selector with element.

110
Q

How can you retrieve the value of an element’s attribute?

A

getAttribute() / method, the argument will be the string of the name of attribute.

111
Q

At what steps of the solution would it be helpful to log things to the console?

A

when expecting something to happen and checking if it matches your expectation.
to check when you grab something to assign to variable and checking if the variable is actually storing it

112
Q

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?

A

will have to add eventListener for each one, it is a code that is not scaleable.

113
Q

If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?

A

will have to manually do if statement for each of the new thing to check

114
Q

What is JSON?

A

JS Object Notation, format for rendering data follows JavaScript

115
Q

What are serialization and deserialization?

A

serialization: JSON.stringify is an example, making a data into all string and is stored in one location all in a row, in one continuous stream.
deserialization: taking the serialized data and making it into a javascrip object, making efficient accessible.

like packing for a trip, toothbrush, clothes, accessories into one bag.

116
Q

Why are serialization and deserialization useful?

A

deserialized data is easier to work with, good for interaction with the data

serializaed is good for getting info

117
Q

How do you serialize a data structure into a JSON string using JavaScript?

A

stringify method of the JSON obj

118
Q

How do you deserialize a JSON string into a data structure using JavaScript?

A

JSON.parse()

119
Q

How do you store data in localStorage?

A

setItem() method of localStorage

120
Q

How do you retrieve data from localStorage?

A

getItem() method of localStorage

121
Q

What data type can localStorage save in the browser?

A

only strings

122
Q

When does the ‘beforeunload’ event fire on the window object?

A

when the resouses are about to be unloaded, close a tab, refresh tab, close the broswer or crashes.

123
Q

What is a method?

A

is a function
A function which is a property of an object. 2 kinds of methods:
instance methods, which are built-in tasks performed by an object instance.
Static methods which are tasks that are called directly on an object constructors.

124
Q

How can you tell the difference between a method definition and a method call?

A

in method definition, will have to assign function with the parameter, if needed, and the function code block to the method’s name (property). funtion keyword.
in a method call, you will actually use that method to process what is inside the function code block by calling the property name with () and argument if needed.

125
Q

Describe method definition syntax (structure).

A

within an object.

method_name: function () { }

126
Q

Describe method call syntax (structure).

A

object.method_name(arguments);

127
Q

How is a method different from any other function?

A

a method is a property of an object while function is not. associated/attached with an object,
in order to call a method, need a dot notation and the object.
object.method

128
Q

What is the defining characteristic of Object-Oriented Programming?

A

it can have both data (as properties and values) and behavior (as methods)

129
Q

What are the four “principles” of Object-Oriented Programming?

A

Abstraction
Encapsulation
Inheritance
Polymorphism

130
Q

What is “abstraction”?

A

able to work with (possibly) complex things in simple ways.

It only displays the relevant attributes of objects and hids the unnecessary details

131
Q

What does API stand for?

A

Application Programming Interface

132
Q

What is the purpose of an API?

A

to give programmers a way to interact with a system in a simplified, consistent fashion: aka, an abstraction.

133
Q

What is “this” in JavaScript?

A

“this” is a keyword and it determines by how a function is called. always a reference to an object.
when it’s being provoked

134
Q

What does it mean to say that this is an “implicit parameter”?

A

it is availalbe in a function’s code block even though it was never included in the function’s parameter list or declared with “var”
it’s alway there, able to get the value of it.

135
Q

When is the value of “this” determined in a function; call time or definition time?

A

it is determined in the call time.

136
Q
What does this refer to in the following code snippet?
var character = {
  firstName: 'Mario',
  greet: function () {
    var message = 'It\'s-a-me, ' + this.firstName + '!';
    console.log(message);
  }
};
A

nothing, since it’s not called yet.

137
Q

Given the previous (card #137) character object, what is the result of the following code snippet? Why?

character.greet();

A

It’s-a-me, Mario!
because it is using this object’s (character) firstName.
since we invoked character.greet();

138
Q
Given the previous (card# 137) character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();
A

it will console.log “It’s-a-me, undefined!”
because there is no firstName property in hello object?

hello() is free floating function. when there is no object, it will try to access window and windows doesn’t have a property named firstName.

139
Q

How can you tell what the value of “this” will be for a particular function or method definition?

A

use the object and the method without the parantheses

can’t guarantee it’s going to be anything.

140
Q

How can you tell what the value of “this” is for a particular function or method call?

A

use the object and the method with the parantheses

whatever is the left of the dot.

141
Q

What kind of inheritance does the JavaScript programming language use?

A

prototype-based (prototypal inheritance). In prototypal inheritance, an object “inherits” properties from another object via the prototype linkage.

move properties and methods that we’d like to reuse into a “prototype” object and then tell other objects to simply delegate to that “prototype” object when they aren’t able to perform the required tasks themselves

142
Q

What is a prototype in JavaScript?

A

an object that is associated with every functions and objects by default. where function’s prototype property is accessible and modifiable and object’s prototype property (aka attribute) is not visible. every function includes prototype object by default.

JavaScript prototype is simply an object that contains properties and (predominantly) methods that can be used by other objects. created a tool that can be passed to be used by others.

143
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on strings, arrays, and numbers?

A

these methods are defined on a “prototype” object and arrays and strings simply borrow those methods when they’re needed. will have a prototype that will have the shared behavior

144
Q

If an object does not have it’s own property or method by a given key, where does JavaScript look for it?

A

prototype object. it will search it’s nearest paraent and nearest parent and so on. prototypal chain. will look at prototypal chain ancestor.

145
Q

What does the “new” operator do?

A

creates an instance of a user-defined object type or one of the built-in object types that has a constructor function.

  1. makes an empty object
  2. run the function block
  3. it returns an object if no return is specified.
146
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

prototype property.

147
Q

What does the instanceof operator do?

A

tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object.
object instanceof class(constructor function)

148
Q

What is a “callback” function?

A

function passed arond as a variable inside function to be called later

149
Q

Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?

A

setTimeout()

150
Q

How can you set up a function to be called repeatedly without using a loop?

A

setInterval()

151
Q

What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?

A

0, it runs immediately or more accurately, the next event cycle
action gets pushed into que immediately

152
Q

What do setTimeout() and setInterval() return?

A

timeoutID and intervalID, which is a positive integer

153
Q

What is AJAX?

A

Asynchronous JS and XML. allows you to update parts of the DOM of an HTML page without need for a full page refresh

154
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML

155
Q

Which object is built into the browser for making HTTP requests in JavaScript?

A

new “XMLHttpRequest” ()

156
Q

What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?

A

‘load’ event

157
Q

Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?

A

prototypal inheritance. they share a prototype

158
Q

How do you remove the last element from an array?

A

pop() method

159
Q

How do you round a number down to the nearest integer?

A

Math.floor(). Math.trunc = will chop the decimals

160
Q

How do you generate a random number?

A

Math.random()

161
Q

How do you delete an element from an array?

A

splice

162
Q

How do you append an element to an array?

A

push

163
Q

How do you break a string up into an array?

A

split

164
Q

Do string methods change the original string? How would you check if you weren’t sure?

A

string methods do not change. use console.log

165
Q

Roughly how many string methods are there according to the MDN Web docs?

A

a lot refer to string in MDN

166
Q

Is the return value of a function or method useful in every situation?

A

NOT ALL, push and unshift are not really useful

167
Q

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN

168
Q

Give 6 examples of comparison operators.

A

> , >=, <, <=, ===, !==

169
Q

What data type do comparison expressions evaluate to?

A

BOOLEAN true/false

170
Q

What is the purpose of an if statement?

A

to check if the condition stated in the if statement is true and if true, process the code inside the conditional code block. evaluates/checks a condition, if true, any statement in the subsequent code block are executed.

171
Q

Is else required in order to use an if statement?

A

no it is not required, else is used when the condition in the if statment is false.

172
Q

Describe the syntax (structure) of an if statement.

A

if (condition) {

}

173
Q

What are the three logical operators?

A

and &&, or ||, not !

174
Q

How do you compare two different expressions in the same condition?

A

by using the logical operator &&, ||

175
Q

does the condition in if statment have to be true/false

A

no, it can also look at truthy/falsy values