Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function zmenFormat(cislo){
  2.         if (cislo == "-") return "-";
  3.         if (!isNaN(cislo)) {
  4.             var moje_cislo = cislo.replaceAll(" ","");
  5.             var index = (moje_cislo.indexOf(".")==-1) ? (moje_cislo.length-1) : (moje_cislo.indexOf(".")-1);
  6.             var pocitadlo = 1;
  7.             while (index>0){
  8.                 if (pocitadlo%3==0){
  9.                     moje_cislo = moje_cislo.substr(0,index)+" "+moje_cislo.substr(index);
  10.                 }
  11.                 pocitadlo += 1;
  12.                 index -= 1;
  13.             }
  14.             return moje_cislo;
  15.         }
  16.         return cislo;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement