forked from orangecapinnovative/job-quest-intern-2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.js
32 lines (28 loc) · 798 Bytes
/
2.js
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
let hero = require('./hero.json');
let total = 0;
let intHero = 0;
let intHeroLevel = 0;
let mostAssist = "";
let cAssist = 0;
let worstRatio = "";
let cRatio = 1000;
for(let i=0;i<hero.length;i++){
let chero = hero[i];
total += chero.networth;
if(chero.primary_attribute === "intelligent"){
intHero++;
intHeroLevel += chero.level;
}
if(chero.assist > cAssist){
cAssist = chero.assist;
mostAssist = chero.name;
}
if(chero.death > 0 && chero.kill/chero.death < cRatio){
cRatio = chero.kill/chero.death;
worstRatio = chero.name;
}
}
console.log("Average networth : "+total/hero.length);
console.log("Average level of intelligent hero : "+intHeroLevel/intHero);
console.log("Most assist : "+mostAssist);
console.log("Worst kill/death ratio : "+worstRatio);