Basic Programming 1111
|
let variableName = value
|
|
|
let
|
required keyword to initialize a variable
|
|
variableName
|
arbitrary name, no spacing, must contain letter, no punctuaction, cannot use reserved keywords, camel-cased
|
|
=
|
assign
|
|
value
|
any data type
|
|
camel-case
|
no spacing between words, every word except the first is capitalized e.g a red balloon -> aRedBalloon
|
|
+
|
plus
|
|
-
|
minus
|
|
*
|
multiply
|
|
/
|
divide (5/2 = 2.5)
|
|
%
|
remainder (5 % 2 = 1)
|
|
>
|
more than
|
|
<
|
less than
|
|
>=
|
more than or equals
|
|
<=
|
less than or equals
|
|
i++
|
i = i + 1
|
|
i--
|
i = i - 1
|
|
==
|
equal value
|
|
===
|
equal value and data type
|
|
i (+,-,*,/) = value
|
shorthand for i = i + value, i= i - value, etc
|
|
String
|
'string'
|
Anything in quotes. If there are quotations inside the string, use a different type of quotation ( ' and " )
|
|
Number
|
1, 23, 400
|
number
|
|
Boolean
|
true, false
|
true/false value
|
|
Character
|
'a', '2'
|
single input
|
|
Undefined
|
let variable
|
variable instantiated but not assigned a value
|
|
Null
|
variable not defined(instantiated)
|
|
Array
|
['string', 2, true]
|
|
Object
|
let object = { key1: value1, key2: value2 }
|
|
if
|
if condition is true, execute block
|
|
else
|
must be used with if, executes if if condition is false
|
|
if else
|
additional if statements after the first if statement
|
|
while
|
while condition is true, keep executing block
|
|
for
|
for (let i = 0; i< 10; i++), a condensed while loop
|
|
for
|
for (let number of numbers)
|
|
for
|
for (let number in numbers)
|
|
function foo(param1, param2) { return param1 + param2}
|
|
|
function
|
keyword to instantiate function
|
|
foo
|
function name, use to describe function purpose, camel-case
|
|
param1, param2
|
parameters to put into function (optional)
|
|
return
|
value to get back from function (optional)
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.