Created
January 29, 2016 11:01
-
-
Save lkLeonov/303934e2847f8f669199 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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