var cost 157 98 54 var size 15 25 var max cost size var min cost size

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var cost = [157,98,54];
var size = [15, 25, 8];
// =======================================================================
var max = [cost[0], size[0]]
var min = [cost[0], size[0]]
var sum = [0, 0]
for (i = 0; i < cost.length; i++){
if (cost[i] > max[0]){
max[0] = cost[i];
}
if (cost[i] < min[0]){
min[0] = cost[i]
}
sum[0] += cost[i]
if (size[i] > max[1]){
max[1] = size[i];
}
if (size[i] < min[1]){
min[1] = size[i]
}
sum[1] += size[i]
}
var middle = [sum[0] - (min[0] + max[0]), sum[1] - (min[1] + max[1])];
console.log(max);
console.log(middle);
console.log(min);
console.log(max[0] * max[1], middle[0] * middle[1], min[0] * min[1]);
// =======================================================================
var max = 0;
for (var i = 0; i < cost.length; i++) {
for (var j = i; j < size.length; j++) {
if (cost[i] * size[j] > max) {
max = cost[i] * size[j];
}
}
}
console.log(max);