CC-01: Conditionals
with Carmen Salas β’ 2024/10/02
Truthys and Falsys
Truthy JS values:
'0'- a string containing a single zero'false'- a string containing 'false'[]- empty array{}- empty objectfunction(){}- an empty function
Falsy JS values:
false0zero as a number and-0minus zero as a number'',""- empty stringsnullundefinedNaN
Important tidbit:
typeof Hierarchy in JS:
typeof Hierarchy in JS:Conditionals Overview
Comparison Operators
The strict equality operator === always considers operands of different types to be different.
not all languages implement this operator!
Code Challenge
Write a function named
greatestOfTwothat 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.
Last updated