var biggestSalary function obj var max var for var key in obj obj key

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
var biggestSalary = function(obj) {
var max;
var b = 0;
for (var key in obj) {
(obj[key] > b) ? max = key : max;
b = obj[key];
}
return (max == undefined) ? 'нет сотрудников' : max;
};
var salaries = {
"Вася": 100,
"Петя": 300,
"Даша": 250
};
alert(biggestSalary(salaries));