1
2//For Values
3var arr =[1,10,3]
4var min = Math.min.apply(null, arr),
5 max = Math.max.apply(null, arr);
6
7//For Objects
8var arr = [{a: 1},{a: 10},{a: 3}]
9var values = arr.map(val => val.a);
10var max = Math.max.apply(null, values);
11console.log(max)
12
1var array = [3 , 6, 2, 56, 32, 5, 89, 32];
2var largest= 0;
3
4for (i=0; i<=largest;i++){
5 if (array[i]>largest) {
6 var largest=array[i];
7 }
8}
9
10
11
12
13console.log(largest);
1var peopleData = [
2 { name: "Paul", height: 180, age: 21 },
3 { name: "Johnny", height: 198, age: 43 },
4 { name: "Brad", height: 172, age: 49 },
5 { name: "Dwayne", height: 166, age: 15 }
6];
7
8//Find biggest height number
9var maxHeight = 0;
10
11for (var i = 0; i < heights.length; i++) {
12 if (peopleData[i].height > maxHeight) {
13 maxHeight = peopleData[i].height;
14 //if you console.log(maxHeight); you should get 198
15 }
16}
1//get min/max value of arrays
2function getArrayMax(array){
3 return Math.max.apply(null, array);
4}
5function getArrayMin(array){
6 return Math.min.apply(null, array);
7}
8var ages=[11, 54, 32, 92];
9var maxAge=getArrayMax(ages); //92
10var minAge=getArrayMin(ages); //11
1function findHighestNumber(nums) {
2
3 let inputs = nums.filter((val, i) => nums.indexOf(val) === i)
4 let max = Math.max(...nums);
5 let min = Math.min(...nums);
6
7 return max + (-min);
8}
9
10console.log(difference([1, 7, 18, -1, -2, 9]));