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
fn main() { | |
println!("Meh! Hello World!"); | |
} |
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 fakeAPI = (fakeURL, fakeId) => { | |
return new Promise((res) => { | |
setTimeout(() => { | |
console.log(`Calling our ${fakeURL} with our ${fakeId}`); | |
res(); | |
}, 1250); | |
}); | |
}; |
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 withFakeAPI = (fakeURL) => (fakeId) => (e) => { | |
e.preventDefault(); | |
return new Promise((res) => { | |
setTimeout(() => { | |
console.log(`Calling our ${fakeURL} with our ${fakeId}`); | |
res(); | |
}, 1250); | |
}); | |
}; |
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 User(name, age) { | |
const getName = () => name; | |
const getAge = () => age; | |
const setName = newName => { name = newName; }; | |
const setAge = newAge => { age = newAge; }; | |
return { | |
getName, | |
getAge, | |
setName, |
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
// Closure version | |
const withFakeAPI = fakeURL => fakeId => { | |
return new Promise((res) => { | |
setTimeout(() => { | |
console.log(`Calling our ${fakeURL} with our ${fakeId}`); | |
res(); | |
}, 1250); | |
}); | |
}; |
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 firstLevel(a) { | |
return function dungeonLevel(b) { | |
return function waterLevel(c) { | |
return function bowserLevel(d) { | |
return a + b + c + d; | |
} | |
} | |
} | |
}; |
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 outerFunction(name) { | |
const myName = 'Jeff'; | |
return function innerFunction() { | |
console.log(`Nice to meet you ${name}. My name is ${myName}`); | |
} | |
} |
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 fakeAPICall = (id) => { | |
const people = [ | |
{name:'Jim Halpert', position:'Sales Person', location: 'PA', department: 'Sales'}, | |
{name:'Dwight Schrute', position:'Sales Person', location: 'PA', department: 'Sales'}, | |
{name:'Pam Beasly', position:'Office Manager', location: 'PA', department: 'HR'}, | |
{name:'Stanley Hudson', position:'Sales Person', location: 'PA', department: 'Sales'}, | |
{name:'Michael Scott', position:'Manager', location: 'PA', department: 'Management'}, | |
{name:'Karen Filipelli', position:'Sales Person', location: 'CT', department: 'Sales'}, | |
{name:'Creed Bratton', position:'QA', location: 'PA', department: 'QA'}, | |
{name:'Jo Bennett', position:'CEO', location: 'FL', department: 'Management'}, |
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 fakeAPICall = (id) => { | |
const people = [ | |
{name:'Jim Halpert', position:'Sales Person', location: 'PA', department: 'Sales'}, | |
{name:'Dwight Schrute', position:'Sales Person', location: 'PA', department: 'Sales'}, | |
{name:'Pam Beasly', position:'Office Manager', location: 'PA', department: 'HR'}, | |
{name:'Stanley Hudson', position:'Sales Person', location: 'PA', department: 'Sales'}, | |
{name:'Michael Scott', position:'Manager', location: 'PA', department: 'Management'}, | |
{name:'Karen Filipelli', position:'Sales Person', location: 'CT', department: 'Sales'}, | |
{name:'Creed Bratton', position:'QA', location: 'PA', department: 'QA'}, | |
{name:'Jo Bennett', position:'CEO', location: 'FL', department: 'Management'}, |
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 groupBy(arr, groupByKey) { | |
return arr.reduce((group, element) => { | |
const key = element[groupByKey]; | |
if (key in group) { | |
group[key].push(element); | |
} else { | |
group[key] = [element]; | |
} | |
return group; |