Javascript Flashcards

1
Q

var body = document.body

A

this selects the whole body and we can use

bodyt.append(‘Hello World’) in order to have hello word show up on the page

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

appendChild()

A

you can only append nodes and not text

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

setAttribute()

A

you can use the setAttribute to set classes and id

first parameter is what you want to set and the second is value you want to set

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

chunk Array in groups

A
function chunkArrayInGroups(arr, size) {
  let newArr = [];
  let i = 0;
while (i < arr.length){
  newArr.push(arr.slice(i,i + size))
  i+= size
}
return newArr

}

chunkArrayInGroups([“a”, “b”, “c”, “d”], 2);

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

what does parseInt do

parseInt syntax: parseInt(string, radix)

A

The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN . If not NaN , the return value will be the integer that is the first argument taken as a number in the specified radix

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

what does the String.fromCharCode() method do

A

The String. fromCharCode() method converts Unicode values to characters

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