Free Code Camp Flashcards

1
Q

what does target=”blank on a link mean?

A

it means that when you click on a link it opens in a new window

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

how do you create an internal link to another section of the website?

A

on the href of the a tag…. you add the id of the section you want to go to

a href=#contactsPage

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

how do wwe comment out in html? (non shortcut)

A

basically two arrows using dashes, the first set gets an exclamation point

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

how do you make an image a link?

A

nest the img tag inside of an anchor tag

a href >

img src />

/a>

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

What does HTML stand for?

A

Hyper Text Markup Language

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

Using the analogy of a body, what is HTML?

A

The bones of the body.

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

h1 is the first h tag, what is the lowest ?

A

it goes from h1 - h6

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

What is the purpose of h1 - h6 tags

A

Tells the browser about the structure of your page

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

h1 is specifically used for what?

A

Main heading of page

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

h2 is specifically used for what?

A

sub headings on page

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

h3 - h6 is specifically used for what?

A

for different sections on the page

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

What does every img tag need?

A

an alt tag

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

What does an alt tag do? What is the purpose?

A

In the event that a picture doesnt load, the alt tag’s text will be displayed so we will still know what it is.

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

What is the difference between an ul and an ol tag? And what do they stand for?

A

The ul, is an unordered list - meaning that the order of the list item doesnt matter. The list items are bulleted.

The ol, is an ordered list - meaning that the order of the list items does matter. The list items are numbered.

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

When do you use an input tag?

A

When you want the user to input information, or you want to gather information from the user.

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

What type of input do you use when you want the user to enter text?

A

input type =”text”

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

What do we want to wrap a collection of our inputs in?

A

a form tag

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

What attribute do we want to place on a form tag? And what does its value do?

A

action =

its value tells the form what to do with the information that has been input by the user.

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

How does a form tag know when the user is done entering information inside of the input tags it contains?

A

The best practice is a submit button that a user can click at the end of the form. This will trigger the action attribute on the form tag.

button type=”submit”

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

What is the required attribute on an input tag do? And When do we want to use it?

A

It makes an input box required to be filled for the submit button to work.

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

What are radio buttons and how do you render them?

A

Radio buttons are for when you want the user to pick only one answer out of a list of choices.

input type=”radio”

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

What should we always nest our radio and checkboxes inputs in ?

A

a label tag

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

What do label tags do?

A

a label renders the name of the choice to the user so they can see what they are clicking.

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

What happens if you dont use label tags on checkboxes and radio buttons?

A

The boxes and buttons will have no names for the user so he or she will not be able to make a selection because they wont know what they are actually choosing. It’s pointless without labels

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

All radio button inputs must share the same type=”radio” and what other attribute?

A

They must share the same name attribute, this way the page knows that only one of the buttons can be selected at a time. If buttons dont have the same name multiple ones can be selected at the same time, thus defeating the purpose of radio buttons in the first place

input type =”radio” name=”gender”
input type =”radio” name=”gender”

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

Whats the difference between radio buttons and checkboxes?

A

With radio boxes you check one of a group.

With checkboxes you can select one or more. Or you can select none

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

All input tags should have at least what four attributes?

A

type name id {always}

value {for react and changing state in react}

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

What is the checked attribute and what type of inputs does it go on?

A

It sets particular buttons to be already checked by default. The user would have to click it to uncheck it or check another option to change it if it were incorrect.

It goes on radio inputs and checkbox inputs

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

What does CSS stand for?

A

Cascading Style Sheets

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

What is the DOM stand for?

A

Document Object Model

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

What is Inline Styling?

A

It is styling an HTML element directly in the HTML line of code.

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

What attribute do we add to the HTML element in order to add inline styling?

A

style=” “

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

How do we apply the value to a style tag?

A

style= “ name : value “

style=”color: red”

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

What does the CSS property ‘color’ do?

A

It sets the color of the text of an element

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

What is Internal Styling?

A

It is styling an HTML element inside the HMTL file but not inside of the line. You do it the same way as you would style it externally except that you wrap the styling in a style tag.

style >
  h1 {
     color: blue
}
/style>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What CSS property changes the font?

A

font-family:

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

What tag and attribute combination do we use to import fonts/stylesheets to our HMTL page?

A

link href />

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

What is the head tag?

A

The Head tag is where we place all our meta data about our page, like the stylesheets and fonts and tltles etc. Not the actual content that will be rendered.

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

What is the Title tag?

A

The Title tag is the name of page. It is the name or the content that shows up on the tab when the page opens. Usually goes along with a logo

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

How do you add multiple fonts to a font-family and why would you do that?

A

You add a comma between the names of the fonts

font-family: helvitica, sans-serif

You would do this to basically say….if the first font is there - use that. If not, use the other. If neither is there then your browser will assign a default font.

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

How do we make any border into a perfect circle?

A

border-radius : 50%

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

What does the CSS property Padding do?

A

It increases the space between the content of an element and its borders on all sides.

p {
padding : 20px
}

this will push the borders on the top, left, right, and bottom away from the paragraph text.

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

What happens if you set the padding of an element ‘s content to a value less than the established width or height already assigned?

A

You wont see a difference in appearance. The padding will get bigger still, but you wont see it because it wont actually affect the border at all because the border is already farther out

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

What is the CSS property Margin do?

A

It increases the space between the border of the element and other elements on the page

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

What is the operating order of Clockwise Notation?

A

top, right, bottom, left (like a clock)

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

What is the name of setting 4 numeric values to a CSS property like border to an element?

A

Clockwise Notation.

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

What is Inheritance in CSS?

A

When an element has no specific styling in regards to a particular aspect of its appearance and adopts or inherits styling from a parent element or grandparent that it is nested in.

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

When you have contradictory styling on a HTML element, which styling is going to get applied?

A

The more specified element

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

When you have contradictory styling on a HTML element, AND they have the same specificity which styling is going to get applied?

A

The style rule that is lower on the style-sheet.

It gets read in the code last so it gets applied to the DOM last so its the one that you see,

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

If your HTML element has multiple classes with contradictory styling declarations, does the order of these classes in the element code affect which style gets rendered?

A

No the order of the classes and how they are listed and applied to the element have no bearing on which style gets rendered. In this case, the style that is lower in the style sheet is the one that will get rendered.

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

If you have contradictory styling declarations on an HTML element, lets say one set rules on a class and another on an id , which style will get rendered?

A

The Id style will get rendered because it is more specific than class

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

When it comes to CSS styling, what overrides any other type of CSS rules being declared on the element?

A

Inline Styling.

Hard coding the element with a style attribute will override any CSS assigned through internal or external stylings.

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

What CSS keyword can you use to get CSS to ignore normal Override Rules and apply a particular CSS declaration?

A

!important

p {
color: red !important
}

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

When setting a CSS value for any one of the color properties, how does RGB work?

A

rgb( red, green, blue, transparency)

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

In a RGB value what is the lowest and highest possible values for the Red, Green and Blue values?

A

0 minimum
255 is the maximum.

Theres 256 values all together with the counting beginning at 0.

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

What is the RGB value for the color black?

A

color: rgb( 0,0,0)

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

What is the RGB value for the color white?

A

color: rgb(255, 255, 255)

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

Which CSS property do we use to adjust the text of an element?

A

text-align:

example:

h1 {
text-align: center;

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

What does the CSS value justify do?

A

Stretches the lines so that each line has equal width (like in newspapers and magazines) except the last line.

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

How do you make something bold text?

A

By adding a strong text around the text

or adding font-weight: bold to it in CSS

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

How do you make something underlined?

A

use the u tag

or

text–decoration: underline in CSS

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

How do you make text italicized?

A

use the em tag

or

font-style: italic in CSS

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

How do you make text with a line cutting through it (strike-through text?

A

use the del tag

or

text-decoration: line-through

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

What does the hr tag do?

A

Its a self closing tag that creates a horizontal line that goes across the length of its containing element.

This is good for sectioning off different topics or sections

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

In RGB, we know that it stands for red, green and blue, but what is the name of the section that controls transparency?

A

Alpha

rgba( 0,0,0,0.1)

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

In RGBA what is the range of possible values for Alpha?

A

0 - 1

example 0.2

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

When setting Alpha values, which contains the most opacity and which contains the least opacity?

A

0, is the most - completely see through

1, is the least - not see through at all

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

What does the CSS property Box Shadow do?

A

It attaches one or more shadows to an element

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

What is the basic syntax for Box Shadow Property?

A

box-shadow: horizontal offset vertical offset color

box-shadow: 5px 5px blue

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

If we want to add multiple shadows to an element how do we do so?

A

By adding multiple shadow values to an element separated by a comma

box-shadow: 5px 5px blue, 10px 10px red, 15px 15px green;

this will give us an element with three different and distinct shadows

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

What is the Blur value on Box-Shadow in CSS and where do we set it in the syntax?

A

The Blue value applies a blurred effect to the shadow of your element. If you want to apply this you would add it after the value for the Vertical Offset. The higher the number the more blurred the shadow.

box-shadow: 5px 10px 18px red

this would be very blurred; if 18px was changed to 3px the blur effect would decrease significantly

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

What is the Spread value on Box-Shadow in CSS and where do we set in in the syntax?

A

The Spread value determines how big the shadow of the element is, a positive number increases the shadow. A negative number decreases the shadow.

The value will be fourth on the box-shadow property

box-shadow: 5px 10px 18px {10px} red

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

If we want to adjust the transparency of an element, but dont need to set a full RGBA property, what CSS property do we use? And what values do we use?

A

Opacity -

And you can set anything from 0.1 to 1.0 …..the higher the number the less see through it will be.

The lower the number, the more see through it will be.

You can use double digit decimals as well

Opacity: 0.25 would set it to 75% opacity.

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

What is the Text-Transform Property in CSS? And what are three values and what do they do?

A

It adjusts the capitalization of text.

lowercase : makes the text lower case
uppercase : makes every letter uppercase
capitalize : makes the first letter of every word capital.

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

What do you need to add to the value of a Font-Family property in CSS when importing it from a stylesheet as opposed to a ready built in font already known by your browser?

A

You need to add quotations.

{built in fonts}

font-family: monospace;

{imported fonts]

font-family: “Open sans” ;

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

What is Font-Weight in CSS? What are the numeric values? What are the non numeric values?

A

It sets how think or thin you want the characters of text to be.

Numeric Values are set from 100 - 900

900 being more bold, 100 being the the least

____________________________________

Non Numeric Values are :

lighter
Normal (400)
bold (700)
bolder

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

What is Line-Height Property in CSS and what is the default setting for most browsers?

A

The Line-Height property determines how much space there is in between lines. This is the most effective way to adjust how much room a group of text will take up on the page.

The default setting for line-height in most browsers
is 110% - 120%

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

How can we remove the underline effect on the hyperlinks of your page, or any other underlined element?

A

text-decoration: none;

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

What is the Hover pseudo-class? What is the syntax to apply it?

A

It allows a visual effect to take place when the mouse/cursor goes over an element but doesn’t click or do anything to activate the element.

element : hover {
property: value
}

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

What is CSS Box Model in a nutshell?

A

CSS treats each individual element as its own box

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

What is a Block-Level Elements?

A

It is an element that automatically begin on a new line.

Think : paragraphs, divs and headers tags

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

What are Inline-Elements?

A

They are element that sit on the same line as other elements, and are surrounded by other elements.

Think: span, bold, underline, image tags

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

What is Normal Flow of a document?

A

Displays elements as they are listed on the document, starting from the top left of the page and go straight down to the bottom.

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

What CSS property can we use to take a document out of Normal Flow?

A

We can use the CSS property Position

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

What does the value of Relative do on the CSS Position property?

A

It allows you to take an element out of normal flow and move it in relation to its regular position in Normal Flow

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

What CSS properties are used in conjunction with Position: Relative to move the desired element?

A

left, right, top and bottom

values can be pixels or percentages.

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

Does changing an element out of Normal Flow take the whole page out of Normal Flow?

A

No it doesn’t. The rest of the page stays in normal flow. The Position property overrides Normal Flow on that specific element but doesn’t change the flow of the page all together.

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

If you can move elements wherever you want using the Position property, does it matter how you write your HTML? People never see it, so what does it matter?

A

Practicing good Semantic HTML is important even if it doesn’t visually represent how the page will look. Mainly because the structure of the page represents the importance of information for screen readers and search engines and allows visually impaired users to successfully navigate and access the desired information on your page.

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

What is the Absolute value for the Position property do?

A

It locks the element in place relative to the closest positioned ancestor. Usually a parent an usually this is done by declaring position: relative on the parent.

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

What happens if you declare Position: Absolute and its parent isnt a positioned element?

A

It will keep looking up the chain looking for a positioned element. If it doesn’t find one it will default to the body tag.

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

When an element is given Position: Absolute, does it remain in normal flow ?

A

No, the element is taken out of normal flow and all of the other elements ignore it like it isnt even there.

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

What is the value of Fixed for the CSS property Position?

A

It is a type of absolute positioning where the element is positioned in relation to the browser window.

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

Are elements that are assigned with the Position of Fixed taken out of Normal Flow?

A

Yes, they are taken out of Normal Flow and other elements don’t realize that the element is there at all

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

What is the main difference between Absolute and Fixed besides its Position relativity?

A

The Fixed element doesn’t move when the user scrolls. It stays in that one spot no matter what the user does.

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

What is the Float property in CSS? And what values does it take?

A

Floated elements take a value of either Left or Right.

This property will take the element and place it either to left or the right of its parent container

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

Which CSS property is often used with Float to adjust how much horizontal space it takes up of the parent element?

A

It is used with Width.

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

Does Absolutely positioned elements recognized the Float property on other elements?

A

No, they ignore them.

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

How can you use a Div and the Float property to style the first letter or word of a paragraph?

A

You can put a div around the first letter, apply Float: left to it to have it stand out from the rest of the paragraph.

Apply a class name to the div, then go into CSS and add styling to the class name to enlarge it or make it a different font or color.

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

Do Floated elements remain in Normal Flow?

A

No they do not, they are taken out of normal flow..so other elements will go along side the left or the right of them if there is space

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

What does the CSS Clear property do?

A

When an element is given the Float property, it is taken out of Normal Flow meaning that other elements will go along the left or the right of it. This might not be a desired effect. Adding a Clear property will tell the browser to not place any elements along side the element in that direction.

note: this only applies to other floated items. so if you want to clear the space both the element and the element you are trying to clear must be floated

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

What are the values of the Clear property in CSS?

A

Left, Right and Both

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

What is the Z-Index property in CSS?

A

When elements are positioned to overlap, the element coming later in the HTML markup will by default appear on top of the earlier written elements.

Z-Index allows you to specify the order in which these elements overlap

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

How does the specification of elements using Z-Index work?

A

Every element that is in the overlap stack takes the property Z-Index: with a full number as a value. The element with the highest number will be on top and the element with the lowest number will be on bottom.

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

How can you center a block element horizontally?

A

by setting its Margin to Auto

if there is no other element on the left or the right of it that is in its way, the block element will be centered

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

Images by default are what type of elements?

A

Inline Elements

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

How do you change an Inline Element to a Block Element?

A

Display: Block

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

What is Linear-Gradient and what CSS property is it used with?

A

It is a way to make one color change into another color.

It is accessed with the CSS property Background.

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

Since Linear-Gradients have to do with color, can we use them whenever we want to add color somewhere, like text or borders?

A

No we cannot because Gradient is technically an Image data type, so it can only be used where images can be used. Basically, through the Background property

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

What is the syntax of Linear-Gradient?

A

Background: Linear-Gradient( gradient direction, color 1, color 2, color 3….)

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

What is Repeating-Linear-Gradient?

A

Repeating Linear Gradient is like Linear Gradient except that it requires color Start/Stop points other wise it works just like regular linear Gradient.

Also, where you place the stop point for the final color will be where the first repetition of the colors will begin. For example

(red 0%, blue, yellow50%)

would have red start the transition and go to blue and then yellow and this transition would be completed at the halfway mark of the div. Then the transition would start again with Red at 51% and then blue and yellow at 100%, which would be a total of two repetitions of the pattern

if you set it as
(red0% blue yellow 10%)

the entire transition would be complete at 10% and then repeat again and again until the div was taken up, meaning there would be a total of 10 repetitions of the patterns

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

What is the default direction for Gradients?

A

Top to Bottom

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

What are the directional Gradient values?

A
To Bottom (default)
To Right 
To Left 
To Top 
To Top Left
To Top Right
To Bottom Left
To Bottom Right
(+/- num)degs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
113
Q

When you use a Linear Gradient, when does the transition from one color start to take place?

A

It starts happening right away. The colors will not be pure except for the end and the very beginning

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

Is there a way for you to set where the transition from one color to the next begins to take place when using a Gradient?

A

Yes, you can add a percentage or a px value after the name or assignment of the color to say basically :

“start transitioning here”

linear-gradient( red 25%, blue)

this will keep red pure all the way until it reaches 25% of the container and then start transitioning to blue along the remaining 75% until it reaches pure blue at the end

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

What is Radial-Gradient?

A

It is the same as Linear-Gradient, but it goes in a circle instead of in one direction

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

What happens if you set the end of a color in the same place as a beginning of a color using a Gradient?

A

There will be no transition, the colors will just have a clean break with a switch from one color to the next

linear-gradient( red 50%, blue 50%)

in the middle of the page, the colors will switch from red to blue with no transition

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

When adding color starts and stops, how many values can you place per color?

A

Two - a start and a stop

(red 35% 50%)

this would make the color red go from 35% of the element - half way through the element.

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

Do the first and last colors in a Gradient need to have both start and stop places specified?

A

No, the first color will start at 0% by default so only the stop place is required.

The last color will automatically stop at 100% so only the start place is required.

(red 25%, blue 25% 50&, yellow 50% 75%, orange 75% )

red is already starting at zero
orange is already stopping at 100

so additional start and stop values arent needed.

Blue and yellow are in the middle, so where they start and stop need to be added if you want to specify where the transition starts and stops

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

How do we add a Background Image to an element?

A

background-image: url(‘ ‘)

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

What does the value Scale do on the Transform CSS property? And what is the syntax?

A

It allows you to increase the size of your image or image like element. The number you put in the parenthasis is the amount of times larger the element compared to its normal, or currently set size.

transform: scale(3)

this will make a picture or image like element three times as big as it currently is

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

What does the SkewX and SkewY value do on the CSS property Transform? What is the syntax?

A

It skews the edges diagonally along the X or Y axis.

transform: skewX(23deg)

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

What do the pseudo elements :Before and :After do?

A

They target or set what comes before or after an element. For example of a list element

li : before {
content: “this is a list item”
}

This would make the string

this is a list item come before every list item on the page

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

What is the Animation-Name and Animation-Duration CSS properties? Where are they placed?

A

They describe the name of the animation and how long it will take to complete or to run the entire animation.

These are placed inside of the elements CSS rule set.

h1 {
animation-name: changeColors;
animation-duration: 10s;
}

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

How do you we set what actually happens in the animation after we have set it on a particular element in CSS?

A
We use 
@keyframes animation-name {
length of time {
what we actually want to happen
}
}
@keyframes changeColor {
0% {
          background-color: red
       }
50% {
           background-color: black;
        }
}

This will start the back ground color at red….this would last for 5 seconds ( if we set the animation duration for 10 seconds) and then it would turn black.

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

What are some popular times to use Animation to change colors or add different effects like slightly enlarging the size of an element?

A

During Hover’s or button onclicks

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

What is Animation-Fill-Mode: Forwards in CSS and why do we use it?

A

When we set an animation, at the end of the duration, it reverts back to its original state and will run again once the code is called again.

Animation-Fill-Mode: Forwards

sets it up so the element stays at the final stage as long as what triggered the animation is still true.

for example, if a page load triggers the animation, then the final animation stage will remain visible because the page is still loaded and will not reset until the page is loaded again.

if Hover triggers the animation, then animation will remain in the final stage as long as Hover is still being utilized. Once you move your mouse, the original animation stage will take back over and will refire once Hover is reapplied.

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

Can you use Animation Rules to create movement of elements on a page?

A

Yes you can, as long as an element has a specified position like relative or fixed. The CSS offset properties like left/right can be used to create animation movement.

This is an example of @keyframes moving an element up and then down while changing the color.

@keyframes rainbow {
  0% {
    background-color: blue;
    top: 0px;
  }
  50% {
    background-color: green;
    top: 50px;
  }
  100% {
    background-color: yellow;
    top: 0px;
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
128
Q

What is the CSS property Animation-Iteration-Count? Which values can it take?

A

This property sets how many consecutive times your animation will run.

You can set it to a specific number
or you can set it to infinite and the animation will keep running.

animation-iteration-count: 3
animation-iteration-count: infinite

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

What is a good styling tip to keep in mind about your Animated elements?

A

You can change their size movements, colors and durations and how many times they run independent of one another. They dont need to all share the same rules so that they have a uniform look….sometimes its good to give them their own independent life so it looks more interactive and lifelike and less robotic.

think of the twinkling stars challenge

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

What is the Animation-Timing-Function property in CSS? What is a good mental model to have about it so it doesnt get confused with Animation-Duration?

A

Animation Duration is the overall road trip. SF to NY. This is the total ground that needs to be covered. We can set this to 5 seconds. This is how long the trip is from A - B.

Animation-Timing-Function is how that trip is travelled. The distance from SF to NY will still be the same and take the same amount of time, but do you speed first through the western states and slow down and take your time in teh eastern states? Or do you take your time and sight see in the western states and speed through the eastern states to get to your destination?

Or do you just take a nice steady course, nice and easy all the way through?

Animation-Timing-Function determines this mode of travel.

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

What is the default value for Animation-Timing-Function whether set or not? What does this value mean?

A

Ease.

start slow, speed up in the middle, slows down again in the end.

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

What is the Ease-Out/Ease-In value on the CSS Animation-Timing-Function property?

A

Ease-Out:
Quick start. Slow End.

Ease-In:
Slow start. Fast End

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

What is the Linear value on the CSS Animation-Timing-Function property?

A

This applies a constant animation speed throughout the course of the animation duration.

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

What does Accessibility refer to, when being discussed in the context of Web Development?

A

means having web content and a user interface that can be understood, navigated, and interacted with by a broad audience. This includes people with visual, auditory, mobility or cognitive disabilities

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

Why is an ALT tag important for search engines?

A

Alt tags are used by search engines to index what is in a photo so it can return related images to a search.

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

Why is an ALT tag important for visually impaired users? If they can’t see the image or the text, why would an ALT tag help them at all?

A

The ALT tag is also read by screen readers so people who cant see can be told what is in an image audibly

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

What are some times where you would want to add an EMPTY STRING to an ALT tag of an IMG? What are some examples of this?

A

Photos that are used for decoration only and dont add any meaning to the content or to the page itself.

examples of this would be

background images for decoration purposes.

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

If an IMG already has a caption in its content explaining what it is - should you use an ALT with a string or an ALT without a string?

A

It is possible to use an ALT without a string even the caption would be redundant because of the caption.

But i would opt to use one because of the screen readers and because the alt tag is used to index photos in search engines.

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

How many times should you use H1 on a page?

A

once.

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

There are H1 - H6, should you pick H#’s by their size and how they look?

A

No you shouldn’t. Choose them by relevancy of their content. H2’s should be a sub section of H1

H3’s should be sub sections of H2’s

H4’s should be sub sections of H3’s and so on and so forth

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

Why is important for your H#’s to have Semantic Meaning and relate to one another?

A

Some screen readers can be set to read only the headings on a page so the user gets a summary of the page.

Its important that your headings facilitate this for the users.

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

Should you skip H#’s ? Like if you have an H1 should you jump straight to an H5?

A

No, this confuses screen readers. You should order your content one header at a time.

Its ok to not use certain headers, but if you do use them, you shouldnt skip them.

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

What is the MAIN tag and how many should there be on the page? Using this tag allows for what functionality?

A

It wraps the main content of a page, shouldnt include repeating content like nav bars etc.

There should be one per page.

Assistive technologies allow a “Jump to Main Content” link that takes users to the main content of a page.

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

What is the Article tag and what is it used for Semantically?

A

Used to group independant, self contained content. Content that can be understood outside of the context of other content.

Think of an article as a book

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

What is the Section tag and what is it used for Semantically?

A

Used to group thematically related content . These can be used inside of Article tags.

If the Article tag is a book,
then the Section tag would be the chapters.

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

What is the Div tag and what is it used for Semantically?

A

It is used to group content when there is no relationship between groups of content

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

What is the Header tag? And why do we use it? Using this tag allows for what functionality?

A

It is used to wrap introductory information or navigation links for its parent tag and works well around content thats repeated at the top of multiple pages.

Header tag allows assistive technologies to quickly navigate to that content.

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

What is the Nav tag and what is it used for? What functionality does using this tag afford?

A

This tag is meant to wrap around the main navigation link in your page.

This tag allows for easy screen reading navigation.

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

If the links in the Nav bar are repeated at the bottom of the page, is a second Nav tag necessary?

A

No, a second Nav tag isnt necessary. A Footer tag will do just fine.

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

What does the Footer tag do? What functionality does it afford?

A

It wraps information about copyright or links related to documents that usually sit at the bottom of the page.

This has built in Landmark features that allow easy navigation to this section using assistive technologies

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

What is a Boolean Attribute?

A

Its an attribute that doesnt need a value. Its presence turns the feature on.

for example

checked, required etc.

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

What is the Audio tag? What is it used for? What is the syntax?

A

It is used to add audio to your webpage

audio controls src=”audio.mp3”>/audio

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

What does the Boolean Attribute ‘Controls’ do?

A

It brings up media controls for audio/video that allows you to play/pause the media file amongst other things.

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

Audio and other type of media also should include what?

A

A text component along with a visual component to accessible to people who are deaf or hard of hearing

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

What is the tag Figure and Figcaption tag and what are they used for? What is the syntax?

A

These tags are used together to wrap a visual representation like a chart or an image along with its caption. The figcaption tag can be used to give the conclusion or findings represented by a chart.

figure>
   img src alt >
   figcaption >
   This Chart says you broke
   /figcaption>
/figure>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
156
Q

How do we use the For attribute on a Label tag?

A

The value of ‘For’ attribute on the label tag should be the same as the value of the Name or ID attribute on the input tag thats wrapped in it.

label for=”email”>
input type=text name=email>
/label>

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

What is the Fieldset tag? What default styling does it come with?

A

A fieldset tag groups a bunch of inputs - radio buttons for example. This sections off the whole are where the user is to put in inputs

It has a default styling of a box around whatever is nested inside of its tags…this default styling can be changed in css

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

What is the Legend tag?

A

The legend tag is the name of a section of related inputs.

form>
  fieldset>
          legend> Whats your fav sport
                 label> baseball
                    input > type =radio
                 label> football
                    input> type ="radio
                 label> football
                    input>type=radio
           legend> whats you fav food etc..
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
159
Q

What is the difference between Legend and Label?

A

Legend is the name of a section of related inputs.

Label is the name of the input themselves

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

How do you add a DatePicker to your page?

A

input type=date>

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

What is the Time tag and what does it do with the Datetime attribute?

A

The time tag is used with the datetime attribute to wrap a date in text. This is to standardize time that may be written informally and can be used by screen readers and others assistive devices.

we went on

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

If an element is Screen Read Only, what does that mean?

A

It means that the element cannot be seen but the information is read by a screen reader.

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

Why would we want an element to be Screen Read Only?

A

If we have a chart that requires sight to get the information from it. You might have to also make a table for a screen reader to read the table the make the information accessible.

But you dont want to put a chart and a table, because it does no good to have both. So you would show the chart for those that can see and make the table screen read only so it is read to those who cant see the chart

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

What is the syntax for making something Screen Read Only?

A
.sr-only {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  top: auto;
  overflow: hidden;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
165
Q

If you make the CSS of an element Display: None or Width/Height: 0px?

A

No, these will make it so the screen reader ignores it too and it wont get read.

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

What is an Accesskey attribute and what is it used for? What is the syntax?

A

It is added to links on a page to allow keyboard users to click a key like SHIFT or CTL plus whatever value you add to the accesskey attribute and it will go to that page.

a href =”wwf.com” accesskey=”g” ><a></a>

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

What two things does setting the attribute/value pair Tabindex=”0” do to an element?

A

It makes it so it can tab to access it the same way you can links and buttons for key board only users

and it can make it so that you can style it using the pseudo class :focus on it.

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

What does applying an integer high than 0 to the value of Tabindex do?

A

It makes sets the focus order for tabbed elements. The element with the value of 1 will go first and then 2 and then so on and so forth

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

What could be a unintended consequence of setting the values for Tabindex on elements?

A

Most if not all keyboard users are used to the keyboard focus on the hitting tab to go from top to bottom. When you set the tabindex it takes it out of normal rotation that could be confusing for some users

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

How do you change the visual appearance of something depending on the screen height and width?

A

You use a media query

@media (min/max-height/width: numpx) {
element {
          property: value
}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
171
Q

How do we make images responsive in CSS? And what does the image need to be wrapped in?

A

it needs to be wrapped in a div or some sort of parent element

img {
width: 100%;
display: block;
height: auto;
}

The max-width of 100%
makes sure the image is never wider than the container it is in.

The height of auto will make the image keep its original aspect ratio

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

What trick do you do to pictures to make sure that they work well with Retina/IOS?

A

Make sure that you set the height and the width of an image to half of that of the original picture

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

Besides percentages and pixels what is another useful way to size objects or pictures based on the viewport itself?

A

Viewport units.

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

What does VW and VH stand for as measurement units?

A

Viewport Width and Viewport Height

The number that goes with it is the percentage of that

header {
height: 100vh
}

means the header is going to be 100 percent of the viewports height.

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

What does Vmin and Vmax stand for as measurement units?

A

Vmin - of whichever screen is smaller

Vmax - of whichever screen is larger

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

Where can we use Viewport Units?

A

We can use them wherever we use px or %’s

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

What can you do to safeguard against browsers that dont support viewport?

A

you can set up, a regular declaration with px’s directly before a Viewport Unit declaration and if the browser supports Viewport Units - it will use that instead. If it doesnt it will use the regular px declaration

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

What happens when you add Display: flex to a container that has block elements nested inside of it?

A

They become stacked horizontally left to right

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

What is a Flex Container?

A

It is a parent element that has display: flex applied to it

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

What is a Flex Item?

A

A child of a flex container that will move depending on how the flex is applied

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

What is Flex-Direction?

A

This is the property that dictates the direction that the flex items are displayed in

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

What is the default Flex-Direction?

A

Row

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

What are the Four Flex Directions?

A

Row, Row-Reverse

Column, Column-Reverse

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

What is the Main Axis of a row?

A

horizontal line going right through it

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

What is the Main Axis of a column?

A

vertical line going right through it

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

What is Justify-Content Css property?

A

This property aligns flex items along the main axis of the flex direction.

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

What does Justify-Content: center; do?

A

It places the flex items along the main axis in the center of container.

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

What does Justify-Content: flex-start do?

A

It places the flex items on the main axis along the beginning of the container.

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

What does Justify-Content: flex-end do?

A

It places the flex items on the main axis along the end of the container.

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

What does Justify-Content: space-between do?

A

Places outer most flex items along the border of the flex container and divides the spaces in between the remaining flex items

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

What does Justify-Content: space-around do?

A

Splits between the items looks double what they are along the edges because each item gets its on space buffer - which between them looks like double space.

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

What does Justify-Content: space-evenly do?

A

It makes the space between the flex items even on both sides regardless of the amount of space or items

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

What is the Cross Axis of a Row?

A

The vertical line.

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

What is the Cross Axis of a Column?

A

The horizontal line.

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

What does the property Align-Items do?

A

It alings flex items along the cross axis of a flex container

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

What does Align-Items: flex-start do?

A

It aligns the flex items along the start of the cross axis

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

What does Align-Items: flex-end do?

A

It aligns the flex items along the end of the cross axis

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

What does Align-Items: center do?

A

It aligns the flex items in the center of the cross axis

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

What does Align-Items: stretch do?

A

It stretches the flex items the full height/width of the flex container depending on the cross axis of the flex direction

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

What does Align-Items: baseline do?

A

It will make sure that the text inside of the flex elements are lined up even if the actual height/width are not exactly the same amongst the flex items. This helps your texts look consistent

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

What does Flex-Wrap do?

A

It tells CSS to wrap flex items to the next row or column if there isnt enough space on one line.

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

What determines if there is enough space to wrap flex items?

A

The space of the container and the space of the flex items.

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

What is the default value for Align-Items for grid items?

A

Stretch.

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

What is Flex-Wrap: No Wrap?

A

This setting does not wrap flex items and keeps all flex items on the same line.

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

What is the default setting of Flex-Wrap?

A

no-wrap

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

What does Flex-Wrap: Wrap do?

A

It wraps flex items on to the next line depending on the flex direction of the container

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

What does Flex-Wrap: Wrap-Reverse do?

A

Wraps items in the opposite order of Wrap

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

What does Flex-Shrink do? When do we use it?

A

When the flex container’s width/height is smaller than the combined width/height of the flex items, Flex shrink can be used on flex items to allocate which items will shrink faster or slower than other items.

The higher the number, the higher the shrink rate.

flex-shrink: 3 will shrink three times as fast as flex-shrink: 1

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

How can Flex-Shrink be used with Width/Height?

A

box1 {

When flex items are in the same container as long as the container is big enough to have both items have their width/height measurements respected, both will fine. Once the flex container gets smaller and encroaches on the size of the flex items, the flex items will shrink at the desired rate you set on the Flex-Shrink property.

width/height: 200px;
flex-shrink: 2
}

width/height: 200px;
flex-shrink: 1
}

if the flex container is at 600px, both of these boxes will be 200px each, because there is enough space to accommodate both widths/heights.

But if that container were to go down to 300px. Then Flex-shrink would come into play and shrink box 1 and twice the rate as box #2 meaning the 300px would leave the boxes as

box 1 100px
box 2 200px

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

What happens if you add 100% width/height on all the flex items?

A

They will divide it up evenly and give each other equal parts.

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

What happens if you add Flex-Shrink on to flex items with 100 percent width/height on each of them?

A

If there is two and given different flex shrink values then they will automatically adjust to divide up the space.

If two or more or given and are given different values, more often than not only two elements will be divided up and the other elements will be shrunk to the point where you dont see them

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

What is the default value for Flex-Shrink?

A

1

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

What is Flex-Grow? How does it work?

A

It works exactly the same as Flex-Shrink except when the container expands it grows the flex items at the rate that you decide

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

How do you set the starting point of a flex item before it starts growing or shrinking?

A

flex-basis :

with some measurement value

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

Why is it a better idea to use Flex-basis as for flex items rather than width/height or min-width?

A

Because you can do it in the short hand notation of Flex.

And when it comes to min-width, when you get to that small size say for a photo, the image will stay the same size but just make you scroll to see it.

where flex basis will actually shrink the photo or the element to fit into thay space rather than make you scroll.

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

What is the syntax for the shorthand Flex property?

A

flex : grow, shrink, basis

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

What is the Order property?

A

It puts the flex items in the order that they should appear. The number value is that order, it can take negative nums too

order: 1
order: 2

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

Whats the default of the Order property?

A

Flex items will be ordered in the order that they appear in the source HTML

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

What is the Align-Self property?

A

This property allows you to adjust each item’s alignment individually, instead of setting them all at once. This is useful since other common adjustment techniques using the CSS properties float, clear, and vertical-align do not work on flex items.

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

What values does Align-Self take?

A

align-self accepts the same values as align-items and will override any value set by the align-items property.

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

Can any HTML element be made into a Grid Container?

A

Yes any HTML element

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

How do you turn an HTML element into a Grid Container?

A

You apply display: grid; to it

This gives you the ability to use all the other properties associated with CSS Grid

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

How do we add Grid Columns to a Grid Container?

A

We use the property grid-template-columns

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

How are the number of columns determined by Grid-Template-Columns?

A

The number of values applied to the property determines the amount of columns the container will have.

grid-template-columns: 50px 50px 50px 50px

This container would have 4 columns

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

How is the width of columns decided when creating columns with Grid-Template-Columns?

A

The measurements of the values determine the width of the columns

grid-template-columns: 50px 50px 50px 50px

This will set 4 columns of 50px in width each.

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

How do you make Rows instead of Columns with CSS Grid? How does it work?

A

grid-template-rows

it works the same way as grid-template-colums

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

What measurements can we use for Grid-Template-Columns/Rows? And how do they work?

A

We can use the usual set units like px/vh/vw

We can use percentages

We can use auto
(which size is only that of the content it has, like a inline element)

We can use Fr
(this works like a fraction, the number represents the parts it will take up of the remaining space)

grid-template-rows: 1fr 2fr

This will divide the container into three parts….
the first row will get 1/3 and the second row will get 2/3

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

How do you create a gap between Columns when using Grid-Template-Columns?

A

grid-column-gap

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

How to specify how big of a gap is made when using Grid-Column-Gap?

A

The value will determine the size of the gap in between the columns

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

How do we create gaps between rows when using CSS Grid? How does it work?

A

gird-row-gap

it works the same way as grid-column-gap

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

What is Grid-Gap? And how is it used?

A

Its a shorthand for column/row-gap properties.

If it has one value, it will set the width for all columns and all gaps

if it has two values, the first one is for rows and the second one is for columns

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

Grid-Column/Row are not used on Grid Containers, what are they used on?

A

They are used on Grid-Items.

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

What are Row and Column Lines?

A

Think of a Grid….the lines that go horizontal are the row lines. the lines that go vertical are column lines.

The number of column and rows determine the amount of lines there are. These lines are numbered from the top left corner of the page and run downwards for columns and to the right for rows

1 2 3 4
2
3
4

a four column/row grid would look like this

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

How does Grid-Column/Row work?

A

You give two numbers on the value of grid-column/row

the first number is the line that you want the grid item to start

then a forward slash

the second number which is the line that you want the flex item to stop.

so grid-column: 2/4

would start on line 2 go across line 3 and stop on line 4. Meaning this item would cover two columns

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

What is the Repeat value on the Grid-Template-Row/Column property? What is the syntax?

A

The repeat value will allow you to make as many columns or rows of a particular container that you want. It takes two parameters. The first one is how many rows/columns that you want. The second will be the width/height

grid-template-columns: repeat(3, 1fr)

This will make 3 columns that take up 1/3 of the container each.

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

What is a Cell in CSS Grid? Is every Cell a Flex-Item?

A

It is the space in which the Flex Item sits. The space in between the row/column lines that make up the columns/ rows. Every Cell isn’t a Flex-Item. They would occupy the same space but Cells can be empty.

Think of Cell as Jail Cell, but Flex Items are the prisoners inside of the cell. They can move around the cell and be in different positions of the cell, the cell could be empty - but the prisoner and the cell are not the same even if they occupy the same space.

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

How can you move the content HORIZONTALLY inside of a CSS Cell?

A

You can use the property justify-self

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

What is the default value of the Justify-Self property in CSS Grid? What does it do?

A

Stretch.

This will make the content fit the entire width of the cell.

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

What are the values of Justify-Self property in CSS Grid?

A

Start - justifies the item to the left of the cell.

Center - justifies content to the center of the cell

End - justifies content to the end of the cell

Stretch - content covers entire width of the cell

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

How do you can you move content Vertically inside of a CSS Cell? And what values does it take?

A

By using the align-self property.

It takes all the same values as justify-self

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

If you want to move the content inside of the Cell Horizontally for all the Grid Items what can you use? What values does it take?

A

justify-items

Takes the same values as justify/align-self:

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

If you want to move the content inside of the Cell Vertically for all the Grid Items what can you use? What values does it take?

A

align-items

Takes the same values as justify/align-self

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

What element do you apply Align/Justify - Items on when making a grid?

A

the Grid Container

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

When you use Justify/Align-Items on content, How will the height and width be determined?

A

The height and the width will be determined by what the content dictates.

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

What is an Area in CSS Grid? How do they work?

A

An Area are rows of the container grouped together by a custom/variable/class name

Each row is placed between quotations

          1                2                3                 4

1 “header header header header”

2 “ad content content ad”

3 “content content content content”

4 “footer footer footer footer”

Each different name is a different Area

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

What if there is a section of your Grid that has empty cells, how would you label it when creating Areas?

A

You place a period where there is an empty cell.

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

How do you create Areas in CSS Grids?

A

use grid-template-areas:

and then use quotations and to section off rows and classify custom cell names

grid-template-areas:
“header header header”
“ad content ad”
“footer footer footer”

this will create 4 areas

header, ad , content and footer

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

Does creating Grid Areas, does that automatically place the Grid-Item into it? Meaning, are they linked for CSS styles and things of that nature?

A

No, creating the area is literally assigning a name to the space, Not to the Grid item itself. The Grid Item will still need to be linked to the area name.

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

How do you assign an Grid Item to a Grid Area?

A

By using grid-area on the grid item

item1 {
grid-area: header,
}

This lets the grid know that you want the item1 class to go in the area named header. In this case, the item will use the entire top row because that whole row is named as the header area.

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

What is you want to add an Area to an item in particular to a grid that doesn’t have a Grid-Template-Row/Column property set?

A

you can use grid-area

the values are separated with forward slices

the values are

horizontal start / vertical start / horizontal end/ vertical end

grid-area: 1/1/2/4;

So the item in the example will consume the rows between lines 1 and 2, and the columns between lines 1 and 4.

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

What if you wanted to make multiple Rows/Columns with the same width, but wanted to make one or more with different width/height than the rest?

A

You can add another value after/ before the Repeat( ) function.

grid-template-columns : repeat(3, 50px) 100px;

this would make 3 columns that are 50px each and then put a column that is 100px after it.

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

How do we use the Minmax function along with Grid-Template-Row/Column? Whats the syntax?

A

This is used to set the min and the max width/height of the row/column after setting the starting width/height in the event that the container/browser grows/shrinks.

minmax( min , max)

grid-template-rows: repeat(3,50px) minmax( 25px, 100px)

this will make three rows where the height is set to 50px, but when the container shrinks it will shrink the rows up until it reaches 25px

if the container grows the grid items will grow until it reaches 100px

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

Can you use the Minmax function inside of the Repeat function?

A

Yes you can.

grid-template-columns: repeat(3, minmax(90px, 1fr)) ;

This will make a three columns that will take up 1/3 of the container but will not get smaller than 90px

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

How do you use Auto-Fill with the Repeat function? What does it do and what is the syntax?

A

Auto fill allows the container to add rows/columns when the container grows or shrinks. If there is Grid Items they will slide up to fill the row/column if the container grows, if it shrinks the Grid items will wrap to the next column/row

repeat( auto-fill , minmax(90px, 1fr)

this will look at the container size and see how many 90px’s can fit into the height/width and make the proper amount of rows/columns.

The item will never go less than 90px.

As the screen grows, each item will take a fraction of the total amount of rows/columns. So if they are 5 columns - the grid items will take 1/5th - if there 10 rows/columns the grid items will 1/10th of the container.

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

What is Auto-Fit and how is it different than Auto-Fill?

A

auto-fit works almost identically to auto-fill. The only difference is that when the container’s size exceeds the size of all the items combined, auto-fill keeps inserting empty rows or columns and pushes your items to the side, while auto-fit collapses those empty rows or columns and stretches your items to fit the size of the container.

Note: If your container can’t fit all your items on one row, it will move them down to a new one.

auto-fill:

1 2 3 4 5 6 empty empty empty empty

auto-fit:

1 2 3 4 5 6

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

How can we use Media Queries with Grid-Template-Areas to make our pages responsive?

A

When can name our grid areas and then change them depending on the grid size

set:

grid-template-areas : 
      "header"
      "advert"
      "content"
      "footer";

this is one column; 4 rows - at 300px

we can change that when we get to 400px

@media query (min-width: 400px) {
grid-template-areas: 
        "advert header"
        "advert content"
        "advert footer";

This will make 2 colums; 3 rows and take the advertisement section and place it along the left side of the page.

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

Can you make a Grid inside of a Grid?

A

Yes, take one of the Grid Items, and in the CSS

apply

display: grid;
and grid-template-row/column:

and define the grid that you want.

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

What is the most efficient way to get unstuck when you are stuck on a coding problem?

A

When you get stuck, remember: Read-Search-Ask.

Read the documentation or error
Search Google
Ask your friends for help

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

How do we link a CSS file to a HTML file?

A

link rel=”stylesheet” type=”text/css” href=”tribute.css” />

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

Whats the best way to add images to Grid’s?

A

use the background image property on the grid item

and then place :
background-size: cover;
background-position: center;
background-repeat: no-repeat;

on the grid container

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

What is the CODE tag used for?

A

It turns the text inside of into monospace. This code is where you add code to the page. This code tag is semantic.

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

Should you comment out regularly and explain what your code is doing?

A

Yes, this is a good practice for others that need to see your code and know what it is doing, But also to your future self to help explain what your code is doing as sometimes it gets confusing.

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

In computer science what does DATA refer to?

A

anything that is meaningful to the computer

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

JavaScript provides eight different data types which are?

A

undefined, null, boolean, string, symbol, bigint, number, and object

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

What is the term we use for creating a variable?

A

Declaring a variable.

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

What are variables ?

A

They are nicknames for a particular piece of Data

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

Are the Variables the same as the Data they are assigned to?

A

No Variables are just a label that POINT TO the data, but are not the data itself.

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

Can Variables store different Data at different times?

A

Yes they can. They can be dynamically changed

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

What is the Assignment Operator?

A

the equal sign =

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

When assigning a Variable does assignment go from left to right, or right to left?

A

Assignment goes from right to left, meaning everything on the right of the equal sign is resolved before the value is assigned to the variable on the left

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

What is Initialization?

A

Initialization is giving a declared variable its first value

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

What are the two steps of assigning a Variable and giving it a value?

A

Declaration and Initialization

var myName (declaration)

= rashaan (initialization)

var myName = rashaan

declaration and initialization

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

If you declare a variable but do not initialize it, what value does it have?

A

undefined.

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

If you do a mathematical operation on an undefined variable what will the result be?

A

NaN,

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

What does NaN stand for?

A

Not a Number.

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

If you Concatenate a string with an undefined variable what will the result be?

A

string of Undefined

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

How can increase and decrease a variable with a number data type by one

A

withe the ++/–operator

variableName++ (+ 1)
variableName– ( - 1)

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

What is a Float Number?

A

a decimal number

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

What do we need to remember about the accuracy of Floating numbers?

A

Not all real numbers can be represented in Floating Numbers, this can lead to rounding errors.

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

Can you use the same Mathematical Operators on Float numbers as you would Integer numbers?

A

Yes you can.

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

What are Integer numbers?

A

Whole numbers

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

What is the Remainder Operator?

A

%

and it gives the remainder of the division of two numbers.

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

How can we use the Remainder Operator to check if a number is even or odd?

A

We can use the operator by two… and if it has a remainder it is odd and if it doesnt it is even.

myVar % 2 = 1 (odd)

myVar % 2 = 0 (even)

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

What should we not confuse the Remainder Operator with?

A

The modulus operator. It is very similar but does not work properly with negative numbers.

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

What is Compound Assignment?

A

When you want to update the current variable with a new value using a mathmatical operator.

myVar =+ 5

this is the same as

myVar = myVar + 5

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

When using Compound Assignment which operator comes first?

A

The Math Operator comes first and then the Assignment Operator

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

What is a String Literal?

A

A series of zero or more characters that are enclosed in single or double qoutes.

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

What is Escaping Quotation marks with a BackSlash?

A

Every string needs to start and end with single or double quotes. But when we need to use quotes inside of a string, we can use a BACKSLASH \

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

Where do we place the Escaping Backslash in relation to the inside Quotes?

A

Before both sets of Inside Quotes.

" lets go "

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

How do you Escape Quotation marks with other Quotation marks?

A

Every string needs to begin with matching sets of single or double qoutes. If you start with single you can safely use doubles inside of the string, and vice versa

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

How do we Escape a Backslash to show a Backslash inside of a string?

A

\

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

What does \n mean inside of a string?

A

it creates a new line in the string

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

What does \t mean inside a string?

A

it means Tab and creates a tab sized space inside a string

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

What is the Concatenate Operator? What does it do?

A

It is +

It is used with strings and creates new strings by adding them together

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

When using the Concatenate Operator does it add spaces?

A

No it doesnt, so you have to add the spaces yourself.

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

How do we use Compound Concatenation?

A

We can add a string to the end of another string

var ourStr = “I come first. “;
ourStr += “I come second.”;
ourStr is now “I come first. I come second.”

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

Can you Concatenate strings with Variable Names?

A

Yes, you dont need to use quotations with variable names.

var ourName = "freeCodeCamp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";
// ourStr is now "Hello, our name is freeCodeCamp, how are you?"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
298
Q

How to Concatenate Variable Names with other Variable Names?

A

We can use Compound Concatenation

var anAdjective = "awesome!";
var ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
// ourStr is now "freeCodeCamp is awesome!"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
299
Q

What is a String Variable as opposed to a string literal?

A

It is a variable name that has a string stored inside of it

myStr = “this is a string”

myStr (string variable)

“this is a string” ( string literal)

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

How can you find the length of a string from a String Literal and a String Variable?

A

by using .length on the end of it. It will tell you how many characters are in the string. Even the spaces.

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

What is Bracket Notation on a string? What is the syntax?

A

It is a way to get a character at a specific index within a string?

firstName = “Charles”;
firstName[0];

firstLetter is “C”

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

What is Zero-Based-Indexing?

A

That the count on indexing doesnt start at 1 like normal. It starts with 0.

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

What does it mean if something are Immutable?

A

That it cannot be changed once it is set.

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

Are String Values Immutable? In Other words, Can you the individual characters in a String Literal be changed using Bracket Notation?

A

Yes they are. You cannot change the individual character of a string literal using Bracket Notation.

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

If String Variable values are immutable, how can we change the value?

A

We have to reassign the variable name to a different value all together.

var myStr = "Bob";
myStr = "Job";
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
306
Q

What does the nth number mean?

A

Its a generic number holder for an unknown number.

its like the x variable in algebra

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

How do we use Bracket Notation to find the last character in a string?

A

variableName[variableName.length - 1]

var firstName = "Charles";
var lastLetter = firstName[firstName.length - 1]; // lastLetter is "s"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
308
Q

How do we Use Bracket Notation to Find the Nth-to-Last Character in a String?

A

You can add any number after the subraction operator to get that index character.

firstName[firstName.length - 3]

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

Does Zero-Based-Indexing work the same way in reverse? For example, when using the [.length - n ] method to access characters at the end of a string?

A

No, zero based indexing only works in a linear fashion.

the first character will be 0 no matter what and doesnt change depending on the way that you are counting.

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

How do we store several pieces of data in one place?

A

With an Array

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

Whats the difference between Using Bracket Notation on arrays vs Strings?

A

In arrays, the whole item is returned and not just the character

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

Are array entries/items Immutable?

A

No they are not, meaning you can change them using bracket notation.

var ourArray = [50,40,30];
ourArray[0] = 15; // equals [15,40,30]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
313
Q

What is a Nested Array?

A

It is an Array inside of another Array.

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

What is a Multi-Dimensional Array?

A

It is an Array of Arrays

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

How do we Index Nested Arrays and Multi-Dimensional Arrays?

A

We start indexing from the outside first and then work our way down

var arr = [
  [1,2,3],
  [4,5,6],
  [7,8,9],
  [[10,11,12], 13, 14]
];
arr[3]; // equals [[10,11,12], 13, 14]
arr[3][0]; // equals [10,11,12]
arr[3][0][1]; // equals 11
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
316
Q

What does .push( ) do?

A

It adds the item or array inside the parens to the end of the array.

var arr1 = [1,2,3];
arr1.push(4);
// arr1 is now [1,2,3,4]
var arr2 = ["Stimpson", "J", "cat"];
arr2.push(["happy", "joy"]);
// arr2 now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
317
Q

What does .pop( ) do?

A

This is used to take the value off the end of an array.

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

What does push( ) return?

A

The length of the new array

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

What does .pop( ) return?

A

It returns the item that was popped off the end

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

How can we store a popped off item of an array?

A

Store it in a variable

storedVariable = array.pop( )

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

What does .shift( ) do?

A

Removes the first item of an array and returns it

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

What does unshift( ) do?

A

Adds an item to the beginning of an array and returns the length of the new array

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

What is a function?

A

It is a piece of reusable code.

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

What are Parameters?

A

Parameters are variables that act as placeholders for the values that are to be input to a function at the time that it is called.

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

What does are Arguments?

A

Arguments are the actual values that go in the place of parameters when the function is called.

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

What does “Passing through” an argument mean?

A

It means inputting the Argument values in the place of parameters

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

When we discuss Scope, what does it refer to?

A

The visibility of variables.

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

Variables that are defined outside of a function have what Scope?

A

They have Global Scope. Meaning they can be seen everywhere in your JS code.

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

Variables that are defined without using the keyword var/let/const are in what Scope?

A

They are in Global Scope.

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

Should you ever declare a function without using a Keyword like let/var/const?

A

No you should not. If you want to make it Global, then use a Keyword and Variable Name outside a function.

If you want it local then declare it inside of a function

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

Why should you not declare a variable without using a keyword?

A

Because it will cause unintended consequences elsewhere in your code and it will be really hard to debug

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

Variables declared within a function have what Scope?

A

They have local scope.

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

Variables that are passed through as Arguments have what Scope?

A

They have local scope

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

What does Local Scope mean?

A

It means that the variable can only be seen within that specific function

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

When there is a Global and Local Variable with the same name which one takes precedence?

A

The Local Variable takes precedence over the Global.

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

When do we use a Return Statement in a function?

A

When we want to send a value outside of the function

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

What happens when your function produces a value but does not have a return statement?

A

It produces an Undefined result.

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

What two values do Booleans have?

A

True or False

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

Are Boolean Values every written in Quotations?

A

No they are not.

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

What are If Statements?

A

They are code that allows you to run one type of code if the boolean is true and another type of code if the boolean is false

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

What are Comparison Operators?

A

These are operators that compare two values. like lesser than and greater than >

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

What values do Comparison Operators return?

A

Booleans (true or false)

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

What is the Equality Operator?

A

==
This checks to see if the left value is equal to the right value. If so True is returned
if not False is returned

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

What is Data Type Coercion? When is it used?

A

It is when the Equality Operator is used on two different data types… this converts the data into the same type and then compares them.

1 == 1 // true
1 == 2 // false
1 == ‘1’ // true
“3” == 3 // true

the strings and the number data types return true because their value is equal even though the data type is not

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

What is the Strict Equality Operator? How does it work?

A

===
It works the same way as the Equality Operator except that it doesnt perform Data Type Coercion. Meaning the data type and the value have to be equal for it to return a true.

3 === 3 // true
3 === ‘3’ // false

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

How can you check the type of data something is?

A

by using the typeof operator.

typeof 3 // returns ‘number’
typeof ‘3’ // returns ‘string’

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

What is the Inequality Operator? How does it work?

A

!=

It works the same way the Equality operator does except it returns True when unequal and False when they are equal.

This perfroms Data Coercion

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

What is the Strict Inequality Operator?

A

!==

It works the same way as === except it returns True when they are unequal and False when they are equal

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

Does Type Coercion also take place with > Greater than or < Less than or >= or <=?

A

Yes, these will compare different data types

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

What is the && Operator?

A

It returns true if both sides of the operator are true. Otherwise it returns false.

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

What is the | | operator?

A

It returns True if at least one side of the operator is true

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

What should we keep in mind when we are creating If/Else statements about the order that we put them in?

A

The If statement will stop executing at its first true. So Its important to put it in the right order.

This is the wrong way:
  if (val < 10) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}

If the whats passed in for Val is a 2.. it will return a true and stop running the code. Its less than 10, but its more correct to say that its less than 5. Thats the code we want to run.
______________________

This is the right way
if (val < 5) {
    return "Less than 5";
  } else if (val < 10) {
    return "Less than 10";
  } else {
    return "Greater than or equal to 10";
  }
}

If 5 returns a false, then we look to see if its less than 10 and so on and so forth.

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

What is a Switch Statement?

A

It does the same thing as If statement but can run code if there are more options than just True or False. We can use this when there are more options available than just the two

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

Can a Switch Statement be used in another function?

A

Yes, its just like an If statement, it can be used inside of a function.

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

Do we need a parameter when starting a switch statement ?

A

Yes we do, we need to pass in an argument to a parameter

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

How do we begin a Switch Statement?

A

switch (param1){

}

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

What is a Case when using a Switch Statement? What is the syntax?

A

A Case is a possible value for the Param. There can be as many as you want.

case “value” :

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

How does the Beginning of a Switch Statement look with one case option?

A

switch (param){

case “value” :

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

Where do you put the code that you want ran when the Argument matches a Case?

A

You place it after the colon after the case value.

case “value” :
console.log(‘this code’)

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

What does a Switch Statement look like with its beginning, case statement and code to be ran?

A

switch (param){
case “value”:
console.log(‘run this code’)

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

What is a Break Statement inside of a Switch Statement?

A

It Breaks the code from executing the rest of the switch function and allows the code to move down the document.

362
Q

If there is no Break in the switch statement, what happens?

A

If theres no break, then the code will keep executing even if the param found its matching case

363
Q

What is a reason that you might purposefully leave out a Break in a switch Statement?

A

If you have multiple possibilities for the param but would like them all to run the same code as a result.

switch(animal)
case 'cow': 
case 'pig': 
case 'duck':
console.log('This is a farm animal')
break
case 'spider':
console.log('this is not a farm animal)

There is no break for the first three options, meaning if the animal value is one of those three it will return the same code and then break.

but if it takes spider, then it will return a different code.

364
Q

What is a Default Statement in a Switch Statement? What is the syntax?

A

This is like an Else in an If Statement. If the parameter doesn’t get passed a value that matches one of the Cases…it will run whatever code is in the default section.

default :

365
Q

How would a 3 Case Switch Statement look with Breaks and a Default?

A
switch(team){
case "49ers":
console.log('49ers')
break;
case "Giants":
console.log('Giants')
break;
case "Warriors":
console.log('Warriors')
default: 
console.log('if it aint these, then it aint shit)
}
366
Q

Are Case values in Switch Statements tested against Normal Equality or against Strict Equality?

A

Strict Equality.

367
Q

What happens when a Return Statement is reached inside of a function?

A

The execution of the current function stops.

function myFun() {
  console.log("Hello");
  return "World";
  console.log("byebye")
}

The above outputs “Hello” to the console, returns “World”, but “byebye” is never output, because the function exits at the return statement.

368
Q

Whats the difference in the way Objects are indexed/accessed as opposed to Arrays?

A

Arrays items are indexed/accessed by Numbers representing their location within the array

Objects are indexed/accessed by their properties

369
Q

What are two ways to access the properties of an object?

A

Dot Notation and Bracket Notation.

370
Q

When must you use Bracket Notation on an Object?

A

If the property of the object you are trying to access has a space in its name, you will need to use bracket notation.

 myObj = {
  "Space Name": "Kirk",
  "More Space": "Spock",
  "NoSpace": "USS Enterprise"
};
myObj["Space Name"]; // Kirk
myObj['More Space']; // Spock
myObj["NoSpace"];    // USS Enterprise
371
Q

Property Names of an Object that have spaces in them must be put inside of what?

A

property names with spaces in them must be in quotes (single or double).

372
Q

How can you use Bracket Notation to to access Object Properties using Variables?

A

You can store a key name of an objects key/value pair inside a variable and use Bracket Notation on that variable name to access the information in the object eventhough that variable name isnt in the object itself.

example

obj = {
8: Farve,
16: Montana,
12: Marino
}

We can save the number 16 to a variable name.

playerNumber = 16

then we can use the new variable name in object bracket notation even though the variable name isnt in the object itself

obj[playerNumber]

This would return Montana, just as it would if you ran

obj[16}

373
Q

How can we update a Object’s Key/Value pair?

A

With Bracket or Dot Notation.

we update this object’s name property: ourDog.name = “Happy Camper”; or ourDog[“name”] = “Happy Camper”

374
Q

How can we add key value pairs to an Object?

A

We can use Dot or Bracket Notation. The same way we would modify an existing key/value pair we can add other and new key value pairs

375
Q

How do we delete key/value pairs in an object?

A

By using the delete keyword.

delete objectName.propertyName

376
Q

How can we check to see if a Object has a particular property or not?

A

We can use the .hasOwnProperty(propname) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.

Example

myObj.hasOwnProperty(“top”); // true
myObj.hasOwnProperty(“middle”); // false

377
Q

What is a While Loop? Whats the syntax?

A

Its a loop that runs WHILE a specific condition is true.

var ourArray = [];
var i = 0;
while(i < 5) {
  ourArray.push(i);
  i++;
}

this will produce an array with the numbers going from 1 - 5

378
Q

When using a loop and you want to increment or decrement by more than one, we cant use ++ or –. So how can we so this?

A

We have to use Compound Assignemnt

i += 10

this will iterate it by 10 every iteration instead of i++ and you cant just say i = 10

379
Q

Can you nest For Loops inside of other For Loops?

A

Yes you can. The outer loop will begin the inner loop and when the inner loop stops the outer loop will loop the inner loop again until both loops are completed.

380
Q

What do we need to remember when we are looping through Nested Arrays/Multi-Dimensional Array’s?

A

We have to remember that we have to add the outer loops variable to the second loop.

For example,

first loop will take something like

array.length; i++

to dictate when it stops and how it increments

the inner loop will have something like,

array[i].length; i++;

because we need i to access the inner arrays inside of the outer array

381
Q

What is a Do…While Loop?

A

It is the same as a While Loop except that it runs a piece of code once before it starts the looping. Do…this then Loop that.

Normal While Loop

var ourArray = []; 
var i = 5;
while (i < 5) {
  ourArray.push(i);
  i++;
}

This fails because i = 5 so it wont loop when its time to loop so ourArray will be empty.

Do..While Loop

var ourArray = []; 
var i = 5;
do {
  ourArray.push(i);
  i++;
} while (i < 5);

This also has i = 5 but the code following
Do will run first and then the loop will start.

but i = 6 after the Do code so the while loop wont execute so we will have ourArray = [5]

382
Q

What is the Syntax for a Do….While Loop? What happens with the code that happens in the do block? What happens to the code in the while loop if one is written?

A

do {
(code you want ran once regardless of condition. This code will keep running as long as the condition is true)
i++ (or however you want it to loop)
} while ( will run as long as this is true){
(this code if written will run once when the loop comes to an end)
}

383
Q

What is Recursion? What does it refer to?

A

Recursion refers to a function calling itself inside of it. Basically the name of the function where its declared and created is also in the return function of that function

function MULTIPLY( ) {
if ( some condition) {
do some code 
} else {
return MULTIPLY( )
}
384
Q

Recursion can be used in place of what?

A

Loops.

385
Q

What is a Base Case when in reference to Recursion?

A

It’s the part of the code that that stops the calling of the function when a certain criteria is true or met. Basically the STOP CODE.

386
Q

What is the Recursive Case in reference to Recursion?

A

Its the part of the code that dictates how the function will call itself. It will have some sort of modification so the output will be different each time it is called until it reaches the base case

387
Q

What is an Example of a Recursive Function that adds together elements of an array by their index ?

A

The goal is to add elements of an array together using their indexes.

var times = [1,2,3,4,5] —- example Array

sum(arr , n) — name of function and params
representing array, and stopping place
for the function to stop calling itself.

if (n <= 0 ){ — This is where we set our BaseCase, and
tell the code when to stop. It doesnt
have to be zero. If you want specific
of an array…..say starting with the third item in an array, you can adjust the number 0 to handle that. Zero here is an arbitrary number. This might work well for a countdown app, where you want the function to call itself until it reaches the first item in an array or the number 0 itself. But it doesnt have to be a zero

return 0 — This is what we want to happen instead
the function being called again. Again, can be anything. But in the case of a countdown, you might want it to return zero as the final number in the countdown. Or can say something like “Happy New Year”

 else {
  return sum(arr, n - 1) + arr[n - 1]
}

This is the the recursive case where we call the function again. What this is doing in the first N is controlling how many more times the function will run

the second N gets the value from the array by its index.

so everytime it runs it logs the value of the array index so if N = 5 it would add the array index 5 plus 4 plus 3 plus 2 and keep going this way until N reached whatever value was set in the IF statement

Example of full code:

function sum(arr, n) {
if ( n <= 0){
  return 0
} else {
  return sum(arr, n - 1) + arr[n - 1]
}
}
388
Q

Must you use Bracket Notation when accessing object properties with a function Parameter/Argument?

A

Yes you must use bracket notation otherwise it will come up as undefined and youll want keep doing it over and over and want to shoot everyone in the face

389
Q

What does Math.random( ) do?

A

It creates a random decimal number. It can make any decimal number including 0 - 1… it can return 0 but it will never return 1

390
Q

How do we generate a Random Whole Number? And what do we need to remember about how it rounds down?

A

Math.floor(Math.random() * whole number)

this will create a random whole number below the whole number.

It rounds down to the nearest whole number, so if you put

Math.floor(Math.random() * 20)

it will choose a random number between 1 -19 but it will never choose 20, so you have to account for that in your code

391
Q

How to create a Random Number within a range of numbers?

A

Math.floor(Math.random() * (max - min + 1)) + min

console.log(Math.floor(Math.random() * (20 - 10 + 1 )) + 10)

will only produce numbers between 10 - 20

392
Q

What does parseInt( ) do? What does it return when used with a number and when its used with something that cant be converted into a number?

A

It turns a string into an integer… so

a = parseInt(“007”)

would make a = 7

if you try to use parseInt and the first character of the string cant be made into a number it will return NaN

393
Q

When is an example of a time where you might need to use parseInt and turn a string into a number?

A

Some times in your JSON and API calls you get strings that are numbers and this is a good way to turn them into numbers.

394
Q

What is a Ternary Operator? What is the syntax?

A

It is a one line if/else statement.

condition ? statement if true : statement if false

395
Q

Can you chain multiple Ternary Operators together? What is the best practice?

A

Yes you can and the best practice is to start each additional ternary operator on another line. That way it is easy to read

Each new lines begins with the colon

396
Q

What happens if you dont put Return in the Base Case of a Recursive Function?

A

It will continue and eventually overflow

397
Q

How does Recursive Functions affect the JS Call Stack?

A

The functions that are called in an recursive function, do not return anything at first, they are merely put inside of a queue and are waiting until the Base Case is reached. Once the base case is reached then, that return sets off a chain reaction that will start with the base case function (1 or 0 usually) then that will fire the next one and the next one and the next one.

398
Q

How to create an Array inside of a Recursive Function?

A

Create an empty array or an array with starting values in the Base Case - and then assign the recalled function to variable name and then push or unshift from there in the recursive case

function recursiveFunctionName(arrayParam, numParam){
  if ( numParam <= 0){
    return;
  }
  else {
    arrayParam.push(numParam)
    console.log(arrayParam)
    return recursiveFunctionName(arrayParam, numParam - 1)
  }
}
399
Q

Why should you not use the Var keyword to declare a variable?

A

Because the original value declaration can be overwritten without throwing an error. So you can ruin your code bigtime and not even know

400
Q

When you use Let as a variable it creates a local variable, but so does Var…Whats the difference in usage between these two in this case?

A

Let is tied and bound to not just the function but whatever expression it is tied to. So its possible to have a variable have a value in a loop statement and then a different value in an if statement in the same function.

But this is not encouraged to do.

401
Q

What is the difference between Let and Const?

A

Const is ‘read only’ meaning that it only can be read and its value cannot be changed once it is set.

402
Q

What is a common practice of typing Const Variables to not confuse them with Lets?

A

Typing them in ALL CAPS and separating words with underscores.

403
Q

Const Variables cannot have their values reassigned, can they be changed at all?

A

Yes, the can be updated and mutated.

for example a object or an array can be updated with dot or bracket notation just like it would be if declared with LET

const s = [5, 6, 7];
s = [1, 2, 3]; // throws error, trying to assign a const
s[2] = 45; // works just as it would with an array declared with var or let
404
Q

What does Object.freeze( ) method do?

A

This makes an object unchangeable. Any attempt to update or delete the properties on a frozen object will be ignored and an error will not be thrown - it just will be ignored.

405
Q

What is an Anonymous Function? What is a syntax example?

A

It is a function that doesn’t have a name, and it doesn’t have a name because it wont be reused.

function() {
  const myVar = "value";
  return myVar;
}
406
Q

How can we write an Anonymous Function as an Arrow Function?

A

(Anon)

function() {
  const myVar = "value";
  return myVar;
}
(Arrow)
() => {
  const myVar = "value";
  return myVar;
}
407
Q

What two things can we Omit from our Arrow Function when the function doesn’t have a Function body and only a Return Statement?

A

Arrow functions can omit

  1. Return Keyword
  2. Curly Brackets

This helps it be on one line and easier to read

() => “value”;

408
Q

When an Arrow Function has only one Parameter what can be omitted from it?

A

The parenthesis that go around the parameter.

item => item * 2;

409
Q

How do we pass more than one Parameter in an Arrow Function?

A

We place them inside the parens like normal functions.

(item, multi) => item * multi

410
Q

What does the .concat( ) method do? What is the syntax?

A

str/array.concat(str/array)

This adds a string to another string.

411
Q

What is a Default Parameter and how is it used? Whats the syntax?

A

A Default Parameter is a parameter that you give a default value to in the event that one isn’t specified. This can be used to set a parameter that you want something to be the majority of the time and change under specific circumstances.

To do this you add = value to the parameter.

function (greeting = Hi , 
name = Rashaan) {

return greeting + name

}

Hi Rashaan

this function can be called with other parameters for name or greeting and it will change. But if no other one is specified it will say Hi Rashaan as the default instead of throwing an undefined error

412
Q

What is a Rest Parameter? What is the syntax?

A

A parameter is a parameter that is an array basically, it holds more than one value in its value name and can be accessed with various array methods like .reduce( ) .map( ) etc

413
Q

What is a Rest Parameter? What is the syntax?

A

A parameter that accepts multiple unrelated values and puts them inside an array to be used and accessed within a function.

for example

calling restTest(2, apples, oranges, bananas)

function restTest(param1, …arr2)

will treat Param 1 as the value 2

and put apples, oranges and bananas in an array that you can then use array methods on like reduce or map or filter etc

414
Q

What is the Spread Operator and how is it used? Whats the syntax?

A

It looks the same as the Rest Parameter …variableName.

it takes an already made array and makes it able to
used to

  1. add new elements to arrays
  2. pass elements of an array as parameters of a function
  3. copy arrays
  4. concatenate arrays
415
Q

How do you use the Spread Operator to Add Elements to an existing array?

A

just add the spread operator into the existing array or use an array method to add it an existing array and this will make one new array.

No spread array
fruit = [grapes, bananas]
{apple, orange] + fruit

returns

[apple, orange, [grapes, bananas ]]

Spread Array

fruit = [grapes, bananas]
[apples, orange, …fruit]

returns
[apples, oranges, grapes, bananas]

416
Q

How to pass elements of an array as arguments to a function using the Spread Operator?

A

fruit = [grapes, bananas, oranges]

function (...fruit) {
}

this allows you to use the array in the function

417
Q

How do you copy an array using the Spread Operator?

A

You just store it in another variable name

arr1 = [1,2,4]
arr2 = [...arr1]

arr2 = [1,2,4]

418
Q

How do you use Spread Operator to concatenate Arrays?

A

Save two arrays to another variable name by making an array containing two spread operators. This will add both arrays into one big array accessible throught the new variable name.

arrAll = […arr1, …arr2]

419
Q

You can use the method concate( ) to add arrays together, why might you choose to use the Spread Operator over this method?

A

You might choose to use the Spread Operator if you want to add other elements along with the array.

fruit = [oranges, bananas, apples]

fruitALL = [grapes, kiwis, …fruit, “pineapples”]

This allows you to add not only the array under fruit but also add pineapples. Where using array.concate.(array) wouldnt allow you to do that.

Also, you can decide where you want the array to take place using the Spread Operator

fruit = [oranges, bananas, apples]

fruitALL = [grapes, kiwis]

you can add fruit to fruit all like

[grapes, …fruit, kiwis]

and it will be [grapes, oranges, bananas, apples, kiwis]

the array will go wherever you put it

array.concate.(array) only allows you to put one whole array before another whole array

420
Q

When using a Spread Operator is it possible to just use …variableName anywhere?

A

No, this operator has to be used in place, meaning that it has to have some sort of Brackets or Parens around it such as array brackets or a parameter parens in a function

[...arr]
function(...arr){
}
421
Q

What is Math.max( ) and what does it do?

A

It takes numeric values separated by a comma and returns the largest value.

Math.max (5,6,6,7, 734)

returns 734

422
Q

Can we use an array name with Math.max( ) ?

A

No you cant, it returns NaN

you have to use the Spread Operator

num = [32, 22, 112]

Math.max(…num)

returns 112

423
Q

What is Destructuring Assignment and how is it used? Whats the syntax?

A

Destructuring Assignment is used to extract values from objects and apply them to variable names outside of the object. The names of the keys and the variable names will be the same

{ object key , object key } = object name

cat = {
      name: "whiskers"
       age : 14
       color; "white"
}

{name , color } = cat

this will assign the value of cat.name to name
and cat.color to color outside of the function

424
Q

How do we assign Objects key Values to new Variable Names using Destructuring Assignment? Meaning, what do we do if we want to change the name of the variable so it doesn’t match the key.

A

add colons and the new variable name after the object key name

cat = {
      name: "whiskers"
       age : 14
       color; "white"
}

{name : catName , color: catColor } = cat

this will assign the value of cat.name to catName
and cat.color to catColor outside of the object

425
Q

Do you need to use a Keyword like Let or Const when using Destructuring Assignment?

A

Yes, you have to use a keyword otherwise it will throw an error

426
Q

How do you use Destructuring Assignment for nested objects? What do we need to make sure we add along with the nested object key name?

A

You use it the same way as normal Destructing Assignment except you add more curly brackets around the objects. Everything else is the same.

MAKE SURE YOU HAVE COLONS BEHIND THE NESTED OBJECT KEY NAME

const user = {
  johnDoe: { 
    age: 34,
    email: 'johnDoe@freeCodeCamp.com'
  }
};

const { johnDoe: { age: userAge, email: userEmail }} = user;

this will create a variable of
userAge with the value of 34

and a variable of
userEmail with the value of
‘johnDoe@freeCodeCamp.com’

427
Q

How do you use Destructuring Assignment with Arrays? What is the syntax

A

const [newName1, newName2, newName3 = [1, 2, 3]

whatever is in the place of the 0 position will be assigned that and so on and so forth

428
Q

How do we use commas in Destructuring Assignment with Arrays to skip places?

A

We add as many commas as needed and for every comma one item gets skipped.

const [index1,,,,,,,,, index10] = [10,20,30,40,50,60,70,80,90,100]

index1 = 10
index 10 = 100

429
Q

How do we use the Rest Parameter with Arrays in Destructing Assignment?

A

We can use the Rest Parameter in conjunction to assign the remainder of an array to a variable name.

const [index 1, index 2, ….restArrayName] = [5, 10, 15, 20, 45]

this will make 
index 1 = 5
index 2 = 10
and this will make 
restArrayName equal the rest of the array so 
[15,20,45]
430
Q

How do we Use Destructuring Assignment to Pass an Object as a Function’s Parameters?

A

In this case we want to just add the name of the keys that we want/ or the keys + new variable names we want to add to the values in the parameter place and then in the function block say what we want to do with it.

const stats = {
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85
};

const half = ({max, min}) => (max + min) / 2.0;

the values for max and min in the object is placed where the parameters go inside of curly brackets –t the curly brackets signifies the destructuring…

then the arrow function to let us know were about to do stuff with it. and then in the function block we add both numbers and then divide the sum in half and save all of that to the half variable name.

431
Q

What is a Template String?

A

its when you use backticks to add variable names or accessed data inside of a string

it also can be used to make a string multi line

let dataType = “string”

` this is a template ${dataType}`

produces
“this is a template string”

432
Q

How can we use Object Shorthands to create new Objects? And when/how might we use them?

A

We can use Object Shorthands when we know that we are going to create multiple objects using the same keys

For example, we are going to make and need objects of wrestlers that all are going to have the keys of

name
finisher
title
slogan

instead of making each and every object, one by one every time – we can make a function that will do it for us for example

const wrestler = (name, finisher, title, slogan) => {
 return {
            name, finisher, title, slogan
}
}

then we can just call the function with the values of the parameters and store it in a variable name and we wil have new objects

const bretHart = wrestler(“the hitman”, “sharpshooter”, “WWF”, “Excellence of Execution”)

this will produce the object

bretHart = {
name: the hitman,
finisher: sharpshooter,
title : wwf,
slogan : excellence of execution
}

and any time you need to make a function you just call it with the proper parameter values and it will create the object and then you can access it the way you would anything else

bretHart.name returns “the hitman”

433
Q

When calling functions inside of an Object what shorthand can we write to make it more concise?

A

So usually when we call a function in an object it will usually look like this :

const person = {
  name: "Taylor",
  sayHello: function() {
    return `Hello! My name is ${this.name}.`;
  }
};

We can take off the function keyword and we can remove the colon:

const person = {
  name: "Taylor",
  sayHello() {
    return `Hello! My name is ${this.name}.`;
  }
};
434
Q

What is a Constructor Function? What is the job of such a function?

A

It is a function who’s job is to construct/create an object

435
Q

When making Constructor Functions should we use camel case?

A

No the first letter of every word should be capitalized

436
Q

We can use Object Shorthands to create templates for new objects how can we use Constructor Functions to create the same type of template for Object creation? what is the syntax?

A
function ConstructorName(param1, param2, param3){
this.param1 = param1;
this.param2= param2;
this.param3= param3;
}

const variableStore = new ConstructorName(“value1”, “value2”, “value3”)

this will produce an object like this:

variableStore = {
param1 = value1;
param2= value2;
param3= value3;
}
437
Q

How can you make a Constructor Function using the Class keyword?

A
class Wrestler {
  constructor(name,finisher,slogan){
    this.name = name;
    this.finisher = finisher;
    this.slogan = slogan;
  }
}

const bookerT = new Wrestler(“Booker T”, “Spinarooni”, “Can you dig it?”)

438
Q

What 4 things do we need to remember about Constructor Functions?

A
  1. You have to call them with the “new” keyword
  2. You don’t need a return statement
  3. If you use Class you have to use the Constructor method/ if you use Function you dont
  4. you have to use the “this” keyword
439
Q

What are Getters and Setters at their very core?

A

They are methods/functions inside of an object that return values or set values that look like properties.

object = {
year: 1979 (this is an actual property/key value pair)
get/set year( ) {
some code that returns/sets 1979

(this is a function that runs and returns the value of
1979 as if it were the property)
}
}

get obviously would return the value and set would obviously set the value

440
Q

What is a good mental model for Getters and Setters?

A

An account log in list. When someone logs in, names are saved into an array value. This whole array can be shown at once, also the last person that logged in can be displayed.

class Account {
  constructor(allAccounts, username){
    this.allAccounts = allAccounts;
    this.username = username;
  }
  set getAccount(updatedUserName){
    this.username = updatedUserName;
    this.allAccounts.push(updatedUserName)
  }
  get getAccount(){
    this.allAccounts = allAccounts;
    this.username = username;
  }
}

let currentList = new Account([],”no username logged in yet”);

currentList.getAccount = "rmungo49@gmail.com";
currentList.getAccount = "JenanAbderrahman@gmail.com";
currentList.getAccount = "mungoRashaan@gmail.com";
currentList.getAccount = "baysauce35@yahoo.com"

console:

[ 'rmungo49@gmail.com',
  'JenanAbderrahman@gmail.com',
  'mungoRashaan@gmail.com',
  'baysauce35@yahoo.com' ]
baysauce35@yahoo.com
441
Q

When calling a Getter or Setter function, what do we need to remember about calling the functions outside of the Class function?

A

We need to call them not like a function, but in the same way that we add a key/value pair to an object with dot/bracket notation.

set function:
currentList.getAccount = “rmungo49@gmail.com”;

the value after the equal sign of this becomes the parameter of the set function (updatedUserName).

set getAccount(updatedUserName){
    this.username = updatedUserName;
    this.allAccounts.push(updatedUserName)
}

get

currentList.username

this returns the value of username on the object without actually accessing the original objects properties.

get getAccount(){
    this.allAccounts = allAccounts;
    this.username = username;
  }
442
Q

Before we can start Importing and Exporting different parts of code to be used in different files what do we first need to do to our HTML document?

A

We need to add a script tag with the type module with src of the main javascript file.

443
Q

How do we Export a function so it can be used in other files?

A

export { function name}

444
Q

Can you Export multiple functions at the same time?

A

Yes you can. All you have to do is separate the function name with a comma.

export { function1, function2, function3}

445
Q

How do you Import a function after it has been Exported? How do you import multiple functions at once?

A

Import {function name} from ./filename.js

You can add multiple functions to a an import statement by adding it inside of the curly braces

Import {function name, function name 2} from ./filename.js

446
Q

What do we need to make sure that we have around the file name when we are using and Import Statement?

A

Quotations around the file name

”./filename.js”

447
Q

What do we do if we want to import ALL of the code from another file? What is the syntax? Whats different?

A

The main difference is the —* as objectName — instead of {function name}

The name can be anything you want.
This saves all the functions and code in one big Object.

import * as myMathModule from “./math_functions.js”;

448
Q

When you have Imported all the code from another file and it is saved as an object, how do you access it in the new file ?

A

The same way you would access any other object. Dot/Bracket Notation.

objectName.functionName(parameters)

myMathModule.add(2,3);
myMathModule.subtract(5,3);

449
Q

When do we use Export Default?

A

When we are only exporting one value/function

let iceCream = vanilla

export default iceCream

450
Q

Do you need the curly braces when using export default either Importing or Exporting?

A

No you do not, it is not necessary

451
Q

When using Default Export, how can we IMPORT it under a different variable name?

A

Just Import it using the curly braces and ‘default as variable name’

import {default as newName} from “somefile.js”

There will only be one default export from the file location so it will know which one to rename

452
Q

What type of function is Promise?

A

It is a constructor function

453
Q

What keyword do we need to make sure we use when creating a Promise?

A

We need to use the ‘new’ keyword because its a constructor function.

const myPromise = new Promise((resolve, reject) => {

});

454
Q

What does a Promise take as an argument/parameter?

A

It takes a function with two parameters

const myPromise = new Promise((resolve, reject) => {

});

455
Q

What are the three states of a Promise?

A

Pending, Fulfilled and Rejected.

456
Q

What does the calling of the Resolve argument inside a Promise trigger? What does the Reject argument trigger?

A

Resolve => the Then method following it. Which tells us what to do with successful data or value we achieved in the resolve function.

Reject => the Catch method following it. This tells us that our promise was unsuccessful and will either retry the call, do something else, or tell the user there was an error

457
Q

Whats a conceptual difference between a Promise and an If/Else statement?

A

Promises are promises. They are things that need to happen, there is weight to whether they do their job or not. If you have a webpage that prominent functionality that depends on the data of an outside APi or something, your app needs to get that information. It is a promise, like ‘Ill promise to be to work on time’

and if that promise isnt fulfilled - you need a way to handle it.

An If/Else statement is basically just a lower level example of this… where the functionality of the app isnt dependent on this working. If you have an If/Else statement that says if this number is even…do this.. but if its odd, do this…isnt going to break the code. It isnt weighted… it isnt a promise …life will go on

458
Q

When is a good time to use Promises?

A

When you have something thats going to take a minute to happen, like download a picture from a different server or perform an API call and you dont want all the code to stop running waiting for that to finish. This way you can keep running the rest of the code and whenever the promise gets what its looking for, it will bring it back and perform a function on it.

This is why its called a promise, because the rest of the code is going on without it - with the expectation that it will come back with what its looking for.

459
Q

What is the basic syntax of the Promise?

A
const myPromise = new Promise((resolve, reject) => {
  if(condition here) {
    resolve("Promise was fulfilled");
  } else {
    reject("Promise was rejected");
  }
});
460
Q

What can we pass in the parens of Resolve or Reject?

A

We can pass anything we want, a function - a string - a number. Anything.

461
Q

When adding a Then/Catch method do we chain them or code them separately?

A

We chain them

then( ).then( ).catch( )

462
Q

What are Regular Expressions?

A

Regular expressions are special strings that represent a search pattern

463
Q

What are Regular Expressions?

A

Regular expressions are special strings that represent a search pattern. They are used in programming languages to match parts of strings. You create patterns to help you do that matching.

464
Q

What is the test( ) method and what does it do?

A

It is added to the end of a Regular Expression or Regular Expression Variable and takes a String or Variable String and checks to see if that string has that text pattern.

regEx.test(string)

let testStr = “freeCodeCamp”;
let testRegex = /Code/;
testRegex.test(testStr);
// Returns true

465
Q

What type of value does the test( ) method return?

A

It returns a Boolean

466
Q

What is the Regular Expression /string/ ?

A

Whatever is in between the slashes is checked for in the larger string when used with the .test( ) method.

“the dog is running fast”

/dog/

would return true

467
Q

Is the test( ) method case sensitive?

A

Yes it is. A search for /Kevin/ would not return a true boolean for KEVIN or kevin

468
Q

How can you search for more than one string using the test( ) method?

A

you can use the OR Operator |
in between different strings patterns you want to search for.

/yes|no|maybe/

this would search for the strings of yes no or maybe.

469
Q

How can we search for a string pattern using the test( ) method while ignoring the case of the string?

A

You can add the “ i “ flag to tell the method to ignore the case.

/ignoreCase/i

this would return true

for any combination of ignoreCase

IGNORECASE
ignorecase

etc

470
Q

What does the match( ) method do?

A

The match method is the opposite of the test( ) method. It extracts the actual matched value of the string and returns it.

The match method is applied to the string and the Regex is added withing the parens of the match( ) method.

471
Q

What does the match( ) method do?

A

The match method is the opposite of the test( ) method. It extracts the actual matched value of the string and returns it.

The match method is applied to the string and the Regex is added within the parens of the match( ) method.

472
Q

Can the match method( ) be attached to the actual string itself or can it only be added to the a string already stored in to a variable name?

A

The method can be applied to the string itself as well as a variable name.

“Hello, World!”.match(/Hello/);

473
Q

How do we search for more than one pattern in a string?

A

We can use the “g” flag along with the match( ) method.

let testStr = “Repeat, Repeat, Repeat”;
let repeatRegex = /Repeat/g;
testStr.match(repeatRegex);
// Returns [“Repeat”, “Repeat”, “Repeat”]

474
Q

What does the “g” flag return?

A

It returns an array consisting of the amount of times a pattern was found inside of a string.

let testStr = “Repeat, Repeat, Repeat”;
let repeatRegex = /Repeat/g;
testStr.match(repeatRegex);
// Returns [“Repeat”, “Repeat”, “Repeat”]

475
Q

Is it possible to chain flags on the end of Regular Expressions?

A

Yes you can

/twinkle/gi

this would search for every instance of the word ‘twinkle’ in a string regardless of the case – and add it in an array and return it

476
Q

What is the Wildcard Period and how do we use it?

A

The Wildcard period is just a normal period but you use it in Regular Expressions to replace a character that you might not actually know or want to specifiy.

let humStr = "I'll hum a song";
let hugStr = "Bear hug";
let huRegex = /hu./;
huRegex.test(humStr); // Returns true
huRegex.test(hugStr); // Returns true
477
Q

How can we match a character with multiple possibilities when using Regular Expressions?

A

You can place each character that you want to search for inside of brackets [ ]. This is called a Character Class.

/b[aui]g/

this would search and return true for

bag, bug, and big

but wouldnt return true for

bog, beg, bkg etc

478
Q

What is a Character Set and How do we use them?

A

When you want to search for a range of characters using match( ) or test( ) methods in Regular Expressions you can use a hyphen between two characters and all of them in between will be searched for. This keeps you from having to individually type every letter you want to search for. Character sets are inclusive the the values you place on the book ends.

let catStr = “cat”;
let batStr = “bat”;
let matStr = “mat”;
let bgRegex = /[a-e]at/;
catStr.match(bgRegex); // Returns [“cat”]
batStr.match(bgRegex); // Returns [“bat”]
matStr.match(bgRegex); // Returns null

This works with numbers too.

/[0-9]/

479
Q

Can you search for both Numbers and Letters in a Character Set?

A

Yes you can.

/[a-z0-9]/ig;

This would search for all letters and all numbers.

480
Q

What are Negated Character Sets? How do we apply them?

A

They are the same thing as normal character sets expect they specify characters that you dont want to match. You apply these with a ^ instead of a -

The caret goes before the list of characters you want to exclude. Anything other than these characters will get matched including symbols and whitespace.

/[^aeiou]/gi

This will match everything except for vowels.

481
Q

How can you find characters that appear ONE OR MORE times in a row?

A

you can use the addition operator after the character.

-If the character is there just once it will return just the character

/a+/ = “a”

-if the character is there more than once it will return the original and the repeated characters.

/a+/ = “aa”

482
Q

What’s the Regular Expression to check to see if something occurs in a string Zero or more times?

A

The start symbol *

483
Q

What is a Greedy Match when referring to Regular Expressions?

A

It means that by default Regular Expressions search for the longest possible match in the string that properly validates.

For Example

/t[a-z]*i/

in the string titanic would return

titani

as opposed to “ti” which would also fit the criteria of the expression.

484
Q

Regular Expressions by default are Lazy or Greedy?

A

Greedy

485
Q

What is Lazy Match and how do we apply in when using Regular Expressions?

A

It returns the shortest possible valid string pattern

you add a question mark

/[a-z]?

486
Q

How do we search for a character pattern at the beginning of a string with Regular Expressions?

A

You can you use the ^ outside of a character set and it will do this?

/^Ricky/

487
Q

How do you search for a character pattern at the end of a string in Regular Expressions?

A

You add a dollar sign at the end of a string

/Ricky$/

488
Q

What is the \w shortcut mean when using Regular Expressions?

A

It basically returns true for all numbers and all letters of the alphabet and also the underscore.

/\w+/

489
Q

What is the \W shortcut mean when using Regular Expressions?

A

It returns everything BESIDES numbers and letters and underscore..

Its the opposite of \w

490
Q

How do you search for just Numbers in Regular Expressions?

A

\d

491
Q

What do we need to remember about searching for character patterns in Regular Expressions? How many do they return.

A

By default, these do not return all or more than one matching characters.

You have to specify if you want it to find all the instances or multiple instances. In general they return the first one they find

492
Q

How do you search for everything besides numbers in Regular Expressions?

A

\D

493
Q

What is /s in Regular Expressions?

A

It the way you find the white space in a string.

494
Q

What is the /S in Regular Expressions?

A

It returns everything besides whitespace (spaces, tabs, new lines etc)

495
Q

How do you set the range of characters that you want to search for inside of a string using Regular Expressions?

A

{minimum amount, maximum amount }

/a{3, 8}/

this will look at the expression and see if there are a number of a’s between the quantities of 3 and 8. So two a’s return a false, 6 a’s return a true.

496
Q

How do we set a minimum number of characters that you want to search for inside a string using Regular Expressions?

A

Just set the minimum value

/Haz{4,}ah/

this would return a true for

Hazzzzah
Hazzzzzah
Hazzzzzzah

or any combination of hazah that has more than 4 z’s

497
Q

How do we set an exact number of characters that you want to search for inside a string using Regular Expressions?

A

You simply place a number inside of curly brackets

/Tim{4}ber/

returns true for

Timmmmber

498
Q

How do you say a certain character is optional when using Regular Expressions?

A

You can apply a ? before a character and it makes it optional

/favou?rite/

/colou?r/

This will turn true for favourite or favorite and color and colour

499
Q

What is a Lookahead in Regular Expressions?

A

Lookaheads are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string

500
Q

What is a Positive Lookahead?

A

A positive lookahead will look to make sure the element in the search pattern is there, but won’t actually match it. A positive lookahead is used as (?=…) where the … is the required part that is not matched.

let quit = “qu”;

let quRegex= /q(?=u)/;

quit.match(quRegex); // Returns [“q”]

This returns true, because it looks ahead to the U and sees that there is one, so its true –But it doesnt return the U, it just makes sure that its there.

501
Q

What is a Negative Lookahead?

A

On the other hand, a negative lookahead will look to make sure the element in the search pattern is not there. A negative lookahead is used as (?!…) where the … is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present.

let noquit = “qt”;

let qRegex = /q(?!u)/;

noquit.match(qRegex); // Returns [“q”]

This returns true, because it looks ahead to see if there is a U and sees that there isnt one, so its true –But it doesnt return the U or the T , it just makes sure that it isnt there.

502
Q

In a Character Set in Regular Expressions what does a dot represent?

A

A regular Dot. A literal Dot.

Outside of character sets it represents any character, but inside the brackets it just represents itself

503
Q

How can we use Escape in Regular Expressions?

A

The same way we would use them in quotations for strings with a \

504
Q

The dash character can mean two different things inside a character set. What are these two things?

A

If it is the first thing in a character set it represents itself, a dash literal [ - . ]

if its not the first character in a character set then it represents a range. [A - Z]

505
Q

You can use the Pipe Operator to mean OR when using the .test( ) method to choose between various values in Regular expressions. How can you use this same functionality when writing longer Regular expressions?

A

When writing longer Regex, you can add parens around the terms using the pipe operator

[a-zA-Z]0-9

the parens separate it from the rest of the expression so it can work.

this isnt needed when its the only expression being hard coded straight into the test( ) method. Test already has parens that the pipe operators and values already go inside of

test( yes | no | maybe)

506
Q

What happens when your Regex finds a match as far as grouping?

A

It saves the whole string to the computers memory. It groups it all together.

507
Q

What happens when you use parens inside your Regex code as far as grouping?

A

Additional groupings occur, meaning that the computer stores memory of that part of the string separately in addition to the original string.

so a-z([0-9])

creates three groups…..

group 0 - the whole string
group 1 - the first paren group to the right
group 2 - the next paren group to the right

508
Q

How can you access groups of code when grouped by Regex?

A

You can use backslash and a number

\1 will be the first group with parens left to right
\2 will be the second etc

let repeatStr = "regex regex";
let repeatRegex = /(\w+)\s\1/;
repeatRegex.test(repeatStr); // Returns true
509
Q

How can you use replace( ) with Regex?

A

You can search and replace text in a string using .replace() on a string. The inputs for .replace() is first the regex pattern you want to search for. The second parameter is the string to replace the match or a function to do something.

let wrongText = “The sky is silver.”;
let silverRegex = /silver/;
wrongText.replace(silverRegex, “blue”);
// Returns “The sky is blue.”

510
Q

How do we remove whitespace ONLY from the beginning and end of a string using a method and using regex?

A

let hello = “ Hello, World! “;
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, “”); // Change this line

trim( ) does this without regex

using regex /\s+/g

will remove spaces everywhere in the string

511
Q

What are the three general types of errors and what do they mean?

A

syntax errors that prevent a program from running
runtime errors when code fails to execute or has unexpected behavior
semantic (or logical) errors when code doesn’t do what it’s meant to.

512
Q

What habit should we get into in putting console.log( ) in our code.

A

Every function should have a console.log, this will help with keeping track with what’s happening in your code

513
Q

What is console.clear( ) and how can we use it?

A

Constantly using console.log( ) will make your console cluttered and hard to read whats going on. You can strategically place console.clear to clear the console without getting rid of the console logs so you can them there in case a problem arises later

514
Q

What data type are arrays technically?

A

They are objects technically

515
Q

What type of error is a Reference Error?

A

Transposed, missing, or mis-capitalized characters in a variable or function name will have the browser looking for an object that doesn’t exist - JavaScript variable and function names are case-sensitive.

516
Q

When using push or unshift on an array to add another array how will the array be produced?

A

As a multi-dimensional array.

—-adding array literal with push: —-

array = [1,2,3]

array.push([4,5,6])

produces [1,2,3[4,5,6]]

—-adding array stored in an array with push: —-

array = [1,2,3]

storedArray = [4,5,6]

array.push(storedArray)

produces {1,2,3[4,5,6]]

517
Q

When using push or unshift on an array to add individual items not in an array how will the array be produced?

A

as a one-dimensional array

—adding individual literal values with push: —-

array = [1,2,3]

array.push(“four”,5,”six”)

produces [1,2,3,”four”,5”six”)

518
Q

What is the only way that you can use push( ) or unshift( ) on an array and not have it become a multidimensional array?

A

by adding items not as an array inside of the unshift( ) or push( ) - you can add as many items as you want inside of the parens

array = [1,2,3]

array.push(“four”,5,”six”)

produces [1,2,3,”four”,5”six”)

519
Q

What do we use to remove elements from an array?

A

splice( )

this allows us to remove any number of consecutive elements from anywhere in the array

520
Q

How many parameters does splice( ) take?

A

It can take up to three.

521
Q

What is the first parameter of splice( ) represent?

A

it represents the starting position. Remember this uses zero based indexing so the first one starts at zero.

522
Q

What does the second parameter of splice( ) represent?

A

It represents how many total items we want removed from the array.

let array = [‘today’, ‘was’, ‘not’, ‘so’, ‘great’];

array.splice(2, 2);
// remove 2 elements beginning with the 3rd element
// array now equals ['today', 'was', 'great']
523
Q

What does splice( ) return?

A

A new array of the removed items.

It represents how many total items we want removed from the array.

let array = [‘today’, ‘was’, ‘not’, ‘so’, ‘great’];

array.splice(2, 2);
// remove 2 elements beginning with the 3rd element
// array now equals ['today', 'was', 'great']

slice returns

[‘not’, ‘so’]

524
Q

What is the third parameter of splice( ) ?

A

The third parameter is used to add items to an array after you have removed elements from an array.

525
Q

How many arguments does the third parameter of splice( ) take ?

A

It can take as many arguments as you want as long as they are separated by a comma.

const numbers = [10, 11, 12, 12, 15];
const startIndex = 3;
const amountToDelete = 1;

numbers.splice(startIndex, amountToDelete, 13, 14);
// the second entry of 12 is removed, and we add 13 and 14 at the same index
console.log(numbers);
// returns [ 10, 11, 12, 13, 14, 15 ]

526
Q

What does the slice( ) method do?

A

It copies particular elements of an array and copies them to a new array without modifying the original array.

527
Q

How many parameters does slice( ) take?

A

It takes two.

528
Q

What do the parameters of slice( ) do?

A

The first one is the starting point of where the copying of the array will begin (zero indexing).

The second one is the point that you want the copying to stop. This is non inclusive, so whatever point you put as the stopping place will not be included. So add one more to the last element you want in the array.

let weatherConditions = [‘rain’, ‘snow’, ‘sleet’, ‘hail’, ‘clear’];

let todaysWeather = weatherConditions.slice(1, 3);
// todaysWeather equals ['snow', 'sleet'];
// weatherConditions still equals ['rain', 'snow', 'sleet', 'hail', 'clear']

notice that the stopping point was 3 which in the array = hail
but the last item copied is sleet which is the element before 3.

529
Q

How can you completely copy an array? Do you need to use splice( )?

A

YOU DONT NEED SPLICE!!!

just use the spread operator.

let thisArray = [true, true, undefined, false, null];
let thatArray = [...thisArray];  <= <= <= <= EXAMPLE
// thatArray equals [true, true, undefined, false, null]
// thisArray remains unchanged, and is identical to thatArray
530
Q

How can we search an array for a particular element and get it to return the index of that element?

A

array.indexOf( “element” )

let fruits = [‘apples’, ‘pears’, ‘oranges’, ‘peaches’, ‘pears’];

fruits.indexOf(‘oranges’); // returns 2

531
Q

When using array.indexOf( ) on an element and the element isnt present in the array, what will it return?

A

-1

532
Q

What does the every( ) method do on an array?

A

The every( ) method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.

const isBelowThreshold = (currentValue) => currentValue < 40;

const array1 = [1, 30, 39, 29, 10, 13];

console.log(array1.every(isBelowThreshold));
// expected output: true
533
Q

What can you iterate through the keys of an object? And what is the syntax?

A

with a ‘For ….. In’ loop.

for ( let newVariable name In nameOfObject) {
what do you want to happen in loop
}

users = [‘Alan’, ‘Jeff’, ‘Sarah’, Ryan’]

for (let user in users) {
console.log(user);
}

// logs:
Alan
Jeff
Sarah
Ryan
534
Q

How can we use a ‘counter’ variable to count how many times something happens in a function when using a loop?

A

Create a variable that equals 0 and when the code executes whatever you want, or finds a true value or whatever it is your looking for and increase the variable name by 1 ++

function countOnline(obj) {
  // change code below this line
  let result = 0;
  for (let user in obj) {
    if (obj[user].online === true) {
      result++;
    }
  }
  return result;
535
Q

What is Object.keys( ) and what does it return?

A

it returns an array consisting of the keys of an object.

return Object.keys(obj)

[ ‘Alan’, ‘Jeff’, ‘Sarah’, ‘Ryan’ ]

536
Q

How do we turn an array into a string without commas?

A

.join(‘ ‘)

537
Q

Which are two ways in which you can reverse a string?

A

1.

function reverseString(str) {
  let reversedStr = " ";
  for( let i = str.length - 1; i >= 0; i--){
      reversedStr += str[i]
  }
  console.log(reversedStr)
  return str;
}

2.

function reverseString(str) {
  return str
    .split("")
    .reverse()
    .join("");
}
538
Q

What does split( ) do?

A

Split( ) takes a string and turns it into an array of substrings

(‘’) will separate every character by a comma.

(“ “) will separate every word with a comma, or where ever there is a space.

539
Q

What does .reverse( ) do ?

A

reverse will reverse the order of the items inside of an array.

540
Q

What is a short concise way to find the longest string in an array?

A
function findLongestWordLength(str) {
  return Math.max(...str.split(" ").map(word => word.length));
}
541
Q

What does .sort( ) do? and what is the default?

A

It sorts the items of an array. By default it sorts strings alphabetically

542
Q

How does sort( ) work with numbers?

A

Sort sorts numbers not by the value they represent but by individual digits… so 25 would come before 100 because the digit of 2 is higher than 1 in the first place of the hundreds place

543
Q

What is reduce( )?

A

The reduce( ) method reduces the array to a single value.

544
Q

What does find( ) do?

A

The find( ) method returns the value of the first element in an array that pass a test (provided as a function).

545
Q

What does filter( ) do?

A

The filter( ) method creates an array filled with all array elements that pass a test (provided as a function).

546
Q

What does the replace( ) method do?

A

The replace() method searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced.

Return a string where “Microsoft” is replaced with “W3Schools”:

var str = "Visit Microsoft!";
var res = str.replace("Microsoft", "W3Schools");
547
Q

What should we note and remember about the

replace( ) method?

A

That it only replaces the first instance of the matched expression if using a string as a replacement.

548
Q

How do we take a string and make the first letter capitalized?

A
function titleCase(str) {
  var convertToArray = str.toLowerCase().split(" ");
  var result = convertToArray.map(function(val) {
    return val.replace(val.charAt(0), val.charAt(0).toUpperCase());
  });
  return result.join(" ");
}

titleCase(“I’m a little tea pot”);

549
Q

What does charAt( ) do?

A

it returns the character at that specified place in the index, which is placed in the parens.

Return the first character of a string:

var str = "HELLO WORLD";
var res = str.charAt(0);
550
Q

How can we find out if a data type or variable name has a Boolean of truthy or falsy?

A

Boolean(variableName)

this will return a true of the data type is truthy

will return a false when the data type is falsy

null, undefined, false, an empty string, 0 or NaN

551
Q

Whats the difference between indexOf( ) and

findIndex( ) ?

A

indexOf( ) can be used by just adding the value or name inside the parens. It will search the array or the string for it and return the index.

findIndex( ) is used to pass a function inside of the parens, this can be used to find an item in which you dont already know the variable name or whats in the array, or want the first of many possible items of an array.

552
Q

What does includes( ) do?

A

The includes() method determines whether an array contains a specified element.

This method returns true if the array contains the element, and false if not.

Note: The includes() method is case sensitive.

553
Q

Why do we use the ‘this’ keyword in a object method?

A

We use it when we want to access another property of the object.

let dog = {
  name: "Spot",
  numLegs: 4,
  sayLegs: function() {return "This dog has " + this.numLegs + " legs.";}
};

This allows us to

554
Q

Why should we use the this keyword for Dot Notation in object methods?

A

Because sometimes we need to change the name of objects and if the object of the name changes we dont want the code to break when we call the object method

555
Q

What are object key values that are functions called?

A

They are called methods

556
Q

What are constructors?

A

Constructors are functions that create new objects. They define properties and behaviors that will belong to the new object. Think of them as a blueprint for the creation of new objects.

557
Q

How do we visually distinguish constructor functions from other types of functions?

A

They start with a capital letter and they set properties using this keyword

558
Q

What is the name for when a Constructor creates a new Object?

A

Its called an Instance

559
Q

How can we figure out if a object was created by a particular Constructor?

A

the instanceof operator. instanceof allows you to compare an object to a constructor, returning true or false based on whether or not that object was created with the constructor

crow instanceof Bird; // => true

560
Q

What are Own Properties?

A

Own Properties are properties that are defined in the object themselves, either through hardcoding the properties yourself or through the use of a constructor function. Both are considered Own Properties

561
Q

If you have an object that will have a set property for all instances of the object, how can we set that property so we dont have to keep repeating it. Like a name property for a lot of people objects.

A

By using prototype

Properties in the prototype are shared among ALL instances of the objects that a Constructor creates.

Bird.prototype.numLegs = 2;

Now all instances of Bird have the numLegs property.

console. log(duck.numLegs); // prints 2
console. log(canary.numLegs); // prints 2

562
Q

When you assign a Object Property to a Constructor using Prototype do you do it inside or outside of the Constructor function?

A

It doesnt matter, it will take affect anywhere you declare it

563
Q

Are Prototype Properties and Own Properties the same?

A

No. You will not see the Prototype Properties when you print out or console.log the the Object Name. It is applied to the object behind the scenes and is technically apart of the constructor that constructs the object and not the object itself.

564
Q

If we cant see Prototype Properties on the actual object themselves or when we console.log the object, how do we access it or see it?

A

using dot/bracket notation

pitBull.prototype.name = “Spot”

565
Q

How can we add all Object Properties, whether Own or Prototype to a new array?

A

with an if/else statement

if own props are found => push to new array

else if prototype props are found => push to same array

return array

566
Q

What is a Constructor Property? How can it be used? What is it similar to?

A

A constructor property can be used to check to see if a object was made by a particular constructor function. Will return a boolean.

spot. constructor == Dog => true

this is similar to the instanceof keyword

567
Q

Is it better to use the constructor or the instance of keyword to check if an object was made by a particular constructor?

A

Its better to use instanceof because constructor can be overwritten

568
Q

Instead of creating individual Object Prototype Properties how can we add more than one at a time?

A

You can add all the prototype value/keys to a prototype object.

Bird.prototype = {
  numLegs: 2, 
  wings: 2,
  beak: 1,
  eat: function() {
    console.log("nom nom nom");
  },
  describe: function() {
    console.log("My name is " + this.name);
  }
};
569
Q

What is a crucial side effect of setting a prototype object?

A

It erases the constructor property

570
Q

How do we need to do to counteract a Prototype Object erasing the Constructor Property?

A

we set the constructor property and the value in the Prototype Object.

Bird.prototype = {
  constructor: Bird, // define the constructor property
  numLegs: 2,
  eat: function() {
    console.log("nom nom nom");
  },
571
Q

What does isPrototypeOf( ) do?

A
function Bird(name) {
  this.name = name;
}
let duck = new Bird("Donald");
duck inherits its prototype from the Bird constructor function. You can show this relationship with the isPrototypeOf method:

Bird.prototype.isPrototypeOf(duck);

572
Q

Do all Objects have Prototypes?

A

Not all but Most

573
Q

A Prototype in its essence is what?

A

It is an object

574
Q

Can Prototypes also have Prototypes?

A

Yes they can

Because a prototype is an object, a prototype can have its own prototype! In this case, the prototype of Bird.prototype is Object.prototype:

Object.prototype.isPrototypeOf(Bird.prototype); // returns true

575
Q

A Object made by a constructor is what in relation to the ConstructorFunctionName.Prototype?

A

It is the child, its lower than it on the chain.

the object of ‘alex’
and the object of ‘dave’

are both children and inherit properties from
Person.prototype

if Person.prototype.species = human

all objects coming out of person would take the property species : human

576
Q

How can we override the properties in the prototype object connected to our objects?

A

We use bracket and dot notation to apply new key/value pairs to our objects.

for example

Initial set => taking value from prototype

Person {name: "Sarah", age: 16}
age: 16
name: "Sarah"
\_\_proto\_\_:
fingers: 10    <= passed in from set prototype

Overriding with Dot Notation

sarah.fingers = 8;

Person {name: “Sarah”, age: 16, fingers: 8}
age: 16
fingers: 8 <== this will show up when you run it
name: “Sarah”
__proto__:
fingers: 10

577
Q

What is at the top of the Prototype Chain?

A

At the very top Object.prototype is at the top…everything runs up and comes from this.

578
Q

What does DRY stand for? Why is this principle important?

A

Don’t Repeat Yourself.

If you change something you have to change it in all the places.

Also, more times you have to write the same code the more likelihood for bugs and more work for yourself and for others.

579
Q

If two prototypes share the same key/value what should we do in What spirit of DRY?

A

Create a superType and place the shared key/value there.

These both have the same ‘eat function’

Bird.prototype = {
  constructor: Bird,
  describe: function() {
    console.log("My name is " + this.name);
  }
};
Dog.prototype = {
  constructor: Dog,
  describe: function() {
    console.log("My name is " + this.name);
  }
};

We should make a supertype called animal and add the eat function to it and remove it from the other prototype objects

function Animal() { };

Animal.prototype = {
  constructor: Animal, 
  describe: function() {
    console.log("My name is " + this.name);
  }
};
580
Q

What is Inheritance when referring to Object Oriented Programming?

A

Its receiving properties and data from objects and constructors without having to hard code it yourself.

It then can be modified or changed without changing the original properties or values

581
Q

When an object inherits its prototype from another object, it also inherits what?

A

When an object inherits its prototype from another object, it also inherits the supertype’s constructor property.

582
Q

How do you reset a constructor property after you’ve used inheritance?

A

Bird.prototype.constructor = Bird;

583
Q

How do we set up Inheritance in Objects between parents and child?

A

function Animal() { }

set parent and give prototypes 
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
function Bird() { }
function Dog() { }

set sub objects and any hard coded key/values you want to have
________________________________________

Bird.prototype = Object.create(Animal.prototype);
Dog.prototype = Object.create(Animal.prototype);

bind children to parents prototypes
________________________________________

Bird.prototype.constructor = Bird;

change back constructors of children objects

________________________________________

Add additional methods or properties you want that specific sub object to have

Dog.prototype.fly = false <= string example

Dog.prototype.facts = {   <= object example 
city: 'Philly',
  type: 'Pitbull',
  friendly: 'Yes',
  owner: 'yes'
}

__________________________________________

Create new specific instances with prepassed properties and now can add individual properties if you like

let duck = new Bird();
let beagle = new Dog();
584
Q

Can you override and inherited prototype ?

A

Yes you can, the same way you update or do anything in Objects. Dot Notation.

Just use the same path and name and give it a new value.

Animal.prototype.eat = function() {
return “nom nom nom”;

changed to

Bird.prototype.eat = function() {
return “peck peck peck”;
};

585
Q

When attempting to inherit data from objects to other objects, why is it important to make sure that you change and reset the constructor property?

A

If you do not, any time you try to add additional properties - it will make you choose one or the other (parent or child) to update. One overriding the other.

If you set the parent,
then change the constructor back to itself (child object)
then you can add new methods and properties to the child element

586
Q

When is inheritance not the best approach for object behavior sharing? What should be used instead?

A

When the objects are unrelated.

An object representing Birds

And an object representing Airplanes both fly but shouldnt use inheritance to share that behavior.

Mixins should be used instead.

587
Q

What is a Mixin? What does it do and what is the syntax for it?

A

A mixin allows other objects to use a collection of functions.

let flyMixin = function(obj) {
  obj.fly = function() {
    console.log("Flying, wooosh!");
  }
};
The flyMixin takes any object and gives it the fly method.

flyMixin(bird);
flyMixin(plane);

result

bird. fly(); // prints “Flying, wooosh!”
plane. fly(); // prints “Flying, wooosh!”

588
Q

What is a Public Property?

A

It can be accessed and changed outside of the objects function.

589
Q

What is a Private Property?

A

a property that can only be accessed and changed by methods also within the constructor function.

590
Q

What is an example of code that you want to be Private instead of Public?

A

Account numbers, bank statements, social security numbers, passwords etc.

591
Q

What is the simplest way to create a Private Property?

A

Create the variable inside of the constructor function. This takes the scope outside of global

592
Q

What is a Privileged Method?

A

Its a method that has access to a private property inside of the same constructor function.

let hatchedEgg = 10; // private variable

  /* publicly available method that a bird object can use */
  this.getHatchedEggCount = function() { 
    return hatchedEgg;

here getHactchedEggCount is the Priveledged Method of the private property hatched egg

593
Q

What is Closure when it comes to Private/Public Properties?

A

Closure is the act of setting a variable inside of a constructor method to make it private, and then creating a privileged method in the same constructor that is equal to the same value as the private property. This allows the value to be changed and manipulated from the outside without changing the actual data inside the function.

let hatchedEgg = 10; // private variable

  /* publicly available method that a bird object can use */
  this.getHatchedEggCount = function() { 
    return hatchedEgg;
  };
}
let ducky = new Bird();
ducky.getHatchedEggCount(); // returns 10
594
Q

What is an Immediately Invoked Function and what does it do? What is the syntax?

A

It calls the function as soon as its declared.

(function () {
console.log(“Chirp, chirp!”);
})();

its basically a normal function with 4 main differences

  1. No name
  2. No variable
  3. wrapped in extra parens
  4. extra parens at the end
595
Q

How are Immediately Invoked Functions usually used?

A

To group functionality inside of one object/module.

For example two different mixins are placed under one variable name and is called immediately. This makes it so that all the information is not in an array and can be used

let motionModule = (function () {
  return {
    glideMixin: function(obj) {
      obj.glide = function() {
        console.log("Gliding on the water");
      };
    },
    flyMixin: function(obj) {
      obj.fly = function() {
        console.log("Flying, wooosh!");
      };
    }
  }
})();

Now we can call motionModule.glideMixin(duck)
or motionModule.flyMixin(dog) and assign these prototypes to these unrealted functions.

596
Q

What is Functional Programming? What are its main three tenets ?

A

Functional programming is a style of programming where solutions are simple, isolated functions, without any side effects outside of the function scope.

1) Isolated functions - there is no dependence on the state of the program, which includes global variables that are subject to change
2) Pure functions - the same input always gives the same output
3) Functions with limited side effects - any changes, or mutations, to the state of the program outside the function are carefully controlled

597
Q

What is a Callback Function?

A

Callbacks are the functions that are slipped or passed into another function to decide the invocation of that function. You may have seen them passed to other methods, for example in filter, the callback function tells JavaScript the criteria for how to filter an array.

598
Q

Whats a First Class Function?

A

Functions that can be assigned to a variable, passed into another function, or returned from another function just like any other normal value, are called first class functions. In JavaScript, all functions are first class functions

599
Q

Whats a High Order Function?

A

The functions that take a function as an argument, or return a function as a return value are called higher order functions.

600
Q

Whats a Lambda?

A

When the functions are passed in to another function or returned from another function, then those functions which gets passed in or returned can be called a lambda.

601
Q

What is Imperative Programming?

A

Telling the computer what to do and exactly how to do it

602
Q

What is declarative Programming?

A

Telling the computer what you want done and less how you want it done

603
Q

In functional programming what do we call changing or altering things?

A

Mutation

604
Q

What are the effects of mutation called in Functional Programming?

A

Side Effects

605
Q

What is an example of Mutation and a Side Effect?

A
// The global variable
var fixedValue = 4;

function incrementer () {

return fixedValue ++ ;

}

This causes mutation….

the side effect is that the global value is changed to 5

the better way is to go fixedvalue + 1

this keeps the global value the same and still has the function produces the desired result of 5

606
Q

What Principal should we always adhere to when it comes to arguments in Functional Programming?

A

if a function depends on a variable or object being present, then pass that variable or object directly into the function as an argument.

var fixedValue = 4;
function incrementer (x) {
  return x + 1;
}
607
Q

If you pass arrays as parameters and alter them with methods like push and shift, will the global array be effected?

A

Yes, they will be. So its important to copy the array even after you pass it in as an argument and then alter it

function add (list, bookName) {
let newArr = list.slice();
 newArr.push(bookName)

return newArr;

608
Q

What does filter( ) return?

A

An Array containing all the array elements that pass the test. If no elements pass the test it returns an empty array.

609
Q

What is an elegant way to add or remove an parameter from an array also passed in as a parameter?

A
function add(list, bookName) {
  return [...list, bookName];
}
function remove(list, bookName) {
  return list.filter(book => book !== bookName);
}
610
Q

Map( ) returns what?

A

A new array

611
Q

Map( ) has three arguments that it returns what are they?

A
  1. element itself
  2. index it takes in array
  3. the whole array that map is being ran on
612
Q

When pushing parts of an object into a new array can you rewrite the keys and just access the values through bracket or dot notation?

A

Yes you can. It is not neccesary to try and get the key to be the same or find a way to bring it with the value….

just write the key, or make a new one similar and then just use dot notation to bring over the important information to where you want it to be.

[{“title”:”Inception”,”rating”:”8.8”},{“title”:”Interstellar”,”rating”:”8.6”},{“title”:”The Dark Knight”,”rating”:”9.0”},{“title”:”Batman Begins”,”rating”:”8.3”},{“title”:”Avatar”,”rating”:”7.9”}]

if we wanted to loop through this and take all the movie titles to a new array.. you wouldnt need worry about the keys just create new keys like “MovieName” instead of Title

push.({MovieName : object.title})

and this will do what you need it to do

613
Q

Whats the difference between parseInt and parseFloat ?

A

parseFloat will keep a decimal number a decimal it will just turn it from a string to a number

parseInt does the same thing but will make it an integer, decimal number get rounded down to the nearest whole number

614
Q

What does the slice( ) method return?

A

It returns an extracted part of the array as a new array

615
Q

does slice alter original array?

A

No it doesn’t, it copies and returns a new array that you can save in a variable

616
Q

does splice alter the original array?

A

yes it does, it returns what is removed and that can be save in a variable but the original array is also altered

617
Q

concat( ) adds two strings or arrays together and creates a new array, does it affect the individual strings or arrays?

A

No the original variables stay unaltered. It just creates a new array that you can store in a new variable

618
Q

What is concat( ) relationship to push( )?

A

They both add things to arrays, but concat does not alter the original array which mean its the preferred way as far as functional programming is concerned

619
Q

How can you find out or check to see if a number is a float or an integer?

A

Number.isInterger( )

place the number in the parens and it will return a boolean with true or false

620
Q

How do we find the square root of a number?

A

Math.sqrt( )

place the number in between the parens

621
Q

When using sort( ) with strings do we need to add a compare function?

A

No, by default it will put it in alphabetical order. just put .sort( ) on the array

622
Q

What is a compare function on sort( )?

A

It is the function that you have to use with numbers to make sure that it sorts the numbers correctly.

623
Q

Does sort( ) change the items in the original array?

A

Yes it does.

624
Q

Can Regular Expressions be used with Split( )?

A

Yes it can

var otherString = "How9are7you2today";
var byDigits = otherString.split(/\d/);
// Sets byDigits to ["How", "are", "you", "today"]
625
Q

What does \W represent in RegEx?

A

Any non word characters [numbers and symbols]

626
Q

When we use join( ) what will be added between the words being joined together?

A

A comma

627
Q

When using join( ) how do we specify what goes between the words?

A

Add them in the parens. If you want a space add a space .join(“ “)

if you want dashes add dashes .join(“.”) etc

628
Q

What does the method some( ) do and what does it return?

A

its the opposite of every, it runs a function and checks to see if ANY of the items meet the criteria.

it returns a boolean

629
Q

What does Math.min( ) and Math.max( ) do?

A

Returns the highest and the lowest numbers in an array

console. log(Math.min(…arr))
console. log(Math.max(…arr))

sumAll([1, 4]);

1
4

630
Q

What two array methods can we use to see if an array has a particular element, value or item?

A

Index0f( ) = this will return the index of the item if found or an - 1 if not found

includes( ) = will return a Boolean true/false depending on if the array has it or not.

631
Q

If you need to run a function forwards and backwards do we need to write the function twice?

A

No, we should look to write the function in a way that we can call it once, and switch the parameters around to produce various results.

INSTEAD OF — this calls two functions preforming the same function on one array and then switches the order of the arrays starting with arr1 and then arr2

 function modify(arr1, arr2){
  arr1.map(item => {
   return arr2.includes(item) ? null : newArr.push(item)
  });
  arr2.map(item => {
   return arr1.includes(item) ? null : newArr.push(item)
  })
  }

WE SHOULD DO — this makes one function and switches the arguments

 function modify(arr1, arr2){
  arr1.map(item => {
   return arr2.includes(item) ? null : newArr.push(item)
  });

Modify(first, second);
Modify(second, first);

632
Q

How do we add spaces or anything in between particular letters using Regex? Not substitute letters for white spaces or symbols, but to add spaces or symbols when they are not there?

A
  1. use replace
  2. create two groups with each group representing what you want to come before the space/symbol ([group1 ])
  3. the third group represents what you want to come after the space or the symbol ([group 2])
  4. add $1 and $2 to represent each group
  5. place whatever you want to go in the space between to be in between $1/$2 group

str.replace(/([a-z])([A-Z]/g, “$1 ! $2”)

this will place a ! in any place where a lowercase number is followed by a capital case letter

633
Q

What does every( ) return and how does it decide what it returns?

A

It checks that every item in an array validates to true…if every item validates to true it returns a true….

if even one returns false then the whole thing is false.

634
Q

What to remember about using the Rest Parameters when it comes to adding other parameters? When might it come in handy?

A

You can take the first items of an array and give them specific parameter names and then place all the other array items in an array by it self using the rest parameter operator/spread operator

[1,2,3,4,5]

function seperate(one, two, …threeToFive)

this will make three arguments
1
2
[3.4.5]

This can come in handy when you need to do something with the first couple of elements but also be able to access unknown number of parameters

635
Q

If you need to use concat( ) but dont have a second or third array in which to append .concat( ) on what can you do?

A

you can create an empty array

array = [ ]

and then use concat( ) on that and attach the array you want to use

array.concat(otherarray)

636
Q

Can you chain replace( ) methods together?

A

yes you can.

let gotit = 
   str.replace(/&amp;/g, "&amp;")
   .replace(//g, ">")
   .replace(/"/g, """)
   .replace(/'/g, "'")
   .replace(/<>/g, "<>");
637
Q

How What is an algorithm to find if a number is a Prime Number?

A
function isPrime(num) {
    if(num < 2) return false;
    for (var i = 2; i < num; i++) {
        if(num%i==0)
            return false;
    }
    return true;
}
638
Q

When using Recursive Functions with multiple parameters, do we need to make sure that all our parameters are inside the Recursive Case?

A

Yes we do. Otherwise it will throw a Reference Error/ Error

function recursiveFunctionName(arrayParam, numParam)  THIS IS REGULAR CALL
if ( numParam <= 0){
    return;
  }
  else {
    arrayParam.push(numParam)
    console.log(arrayParam)
    return recursiveFunctionName(arrayParam, numParam - 1) THIS IS RECURSIVE CALL
  }
}
639
Q

If you’re trying to create an array or add to an array using a Recursive Function how would you create/access or accomplish this?

A

Create an empty array outside of the function and pass it through the Recursive Function by passing it in as an argument.

function recursiveFunctionName(arrayParam, numParam){  ARRAY PARAM IS THE ARG.
if ( numParam <= 0){
    return;
  }
  else {
    arrayParam.push(numParam)                                                     ARRAY PARAM IS THE ARG.
    console.log(arrayParam)
    return recursiveFunctionName(arrayParam, numParam - 1)     ARRAY PARAM IS THE ARG.
  }
}
640
Q

What do you do if you have an if statement and you want nothing to happen if a certain condition is met? Instead of returning null.

A

You can just place the Return Keyword.

function recursiveFunctionName(arrayParam, numParam){  ARRAY PARAM IS THE ARG.
if ( numParam <= 0){
    return;
  }
641
Q

In an Recursive Function – inside of the Else Statement – does the Recursive Call need to be the only code inside of it? Does any action we want to happen have to be linked to the Recursive Call itself?

A

No, it doesnt. The call just needs to be there to keep the loop going. But other types of code can be added to and performed inside of the Else Statement. The Recursive Call should go last.

 else {
    arrayParam.push(numParam)
    console.log(arrayParam)
    return recursiveFunctionName(arrayParam, numParam - 1)
  }

I dont need to try and console and push and call the Recursive Function all in the same line of code.

642
Q

In the Recursive Call what do we need to make sure that we have to make sure that the Base Case will eventually be reached and we will avoid a circular loop?

A

We have to adjust the Argument that is being passed through the function and being compared against the BaseCase so that every time the Recursive Function is called it gets closer to being terminated

 else {
    arrayParam.push(numParam)
    console.log(arrayParam)
    return recursiveFunctionName(arrayParam, numParam - 1)  <===
  }

NUMPARAM IS BEING SUBTRACTED BY 1 EVERY TIME IT IS CALLED.

643
Q

When trying to add second and third parameters to Javascript methods like map( ), what do we need to remember about some of them?

A

Some methods like map( ) already come with set meanings of what a second and third parameter represent.

For example, map( ) second parameter is assigned to the index of what the first parameter is. So if you try to assign it to a function or give it some other use - it wont work, or will work in a way that you dont want.

array.map(element, index)

so if you did something like

array.map((a, b) => a + b)

it would produce something like

apples0, banana1, fork2

because you will just be adding the element to its index number.

so if you want to use some sort of other parameter function you should probably declare it somewhere else and use it inside of the map.

array.map(element => [element, functionName(element)])

this would run a particular function on each element of an array and return the original element and the new value inside of a nested array

example original array [A, B, C, D]

[[ A, ABC] , [B, BBC], [C, CBC], [D, DBC]]

644
Q

How to take a value as a parameter and add all the sums of every Prime Number less than it and return the value.

A
function sumPrimes(num) {
   let primes = [2];
  // set up a new array, starting with 2 because we know that we are going to need that there and that 2 is the smallest prime number and the only even prime number, so we just set it because its the only one of its kind. 

for(num; num >= 3; num–){

    // set up a loop that counts down the value of the parameter num
    // also sets it up so the loop stops before it reaches 2, which was hardcoded
    let i = 2;
    let numArr = [];
    while( i < num){
        numArr.push(i)
        i++
    }
  // this sets up an array, that counts from 2 up until the number before the    value of num
  let check = numArr.some(item => {
     return num % item == 0
  })
// This goes through numArr that consists of all the numbers from 2 until the value of num and takes each number and uses % to see if it returns a value of 0. If it returns a value of 0 anywhere along the way, it isnt a prime number. If not it is a prime number. This takes the boolean and stores it in the variable 'check'
 check ? null : primes.push(num);
     // this says if 'check' equals true than do nothing. If it is false then take 
     // the value of num, and add it to the 'primes' array.
  } //    <===   end of loop 
  let total =  primes.reduce((sum, num)=> {
      return sum + num
  })

// this takes all the values inside of the prime array and adds them together using reduce and stores that in the variable ‘total’

return total

//returns total outside of the function

}

645
Q

What is BootStrap?

A

Bootstrap is a front-end framework used to design responsive web pages and web applications. It takes a mobile-first approach to web development. Bootstrap includes pre-built CSS styles and classes, plus some JavaScript functionality. Bootstrap uses a responsive 12 column grid layout and has design templates

646
Q

To get started with Bootstrap what should you first do?

A

Create a DIV with the CLASS of Container-Fluid that will nest other html elements

647
Q

If we wanted to add an image that is exactly the width of our phone’s screen what class would we add in Bootstrap?

A

‘img-responsive’

648
Q

How do we center text in Bootstrap?

A

By adding the ‘text-center’ class to an html element

649
Q

How do you add a bootstrap style of button to your page?

A

By adding the classes ‘btn btn-default’ to the button element

650
Q

Bootstrap buttons have what width by default?

A

They have the width of the content inside the button…

ie ‘Like’ or ‘Submit’

651
Q

How do we get the button to take up the entire space allotted horizontally?

A

We need to turn in into a block element and we do this by adding the class

btn-block

so our button would look like this

Like

652
Q

what does adding btn-primary do when you add it to a bootstrap button instead of btn-default?

A

it makes it facebook blue

653
Q

what does adding btn-info do when you add it to a bootstrap button instead of btn-default?

A

it makes it twitter blue

654
Q

what does the bootstrap button class btn-danger do?

A

it turns the button red and lets the user know that the buttons performs a destructive function

655
Q

What two things do you need to do to put bootstrap elements in a row?

A
  1. nest all elements you want horizontal in a row inside a div with a class of ‘row’
  2. specify how wide you want the elements to be by nesting the elements individually in a div while using the class ‘col-screensize- width’
656
Q

How do you specify the width and the screen size of item put into a bootstrap row?

A

col-screen size- width

col-md-4

this would tell the element when the screen is medium sized to take up 4 of the 12 available columns. (so basically be one third of the available space)

col-xs-2

this would tell the element when the screen is extra small to take up two of the 12 available columns - so basically take up 1/6th of the available space

657
Q

What do we need to remember about bootstrap grids and how many columns it uses?

A

They work off a 12 column grid and so the number on the end of col-screensize-width represents how many of those 12 columns will be taken up by the element.

12 equals all
8 is 75%
6 equals half
4 equals a third
2 equals a sixth 

etc

658
Q

How can we change the color of text using bootstrap the same way that we can change the buttons?

A

use text instead of the word btn in the class

text-primary
text-danger
text-info

659
Q

We can use the element span to do what as far as styling?

A

We can next particular inline elements with span and then apply classes to them in bootstrap that will change the color of aspect of the element while keeping it an inline element

660
Q

What is ‘Font Awesome’?

A

Font Awesome is a convenient library of icons. These icons can be webfonts or vector graphics. These icons are treated just like fonts. You can specify their size using pixels, and they will assume the font size of their parent HTML elements.

661
Q

How do we add Font Awesome icons to an element?

A

You add font icon classes to either an i element or a span element

662
Q

How do you add an Info Icon and thumbs up icon? What are the classes?

A

fas fa-info-circle
fas fa-thumbs-up

attach these to either an i element or a span element.

663
Q

What class do i add to an i element or a span element to add the paper plane icon?

A

‘fa fa-paper-plane’

664
Q

What does wrapping all your HTML content in a bootstrap div with the container-fluid class do?

A

It makes all of your content on the page responsive

665
Q

What does the BootStrap Class ‘Well’ do?

A

Bootstrap has a class called well that can create a visual sense of depth for your columns.

666
Q

What does the .css( ) Jquery method do?

A

it changes the Css of the selected element. It works just like css, but they both take quotes and there is a comma instead of a colon

$(‘p’).css(‘transform’, ‘capitalize’) – this will make all the text capitalized.

667
Q

How do you use Jquery to disable a button or some other element that can be disabled?

A

add .prop(‘disabled’, true) to the selector and it will be disabled

668
Q

What does the .html( ) jquery method do?

A

it replaces the html and content of the selected element

669
Q

What does the .text( ) jquery method do?

A

it replaces the text of the selected element and not the html. If html tags are used here, the tags would be rendered like normal text

670
Q

What does .remove( ) do in jquery?

A

it removes an Html element completely

671
Q

What does .appendTO( ) do in jquery?

A

it puts an element inside of a div.

it can be used to move one element from one div to another or it can be used to place an element into a div for the first time

672
Q

What does .clone( ) do in jquery?

A

it creates a copy of an element

673
Q

What does .parent( ) and .children( ) do in jquery?

A

it allows you to access the parent or child of an element

674
Q

What does element:nth-child(n) do in jquery?

A
It allows you to specify a particular child of an element
if you have 5 children that all have the same class of 'item'

you would access the fourth one like this

$(‘.item:nth-child(4)’).css(‘color’,’blue’)

this will turn the fourth element of the 5 the color blue

675
Q

What does :even and :odd mean in jquery and what do we need to keep in mind about it?

A

this allows us to choose the even or odd numbers of a child by selecting the class name and then adding :even or :odd after it in the jquery selector

then you can do something with it

$(‘.item:odd’).color(‘blue’)

this will take all the elements with the class of item and find the ones that have odd number as a position and then turn them blue.

we have to remember that eventhough we are choosing Odd - zero base indexing means that odds will be the second item (index 1) the fourth item (index 3) and so on. and evens will be the first item ( index 0) and the third item ( index 2)

676
Q

What does SASS stand for? And what is it?

A

Syntactically Awesome StyleSheets….

it is a language extension of CSS.

677
Q

What is SCSS?

A

It is s syntax of SASS, known as Sassy CSS. It is an extension of CSS.

files using this syntax have the .scss extension.

678
Q

How do you store variables in SASS?

A

you initialize it with a dollar sign followed by the variable name followed by colon and the css values.

examples

$main-fonts: Arial, sans-serif;
$headings-color: green;

679
Q

How do you use variables in SASS?

A

You would use it the same way as normal CSS except instead of manually typing the value, you just use the variable name instead

h1 {
font-family: $main-fonts;
color: $headings-color;
}

680
Q

What is a good example of why you would want to use variables in CSS/SASS?

A

Because if you have 10 elements that all needs the color red

you can set the color red as a variable and then apply it. That way if later you choose you want to change it to blue. You dont need to change 10 elements, you just change the variable and it will change everything.

681
Q

How can you nest css rule sets using SASS?

A

Normal CSS:
nav {
background-color: red;
}

nav ul {
list-style: none;
}

nav ul li {
display: inline-block;
}

Nesting with SASS:

nav {
background-color: red;

ul {
list-style: none;

    li {
      display: inline-block;
    }
  }
}
682
Q

What is a Mixin in SASS? And why do we use it?

A

A SASS Mixin is a way to set up CSS properties that might not work on particular browsers.

We basically create a funciton(the mixin) that applies the css function to specific types of browsers, then we place the mixin on the css rule set whereever we want it instead of having to rewrite the whole mixin anytime.

example of setting up a mixin

@mixin border-radius($radius){
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  -ms-border-radius: $radius;
  border-radius: $radius;
}

example of applying a mixin

  #awesome {
    width: 150px;
    height: 150px;
    background-color: green;
    @include border-radius(15px)

}

683
Q

Why would we need to use a SASS Mixin?

A

Newer CSS features take time before they are fully adopted and ready to use in all browsers. As features are added to browsers, CSS rules using them may need vendor prefixes.

For Example –

@mixin border-radius($radius){
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  -ms-border-radius: $radius;
  border-radius: $radius;
}
684
Q

How do you use @if and @else in SASS?

A

They work the same way as If and Else statements in Javascript, but they are used with mixins and variables

for example

@mixin text-effect($val) {
  @if $val == danger {
    color: red;
  }
  @else if $val == alert {
    color: yellow;
  }
  @else if $val == success {
    color: green;
  }
  @else {
    color: black;
  }
}
  #box {
    width: 150px;
    height: 150px;
    background-color: red;
    @include box-color(success);  <==== this is how it is called
  }
685
Q

What is @for used for in SASS?

A

It creates a version of a For loop but it has two types of loops :

a start to end loop
and a start through end loop

686
Q

What is the difference between a ‘start to end’ and a ‘start through end’ @for loop?

A

A ‘start to end’ loop is a loop that loops up until the end and does not include the last item.

A ‘start through end’ loop loops from start and includes the end/last item

687
Q

This is a @for loop in SASS, explain whats going on..

@for $j from 1 through 6 {
.text-#{$j} {font-size: 15px * $j }
}

A

{$j} – this places the variable value on the end of the element class so it will in total be

@for – this starts the loop syntax
$j – this makes a variable J that we are going to use
from 1 through 6 – this tells us the start and stop place of the loop

.text- – this is the start of the class of the element the styling will be applied to

.text-1 .text-2 .text-3 and so on until it reaches 6.

{font-size: 15px * $j } – this is the actual styling.

each element with the .text-# class will have the font-size increased by 15 * 1 and then 15 * 2 and then 15 * 3 etc.

688
Q

This is an example of using @each with a list…what is happening here?

@each $color in blue, black, red {
.#{$color}-bg {background: $color}
}

A

@each – is the beginning of the iterating syntax
$color – is the created variable that we will use

in blue, black, red – is the created list we will iterate through

.#{$color} – is the first part of the string that will match the element’s class, the its basically the same as back ticks variable in a string with an added # in SASS

-bg – this is the second part of the element’s class that will be matched.

{background: $color} – this takes the iterated value and places it on the value of background

this would iterate through the colors and apply them to the divs below and apply the background

<div></div>

<div></div>

<div></div>

689
Q

What is the @while loop in SASS? What does this code mean?

$x : 1;
@while $x <= 5 {
  .text-#{$x} { font-size: 15px * $x}
  $x: $x + 1;
}
A

{$x} – this is the second part of the elements class that will also be the value of x….

is works like a javascript while loop but it applies a styling while a condition is true

$x: 1; – this creates a variable and initiating it to the value of 1

@while $x <= 5 – this sets the stop point of loop

.text- – this is the beginning part of elements class

so together it will be .text-1 .text-2 .text-3 etc

{font-size: 15px * $x} – this is the styling being applied to the element. It increases 15px by each multiple of x …so 15px * 1 is 15
15px *2 = 30px …etc

$x: $x + 1 – this increments the value of x at end of the code and before it loops, this allows it to reach the place to stop the loop so it doesn’t become an infinite loop

690
Q

What is REACT?

A

Intro: React is an Open Source view library created and maintained by Facebook. It’s a great tool to render the User Interface (UI) of modern web applications.

691
Q

What is JSX?

A

Its a syntax that allows you to write HTML directly into Javascript

692
Q

When you want to write Javascript directly with JSX, where do we place the Javascript code?

A

within the curly brackets

{ ‘this is treated as JavaScript code’ }

693
Q

What do we need to remember about Nested JSX?

A

JSX can only return one main element..usually meaning we need to wrap everything in a single div

Valid JSX:

<div>
  <p>Paragraph One</p>
  <p>Paragraph Two</p>
  <p>Paragraph Three</p>
</div>

Invalid JSX:

<p>Paragraph One</p>

<p>Paragraph Two</p>

<p>Paragraph Three</p>

694
Q

How do you comment out in JSX?

A

The same way as normal but you have to also put it in curly brackets.

so

{/* */}

695
Q

How do we render react elements/components to the DOM?

A

ReactDOM offers a simple method to render React elements to the DOM which looks like this: ReactDOM.render(componentToRender, targetNode), where the first argument is the React element or component that you want to render, and the second argument is the DOM node that you want to render the component to.

ReactDOM.render(JSX, document.getElementById(‘challenge-node’))

JSX here is variable name that holds html elements for example

const JSX = (
  <div>
    <h1>Hello World</h1>
    <p>Lets render this to the DOM</p>
  </div>
);

and challenge-node is the id of some element

<div></div>

696
Q

Can we use the keyword class to define classes in JSX like you would in HTML?

A

No you have to use the word className

Also note that CamelCase is the spelling convention that we use in JSX as opposed to all lower case in HTML

697
Q

What is the difference in tags in HTML and JSX?

A

Any JSX tag can be self closing, even if it the HTML version of the tag cannot be. And any self closing tag must have a closing slash as well.

Valid JSX
div /div
or
div />

698
Q

What is a Stateless Function in React? How do you create it? What does it return?

A

think of a stateless function as one that can receive data and render it, but does not manage or track changes to that data

You create it with a normal Javascript function
that returns JSX or null

Valid Stateless Function:

const MyComponent = function() {
return <div> This is a string </div>
}

or

function MyComponent( ){
return <div> This is a string </div>
}
699
Q

What does a React Function name have to start with?

A

A capital letter

700
Q

How do you create a React Component and what is the difference between it and a React Function?

A

A React Component extends the React.Component so the component itself has access to many useful React Features.

A React Component has:

  1. class keyword
  2. extends React.Component after Name
  3. constructor(props)
  4. super(props)
  5. render( )
  6. return
701
Q

How do you render a Component inside another Component as a child?

A

To render a component as a child in a React component, you include the component name written as a custom HTML tag in the JSX. For example, in the render method you could write:

return (

)

this would be if you created three different components named NavBar, Dashboard and Footer

and placed them in the return section of a Component named App

702
Q

How do you pass props to Child Components in React?

A

By passing the a created prop name and value when you nest it within the Parent Component and then applying props.createdpropname within the child component itself

Parent--
class CurrentDate extends React.Component 
  render( ) {
    return (
      <div>
         <======
      </div>

CurrentDate - name of child component
date - created propname
Date( ) - value of created propname

Child –

const CurrentDate = (props) => {
  return (
    <div>
      <p>The current date is: {props.date} </p>
    </div>
  );

props – is the default name for passing props in child components

.date == references the value that was applied in the Parent Component

result:

The current date is: Thu Aug 20 2020 09:05:17 GMT-0700 (Pacific Daylight Time)

703
Q

How do we pass an Array as props into a Child Component?

A

you do it the same way as normal props passing except you wrap the array in curly brackets

Then inside of the Child Component you can apply array methods to it

const List = (props) => {
  return <p>{props.tasks.join()}</p>
};
704
Q

What are Default Props in React and how do you apply them?

A

Default props are props that will show up in the event that a prop is not specified. This is a prop that will be shown if one isnt provided.

you apply it with the syntax of

ComponentName.defaultProps = {createdPropName : ‘prop value’ }

ShoppingCart.defaultProps = {items: ‘items: 0’}

705
Q

How do you override Default Props when you want to set a value in React?

A

you set it the normal way that you would if there wasnt a Default Prop set. Setting it in the normal will override the default props.

This is the CHILD COMPONENT ———

const Items = (props) => {
  return <h1>Current Quantity of Items in Cart: {props.quantity}</h1>
}

This is setting the DEFAULT PROPS ———–

Items.defaultProps = {
quantity: 0
}

This is the PARENT COMPONENT OVERRIDING ————–

class ShoppingCart extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return  <== override
  }
};
706
Q

When putting an Integer in JSX do we need to use qoutes?

A

No we dont need the quotes but we do need to put it in curly brackets

{100}

707
Q

What is PropTypes in React and how is it set up?

A

PropTypes allows you to verify that your Component receives the correct type of of prop (number, string, boolean, etc).

You set it the same way that you set Default Props:

ComponentName.propTypes = { createdPropName: PropTypes.type

MyComponent.propTypes = { handleClick: PropTypes.string }

if wrong type it will cause an error

708
Q

When Using PropTypes what two types of data types have different spellings?

A
Function = func
Boolean = bool
709
Q

What is .isRequired when using PropTypes and what does it do?

A

.isRequired makes it so that the prop is neccesary for the component to run

Items.propTypes = {quantity: PropTypes.number.isRequired}

710
Q

In the later installements of React, Protypes is imported independently of React….how do you import it?

A

import PropTypes from ‘prop-types’;

711
Q

How do we pass a prop from a class component to a child component that also happens to be another class component?

A

We do it the same we would if we were passing a prop to a stateless function, the only difference is when we access it from within the function we have to use the keyword this.

so for a component class it would be accessed like

this.props.createdname

as opposed to a stateless function that would access its prop like

props.createdname

712
Q

When applying Default Props and PropTypes to a component — on the left side of the assignment operator how do we write it? And on the right side of the assignment operator?

A

On the left side we write it in camel case

MyComponent.defaultProps =
MyComponent.propTypes =

On the right side we write it Component style with each word being Capitalized

= {name: PropTypes.func.isRequired}

713
Q

How do you create State in a React Component?

A

you need to have a class component that extends React.Component and apply state inside of the components constructor method as an object:

class StatefulComponent extends React.Component {
  constructor(props) {
    super(props);
      this.state = {
        name: 'dat boi good'
      }
714
Q

How do you render State in the User Interface?

A

Once you define a component’s initial state, you can display any part of it in the UI that is rendered. If a component is stateful, it will always have access to the data in state in its render() method. You can access the data with this.state.

If you want to access a state value within the return of the render method, you have to enclose the value in curly braces.

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'freeCodeCamp'
    }
  }
  render() {
    return (
      <div>
           <h1>{this.state.name}</h1>
      </div>
    );
715
Q

How can we render State by variable name?

A

store state in a variable name in the render section and then produce it after the return statement

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'freeCodeCamp'
    }
  }
  render() {
    const name = this.state.name
    return (
      <div>
          <h1>{name}</h1>
      </div>
    );
  }
716
Q

what method do we call to change the State of a React Component? and how and where do we call it?

A

we call setState( )

inside of a function before the render( ) method.

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'Initial State'
    };
    this.handleClick = this.handleClick.bind(this);
  }
  handleClick() {     <== this is the function changing state
      this.setState({
        name: 'React Rocks!'
      })
  }
  render() {
717
Q

How do you bind a function name to the ‘this’ keyword inside of a React Component?

A

place

this.FunctionName = this.FunctionName.bind(this)

inside of the constructor method

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      text: "Hello"
    };
  this.handleClick = this.handleClick.bind(this)
  }
  handleClick() {
    this.setState({
      text: "You clicked!"
    });
718
Q

How do you apply the function that changes State to an element that you want changed? Lets say for example a button?

A

You place the event listener as an attribute and make the value of that attribute as follows

{this.functionName}

 handleClick() {
    this.setState({
      text: "You clicked!"
    });
  }
  render() {
    return (
      <div>
        Click  <== EXAMPLE Me
        <h1>{this.state.text}</h1>
      </div>
    );
719
Q

how do you change the state of a component? Which method do you use?

A

You create a function and use this.setState( ) in it.

inside of the set state method you pass a function

720
Q

What parameters can you use inside of the setState( ) function?

A

You can use any parameters that you want but one for state and props are especially useful

721
Q

Do we need to use the ‘this’ keyword inside of our setState( ) function

A

No you do not.

 toggleVisibility(){
   return this.setState(state => {
  return  state.visibility = !state.visibility
   })
 }
722
Q

When we actually change the state of a Component inside of setState, how do we do so?

A

you access the state object with dot notation

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visibility: false
    };
    // change code below this line
this.toggleVisibility = this.toggleVisibility.bind(this)
    // change code above this line
  }
  // change code below this line
 toggleVisibility(){
   return this.setState(state => {
  return  state.visibility = !state.visibility
   })
 }
723
Q

What does event.target.value do?

A

it returns the value of the element that was targeted that triggered the event in the function and makes it accessible

 handleChange(event){
      this.setState({
       input: event.target.value
      })
  }
724
Q

How would we make an input be updated from a components state instead of from the browser?

A

Take the state and make it the value of the value attribute and put it on the input element in addition to the function that changes state

{}

value = {this.state.input} <==== example

this would come from this state which begins as an empty string

class ControlledInput extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: ''
    };
725
Q

Can you pass the ‘STATE’ of one component as a prop to one of its child components?

A

Yes you can.

class MyApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'CamperBot'   <=== this is state
    }
  }
  render() {
    return (
       <div>
   </div>
);   } };
class Navbar extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
    <div>
      <h1>Hello, my name is: {this.props.name} </h1>  <== accessing state data passed  as prop from parent
    </div>
    );
  }
};
726
Q

What is unidirectional data flow in React?

A

State flows in one direction down the tree of your application’s components, from the stateful parent component to child components. The child components only receive the state data they need

727
Q

What is Separation of State Management and UI in React?

A

This states that complex stateful apps can be broken down into just a few, or maybe a single, stateful component. The rest of your components simply receive state from the parent as props, and render a UI from that state. It begins to create a separation where state management is handled in one part of code and UI rendering in another. This principle of separating state logic from UI logic is one of React’s key principles. When it’s used correctly, it makes the design of complex, stateful applications much easier to manage.

728
Q

Can you pass functions down from a Parent component to a child component the same way you can pass a prop or a state in react?

A

yes you can.

class MyApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      inputValue: ''   <=== state
    }
    this.handleChange = this.handleChange.bind(this);
  }
  handleChange(event) { <=== function that changes state
    this.setState({
      inputValue: event.target.value  
    });
  }
  render() {
    return (
       <div>
        { /* change code below this line */ }
             <== passing function as prop
        { /* change code above this line */ }
       </div>
    );
  }
};
class GetInput extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h3>Get Input:</h3>
          <== applying function of parent in the child after being passed as a prop
      </div>
    );
  }
};
729
Q

