Question:

Write a function called biggestArg() that takes a variable number of integer arguments and returns the largest integer. biggestArg(1, 3, 33, 4) should return 33.

Answer:

function biggestArg () {
  return Math.max.apply(Math, arguments)
}

We don't need to use Math as the first argument for the apply() function, but it makes the code more readable. This code would also work:

Math.max.apply("", arguments)

Keywords:

© 2017 QuizBucket.org