CC-01: Conditionals
Last updated
Last updated
with Carmen Salas • 2024/10/02
Truthy JS values:
'0'
- a string containing a single zero
'false'
- a string containing 'false'
[]
- empty array
{}
- empty object
function(){}
- an empty function
Falsy JS values:
false
0
zero as a number and -0
minus zero as a number
''
, ""
- empty strings
null
undefined
NaN
Important tidbit:
typeof
Hierarchy in JS:The strict equality operator ===
always considers operands of different types to be different.
not all languages implement this operator!
Write a function named greatestOfTwo
that takes in two integer arguments and returns the largest of both arguments. You can assume both integers will be different values.
Write a function named areBothSame
, that takes in two arguments and returns true if both arguments are truthy in value, and returns false if not.
Write a function named areBothEqual
, that takes in two arguments and returns true if both arguments are the same in data type and value, and returns false if they are not.