What is a lifecycle method in react?

A

They are methods that allow you to perform particular functions at particular times in a components life, for example when it first runs, before they are rendered, before they update, before they receive props, before they unmount, and so on.

730
Q

What is componentWillMount( )?

A

the code inside of it will run before the render method in a react component does

731
Q

What is the best place to place to an API call or any other call that goes to the server inside of a React Component?

A

you place it inside of the componentDidMount( )

732
Q

What is componentDidMount( )? And what happens when you put setState inside of it?

A

This method is called after a component is mounted to the DOM. Any calls to setState() here will trigger a re-rendering of your component. When you call an API in this method, and set your state with the data that the API returns, it will automatically trigger an update once you receive the data.

733
Q

what does setTimeout( ) do?

A

sets a timer which executes a function or specified piece of code once the timer expires.

componentDidMount() {
    setTimeout( () => {
      this.setState({
        activeUsers: 1273
      });
}, 2500)
this sets up a change of state that will take place after 2500 milliseconds which is 2.5 seconds.
734
Q

What is the best place to add event listeners to your React Components? How do you do so?

A

Inside of componentDidMount( )

eventTarget.addEventListener(triggering event, function of what you want to happen);

button.addEventListener(‘click’, this.handleClick)

this would make it so a button gets clicked the function handleclick will run

735
Q

There are some already built in eventListeners in react like onClick or onChange that you can use as props for elements. Why then would you need to use eventTarget.addEventListener( ) ?

A

You would use this when you wanted to add event listeners to the document object or the window object.

736
Q

What is the opposite of componentDidMount( ) and eventTarget.addEventListener( )?

A

componentWillUnmount( )

eventTarget.removeEventListener( )

they work exactly like their counterparts but remove instead of add

737
Q

What does shouldComponentUpdate( ) do?

A

it returns a boolean and see if a prop has a new value, if it has a new value you can set it up so it returns true. If it returns true the code will keep running and will re-render. But if it turns false, it wont re-render.

this keeps from unnecessary renderings when props or the state hasnt changed. This improves app performance.

   shouldComponentUpdate(nextProps, nextState) {
    console.log('Should I update?');
      if (nextProps.value % 2 == 0){
        return true;
      } else {
        false;
      }
  }

{these functions will only run if shouldUpdate returns a true}

  componentDidUpdate() {
    console.log('Component re-rendered.');
  }
  render() {
    return <h1>{this.props.value}</h1>
  }
};
738
Q

