Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

find min and max date in array javascript

const dates = [];
dates.push(new Date('2011/06/25'));
dates.push(new Date('2011/06/26'));
dates.push(new Date('2011/06/27'));
dates.push(new Date('2011/06/28'));
const maxDate = new Date(Math.max.apply(null, dates));
const minDate = new Date(Math.min.apply(null, dates));
Comment

max and min value in array

 public static void main(String[] args) {

        int[] xr = {2, 4, 1, 3, 7, 5, 6, 10, 8, 9};

        //find maximum value
        int max = xr[0];
        for (int i = 0; i < xr.length; i++) {
            if (xr[i] > max) {
                max = xr[i];
            }
        }

        //find minimum value
        int min=xr[0];
        for (int i = 0; i <xr.length ; i++) {
            if (xr[i]<min){
                min=xr[i];
            }
        }

        System.out.println("max: "+max);
        System.out.println("min: "+min);
    }
Comment

javascript min max array

Math.max(1, 2, 3)    // 3
Math.min(1, 2, 3)    // 1

var nums = [1, 2, 3]
Math.min(...nums)    // 1
Math.max(...nums)    // 3
Comment

find max and min value in array javascript

var numbers = [1, 2, 3, 4];
Math.max(...numbers) // 4
Math.min(...numbers) // 1
Comment

how to return the max and min of an array in javascript

function minMax(arr) {
  return [Math.min(...arr), Math.max(...arr)];
}
Comment

get min/max array

function arrayMin(arr) {
  return arr.reduce(function (p, v) {
    return ( p < v ? p : v );
  });
}

function arrayMax(arr) {
  return arr.reduce(function (p, v) {
    return ( p > v ? p : v );
  });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Jquery get value of dropdown selected 
Javascript :: hide element js 
Javascript :: v-switch vuex store 
Javascript :: Adblock detection in website using javascript 
Javascript :: jquery test div exists 
Javascript :: how to set validation for email in javascript 
Javascript :: js iterate set 
Javascript :: how to loop through an object using lodash 
Javascript :: convert number to array javascript 
Javascript :: js money format br 
Javascript :: npm 
Javascript :: nuxt scroll to top 
Javascript :: mongoose.connect 
Javascript :: REMOVING EMPTY ARRAY INDEX 
Javascript :: scrollview scroll to bottom react native 
Javascript :: how to change the color using js 
Javascript :: javascript check object methods 
Javascript :: next js active nav link 
Javascript :: How to know react and react-native version 
Javascript :: javascript remove period from end of string 
Javascript :: how to simulate a keypress in javascript 
Javascript :: How to create $(document).ready() for vanilla JavaScript 
Javascript :: Form.Control textarea react bootstrap 
Javascript :: window location redirect javascript 
Javascript :: js object contain key 
Javascript :: open json file in current directory python 
Javascript :: react canvas clear 
Javascript :: express js cors 
Javascript :: scroll to bottom of div javascript 
Javascript :: knockout dump variable 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =