Global

Methods

adamAndEveApples(peopleWithApples) → {number}

Takes in an object with peoples names as the keys and the number of apples they have as values. Should return the total number of apples for Adam and Eve.
Parameters:
Name Type Description
peopleWithApples Object apple object with names and numbers
Source:
Returns:
Sum of Adam and Eve's apples.
Type
number

addsCountry(countriesAndCapitals, country, capital) → {Object}

Takes in an object of countries and their capitals and a country and capital. The country and capital should be added to the object. Return the original object.
Parameters:
Name Type Description
countriesAndCapitals Object countries and capitals
country string
capital string
Source:
Returns:
countriesAndCapitals
Type
Object

addsJamaica(countriesAndCapitals) → {Object}

Takes in an object of countries and their capitals and adds the key value pair "Jamaica" and "Kingston" Return the original object.
Parameters:
Name Type Description
countriesAndCapitals Object countries and capitals
Source:
Returns:
countriesAndCapitals now with Jamaica
Type
Object

appleCount(peopleWithApples, name) → {number}

Takes in an object with peoples names as the keys and the number of apples they have as values. Also takes in the argument of someone's name. Return the number of apples that the person passed in has. If the person does not exist in the object it should return 0.
Parameters:
Name Type Description
peopleWithApples Object
name string name of person
Source:
Returns:
The number of apples name has. Is there a difference between using string notation vs bracket notation? Try them both.
Type
number

appleSet(peopleWithApples, name, appleCount) → {Object}

Takes in an object with peoples names as the keys and the number of apples they have as values. Also takes in the argument of someone's name, and the argument newNumberApple . Update the object to have the name pointing to the newNumberApple
Parameters:
Name Type Description
peopleWithApples Object apple object with names and numbers
name string name of person
appleCount number number of apples
Source:
Returns:
The updated object.
Type
Object

appleSetToZero(peopleWithApples) → {Object}

Takes in an object with peoples names as the keys and the number of apples they have as values. Reset all the apple values to 0 and return the object.
Parameters:
Name Type Description
peopleWithApples Object apple object with names and numbers
Source:
Returns:
Object with values set to zero.
Type
Object

appleSum(peopleWithApples) → {number}

Takes in an object with peoples names as the keys and the number of apples they have as values. Returns the sum of all apples
Parameters:
Name Type Description
peopleWithApples Object apple object with names and numbers
Source:
Returns:
Sum of all apples
Type
number

authorScores(authors) → {Object}

Takes an array of arrays. First element of inner array is authorName, second element of inner array is score. Return an object where the keys are the authorNames and the values are the scores.
Parameters:
Name Type Description
authors Array.<Array> array of arrays [["Mark Twain", 8.9], ["Nathaniel Hawthorne", 5.1]]
Source:
Returns:
{"Mark Twain": 8.9, "Nathaniel Hawthorne": 5.1}
Type
Object

bestScore(peopleAndScores) → {string}

You are given an array of objects. Each object in the array describes the score of a person. Find the person with the best score and return their full name.
Parameters:
Name Type Description
peopleAndScores Array.<Object> array of objects [ { firstName: "Calvin", lastName: "Newton", score: 13} ...]
Source:
Returns:
The full name of person with best score.
Type
string

countAandE(str) → {Object}

Takes in a string and returns an object with the number of a's and the number of e's.
Parameters:
Name Type Description
str string "A good snake"
Source:
Returns:
Counts of e and a. {a: 2, e: 1}
Type
Object

countOccurance(str) → {Object}

Takes in a string and returns an object with the count occurrence of each character.
Parameters:
Name Type Description
str string "A good snake"
Source:
Returns:
Counts of all characters: {a: 2, g: 1, o: 2, d:1, " ": 2, s: 1, n:1, k:1, e: 1}
Type
Object

countOccuranceNoSpaces(str) → {Object}

Takes in a string and returns an object with the count occurrence of each character. Skips spaces
Parameters:
Name Type Description
str string "A good snake"
Source:
Returns:
Counts all characters except spaces {a: 2, g: 1, o: 2, d:1, s: 1, n:a, k:1, e: 1}
Type
Object

cubeObj() → {Object}

Returns an object where the keys are numbers 1 through 20, and their respective values is key cubed (num * num * num).
Source:
Returns:
{1: 1, 2: 8, 3: 27...}
Type
Object

deleteKey(key) → {Object}

Takes in an object and a key. It should delete the key value pair from the object and return the changed object.
Parameters:
Name Type Description
Object
key string
Source:
Returns:
The Object without the key.
Type
Object

eveAppleCount(peopleWithApples) → {number}

Takes in an object with peoples names as the keys and the number of apples they have as values. Return the number of apples that "Eve" has.
Parameters:
Name Type Description
peopleWithApples Object
Source:
Returns:
The number of apples Eve has.
Type
number

eveAppleSet(peopleWithApples, appleCount) → {Object}

Takes in an object with peoples names as the keys and the number of apples they have as values. Also takes in a new number of apples for Eve. Reassign her number of apples to the new value and then return the original object.
Parameters:
Name Type Description
peopleWithApples Object
appleCount number new number of apples
Source:
Returns:
The updated object.
Type
Object

getCapital(countriesAndCapitals, country) → {string}

Takes in an object of countries and their capitals. Takes in a country Return the capital of country given.
Parameters:
Name Type Description
countriesAndCapitals Object countries and capitals
country string
Source:
Returns:
Capital of country
Type
string

mostCommonElement(array) → {number|string}

Takes in an array and returns the most common element.
Parameters:
Name Type Description
array Array array of elements
Source:
Returns:
Most common element
Type
number | string

propertyCount(obj) → {number}

Takes in an object and returns the number of properties it has.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Number of properties.
Type
number

russiaCapital(countriesAndCapitals) → {string}

Takes in an object of countries and their capitals. Return the capital of Russia.
Parameters:
Name Type Description
countriesAndCapitals Object countries and capitals
Source:
Returns:
Capital of Russia
Type
string

updateList(pairs, arr) → {Array.<string>}

Takes in an object and an array. Returns a new array. If the element in the array is a key in the object the new array should have the value in its place. Otherwise just use the array element. Exp Input: {"Ed Sheeran": "guitar", "Ray Charles": "piano"} ["Ed Sheeran", "John Lennon", "Ray Charles"] Output: ["guitar", "John Lennon", "piano"]
Parameters:
Name Type Description
pairs Object
arr Array.<string>
Source:
Returns:
Elements or their pair values.
Type
Array.<string>