Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
Source by thewebdev.info #
 
PREVIOUS NEXT
Tagged: #max #min #js
ADD COMMENT
Topic
Name
4+6 =