How to Get Min Elements of an Array in Node JS?
Aug 02, 2022
Hi friends,
I am going to show you example of how to get the min elements of an array in node js. I would like to show you get min elements of an array in node js. let’s discuss about find min elements of an array in node.js. it's simple example of how to get min value in the array.
This example is how to get min elements of an array in node js. I will give you examples of get the min value from the array list. In this example get the min value using the min function from the array list.
let's see below a simple example with output:
Install Node JS
This step is not required; however, if you have not created the node js app, then you may go ahead and execute the below command:
mkdir my-app
cd my-app
npm init
index.js
//create array list
var myArray = [1, 5, 6, 2, 3];
// get min value
var minVal = Math.min.apply(null, myArray);
console.log(minVal)
Output:
1
- How to Install Node Js and NPM Ubuntu?
- How to used Google ReCaptcha V3 in Node Js Express?
- How to Send Email with Attachment in Node js?
- How to Insert Data from Form into MySQL Database using Node js Express?
- Install Node Js and NPM Ubuntu 18.04/20.04/22.04 Tutorial
- How to Delete Data by id into MongoDB in Node JS?
- Install Node.js 16/17/18 on CentOS 8 Tutorial
- How to Upload File in MongoDB using Node js Express?