Week 2 Review Flashcards
if statement
if(boolean expression){
};
Difference between == and ===
=== has no type conversion
if-else statement
if(boolean experession){
} else {
}
The “and” operator
&&
The “or” operator
||
the “not” operator
!
switch statement
switch(variable) { case var_val_1: break; case var_val_2: break; default: }
while statement
while (boolean) {
}
for statement
for (let i =1; i<5, i++){ }
declare a variable a with string value
a = “ a sentence”; or a = ‘a sentence’;
Operator to concatenate a string
+
concatinate a string with +=
String1 = ‘one’
String1 += ‘two’
find length of string
myString = “William”
myString.length
get second character of a string
myString = ‘William”
myString[1]
Create an array in JS
myArray[]
include a value in a string
my name is ${varble_with_name}
not these are backticks and not single quotes
code to send a message to the browser window
alert(‘that is a no no!’ )
code to ask a question of the user in browser window
prompt(‘What is your mother’s name’ )
keyword to declare a variable that does not change
const
let and const are ________ scoped variables
block
a piece of code that produces a value
expression
add X to end of an array called array1
array.push(X)
delete the last element of an array called array1
array.pop()
remove the first element of an array called array1
array1.shift()
add to the beginning of an array
array1.unshift(x)