Skip to content

Instantly share code, notes, and snippets.

@nickbclifford nickbclifford/dominos.js
Last active Feb 18, 2017

Embed
What would you like to do?
Domino's Pizza JavaScript challenge
function say(firstStr) {
// gotta love currying!
return function(secondStr) {
function hyphenSeparate(str) {
return str.replace(/[.,'"?!]/g, '') // remove punctuation
.split('') // split into array of chars
.reduce((a, v) => a + '-' + v); // concatenate with hyphens in between
}
return hyphenSeparate(firstStr) + ' ' + hyphenSeparate(secondStr);
}
}
console.log(say('Domino\'s')('Pizza') === 'D-o-m-i-n-o-s P-i-z-z-a');
console.log(say('Front')('End!') === 'F-r-o-n-t E-n-d');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.