Week 2 Flashcards

(33 cards)

1
Q

are a special type of object used for storing multiple values in a single variable.

A

Arrays

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

They are ordered collections of elements, where each element is identified by an index (starting from 0).

A

Array

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

Can hold elements of different types: numbers, strings, objects, etc.

A

Arrays

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

let fruits = [‘apple’, ‘banana’, ‘orange’];

A

Arrays Literals

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

let numbers = new Array(1, 2, 3, 4, 5);

A

Array Constructor

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

let emptyArray = [];

A

Empty Array:

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

How do u add elements in the end in array

A

fruits.push(‘grape’);

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

How do u add to the beggining in Array

A

fruits.unshift(‘strawberry’)

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

Removes from the end

A

pop()

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

Removes from the beginning

A

shift()

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

Removes at a specific index

A

splice(index, count)

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

how do u loop a array

A

for (let i = 0; i < fruits.length; i++) {
console.log(fruits[i]);
}

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

how do u use a forEach()

A

fruits.forEach(fruit => console.log(fruit));

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

how do you use uppercase

A

let uppercaseFruits = fruits.map(fruit => fruit.toUpperCase());

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

Finds the first occurrence

A

indexOf(element)

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

Checks if an element is present

A

includes(element)

17
Q

Sorts elements in place

18
Q

Reverses the order of elements

19
Q

how do u use filter()

A

let longFruits = fruits.filter(fruit => fruit.length > 5);

20
Q

how do u use reduce

A

let totalLength = fruits.reduce((total, fruit) => total + fruit.length, 0);

21
Q

the output will be the total length of letters added together in an array

A

document.write(totalLength);

22
Q

is a collection of key-value pairs where keys are unique.

23
Q

how do u create a map in js

A

let myMap = new Map();
myMap.set(‘key1’, ‘value1’);
myMap.set(‘key2’, ‘value2’);

24
Q

how do u access values of maps in js

A

let value = myMap.get(‘key1’);

25
how do u iterate maps
myMap.forEach((value, key) => console.log(key, value));
26
Adds or updates an entry
set(key, value)
27
Retrieves the value associated with a key
get(key)
28
Removes an entry
delete(key)
29
Checks if a key exists
has(key)
30
Removes all entries
clear()
31
are powerful data structures for handling collections of elements.
Arrays
32
Various methods allow for efficient manipulation, searching, and transformation of array data.
JavaScript Arrays
33
provide an alternative way to store key-value pairs with useful methods for management.
Maps