For each of the problems below, write your function and console.log to check your work. While it is good to console.log to help debug, console.logs should not be in the completed function, unless otherwise explicitly stated.
-
Write a function named
identity
that defines one parameter and returns the argument it was called with. -
Write a function named
isOdd
that accepts a number and returns true if the passed number is odd, otherwise false -
Write a function named
isEven
that accepts a number and returns true if the passed number is even, false otherwise -
Write a function named
isPositive
that returns true if the passed number is greater than 0 -
Write a function named
decrement
that accepts a number and returns the number minus 1 -
Write a function named
hasSpaces
that accepts a string and returns true if the string contains any space characters -
Write a function named
isFive
that accepts a number and returns true if the number is equal to 5 -
Write a function named
square
that accepts a number and returns the number times itself -
Write a function named
cube
that accepts a number and returns the number times itself times itself -
Write a function named
half
that accepts a number and returns the number halved -
Write a function named
double
that accepts a number and returns the number doubled -
Write a function named
isValidPassword
that accepts a string and returns a boolean value based on the rules from the working with data types exercise -
A triangle with sides a, b, and c is a right triangle iff a squared plus b squared is equal to c squared. Write a function named
isRightTriangle
with parameters a, b, and c that will be numbers, and that tells if the passed sides can make a right triangle (returns a boolean).