How to get the min and max values in an object with JavaScript

1 Answer

0 votes
const obj = {
  code1: 5,
  code2: 4,
  code3: 9,
  code4: 7,
  code5: 3
};

const values = Object.values(obj);

const max = Math.max(...values);
console.log(max);

const min = Math.min(...values);
console.log(min);

  
  
  
  
/*
run:
  
9
3
  
*/

 



answered Jul 9, 2022 by avibootz

Related questions

1 answer 136 views
1 answer 159 views
1 answer 152 views
1 answer 173 views
1 answer 112 views
1 answer 140 views
...