1 2 3 4 5 6 7
var x = 12345; var left = Math.floor(x/10); var rigth = x%10; while (left >= 0){ left = Math,floor(rigth/10); right = left%10; }