"javascript numbers to words - vigesimal" Code Answer

2

the following function should give you an idea how to approach this:

function getnum(s){
    var n = parseint(s);

    if( 1 <= n && n <= 20 ){ alert(units[n]); }

    if( (40 <= n && n <= 99) || (120 <= n && n <= 199) ){
      var q = math.floor(n / 20);
      var r = n % 20;

      !r && (alert (units[q] + ' ' + units[20]));

      r && (alert (units[r] + ' and ' + units[q] + ' ' + units[20]));    
    }    
}

now you should be able to figure out the conversion for 100 <= number <= 119. also similar for 21 <= number <= 39.

By mvrak on May 11 2022

Answers related to “javascript numbers to words - vigesimal”

Only authorized users can answer the Search term. Please sign in first, or register a free account.