Last active
April 29, 2016 09:03
-
-
Save davidsm/f4f4634b1ce249198b9bd9b3812c53f3 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 counterstring(length) { | |
var curNum = length; | |
var outLen = 0; | |
var numbers = []; | |
var curStr; | |
while (outLen < length) { | |
curStr = curNum.toString() + "*"; | |
curNum -= curStr.length; | |
if (outLen + curStr.length <= length) { | |
numbers.push(curStr); | |
outLen += curStr.length; | |
} | |
else { | |
numbers.push("*"); | |
break; | |
} | |
} | |
return numbers.reverse().join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment