This file contains 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
{ | |
"gitlens.advanced.messages": { | |
"suppressShowKeyBindingsNotice": true | |
}, | |
"workbench.iconTheme": "eq-material-theme-icons", | |
"workbench.colorTheme": "City Lights", | |
"materialTheme.fixIconsRunning": false, | |
"editor.fontSize": 18, | |
"editor.tabSize": 2, | |
"editor.fontLigatures": true, |
This file contains 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
handleChange = event => { | |
const { name, type, value } = event.target; | |
const val = type === "number" ? parseFloat(value) : value; | |
this.setState({ [name]: value }); | |
} |
This file contains 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
Show hidden characters
{ | |
"extends": ["airbnb", "plugin:prettier/recommended", "prettier/react"], | |
"env": { | |
"jest": true | |
}, | |
"rules": { | |
"no-plusplus": "off", | |
"jsx-a11y/anchor-is-valid": [ | |
"error", | |
{ |
This file contains 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
// O(n^2) | |
// function same(arr1, arr2) { | |
// if (arr1.length !== arr2.length) return false | |
// let result = true; | |
// arr1.forEach((num) => { | |
// const currentIndex = arr2.indexOf(num * num) | |
// if (currentIndex === -1) { | |
// result = false |
This file contains 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
/* Inefficient example would be a nested loop -- O(n^2) | |
** Below version uses multiple pointers to achieve O(n) | |
*/ | |
function sumZero(arr) { | |
let left = 0; | |
let right = arr.length - 1; | |
while(left < right) { | |
let sum = arr[left] + arr[right] |
This file contains 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
/* | |
** Given an array of sorted values, return the number of unique values | |
** | |
** Method: Use 2 pointers (lastUniqueIndex and i) to mutate sorted array and | |
** return lastUniqueIndex + 1 for result | |
*/ | |
function countUniqueValues(arr) { | |
if (!arr.length) return 0 | |
let lastUniqueIndex = 0; |
This file contains 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 = funcObjects => startingInstance => | |
funcObjects.reduce( | |
(composed, currentFunc) => | |
composed[currentFunc.method](currentFunc.argument), | |
startingInstance | |
); | |
// Example of how compose would be called with static data | |
// const emailComposed = compose( | |
// { method: "email", argument: "Enter an email, tallywacker." }, |
This file contains 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 taggedTemplate(stringArray, variable) { | |
console.log(stringArray) | |
// [ 'The string will be split here: ', ' Then it resumes here.' ] | |
console.log(variable) | |
// I am the great divider! | |
return `${stringArray[0]}${variable}${stringArray[1]}` | |
} |
OlderNewer