Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

min and max javascript

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

min max value javascript

function lowest(arr) {
    let min = Number.MAX_VALUE
    for (let i = 0; i < arr.length; i++) {
        let mean = 0
        for (let j = 0; j < arr[i].length; j++) {
            mean += arr[i][j]
        }
        mean /= arr[i].length
        if (min > mean) {
            min = mean
        }
    }
    return min
}
Comment

max value and min value using js "Math"

const myArray = [{
  id: 1,
  cost: 200
}, {
  id: 2,
  cost: 1000
}, {
  id: 3,
  cost: 50
}, {
  id: 4,
  cost: 500
}]
const min = Math.min(...myArray.map(item => item.cost))
const max = Math.max(...myArray.map(item => item.cost));

console.log(min);
console.log(max);
Comment

PREVIOUS NEXT
Code Example
Javascript :: node.js name of file 
Javascript :: request entity too large express 
Javascript :: javascript array filter 
Javascript :: js join array 
Javascript :: add 2 for hours in date timestamp js 
Javascript :: react 360 
Javascript :: send mail in node js without password 
Javascript :: find common characters in two strings javascript 
Javascript :: Environment key "jest/globals" is unknown 
Javascript :: first N elements of an array javascript 
Javascript :: vercel rewrites 
Javascript :: jquery filter data 
Javascript :: this.setstate is not a function 
Javascript :: mdn clonenode 
Javascript :: momentjs 
Javascript :: find text in label jquery 
Javascript :: Check for a Null or Empty String in JavaScript 
Javascript :: conditional jsx property 
Javascript :: javascript foreach url parameter 
Javascript :: create document mongoose 
Javascript :: Is date greater than 18 years old javascript 
Javascript :: get selector with specific text puppeteer 
Javascript :: how to capitalize the first letter of a word in javascript 
Javascript :: socket io query 
Javascript :: mongoose connect to atlas 
Javascript :: javascript add an element to an array 
Javascript :: Error: ENOENT: no such file or directory, mkdir 
Javascript :: datatable index column server side 
Javascript :: javascript regex named capture group 
Javascript :: javascipt delay 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =