Jump to content

thundermoth

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by thundermoth

  1. <script>
    function myFunction() {
      var a = Math.min(5, 10);
      var b = Math.min(0, 150, 30, 20, 38);
      var c = Math.min(-5, 10);
      var d = Math.min(-5, -10);
      var e = Math.min(1.5, 2.5);

      var x = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e;
      document.getElementById("demo").innerHTML = x;
    }
    </script>

    What about adding something like one of the follow examples to show how to use the spread operator on an array with Math.min?

    var myArray = [0, 150, 30, 20, 38];

    var f = Math.min(...myArray);

    or

    var f = [a, b, c, d, e];
    var g = Math.min(...f);

×
×
  • Create New...