---
title: "Write a javascript program that takes an array of numbers and returns the highest number."  
description: "Write a javascript program that takes an array of numbers and returns the highest number."  
author: "Revati S Misra"  
published: 2023-04-14  
updated: 2023-11-26  
canonical: https://www.mindstick.com/forum/157801/write-a-javascript-program-that-takes-an-array-of-numbers-and-returns-the-highest-number  
category: "javascript"  
tags: ["javascript", "array"]  
reading_time: 1 minute  

---

# Write a javascript program that takes an array of numbers and returns the highest number.

Write a [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) [program that takes](https://www.mindstick.com/forum/157802/write-a-javascript-program-that-takes-a-string-and-returns-the-longest-word-length) an [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) of numbers and returns the highest number.

## Replies

### Reply by Aryan Kumar

Certainly! You can create a JavaScript [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) that takes an array of numbers and returns the highest number using the **Math.max** function. Here's an example:

```plaintext
function findHighestNumber(numbers) {
  // Use Math.max to find the highest number in the array
  const highestNumber = Math.max(...numbers);

  return highestNumber;
}

// Example usage:
const numberArray = [12, 5, 9, 27, 4, 15];
const result = findHighestNumber(numberArray);

console.log(result); // Outputs: 27
```

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.


---

Original Source: https://www.mindstick.com/forum/157801/write-a-javascript-program-that-takes-an-array-of-numbers-and-returns-the-highest-number

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
