Created
March 9, 2017 12:15
-
-
Save exts/6b46f8dcdfa2791e22df7653abcf9cc6 to your computer and use it in GitHub Desktop.
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 say(a) | |
{ | |
splitUp = function(data) { | |
dataArray = data.split("") | |
stringArray = []; | |
for(x = 0; x < dataArray.length; x++) { | |
if(dataArray[x].match(/[a-zA-Z0-9]/)) { | |
stringArray[stringArray.length++] = dataArray[x]; | |
} | |
} | |
return stringArray.join("-"); | |
} | |
return function(b) | |
{ | |
return splitUp(a) + " " + splitUp(b) | |
} | |
} | |
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