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
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
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
/* 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
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
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
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
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
{questions.map((question, index) => ( | |
<Card | |
key={index} | |
question={question.question} | |
answer={question.answer} | |
index={index} | |
/> | |
))} | |
{Object.keys(decks).map(key => { |
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
onPressHandle() { | |
Alert.alert( | |
'Alert Title', | |
'My Alert Msg', | |
[ | |
{ | |
text: 'Ask me later', | |
onPress: () => console.log('Ask me later pressed') | |
}, |