Wednesday, 15 July 2015

How to get the maximum number from a series digits in Javascript


This is a simple function that returns the highest number in a series of numbers.

  function max_series(x)
  {
      h=0;
      for(i=0; i= h)
          {
              h=arguments[i];
          }
          
      }
      return h;
  }



A simple way to use the function would be:

  
var maximum = max_series(2,3,4,5,5.5);
alert(maximum); //alerts 5.5



No comments:

Post a Comment