Last active
December 20, 2016 23:42
-
-
Save erottman/a79d862663f9cde6092106b8a68c7d1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Struggling with the for-in loop and the differences between the terminology of -variable, property, key, and value, | |
in relation to Objects and this type of loop. It really wasnt covered very well in Objects | |
or accumulator patterns Lectures for my novice brain. | |
#1 Write a function named invert that takes an object and returns an object | |
where the keys and values have been inverted | |
Example: | |
If you pass {id: 1, name: "Joe"} it should return {1: "id", Joe: "name"} | |
*/ | |
#2 Write a function named index that takes an array of objects, and a | |
property name, and returns an object where the keys are the specified property | |
Example: | |
If you pass [{id: 1, name: "Joe"}, {id: 2, name: "Sue"}] it should | |
return {1: {id: 1, name: "Joe"}, 2: {id: 2, name: "Sue"}} | |
*/ | |
#3 Write a function named addSignature that takes an object and a name, and returns an object where | |
- the keys are suffixed with "-signed" | |
- the values are suffixed with " - <name>" | |
Example: | |
If you pass {"contract": "foo"}, "Fred" it should return {"contract-signed": "foo - Fred"} | |
*/ | |
#4 Write a function named pairs that takes an object and returns an array of s | |
trings of key/value pairs | |
Example: | |
If you pass {name: "Will", age: 24} it should return ["name - will", "age - 24"] | |
*/ | |
#5 Write a function named containsValue that takes an object and a | |
value and returns true if the object contains the value | |
Example: | |
If you pass {1999: 4036, 2000: 7654} and 4036, it should return true | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment