What do you use in Javascript to store information for later use?
Variables
what do you use in JavaScript to store multiple values?
Arrays
What is an array?
A list of items.
what do you use in JavaScript to store key/value pairs?
Objects
How do you call/invoke a function
functionName()
what does the DOM stand for?
DAILY DOUBLE!
Document Object Model
can you change the indexes of a array that is assigned as a const variables?
Yes
const arr = [1,2,3,4]
arr[2] = 'pizza'
What can be stored into an array?
Strings, Numbers, Objects, Arrays, pretty much anything
What are the two ways we can access an objects properties?
DAILY DOUBLE!
dot notation obj.property
bracket notation obj['property']
What is the difference between arguments and parameters?
an argument is a value passed in when we invoke a function. parameters are placeholders for those values
What is the difference between const and let?
const is a constant, cannot be changed
let allows us to assign the variable to a new value
What data type is an Array?
Object
Accessing an array is known as?
Bracket Notation arrName[index]
How can I change the name of the property of this object?
const obj = {
name: 'Joe'
}
What does the return do?
Sends a value back from the function
Name two methods to select HTML Elements?
document.getElementById()
document.querySelector()
document.querySelectorAll()
document.getElementsByClassName()
How can you access the last item of an array
DAILY DOUBLE!
arrName[arrName.length - 1]
How can we access the last item on an array?
arrName.length - 1
How can I access the keys of an Object?
Object.keys(objName)
Find the Bug
const count = 0;
const scoreEle = document.getElementById('score')
function count(){
count++
return count
}
scoreEle.textContent = count()
Assignment to constant
Change const to let
Write a for loop to count to 5?
let count = 0
for (let i = 0; i <= 5; i++){
count++
}
Name 4 array methods
.pop .push .unshift . shift etc.
const test = [1,'two',3,{count:4},[5,6,[7]]]
How can I grab 7?
test[4][2]
Access the treasure
const puzzle = {
left: [{right: {
up: ['treasure']}}]
}
puzzle.left[0].right.up[0]
What is subtractLife() returning?
let life = 100
function subtractLife(){
let life = 85;
if (life > 100) {
return life - 20
}
}
subtractLife()
85