Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions exercises/001.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@
Write a function 'transformFirstAndLast' that takes in an array, and returns an object with:
1) the first element of the array as the object's key, and
2) the last element of the array as that key's value.

Example input:
['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce']

Function's return value (output):
{
Queen : 'Beyonce'
}

Do not change the input array. Assume all elements in the input array will be of type 'string'.
Note that the input array may have a varying number of elements. Your code should flexibly accommodate that.

E.g. it should handle input like:
['Kevin', 'Bacon', 'Love', 'Hart', 'Costner', 'Spacey']

Function's return value (output):
{
Kevin : 'Spacey'
}

Starter Code
function transformFirstAndLast(array) {
// your code here
}
*/

function transformFirstAndLast(array) {
//your code here
}

}
12 changes: 8 additions & 4 deletions exercises/002.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
/*
Write a function called "getAllKeys" which returns an array of all the input object's keys.

Example input:
{
name : 'Sam',
age : 25,
hasPets : true
}

Function's return value (output) :
['name', 'age', 'hasPets']

Do not use "Object.keys" to solve this prompt.
Note that your function should be able to handle any object passed in it.

E.g. it should also handle an input like:
{
a : 'a',
number : 11,
hungry : true,
grammyWins : 1
}

Function's return value (output):
['a', 'number', 'hungry', 'grammyWins']

Starter Code:
function getAllKeys(obj) {
// your code here
}
*/

function getAllKeys(obj){
// your code here
//your code here

}
5 changes: 3 additions & 2 deletions exercises/003.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Function's return value (output):
}

Do not change the input string. Assume that all elements in the array will be of type 'string'.
Do not use "Object.fromEntries" to solve this prompt.

Note that the input may have a different number of elements than the given sample.
For instance, if the input had 6 values instead of 4, your code should flexibly accommodate that.
Expand All @@ -20,6 +21,6 @@ Starter Code:
*/

function fromListToObject(array) {
// your code here

//your code here
}
7 changes: 4 additions & 3 deletions exercises/004.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Example input:
Function's return value (output):
['Krysten', 33, false]

Do not use "Object.values" to solve this prompt.
Note that the input may have a different number of keys and values than the given sample.

E.g. it should also handle an input like:
Expand All @@ -28,6 +29,6 @@ Starter Code
*/

function listAllValues(obj) {
// your code here

}
//your code here
}
5 changes: 3 additions & 2 deletions exercises/005.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Given that input, the return value should look like this:
{firstName: 'Mary', lastName: 'Jenkins', age: 36, role: 'manager'}
]

Do not use "Object.fromEntries" to solve this prompt.
Note that the input may have a different number of rows or different keys than the given sample.

For example, let's say the HR department adds a "tshirtSize" field to each employee record. Your code should flexibly accommodate that.
Expand All @@ -25,6 +26,6 @@ Starter Code :
*/

function transformEmployeeData(array) {
// your code here

//your code here
}
8 changes: 6 additions & 2 deletions exercises/006.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/*
Write a function called "convertObjectToList" which converts an object literal into an array of arrays, like this:

Argument:
{
name: 'Holly',
age: 35,
role: 'producer'
}

Return value:
[['name', 'Holly'], ['age', 35], ['role', 'producer']]

Do not use "Object.entries" to solve this prompt.
Note that your function should be able to handle ANY object like this, not just the exact sample provided above.

E.g., it should also be able to handle this, or any other object containing simple key-value pairs.
Expand All @@ -22,5 +25,6 @@ Starter Code:
*/

function convertObjectToList(obj) {
// your code here
}
//your code here

}
6 changes: 2 additions & 4 deletions exercises/007.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Notes:
* Your function should not alter the customerData object to update the number of visits.
* Do not hardcode to the exact sample data. This is a BAD IDEA:


if (firstName === 'Joe') {
// do something
}
Expand All @@ -49,8 +48,7 @@ var customerData = {

function greetCustomer(firstName) {
var greeting = '';
// your code here

//your code here
return greeting;
}