How can you use inline styling in React as opposed to HTML? What two things do we need to remember about how to write it?

A

you need to make it an object and make it JSX

so it will look like it is in double objects

and any key or property names that usually comes with a - in html will be written in camelCase in JSX

class Colorful extends React.Component {
  render() {
    return (
      <div style="">Big Red</div>  <=== example
    );
  }
739
Q

If we have a lot of styling rules that we want to add in inline styling in react, how do we do so without writing them out individually?

A

store it in a keyword and apply it inline instead of writing.

const styles = {
  color: 'purple',
  fontSize: 40,
  border: '2px solid purple'
}

<div>Style Me!</div>

<==  applied stylings
740
Q

where and how can you write regular javascript within a React component?

A

You can also write JavaScript directly in your render methods, before the return statement, without inserting it inside of curly braces. This is because it is not yet within the JSX code. When you want to use a variable later in the JSX code inside the return statement, you place the variable name inside curly braces.

741
Q

How can you create an if/else statement inside of a render statement in a react component?

A
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      display: true
    }
    this.toggleDisplay = this.toggleDisplay.bind(this);
  }
  toggleDisplay() {
    this.setState((state) => ({
      display: !state.display
    }));
  }
  render() {
    // change code below this line
      if(this.state.display == true){
    return (
       <div>
         Toggle Display
         <h1>Displayed!</h1>
       </div>
    );}
    else{
      return (
         <div>
         Toggle Display
       </div>
  )
}   } };
742
Q

