<HTML>
<body>
</body>
<Script>
let salaries = {
"John": 100,
"Pete": 300,
"Mary": 250
};
function topSalary(obj){
let max = 0;
let maxName = null;
for(const [name, sal] of Object.entries(obj)){
if(max < sal){
max = sal;
maxName = name;
}
}
return maxName;
}
alert(topSalary(salaries));
</Script>
</HTML>
<!--
{
if(Object.getOwnPropertyNames(obj).length == 0){
return null;
}
else{
let top = {
name : "",
sal : 0
};
for(let [key, value] of Object.entries(obj)){
if(value > top.sal){
top.name = key;
top.sal = value;
}
}
return top.name;
}
}
//its frustrating regardless of how proud I was, the solution one is better and fancier lol
-->
<body>
</body>
<Script>
let salaries = {
"John": 100,
"Pete": 300,
"Mary": 250
};
function topSalary(obj){
let max = 0;
let maxName = null;
for(const [name, sal] of Object.entries(obj)){
if(max < sal){
max = sal;
maxName = name;
}
}
return maxName;
}
alert(topSalary(salaries));
</Script>
</HTML>
<!--
{
if(Object.getOwnPropertyNames(obj).length == 0){
return null;
}
else{
let top = {
name : "",
sal : 0
};
for(let [key, value] of Object.entries(obj)){
if(value > top.sal){
top.name = key;
top.sal = value;
}
}
return top.name;
}
}
//its frustrating regardless of how proud I was, the solution one is better and fancier lol
-->
댓글
댓글 쓰기