Global

Methods

ageMessage(age) → {string}

Returns "You are a senior" if the age is 65 or older, "You are an adult" if the age is 18 or older, and "You are a minor" otherwise.
Parameters:
Name Type Description
age number The age of the user
Source:
Returns:
- A message about their age
Type
string

doubleStr(str) → {number}

Takes in a string, coverts it to an integer and doubles it. Returns NaN if the string is not able to be converted to a number.
Parameters:
Name Type Description
str string The input string
Source:
Returns:
- The string converted to a number and doubled
Type
number

duplicateArray(arr) → {Array.<number>}

Duplicates all values inside an array. Sample input: [1,4,2,5] Sample output: [1,4,2,5,1,4,2,5]
Parameters:
Name Type Description
arr Array.<number> The input array
Source:
Returns:
- The duplicated array
Type
Array.<number>

evenNumbers(num)

Returns every even number from 0 to a given number
Parameters:
Name Type Description
num number The number to iterate up to
Array.<number> An array of even numbers from 0 to {num}
Source:

firstAndLastAverage(arr) → {number}

Averages the first and last value of an array. Return null if the array has fewer than 2 elements.
Parameters:
Name Type Description
arr Array.<number> The input array
Source:
Returns:
- The average of the first and last values
Type
number

greeting(name) → {string}

Returns a custom greeting string in the form "Hello Avery!"
Parameters:
Name Type Description
name string The name of the user to greet
Source:
Returns:
- The custom greeting
Type
string

incrementGlobalCount(val) → {null}

Adds a number to a global variable called globalCount
Parameters:
Name Type Description
val number The number to add to globalCount
Source:
Modifies:
Type
globalCount
Returns:
Type
null

isNumber(val) → {boolean}

Takes in an value and returns if it is a number
Parameters:
Name Type Description
val any The input value
Source:
Returns:
- Is val a number
Type
boolean

isTruthy(val) → {boolean}

Takes in a value and returns whether it is truthy
Parameters:
Name Type Description
val any The input value
Source:
Returns:
- Is val truthy
Type
boolean

logGreeting(name) → {null}

Logs a custom greeting to the console in the form "Hello Avery!"
Parameters:
Name Type Description
name string The name of the user to greet
Source:
Returns:
Type
null

multiplesToOneThousand(num) → {Array.<number>}

Returns all multiples of a given number up to 1000
Parameters:
Name Type Description
num number The number to find multiples of
Source:
Returns:
- An array of all multiples of {num} up to 1000
Type
Array.<number>

multiply(firstNum, secondNum, thirdNum) → {number}

Multiplies three numbers
Parameters:
Name Type Description
firstNum number The first number
secondNum number The second number
thirdNum number The third number
Source:
Returns:
- The product of the three numbers
Type
number

powersOfTwo(count) → {Array.<number>}

Returns the first n powers of 2 (starting at 0) Sample input: 6 Sample output: [1,2,4,8,16,32]
Parameters:
Name Type Description
count number How many powers of two to find
Source:
Returns:
- An array with the first {count} powers of two
Type
Array.<number>

removeFirstThreeElements(arr) → {Array.<any>}

Removes the first 3 elements from an array. If the array has fewer than 3 elements, return an empty array.
Parameters:
Name Type Description
arr Array.<any> The input array
Source:
Returns:
- The array with the first 3 elements removed
Type
Array.<any>

temperatureMessage(temp) → {string}

Returns "It's freezing!" if the temperature is below 32, and "It's alright" otherwise
Parameters:
Name Type Description
temp number The current temperature
Source:
Returns:
- A message about the temperature
Type
string

temperatureMessageUsingTernary(temp) → {string}

Returns "It's freezing!" if the temperature is below 32, and "It's alright" otherwise. The implementation must use a ternary.
Parameters:
Name Type Description
temp number The current temperatur
Source:
Returns:
- A message about the temperature
Type
string