How can we use the && conditional and how can we use it to make our if/else statements more concise? Can we chain them?

A

Usually && means AND.

but really what it means is if the first condition is true, return the second part of the code.

so you can use it to say, if this is true…return this… and if its not true then the whole thing returns false.

{this.state.display == true && <h1>Displayed!</h1>}

we can also chain these together to add multiple conditions

if this…and that… and that….and that….and that…and that…and that is true return this…..example psuedocode

743
Q

When we need to use an IF/ELSE statement inside of the return statement of a react component, what should we use?

A

We should use a ternary operator or && logic

we can chain these together.

 this.state.userAge === ''
            ? buttonOne
            : this.state.userAge >= 18
              ? buttonTwo
              : buttonThree
        }
744
Q

Can you use ternary conditionals to run different code based on the value of a prop that has been passed down to a Child Component in react?

A

yes you can you can do something like

 return (
      <h1>
      {
        this.props.fiftyFifty ? 'You Win!': 'You lose!'
      }
      </h1> 

this would say if props = true return you win if it is false return you lose to the DOM

you can set up code that will either make the prop 50/50 either true or false before it passes it to the child component and then the component will render a particular type of code depending.

745
Q

How can you set up a random expression that will return true or false with a 50/50 chance of being either?

A

Math.random( ) >= .5 ? true : false

you can store this in a variable name and half the time it will randomly choose true or false. And then from here you can apply the variable name to anything you want along with the true/false variable.

746
Q

How can we set up css rules to applied based on Component State?

A

set up two style objects with different variable names

then set up some logic that will choose which one to apply based off state. This particular state will apply one style if the length is less than 15

regStyle = {
border: 3px solid black
}

dangerStyle = {
border: 3px solid red
}

style= {this.state.input.length > 16 ? dangerStyle : regStyle} ;

747
Q

How can we use .map( ) to render elements within a state Array?

A

You can initialize a value as being an empty array in the state object -
as we update our state we can add these updates to the array….

then in our render( ) we can map through the array and send them to the DOM (or do anything else we want to do with them)

let items = this.state.arraylist.map(item=> <li> {item} </li>)

then in the return statement we can return it to the DOM

return <ul> {items} </ul>

748
Q

When we have react siblings that are the of the same element or items of an array what attribute do we need to make sure that we have on the element tag?

A

We need to make sure that we have a key attribute.

its a best practice to use a unique name key attribute, but an index can also be used as well.

the keys need to be unique in comparison to the other items in the array or other siblings - it doesnt need to be unique globally through the program.

const renderFrameworks = frontEndFrameworks.map(item => {
    return <li>{item}</li>

this goes through an array and adds a li tag to each item and then it adds a key item with the same name as the text inside the list item. BUt every item will have different text that will also match its own key but will not match any other items on the list

749
Q

When trying to use an array method like map( ) or filter( ) to render array items to the DOM, if the code breaks and doesnt work the way it should what should i check?

A

Make sure that the items are not an object. Sometimes when mapping through an array of objects we forget to go to the deeper level of dot notation to access the information that we want.

 const usersOnline = this.state.users.filter(item => iitem.online == true); // 
    const renderOnline = usersOnline.map((item) => <li>{item.username}</li>); 

here the items are objects so simply trying to use <li>{item}</li> wont work. You need to use username to go deeper into the object and access the proper data to the DOM

750
Q

What does the renderToString( ) react method do? and how do we use it?

A

This is a way to render your react app on a server as opposed to on the client side.

ReactDOMServer.renderToString()

751
Q

What are two real world examples of why you would want to render your react app on the server as opposed to the client?

A

There are two key reasons why rendering on the server may be used in a real world app. First, without doing this, your React apps would consist of a relatively empty HTML file and a large bundle of JavaScript when it’s initially loaded to the browser. This may not be ideal for search engines that are trying to index the content of your pages so people can find you. If you render the initial HTML markup on the server and send this to the client, the initial page load contains all of the page’s markup which can be crawled by search engines.

Second, this creates a faster initial page load experience because the rendered HTML is smaller than the JavaScript code of the entire app. React will still be able to recognize your app and manage it after the initial load.

752
Q

When you make a container a grid and it has other elements in it, how are the items displayed or laid out?

A

They are laid out as block elements, and those elements split the space of the container evenly in a row form.

so 5 divs will look like this

1

2

3

4

5

if There was only 3 in the same container it would look like this

1

753
Q

What two things do we need to remember about passing a function to a child component in react?

A

the name of the function needs to be the key and the value when passing it with the child component name

and then we need to use props in the child component

button onClick={this.props.handleClick}

754
Q

When you use max-width: 100% on a responsive image inside of a div what is the difference between normal width: 100%?

A

the image will be responsive shrinking but will not grow past the size of the conatainer div original size. When you set it to regular width it will gorw and expand with the size of the div no matter how big or small

755
Q

how do we write a positive/negative look behind?

A

positive lookbehind ? < =

negative lookbehind ? < !

no spaces between

756
Q

What is a good mental model for look aheads and look behinds?

A

these look to make sure that not only the pattern in your regex is there but also that the look ahead and look behind pattern is there too.

the regex code = abc might be there….

but you want to search for abc thats followed by @gmail.com

so you will use a lookahead to only find the abc followed by gmail

and return just the abc not the gmail.

this can be used if you wanted to find all the usernames of a gmail email list

abc@gmail.com
222@gmail.com
333@yahoo.com
676@hotmai.com
abc@yahoo.com

if you search and match abc in normal regex youll get

abc@gmail.com
abc@yahoo.com

but we only want the ones from gmail

so if we use a look ahead for @gmail.com and abc as our regex

it will match abc@gmail

but only return the ‘abc’ part…which is the username

757
Q

What is Redux?

A

Redux is a state management framework that can be used with a number of different web technologies, including React.

758
Q

What is the Redux Store?

A

In Redux, there is a single state object that’s responsible for the entire state of your application.
the Redux store is the single source of truth when it comes to application state.

759
Q

Anytime you’re using Redux and you want to update any part of your App, where must you do it from?

A

This also means that any time any piece of your app wants to update state, it must do so through the Redux store. The unidirectional data flow makes it easier to track state management in your app.

760
Q

What data type is the Redux Store? What does it manage?

A

The Redux store is an object which holds and manages application state.

761
Q

How do we create the Redux Store?

A

with the createStore( ) on the Redux Object.

762
Q

What Argument is required by the the createStore( ) method?

A

a Reducer Function

let store = Redux.createStore(reducer)

now we can use store to access different methods

763
Q

How can we retrieve the current state of an app held in the Redux Store Object?

A

store.getState( )

764
Q

What is a Javascript Action Object? What info can it have? What info must it have?

A

An action is simply a JavaScript object that contains information about an action event that has occurred.

Sometimes a Redux action also carries some data. For example, the action carries a username after a user logs in. While the data is optional, actions must carry a type property that specifies the ‘type’ of action that occurred.

let action = {
  type : 'LOGIN'
}
765
Q

In Redux all state updates are triggered by what?

A

In Redux, all state updates are triggered by dispatching actions.

Think of Redux actions as messengers that deliver information about events happening in your app to the Redux store. The store then conducts the business of updating state based on the action that occurred.

766
Q

How do you send an action to the Redux Store so it can update its state?

A

by using an Action Creator.

An action creator is simply a JavaScript function that returns an action. In other words, action creators create objects that represent action events.

(action)

const action = {
  type: 'LOGIN'
}

(action creator)

function actionCreater(){
  return action
}
767
Q

What is a Dispatch method?

A

It’s what we use to dispatch actions to the Redux Store.

Calling store.dispatch() and passing the value returned from an action creator sends an action back to the store.

const store = Redux.createStore(
  (state = {login: false}) => state
);
const loginAction = () => {
  return {
    type: 'LOGIN'
  }
};

store.dispatch(loginAction())

store dispatch takes the function loginAction and dispatches back to the Redux Store

768
Q

After an Action has been created and dispatched to the Redux Store, what does the Redux Store need to know and how do we tell it what to do?

A

It needs to know how to respond to that Action

and we tell it what to do with the Action by using a Reducer function

Reducers in Redux are responsible for the state modifications that take place in response to actions

769
Q

A Reducer Function takes what two arguments and what does it always return?

A

it takes State and Action as arguments.

it always returns a new State

770
Q

Does a Reducer Function have any other responsibilities other than returning a new State?

A

No, it does nothing other than this.

771
Q

Should a Reducer Function return a copy of State or change State directly?

A

A Reducer Function should never change State directly. It should return copy of State.

772
Q

How can you handle Multiple Actions at once?

A

With a switch statement. Every Action is an object that has to take a Type property.

in the switch statement you pass action.type – this will be checked against every switch entry. In the Case you match the value of the possible types in the block of that case you put an object with the desired value

for example

one actionCreator will pass the action object

with type: login

another action creator will pass an action object

with type: logout

another action creator will pass an action object

with type: delete

another action creator will pass an action object

with type: post etc

then in the switch you would have (action.type)

case logout: 
 	{authentication : false }
case login: 
	{authentication : true }
case delete:
	{post : false }
case post:
	{post : true }

this will all be in one switch statement hooked up to many different actionCreators so when one is fired, it will find the correct type… and then change and update the State.

Actions that have different types but actually affect the same State.

So both LogIn and LogOUT will update the State of Authentication

And action.type delete and post will update the State of post

773
Q

What do all Redux Switch Statements that update State need? And Why?

A

A default case that returns the current state. Because once your app has multiple reducers they are all run anytime an action dispatch is made even when the action isn’t related to that reducer. In such a case you want to make sure that you return the current State.

774
Q

How should we assign Action Types in Redux?

A

As const variables. Usually the way to do this is
const variable names and then save a string with the same name to it.

for example

const LOGIN = 'LOGIN'
const LOGOUT = 'LOGOUT'

then when you use them in your switch statements and actionCreators and other places you should use the const variable name instead of the string themselves.

775
Q

What is a Store Listener? How do you assign it?

A

A Store Listener is a function that runs whenever an action is dispatched against the store. One simple use of this is to log a message every time an action is received and the store is updated.

You do this by using store.subscribe( )

for example say you want to count how many times an action was sent to the store and updated State.

then you can write a Store Listener to do this.

let count = 0;

const update = () => {
  return count++
}

then you can pass the function in store.subscribe()

like this

store.subscribe(update)

776
Q

What is the first principle of Redux?

A

all app state is held in a single state object in the store.

777
Q

When the state of your app begins to grow more complex, its unreasonable to expect to have one switch statement to handle all the states from all the different actions. How do we handle this while keeping the first principal of Redux intact?

A

You define multiple reducers to handle different pieces of your application’s state, then compose these reducers together into one root reducer. The root reducer is then passed into the Redux createStore() method.

We combine multiple reducers using combineReducers( )

778
Q

How does the method combineReducers( ) work?

A

This method accepts an object as an argument in which you define properties which associate keys to specific reducer functions. The name you give to the keys will be used by Redux as the name for the associated piece of state.

const rootReducer = Redux.combineReducers({
auth: authenticationReducer,
notes: notesReducer
});

each of these values would be a reducer functions with switch statements in them handeling the possibilies of state. saved intoan object and then passed into createStore( )

const store = Redux.createStore(rootReducer);

now this store will have access to all the different possibilities of State.

779
Q

What do Actions usually generate from ? And tend to carry what with them?

A

From user interaction and carry some data with them

Redux often needs to know about this data.

780
Q

If you want to pass in some Data other than type along with Action Dispatch how do you do so?

A

Add a parameter for an argument to be passed in the action creator.

place a key/value pair with the parameter as the value

const addNoteText = (note) => {
   return  {
     type: ADD_NOTE,
     text: note
     }
};

in the reducer’s switch statement, when the case action type is matched return the value of the key value pair with dot notation

const notesReducer = (state = 'Initial State', action) => {
  switch(action.type) {
      case ADD_NOTE :
      return  action.text
      default:
      return state;
  }
};

then dispatch the reducer to the store with the parameter filled

store.dispatch(addNoteText(‘Hello!’));

781
Q

What does Asynchronous Functions/Programming mean?

A

this basically means when your code stops running because its waiting to retrieve data before it can continue. like an API call, this is asynchronous —- dealing with how to handle this so it isn’t inconvenience to the user is asynchronous programming.

782
Q

What is the name of the MiddleWare that Redux provides to handle its asynchronous actions?

A

Redux Thunk MiddleWare

783
Q

How do you include Redux Thunk MiddleWare in your App?

A

You pass it as an Argument
to Redux.applyMiddleware( )

Redux.applyMiddleware(ReduxThunk.default)

784
Q

Where do we place the

Redux.applyMiddleware(ReduxThunk.default) statement?

A

As the second parameter to createStore( )

const store = Redux.createStore(
asyncDataReducer,
Redux.applyMiddleware(ReduxThunk.default)
);

785
Q

How do you create an Asynchronous Action?

A

to create an asynchronous action, you return a function in the action creator that takes dispatch as an argument. Within this function, you can dispatch actions and perform asynchronous requests.

const handleAsync = () => {
  return function(dispatch) {
    dispatch(requestingData());
    setTimeout(function() {
      let data = {
        users: ['Jeff', 'William', 'Alice']
      }
      dispatch(receivedData(data));
    }, 2500);
  }
};
786
Q

What should we do inside of the Asynchronous Dispatch Function before initiating any Asynchronous behavior and why?

A

It’s common to dispatch an action before initiating any asynchronous behavior so that your application state knows that some data is being requested (this state could display a loading icon, for instance)

const handleAsync = () => {
  return function(dispatch) {
    dispatch(requestingData());
    setTimeout(function() {
      let data = {
        users: ['Jeff', 'William', 'Alice']
      }

set time out is a mock API call

the dispatch function is the action telling that its requesting data

787
Q

Inside of your Dispatch Function after you have received the data made by the Data Request Action (API call) what do we do?

A

We Dispatch another Action which carries the data
as a Payload along with information that the action is completed.

const handleAsync = () => {
  return function(dispatch) {
    dispatch(requestingData());
    setTimeout(function() {
      let data = {
        users: ['Jeff', 'William', 'Alice']
      }
      dispatch(receivedData(data));
    }, 2500);
  }
};

set time out is a mock API call

dipatch(rec) is an action with data being passed as the received information.

788
Q

After you pass Dispatch as an Argument in a function handling Asynchronous behavior in Redux, how do you apply it to the actions to dispatch it?

A

you call it like a function

dispatch(requestingData());
dispatch(receivedData(data));

789
Q

What is an example of a Redux App used to make a counter of State?

A
const INCREMENT = 'INCREMENT'; 
const DECREMENT = 'DECREMENT'; 
const counterReducer = (state = 0, action) => {
  switch (action.type){
    case INCREMENT :
    return state + 1
    case DECREMENT :
    return state - 1
    default: 
    return state
  }
};
const incAction = () => {
  return {
    type: INCREMENT,
  }
};
const decAction = () => {
  return {
    type: DECREMENT
  }
}; 

const store = Redux.createStore(counterReducer);

790
Q

We never want to mutate a state directly in Redux we want to make a copy of it and then mutate it. How can we do this and what is an example of it?

A

We can do this with regular javascript inside of a reducer function by copying the state before the Switch Statement.

const todos = [
  'Go to the store',
  'Clean the house',
  'Cook dinner',
  'Learn to code',
];

const immutableReducer = (state = todos, action) => {

let newlist = […todos];

notice that newlist is copied to the global variable of state and not to the state parameter. this is done before the switch statement.

After the Switch Statement we modify the copy

switch(action.type) {
case ADD_TO_DO:
newlist.push(action.todo)
return newlist

todo represents the data updating the todo array which is being returned as the new state

791
Q

When passing extra data along with an action besides Type (like a message or something) does that extra information need to be in object form although the Action creator is returning an object?

A

No the variable name can represent any form of data

// an example todo argument would be 'Learn React',
const addToDo = (todo) => {
  return {
    type: ADD_TO_DO,
    todo
  }
}

Here todo represents a string ‘learn react’. It isnt in the usual data structure of an object. But it can be later accessed in the Reducer function as if it were

switch(action.type) {
    case ADD_TO_DO:
    newlist.push(action.todo)
      return newlist
    default:
      return state;
  }
};

notice the action.todo being pushed to the newlist variable

this will push the string being represented in the action object into the array

792
Q

How can we remove an item from a State array inside of a Reducer function if provided the index, without affecting or mutating State?

A
const immutableReducer = (state = [0,1,2,3,4,5], action) => {
  switch(action.type) {
    case 'REMOVE_ITEM':
      let a = state.slice(0, action.index);
      let b = state.slice(action.index + 1);
      return a.concat(b)
    default:
      return state;
  }
};
const removeItem = (index) => {
  // console.log(index)
  return {
    type: 'REMOVE_ITEM',
    index
  }
}
removeItem(5)
const store = Redux.createStore(immutableReducer);
793
Q

What does Object.assign( ) do?

A

It copies and merges objects

794
Q

How can we use Object.assign( ) to copy an object?

A

let newObject = Object.assign( { }, obj 1)

This will copy all the properties and values in obj1 into the empty array

795
Q

Can you copy more than one object into an empty object by using Object.assign( )? How?

A

Just add more objects as arguments

let newObject = Object.assign( { }, obj1, obj2, obj3)

this will add all of the properties of the three objects into the empty object.

796
Q

What happens if you use Object.assign( ) to copy or merge objects and some of the objects have the same properties?

A

Matching properties are overwritten by the latest object that is added.

This is a way that you can update Objects in Redux when the object represents state.

797
Q

Although React Components can manage their own state locally, with a complex app it is generally better to keep the state where?

A

In a single location with Redux

798
Q

What is a React-Redux package? Why is it needed?

A

Redux isn’t designed to work with React outside of the box so you need to use this package that allows you pass State and Dispatch to React Components as Props

799
Q

How do we make text entered by a User to update State in React? the three things you need are…

A
  1. place in state to be updated
  2. an element for a user to text in
  3. element set with value={this.state.input}
  4. set state in function set to {input = {event.target.value} with an event parameter passed in
800
Q

Besides the Constructor method inside of class Component, where else can you bind a Function that changes State to the keyword ‘This’?

A

You can bind it directly on the element that you are using to change state

input ={this.handleChange.bind(this)}

801
Q

How can you empty an input box or any text of some sort When changing state?

A

apply an empty string to the element as its value.
this is a better way when dealing with State instead of using $(‘input’).val(‘ ‘).

this.setState({
input: ‘’
})

using better

802
Q

When adding items to an array in State, how should we do it besides using the push method?

A

we should use the spread operator to concatenate them into a new array.

messages : […this.state.messages, this.state.input]

803
Q

What is the Provider tag and how is it used and what is it used for?

A

The Provider is a wrapper component from React Redux that wraps your React app. This wrapper then allows you to access the Redux store and dispatch functions throughout your component tree.

 class AppWrapper extends React.Component {
    render() {
      return (
  );
}
804
Q

What two things do you need to make sure you provide with the Provider tags?

A

You need to add Store as a prop

and you need to place the React Component you want to connect with Redux inside the wrapper Provider tags.

805
Q

How do we create the Provider tag?

A

const Provider = ReactRedux.Provider;

then you can use it as a tag

806
Q

What does mapStateToProps( ) do? What is the purpose ? How do we construct it?

A

You use this to create a function that specifies to you React Component which State it has access to.

let mapStateToProps = (state) => {
  return { messages: state}
}
807
Q

What parameter does mapStateToProps( ) take?

A

state.

808
Q

What is mapDispatchToProps( )? What does it do?

A

The mapDispatchToProps() function is used to provide specific action creators to your React components so they can dispatch actions against the Redux store.

809
Q

How do we construct mapDispatchToProps( )? What are the 6 steps?

A
  1. mapDispatchToProps( ) takes dipatch as param
  2. returns an object with one property
  3. property value is a function with param
  4. function calls dispatch
  5. in param of dispatch it takes action creator and its param
  6. param of action creator matches property function param
const mapDispatchToProps = (dispatch) => {
    return {
        submitNewMessage: (message)=>{
            dispatch(addMessage(message))
        }
    }
}
810
Q

After you have written mapStateToProps( ) and the mapDispatchToPage( ) what then can you do?

A

You can use them to map State and dispatch to the props of one of your React Components

811
Q

How do you create the Connect method and what does it do?

A

const connect = ReactRedux.connect

connects React to Redux

812
Q

How many arguments does the Connect method take? Are they required?

A

This method takes two optional arguments, mapStateToProps() and mapDispatchToProps().
They are optional because you may have a component that only needs access to state but doesn’t need to dispatch any actions, or vice versa.

813
Q

What is the syntax of calling Connect?

A

To use this method, pass in the functions as arguments, and immediately call the result with your component. This syntax is a little unusual and looks like:

connect(mapStateToProps, mapDispatchToProps)(MyComponent)

814
Q

If you want to omit one of the parameters in Connect, how do you do so?

A

You replace the omitted function with ‘null’

815
Q

What is a Presentational Function?

A

. This term generally refers to React components that are not directly connected to Redux. They are simply responsible for the presentation of UI and do this as a function of the props they receive

816
Q

What is a Container Function?

How do you contruct it?

A

By contrast, container components are connected to Redux. These are typically responsible for dispatching actions to the store and often pass store state to child components as props.

const Container = connect(mapStateToProps , mapDispatchToProps)(Presentational)

817
Q

Once Redux is connected to you React Component, what do you need to do next?

A

Extract the state management out of the Presentational component and into Redux.

818
Q

What are the three things that need to be done to Extract Local State into Redux?

A
  1. remove local state to be placed in Redux
  2. replace function that changes state locally and apply Redux Function that changes state through props
    ex. this.props.submitNewMessage(this.state.input)
  3. Produce state in the render method through Props instead of local State

{this.props.messages.map( (message, idx) => {
return (
<li>{message}</li>

819
Q

If we use Redux to manage State, do we need to use state locally in a React Component at all?

A

Yes we still need it, not all things that we put into state will need to be handled by Redux. For example a React Component might have an local state that tracks the input in a text box.

Then that text is to be sent somewhere and done something with, like added to a list or something.

The input of the text might stay local and be handled local… but the adding of the text to a list will be done with Redux.

820
Q

how to play audio file on button click?

A

set audio file up so it works
set button up
add id on audio element
save audio into variable by using getElementById
create onClick function for button
in the function declare variablename.play( )

821
Q

how do we deal with the chain affect of divs when styling

an app that is rendered by a react component?

A

html, body, app(component id), addDiv (id of the manditory div used in react){
height: 100%
}

822
Q

onKeyPress and other Keyboard events in React, dont
work the same way that onClick does. How do we get
‘Key Events’ to work in a React Component then?

A

We use add EventListener like this :

componentWillMount(){
document.addEventListener(“keydown”, this.handlekeypress.bind(this));
}

then create a function like :

handlekeypress(){
console.log(‘working’)
}

then pass it down to the element/child component

return <div>

      </div>   }

then…if you pass it to a child compoenent,
us props to apply it to the element.

onKeyDown={this.props.handlekeypress}

823
Q

What does key.code do?

A

key is just an arbitrary parameter name that
is passed in a function, but adding .code on it
during a keyboard event like ‘keypress’ or ‘keydown’
gives the code for the key that is pressed on the
keyboard by the user.

824
Q

How do we add an event listener?

A

document.addEventListener(firing event, function to happen)

825
Q

Does a React Child Component need to have a
constructor or super if its purpose is just to
show the design and visual component of the code?

A

No, you just need the render and return statements.

along with extends React.Component

826
Q

How do i use event.target to get the id of an

element in React?

A

let check = event.target.id

827
Q
How do i use event.target to get the class of 
an element in React?
A

let check = event.target.className

828
Q

How do i use event.target to get the inner

content of an element in React?

A

by using jquery

let check = $(event.target).text();

829
Q

How do we disable a function or a prop on an element?

A

by using Jquery and the disable method.

to disable $(element/.class/#id).prop(‘disabled’, true/false)
this will disable or enable it.

** MAKE SURE YOU WRITE ‘DISABLED’ with a D and not ‘Disable’.
It wont work otherwise

830
Q

if you want to turn a string data type into a number data type, how do you do so?

A

save number into variable and place it inside Number()

then save that inside a variable

check = “32”
Number(check)

let result = Number(check)

result = 32

831
Q
When you use a constructor inside of a class what must you also have 
when creating a state?
A

The super( ) method.

832
Q

When making a state with constructor what keyword do you need when setting
the object?

A

this.state = { }

833
Q
When making state without a constructor inside of a class function what 
dont you need?
A

The keyword this.

state = { }

834
Q

How do use Regex to validate US telephone numbers in all their forms including optional country code and mandatory area code?

A

let regex = /^(1\s?)?((\d{3})|\d{3})[\s-]?\d{3}[\s-]?\d{4}$/

835
Q

How do you access object values and keys in a For/In loop?

A

You have to use Bracket Notation to access value because youre
creating a new variable name and variable names have to be accessed with Bracket Notation.

836
Q

How do we change floats into integers?

A

save floats to variable, then save Math.floor(variable)
to another variable, it will be saved as integers.

example  let divide = leftover / currency[coinAmount]
   let results =  Math.floor(divide)
   console.log(results)
837
Q

How do we set up the ready function in Jquery?

A

$(document).ready(function(){

add code you want ran when you first load page here
or name of function (more than likely this one)

})

838
Q

How do you call another jquery function inside another jquery function?

A

just call the name of the function like normal

function OtherJqueryFunction(){

createdfunctionName()
}

839
Q

How do you change the color of an elements text in jquery?

A

.css(‘color’, ‘red’)

840
Q

How do you add a function on an elements click in jquery?

A

.on(‘click’, function(){

type code here

}

841
Q

How should you write your functions in jquery as far as handling funtionality?

A

every function should handle a specific function of the app. Seperation of concerns

842
Q

What is the syntax for Fetching an API call?

A

fetch(“url”).then(response => response.json()).then(data => console.log(data))

this logs it to the console and then you should add a function afterwards to do something with it, using data as a parameter.

843
Q

what is animation delay ?

A

sets how long before an animation runs so it doesnt run right away

844
Q

what does setInterval do?

A

it runs a function over an over again after a certain amount of time which is set by user

845
Q

how do you stop the setInterval method?

A

with a clearInterval method

846
Q

How to make text center horizontally and vertically?

A

text-align: center;

line-height: (set value equal to height of div)

847
Q

z-index only works on what type of elements?

A

positioned elements

848
Q

how do you apply psudeo classes like :hover?

A

we apply it to the very end of the class or id name, with no spaces.

.class-name:hover {
}

849
Q

if we want to add hover to multiple elements how do we do it?

A

we list them all and seperate them with commas

.class-name:hover, .other-class-name:hover {

}

850
Q

if we use psuedo classes on one element, does that mean that every
element chosen as a selector for a rule set have to also have the same psuedo class?

A
No it doesnt, but the ones that dont have the pseudo class will
always show that styling rule.

.class-name:hover, #id-name {
border: blue;
}

id-name will have a blue border always
class-name will only have a blue border when its hovered over

851
Q

What does D3 stand for?

A

Data Driven Documents

852
Q

What is D3?

A

D3 is a JavaScript library to create dynamic and interactive data visualizations in the browser. It’s built to work with common web standards, namely HTML, CSS, and Scalable Vector Graphics (SVG).

853
Q

What is SVG?

A

Scalable Vector Graphics

854
Q

What is the select( ) method in D3? what is the syntax?

A

The select() method selects one element from the document. It takes an argument for the name of the element you want and returns an HTML node for the first element in the document that matches the name. Here’s an example:

const anchor = d3.select(“a”);

The above example finds the first anchor tag on the page and saves an HTML node for it in the variable anchor. You can use the selection with other methods. The “d3” part of the example is a reference to the D3 object, which is how you access D3 methods.

855
Q

What is the append( ) method in D3?

A

The append() method takes an argument for the element you want to add to the document. It appends an HTML node to a selected item, and returns a handle to that node.

d3.select(“ul”)
.append(“li”)

this appends a list item to a selected ul element

856
Q

What two things can a text( ) method do in D3?

A

The text() method either sets the text of the selected node, or gets the current text. To set the value, you pass a string as an argument inside the parentheses of the method.

d3.select(“ul”)
.append(“li”)
.text(“Very important item”);

this is an example of a text method setting a string inside of a list item thats appended to a selected ul element

857
Q

Can you chain methods in D3?

A

yes you can

d3.select(“ul”)
.append(“li”)
.text(“Very important item”);

858
Q

What is selectAll( ) method in D3?

A

D3 also has the selectAll() method to select a group of elements. It returns an array of HTML nodes for all the items in the document that match the input string. Here’s an example to select all the anchor tags in a document:

const anchors = d3.selectAll(“a”);

859
Q

Does selectAll support chaining?

A

yes it does

860
Q

When you have a set of data ( like an array of numbers) you can use D3 to do what?

A

Display it on the page

861
Q

When using D3 methods to display data on the page, what is the first step?

A

Making D3 aware of the Data

862
Q

How do you make D3 aware of data so it can put it on the page?

A

you first select an element or elements and then use the data method and passing the data which is saved in a variable as an argument.

const dataset = ["a", "b", "c"];
    d3.select("ul").selectAll("li")
      .data(dataset)
863
Q

What does the enter( ) method do in D3?

A

When enter() is combined with the data() method, it looks at the selected elements from the page and compares them to the number of data items in the set. If there are fewer elements than data items, it creates the missing elements.

 const dataset = ["a", "b", "c"];
    d3.select("ul").selectAll("li")
      .data(dataset)
      .enter()
      .append("li")
      .text("New item");

It may seem confusing to select elements that don’t exist yet. This code is telling D3 to first select the ul on the page. Next, select all list items, which returns an empty selection. Then the data() method reviews the dataset and runs the following code three times, once for each item in the array. The enter() method sees there are no li elements on the page, but it needs 3 (one for each piece of data in dataset). New li elements are appended to the ul and have the text “New item”.

864
Q

What can text( ) take as an argument in D3?

A

it can take a string or an function as an argument

.text((item) => {
return item + ‘ USD’
});

865
Q

when a function with a parameter passed as an argument in the text( ) method in D3 and bound to array as a data set, what does that parameter represent?

A

the items inside the array.

it works the same way as a parameter in maps( ).

const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

    d3.select("body").selectAll("h2")
      .data(dataset)
      .enter()
      .append("h2")
      // Add your code below this line
  .text((item) => {
  return item + ' USD'
  });

item equals the array items

12 USD
31 USD
22 USD
17 USD
25 USD
18 USD
29 USD
14 USD
9 USD
866
Q

What does the style( ) method do in D3?

A

It allows you to add inline styles to an element

867
Q

How are styles added in D3 style tag?

A

with comma separated key value pairs.

selection.style(“color”,”blue”);

868
Q

How can we use conditional logic to add certain visual aspects to an element if condition is met in D3?

A

We use a call back function with conditional logic as the second argument of the style( ) method

  .style("color", (d) => {
        if (d < 20){
          return 'red'
        }
        else {
          return 'green'
        }
      })
869
Q

How do you add a class to an element using D3?

A

with the attr( ) method

the first paramter will be class and the second param the name of that class

selection.attr(“class”, “container”);

870
Q

How can we use the dataset of a numbers array in D3 to dynamically set the height of div elements like a chart?

A
const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];
    d3.select("body").selectAll("div")
      .data(dataset)
      .enter()
      .append("div")
      .attr("class", "bar")
      .style('height', d => `${d}px`)
871
Q

What does “Scalable” mean in SVG?

A

Here “scalable” means that, if you zoom in or out on an object, it would not appear pixelated. It scales with the display system, whether it’s on a small mobile screen or a large TV monitor.

872
Q

What is SVG commonly used for?

A

SVG is used to make common geometric shapes.

873
Q

Where’s must the SVG shapes go?

A

In the HTML svg tag

d3.select(“body”)
.append(‘svg’)

874
Q

CSS can be used to make scaleable styles when using relative units of measurements like ‘vh’, ‘vw’ or “%’s”, but using SVG for data visualizations is….

A

More flexible

875
Q

Do we need using ‘unit measurements’ for attr( ) when setting things like height or width? What ratio should we set height and width?

A

When using attr( ) width and height attributes do not have units. This is the building block of scaling - the element will always have a 5:1 width to height ratio, no matter what the zoom level is.

    const w = 500;
    const h = 100;
const svg = d3.select("body")
              .append('svg')
              .attr('width', w )
              .attr('height', h)
876
Q

What are the basic 5 steps of creating an SVG shape?

A

create an SVG space for the shape
define its height and width
create an SVG shape that goes inside the space
define its height and width
define where it goes on the x axis of space
define where it goes on the y axis of space

d3.select("body")
                  .append("svg")
                  .attr("width", w)
                  .attr("height", h)
                  .append("rect")
                  .attr('width', 25)
                  .attr('height', 100)
                  .attr('x', 0)
                  .attr('y', 0)
877
Q

How can we add a SVG shape for every item in a dataset?

A

first create a svg space inside an element
save that div in a variable name
then attach the data set and and enter and append to that vairable name along with the same

const svg = d3.select(‘body)
.append(‘svg’)
.attr(“width”, w)
.attr(“height”, h);

svg.selectAll(“rect”)
.data(dataset)
.enter()
.append(“rect”)

878
Q

How do you set the coordinates for multiple shapes inside of an SVG space? How many parameters do we need?

A

With a call back function that dynamically sets the ‘x’ and ‘y’ property with attr( ) method.

 svg.selectAll("rect")
       .data(dataset)
       .enter()
       .append("rect")
       .attr("x", (d, i) => {
        return i * 30
       })

this will make each data item produce a rectangle that starts 30px to the right every iteration

we need two, d represents the item of the array.
i equals the value that will set the x or y axis

NOTE — Each bar has a width of 25, so increasing each x value by 30 adds some space between the bars. Any value greater than 25 would work in this example.

879
Q

Do we need a for loop or a foreach( ) when using the data( ) in SVG?

A

the data() method parses the data set, and any method that’s chained after data() is run once for each item in the data set.

880
Q

When we set SVG shapes with various heights, it can appear which way when only setting the x axis?

A

it can appear upside down because the default is 0 , 0 which places it in the left hand upper corner

881
Q

How can we reverse the appearance of upside down SVG shapes by adjusting the y property?

A

y = heightOfSVG - heightOfBar would place the bars right-side-up.

so…

h = 100 (height of svg area)
3 * d = (height of bar)

so turning the bars upside down by setting the y property by

attr(“y”, (d, i) => h - 3 * d)

882
Q

SVG shapes can be colored with what property in attr( ) ?

A

the fill property

attr(‘fill’,’red’)

883
Q

How can you add pseudo elements/classes or css without using multiple styles or attr( ) methods in D3?

A

You can make a rule set in CSS, and apply the class with a single attr( )

884
Q

What are tooltips?

A

A tooltip shows more information about an item on a page when the user hovers over that item.

885
Q

How can we use tooltips in SVG?

A

You can use the title element and add it to each element you want to add it to like a ‘rect’ element, and then call a text method with a call back function

.append(‘rect’)
.text((d) => d)

this d will go with the dataset and iterate through it and represent each item and take that value and return it as text

886
Q

What are the three main attributes of the circle shape in SVG?

A

cx, cy and radius.

cx and cy set the location of the circle. here the center of the circle will be

r will tell us the radius, the size of the actual circle

887
Q

Are the y and cy attributes measured from the top or the bottom of the SVG area?

A

The top

888
Q

Can cy, cx and r all be set dynamically?

A

yes they all can take the a callback functions

889
Q

What happens to all methods chained after dataset in D3?

A

all methods chained after data(dataset) run once per item in dataset

890
Q

What does the d parameter represent in D3 callback functions? How can we access specific points?

A

The d parameter in the callback function refers to the current item in dataset, which is an array for each point. You use bracket notation, like d[0], to access the values in that array.

891
Q

How can you make a right side up bar chart with the height representing numbers in an array with labels and toolkits on the hover function?

A

const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

    const w = 500;
    const h = 100;
const svg = d3.select("body")
              .append("svg")
              .attr("width", w)
              .attr("height", h);
    svg.selectAll("rect")
       .data(dataset)
       .enter()
       .append("rect")
       .attr("x", (d, i) => i * 30)
       .attr("y", (d, i) => h - 3 * d)
       .attr("width", 25)
       .attr("height", (d, i) => d * 3)
       .attr("fill", "navy")
       .attr("class", "bar")
       .append('title')
       .text((d) => d)
    svg.selectAll("text")
       .data(dataset)
       .enter()
       .append("text")
       .text((d) => d)
       .attr("x", (d, i) => i * 30)
       .attr("y", (d, i) => h - (d * 3 + 3))
892
Q

How to build a scatter plot in SVG with D3, that represents data points?

A
const dataset = [
                  [ 34,    78 ],
                  [ 109,   280 ],
                  [ 310,   120 ],
                  [ 79,    411 ],
                  [ 420,   220 ],
                  [ 233,   145 ],
                  [ 333,   96 ],
                  [ 222,   333 ],
                  [ 78,    320 ],
                  [ 21,    123 ]
                ];
    const w = 500;
    const h = 500;
const svg = d3.select("body")
              .append("svg")
              .attr("width", w)
              .attr("height", h);
    svg.selectAll("circle")
       .data(dataset)
       .enter()
       .append("circle")
       .attr("cx", (d, i) => d[0])
       .attr("cy", (d, i) => h - d[1])
       .attr("r", 5);
    svg.selectAll("text")
       .data(dataset)
       .enter()
       .append("text")
       // Add your code below this line
   .attr("x", (d) => d[0] + 5)
   .attr("y", (d) => h - d[1])
   .text((d) => (d[0] + ", " + d[1]))
893
Q

What method do we use to make a linearScale? And how would you save it in a variable?

A

scaleLinear( )

const scale = d3.scaleLinear()

894
Q

What are scales in SVG and why are they used?

A

When using charts or plot points in SVG areas, sometimes youll have data that is outside of the designated space for that SVG space, so you use a scale or different types of scales to specify how you want the data plotted visually.

You rarely plot data as it - most of the time you want to specify how to scale it inside the height and width inside your space

895
Q

What is the input information for a scale and what is it called?

A

It is called the ‘Domain’

and say if a dataset had a range of numbers from 50 - 480, This would be the domain

domain( )

896
Q

What is the output information for a scale and what is it called?

A

It is called the ‘Range’ and it is the points along the x axis of your SVG space that you want to stay in between. Like 10 - 500

range( )

897
Q

What does domain( ) and range( ) take as arguments?

A

It takes an array of at at least two elements

scale. domain([50, 480])
scale. range([10, 500])

898
Q

How we find the highest or lowest number in an array to help us with setting the domain( ) or range( ) of a scale?

A

You can use .min or .max

const exampleData = [34, 234, 73, 90, 6, 52];

d3. min(exampleData) // Returns 6
d3. max(exampleData) // Returns 234

899
Q

If a dataset has nested arrays we can just use .min and .max on it because it will not return accurate data, what can we do?

A

both the min() and max() methods take a callback function. In this example, the callback function’s argument d is for the current inner array. The callback needs to return the element from the inner array (the x or y value) over which you want to compute the maximum or minimum. Here’s an example for how to find the min and max values with an array of arrays:

const locationData = [[1, 7],[6, 3],[8, 3]];
// Returns the smallest number out of the first elements
const minX = d3.min(locationData, (d) => d[0]);
// minX compared 1, 6, and 8 and is set to 1
900
Q

How can you add padding to the scale to make sure the data points dont brush up against the sides?

A

Add a padding varable saved to a number value and use those in teh equations for range( ) and domain( )

const dataset = [
  [ 34,    78 ],
  [ 109,   280 ],
  [ 310,   120 ],
  [ 79,    411 ],
  [ 420,   220 ],
  [ 233,   145 ],
  [ 333,   96 ],
  [ 222,   333 ],
  [ 78,    320 ],
  [ 21,    123 ]
];
const w = 500;
const h = 500;
// Padding between the SVG canvas boundary and the plot
const padding = 30;
const xScale = d3.scaleLinear()
  .domain([0, d3.max(dataset, (d) => d[0])])
  .range([padding, w - padding]);
901
Q

How do you add the scale parameters to the actual data points before plotting?

A

make them the second argument of the x and y parameters of the attr( ) method – or the cy cx parmeters for circles.

This sets up the functions xscale and yscale

 const xScale = d3.scaleLinear()
                     .domain([0, d3.max(dataset, (d) => d[0])])
                     .range([padding, w - padding]);
    const yScale = d3.scaleLinear()
                     .domain([0, d3.max(dataset, (d) => d[1])])
                     .range([h - padding, padding]);

Then you pass it through like so

.attr(“cx”, (d) => xScale(d[0]))
.attr(“cy”, (d) => yScale(d[1]))

902
Q

How do we create an x or yaxis of our chart that gives up information about what the data means?

A

we first create a variable for it

xAxis =d3.axisBottom(xScale)

or

yAxis = d3.axisLeft(yScale)

const xAxis = d3.axisBottom(xScale);

const yAxis = d3.axisLeft(yScale);

svg.append("g")
   .attr("transform", "translate(0," + (h - padding) + ")")
   .call(xAxis);
svg.append("g")
   .attr("transform", "translate(" + padding + ",0)")
   .call(yAxis)