Javascript Flashcards
var body = document.body
this selects the whole body and we can use
bodyt.append(‘Hello World’) in order to have hello word show up on the page
appendChild()
you can only append nodes and not text
setAttribute()
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
chunk Array in groups
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);
what does parseInt do
parseInt syntax: parseInt(string, radix)
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
what does the String.fromCharCode() method do
The String. fromCharCode() method converts Unicode values to characters