CC-02: Conditionals 2
Last updated
Last updated
with Carmen Salas • 2024/10/03
and
and or
are the ones that we use for JavaScript
. Unlike equality operators, logical operators don't necessarily evaluate into boolean
.
On operations concerning logical operators, most languages (JavaScript
obviously included), evaluates the operands from left to right. This creates an interesting behavior called short-circuiting. If any of the operands that come first is enough to satisfy either &&
or ||
, the second operand will not be run at all.
Write a function named greatestOfThree
that takes in three integer arguments and returns the largest of all arguments. Solve this problem without using any sorting JS methods. You can assume all integers will be different values.
Write a function named distinstThree
that takes in three integer arguments and returns a boolean if all the three arguments are distinct. Distinct integers are integers that are not equal to each-other.
Write a function named isEvenAndPositive
that checks if a number is both even and positive. This function should return a boolean.
Write a function named leastOfFour
that takes in four integer arguments and returns the least of all arguments. Solve this problem without using any sorting JavaScript methods. You can assume all integers will be different values.