Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Created August 11, 2014 12:25
Show Gist options
  • Save IQAndreas/846e56c0de9e47115d3a to your computer and use it in GitHub Desktop.
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.
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