This is a personal portfolio made for www.freecodecamp.com
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
| // Remove any duplicates from an array of primitives. | |
| const unique = [...new Set(arr)]; | |
| // Returns all non-falsy values from an array | |
| [...].filter(Boolean); | |
| // Just plain english | |
| [...].every(Number.isFinite); | |
| // Array destructuring to see matching elements |
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
| const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); |
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
| function getOptionalProperty(obj, ...props) { | |
| const val = obj[props[0]]; | |
| if (props.length === 1 || !val) return val; | |
| const rest = props.slice(1); | |
| return getOptionalProperty.apply(null, [val, ...rest]); | |
| } | |
| const user = { name: "fluffy" }; | |
| const zip = getOptionalProperty(user, "address", "zip"); | |
| console.log("zip", zip); |