Basics Flashcards
What are variables?
Variables are “data buckets” to store a value for later
What are the 2 part of a variable?
Let age = 25
Declaration: Let age
Assignment: age = 25
What are the function of a declaration and assignment?
A declaration create a “bucket” to store some data
An assignment is the step of putting something into the “bucket”
What can you store in variables?
Strings
Numbers
Booleans
What are Booleans data types?
Data with True and False values
What are strings?
Strings are used to store text and are surrounded by quotes e.g “10283”
Differences between numbers integer and floated value?
Int = 29 Float = 5.14876
can also be signed
Int = +29 Float = -10.375
JS can also do arithmetic, what sign are used?
\+ addition - subtraction * multiplication / Division % Modulus
What is 10 % 6?
Modulus gives us the remaining so it is 4
let imputinterval = document.querySelector(“dancedancerevolution”).value
How can this code be read?
This line looks at the document and select the value present in the HTML document with id of dancedancerevolution and store it in the value imputinterval
How can this code be read?
h1holder.addeventlistener(“click”, sum)
We add an “eventlistener” into the “h1holder” where if you click on the h1holder it will run the function “sum”
What are the logical operators in JS?
== equal to (value )(x = = 8) === equal to (value and type) (x = = = "3") != not equal (value)(x != 8) !== not equal (value and type) (x!== "3") > greater than < less than >= greater or equal <= less or equal
How do you write a conditional syntax?
if(condition is true) { //Do this }else if(condition is true){ //Do this }else{ //default stuff }
How do you write multiple conditions?
if (name===”leon” && status === “ballin”) {
…
}
Can you write multiple condition with or?
Yes you use this symbol “||”
E.g
if (day === “monday” || day === “sunday”){
…
}