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
import React from 'react'; | |
import './App.css'; | |
class App extends React.Component { | |
state = {anonymousFunctions: true, count: 100}; | |
updateCount = e => { | |
this.setState({count: e.target.value}); | |
}; | |
updateAnonymous = () => { | |
this.setState({anonymousFunctions: !this.state.anonymousFunctions}); |
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
let lastFocused = []; | |
setInterval(() => { | |
const focused = document.querySelector(':focus'); | |
if (focused && lastFocused[lastFocused.length - 1] != focused) { | |
lastFocused.push(focused); | |
} | |
}, 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 handleAsManyLicenseCases(data, licenseID) { | |
const returnableLicense = { | |
allLicenses: [], | |
licenseStatement: licenseID, | |
spdx: { | |
osi: false, | |
fsf: false, | |
fsfAndOsi: false, | |
deprecated: false, | |
}, |
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 filter(list, predicate) { | |
return list.reduce((acc, item) => { | |
if (predicate(item)) { | |
acc.push(item); | |
} | |
return acc; | |
}, []); | |
} |
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 map(list, func) { | |
return list.reduce((acc, item) => { | |
acc.push(func(item)); | |
return acc; | |
}, []); | |
} |
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
[ | |
"Harry Potter", | |
"Gryffindor", | |
40, | |
"Hermione Granger", | |
"Gryffindor", | |
140, | |
"Draco Malfoy", | |
"Slytherin", | |
-20, |
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 flatMap(list, func) { | |
return list.reduce((acc, item) => { | |
const mappedItem = func(item); | |
if (Array.isArray(mappedItem)) { | |
acc = acc.concat(mappedItem); | |
} else { | |
acc.push(mappedItem); | |
} | |
return acc; | |
}, []); |
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
[ | |
{ name: "Harry Potter", house: "Gryffindor", points: 40 }, | |
{ name: "Hermione Granger", house: "Gryffindor", points: 140 }, | |
{ name: "Draco Malfoy", house: "Slytherin", points: -20 }, | |
{ name: "Lin Manuel Miranda", house: "Slytherin", points: 5000 }, | |
{ name: "Taylor Swift", house: "Slytherin", points: 100 }, | |
{ name: "Cedric Diggory", house: "Hufflepuff", points: 12 }, | |
{ name: "Sally Perks", house: "Hufflepuff", points: 15 }, | |
{ name: "Luna Lovegood", house: "Ravenclaw", points: 100 }, | |
{ name: "Cho Chang", house: "Ravenclaw", points: 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 flatten(list) { | |
return list.reduce((acc, item) => { | |
if (Array.isArray(item)) { | |
acc = acc.concat(item); | |
} else { | |
acc.push(item); | |
} | |
return acc; | |
}, []); | |
} |
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
[ | |
[ | |
{ name: "Harry Potter", house: "Gryffindor", points: 40 }, | |
{ name: "Hermione Granger", house: "Gryffindor", points: 140 }, | |
{ name: "Draco Malfoy", house: "Slytherin", points: -20 } | |
], | |
[ | |
{ name: "Lin Manuel Miranda", house: "Slytherin", points: 5000 }, | |
{ name: "Taylor Swift", house: "Slytherin", points: 100 }, | |
{ name: "Cedric Diggory", house: "Hufflepuff", points: 12 } |
NewerOlder