Created
August 11, 2014 12:25
-
-
Save IQAndreas/846e56c0de9e47115d3a to your computer and use it in GitHub Desktop.
The "Look and Say Sequence" as if it were written by a regular JavaScript developer.
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 lookAndSay(num) { | |
// TODO: Needs more JQuery | |
return num.toString().replace(/(1+|2+|3+)/g, function(match) { return match.length.toString() + match.substring(0, 1); }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment