Skip to content

Instantly share code, notes, and snippets.

@lkLeonov
Created January 29, 2016 11:01
Show Gist options
  • Save lkLeonov/303934e2847f8f669199 to your computer and use it in GitHub Desktop.
Save lkLeonov/303934e2847f8f669199 to your computer and use it in GitHub Desktop.
function doubleNum(num) {
var
numStr = num + '',
numLen = numStr.length;
if (!(numLen%2)) {
var
first = numStr.substring(0, numLen/2),
second = numStr.substring(numLen/2);
if (first === second) return num;
else return num*2;
}
else return num*2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment