Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

find min value in array javascript

// find mimimum value of array in javascript
// array reduce method
const arr = [49,2,71,5,38,96];
const min = arr.reduce((a, b) => Math.min(a, b));
console.log(min); // 2

// math.min apply method
const min_ = Math.min.apply(null, arr);
console.log(min_); // 2

// or math.min spread operator method
const min__ = Math.min(...arr);
console.log(min__); // 2
Comment

min of an array javascript

const arr = [10, 5, 0, 15, 30];

const min = Math.min.apply(null, arr);

const index = arr.indexOf(min); // get the index of the min in the array
console.log(index); //  2
Comment

js min number in array

var min = Math.min.apply(null, arr),
    max = Math.max.apply(null, arr);
Comment

js to find min value in an array

(function () {
  const arr = [23, 65, 3, 19, 42, 74, 56, -42, 8, 88];
  // const arr = [];

  function findMinValue(arr) {
    if (arr.length) {
      let min = Infinity;

      for (let num of arr) {
        min = num < min ? num : min;
      }

      return min;
    }
    return 0; // or anything what you need
  }

  console.log(findMinValue(arr)); // => -42
})();
Comment

min in array

int min=0;
for(int i=0;i<array.length;i++)
{
	if(array[i] < min)
    	min = array[i]
}
return min;
Comment

PREVIOUS NEXT
Code Example
Javascript :: html get color gradient percentage 
Javascript :: python best practices example 
Javascript :: where to create service angularor nodejs 
Javascript :: how to sort one element in property javascript 
Javascript :: javascript get last element in array 
Javascript :: currying function callback javascript 
Javascript :: how does an if statement work 
Javascript :: how to name a file path in document.geteleementbyid 
Javascript :: npm passport-instagram 
Javascript :: Argument #1 ($client) must be of type AwsS3Client 
Javascript :: check if string javascript 
Javascript :: how to get font size in javascript 
Javascript :: Detect Mobile / Computer by Javascript 
Javascript :: window viewport width 
Javascript :: component navigation without changin the url react router 
Javascript :: var y=5 
Javascript :: mongoose model and joi validation 
Javascript :: how to tell this x = 12 + 30 when i read it in js 
Javascript :: vuejs cordoba pantalla en blanco 
Javascript :: use recoil oitside 
Python :: no module psycopg2 
Python :: pytorch check if using gpu 
Python :: how to iterate through files in a folder python 
Python :: pandas convert string from INT TO str 
Python :: python 1 second delay 
Python :: rename columns in python 
Python :: how to check python version 
Python :: Pandas: How to Drop Rows that Contain a Specific String 
Python :: set recursion limit python 
Python :: get current site django 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =