Write a javascript program that takes an array of numbers and returns the highest number.
Write a javascript program that takes an array of numbers and returns the highest number.
Student
Skilled in SEO, content writing, and digital marketing. Completed several years of working in many organizations including multinational companies. I love to learn new things in life that keep me motivated.
Certainly! You can create a JavaScript program that takes an array of numbers and returns the highest number using the Math.max function. Here's an example:
In this example, the findHighestNumber function takes an array of numbers and uses the spread operator (...) to pass the array elements as separate arguments to the Math.max function. This efficiently finds the highest number in the array.
The example usage demonstrates how to use the function with a sample array ([12, 5, 9, 27, 4, 15]). The result (the highest number) is then printed to the console.