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
## Problem A - WHAT!?!?! | |
Many of us who have worked in the office, miss it. We miss hanging out with our friends, we miss the energy and sometimes we even miss the loud music. | |
Remember the dubstep Christmas carols playlist? It was awesome! | |
Write a function called what which will decipher the conversation from the loud music. | |
Input | |
The input will consist of a single string of words, punctuated by WUBs. There are 0 or more WUBs at the start and at the end. There will be 1 or more WUBs between each word. |
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
/** | |
* A demonstration of building a Type Class in JavaScript with a custom DataType. | |
* | |
* This is a simple container that has three defined properties. | |
* The type methods are functional, mutating none of it's contents. | |
*/ | |
const typeGuard = (ExpectedType, data) => { | |
if (!ExpectedType) { | |
throw new ReferenceError('Expected a Type as first argument'); |
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
/** | |
* Semigroup | |
* | |
* A Semigroup must have a concat method. | |
* Just like JS Array and String | |
* | |
* It simply takes 2 of the same datatype, concats them and returns that same datatype | |
* | |
* The type signature for the concat method: | |
* concat :: Semigroup a => a ~> a -> a |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 register = async params => { | |
const verifyParams = await verify(params); | |
const passwordMatch = await passwordCheck(params); | |
const user = await createUser(params); | |
return { verifyParams, passwordMatch, user }; | |
}; | |
register({ | |
username: 'moosch', | |
password: 'terryfolds', |
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 register = async params => { | |
let verifyParams; | |
try { | |
verifyParams = await verify(params); | |
} catch(error) { | |
throw new Error(error); | |
} | |
let passwordMatch; | |
try { |
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 register = params => { | |
return verify(params) | |
.then(() => { | |
return passwordMatch(params) | |
.then(() => { | |
return createUser(params) | |
.then(user => { | |
// Awesome! | |
return user; | |
}) |
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 verify = params => { | |
return new Promise((resolve, reject) => { | |
const { username, password, confPassword } = params; | |
if (!username || !password || !confPassword) { | |
reject('Invalid params'); | |
} | |
resolve({ username, password, confPassword }); | |
}); | |
} |
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 getUser = id => { | |
// Database call (with mongoose in this example) | |
return User.findOne({ id }); | |
}; | |
getUser(‘xyz’) | |
.then(user => { | |
// Yay! I got my user | |
}) | |
.catch(error => { |
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 getUser = id => { | |
return new Promise((resolve, reject) => { | |
// Some kind of find, but not truely async | |
const user = { | |
id: 'xyz', | |
name: 'Hellboy', | |
}; | |
if (id === user.id) { | |
resolve(user); | |
} |