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
loadFlashCards = async () => { | |
const value = await AsyncStorage.getItem('flashcards'); | |
if (value !== null){ | |
this.setState({ | |
flashcards: JSON.parse(value) | |
}); | |
} | |
} |
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
this.setState((state)=> ( | |
showInput: !state.showInput | |
)) | |
{showInput && ( | |
<View …> | |
) | |
} |
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
var twoSum = function(nums, target) { | |
const hash = {}; | |
for (let i = 0; i < nums.length; i++) { | |
const comp = target - nums[i]; | |
if (hash[comp] !== undefined) { | |
return [hash[comp], i]; | |
} |
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
myList.sort(function(x, y){ | |
return x.timestamp - y.timestamp; | |
}) |
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
/* Create A Reducer | |
* | |
* You need to create a reducer called "appReducer" that accepts two arguments: | |
* - First, an array containing information about ice cream | |
* - Second, an object with a 'DELETE_FLAVOR' `type` key | |
* (i.e., the object contains information to delete the flavor from the state) | |
* | |
* The action your reducer will receive will look like this: | |
* { type: 'DELETE_FLAVOR', flavor: 'Vanilla' } | |
* |
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
for (const day of days) { | |
console.log(day.charAt(0).toUpperCase().trim().concat(day.slice(1))); | |
} |
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 person (name) { | |
return function age (age) { | |
return `${name} is ${age}` | |
} | |
} | |
// if we called | |
const arg1 = 'Richard' | |
const arg2 = 30 | |
console.log(person(arg1)(arg2)) |
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 isLargerOrEqualTo100 = (a) => { | |
return new Promise((resolve, reject) => { | |
if (a >= 100) { | |
resolve(`${a} is >= 100`) | |
} else { | |
reject(`${a} is < 100`) | |
} | |
}) | |
} |
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
/* | |
* ** Diffrence between Tasks and Promises: | |
* Once settled, a promise can not be resettled. Calling resolve() or reject() again will have no effect. The immutability of a settled promise is an important feature. | |
* https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-promise-27fc71e77261 | |
* *** First arg is for 'resolved' status, and the second is for 'rejected' | |
*/ | |
// exampe 1 | |
const myPromise = function () { | |
return new Promise((Yay, Nay) => { |
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
class Person { | |
constructor(name = 'Anonymous', age = 0) { | |
this.name = name | |
this.age = age | |
} | |
getGreeting(){ | |
return `Hi, I am ${this.name}` | |
} | |
getDescription(){ | |
return `${this.name} is ${this.age} years old` |