unit 4 Flashcards
what is a variable?
container for storing value
what does the computer do once a variable is created?
stores it in memory
what is the code for a variable?
var + label
when should we use var?
to change its value
where are the positions of the label and value?
label left, value right
initializing the varable
creating and assigning variable value right away
var lives = 3;
initializing the variable
creating and assigning variable value right away
var lives = 3;
what does ‘=’ mean?
gets the value
how do you use a variable?
refer it by its label
how can you see the value of a variable?
by using console.log as we can’t visually see it
what is the difference between writing the variable’s label with quotations and without?
with - refers to the name itself
without - refers to the value
if a variable is not declared what happens?
the program does not know what it is and an error occurs
example of variables in expression
var score = 3;
var newScore;
newScore = score + 1
what is different with variables when you use expressions?
you don’t assign a value directly
how much a computer determine an expression
use the current value and manipulate it (add, subtract etc) the way the expression wants it to
computer picks apart the expression
variable re-assignment
updating values of variables
why does the order of variables matter?
in expressions, the updates change right then and then that new value is applied to the next line
how does a computer make decisions to see what action to take next?
true or false
what is a boolean expression?
can be either true/false
computer can evaluate it
what is the equality operator?
==
what is the assignment operator?
=
what are comparison operators?
> , >=, <, <=, !=
what do operators do?
propose a question for the computer to answer
what are conditional statements?
tells computer to run specific code if something is true