Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In Firefox, press Ctrl+Shift+K then copy, paste and run.
- function extractNum(num)
- {
- var output = "";
- var length = 0;
- var numTmp = num;
- while(numTmp >= 1)
- {
- length++;
- numTmp /= 10;
- }
- for(var i = length-1; i >= 0; i--)
- {
- var ten = Math.pow(10,i);
- var cur = Math.floor(num / ten) % 10;
- if(cur > 0)
- {
- output += (i < length-1 ? "+" : "")
- + cur + (i > 0 ? "x" + ten : "");
- }
- }
- return output;
- }
- extractNum(102034);
Advertisement
Add Comment
Please, Sign In to add comment