Methods
animalCounts(animal, numberOfAnimals) → {string}
Takes in two variables: animal ('cat', 'dog', etc.) and numberOfAnimals.
Use an if - else to statement to return the
number and animal (in either single or plural form)
Exp: "5 cats" or "1 dog"
Bonus: Make it handle a few collecting nouns like "sheep" and "geese"
Parameters:
Name | Type | Description |
---|---|---|
animal |
string | The type of animal. |
numberOfAnimals |
number | The number of animals. |
- Source:
Returns:
- the number and animal (in either single or plural form)
- Type
- string
aroundTheWorldGreeting(language) → {string}
Takes in a language (e.g "english", "spanish", "german") and returns "Hello World" in that language.
Must work for at least english, spanish, and german.
It should default to English if no argument is passed in.
Translations: English -> "Hello World"
Spanish -> "Hola Mundo"
German -> "Hallo Welt"
Parameters:
Name | Type | Description |
---|---|---|
language |
string | The language. |
- Source:
Returns:
- "Hello World" in the desired language
- Type
- string
aroundTheWorldGreetingWithSwitch(language) → {string}
Takes in a language (e.g "english", "spanish", "german") and returns "Hello World" in that language.
Must work for at least english, spanish, and german.
It should default to English if no argument is passed in.
Translations: English -> "Hello World"
Spanish -> "Hola Mundo"
German -> "Hallo Welt"
Uses a switch statement in its implementation
Parameters:
Name | Type | Description |
---|---|---|
language |
string | The language. |
- Source:
Returns:
- "Hello World" in the desired language
- Type
- string
calculateLetterGrade(grade) → {string}
Takes in a number and returns the letter grade corresponding to that number.
Letter grades consist of "A", "B", "C", "D", or "F"
90 and above is an A
80 and above is a B
70 and above is a C
60 and above is a D
Anything lower than 60 is an F
Parameters:
Name | Type | Description |
---|---|---|
grade |
number | The numeric grade. |
- Source:
Returns:
- The letter grade corresponding to the numeric grade.
- Type
- string
evenOrOdd(a) → {string}
Takes in a number and returns whether that number is even or odd
Parameters:
Name | Type | Description |
---|---|---|
a |
number | The number. |
- Source:
Returns:
- "Even or Odd"
- Type
- string
evenOrOddWithTernary(a) → {string}
Takes in a number and returns whether that number is even or odd
Uses a ternary in its implementation
Parameters:
Name | Type | Description |
---|---|---|
a |
number | The number. |
- Source:
Returns:
- "Even or Odd"
- Type
- string
findLarger(a, b) → {number}
Takes in two numbers and returns the larger number
The numbers are guaranteed to be unique
Parameters:
Name | Type | Description |
---|---|---|
a |
number | The first number. |
b |
number | The second number. |
- Source:
Returns:
- The larger number.
- Type
- number
findLargerOrTie(a, b) → {number|string}
Takes in two numbers and returns the larger number
Returns the string "tie" if both numbers are the same
Parameters:
Name | Type | Description |
---|---|---|
a |
number | The first number. |
b |
number | The second number. |
- Source:
Returns:
- The larger number or string "tie"
- Type
- number | string
findLargerTernary(a, b) → {number}
Takes in two numbers and returns the larger number
The numbers are guaranteed to be unique
Uses a ternary in its implementation
Parameters:
Name | Type | Description |
---|---|---|
a |
number | The first number. |
b |
number | The second number. |
- Source:
Returns:
- The larger number.
- Type
- number
isEqual(a, b) → {boolean}
Takes in two values and returns if they are equal or not
Parameters:
Name | Type | Description |
---|---|---|
a |
* | The first element. |
b |
* | The second element. |
- Source:
Returns:
- Is a equal to b.
- Type
- boolean
isPrimaryColor(color) → {boolean}
Takes in color and returns whether or not the color is a primary color.
The primary colors are "Red", "Yellow", and "Blue"
Parameters:
Name | Type | Description |
---|---|---|
color |
string | The color. |
- Source:
Returns:
- Whether the color is a primary color
- Type
- boolean
isPrimaryColorOneIf(color) → {boolean}
Takes in color and returns whether or not the color is a primary color.
Uses exactly one if statement in its definition
Parameters:
Name | Type | Description |
---|---|---|
color |
string | The color. |
- Source:
Returns:
- If primary color or not
- Type
- boolean
largeOrSmall(word) → {string}
Takes in a word and returns "large" if its length is 5 character or more.
Otherwise returns "small"
Parameters:
Name | Type | Description |
---|---|---|
word |
string |
- Source:
Returns:
- "large" or "small"
- Type
- string
lexicographicalOrder(word1, word2) → {string}
Takes in two words and returns the word that comes first in lexicographical order.
Parameters:
Name | Type | Description |
---|---|---|
word1 |
string | The first word. |
word2 |
string | The second word. |
- Source:
Returns:
- The word that is smaller in lexicographical order
- Type
- string
longerWord(word1, word2) → {string}
Takes in two words and returns the longer word.
Parameters:
Name | Type | Description |
---|---|---|
word1 |
string | The first word. |
word2 |
string | The second word. |
- Source:
Returns:
- The longer word
- Type
- string
positiveNegativeOrZero(a) → {string}
Takes in a number and returns whether that number is positive, negative, or equal to 0.
Parameters:
Name | Type | Description |
---|---|---|
a |
number | The number. |
- Source:
Returns:
- "Positive, Negative, "Zero""
- Type
- string
shortestWord(word1, word2, word3) → {string}
Takes in three words and returns the shortest word.
Parameters:
Name | Type | Description |
---|---|---|
word1 |
string | The first word. |
word2 |
string | The second word. |
word3 |
string | The second word. |
- Source:
Returns:
- The shortest word
- Type
- string