Last active
August 18, 2020 16:20
-
-
Save FBosler/23c0bd8b9e25130e4632c3be25dab614 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IN: | |
const employees = [ | |
{ | |
"name": "John Don't", | |
"performance": "medium", | |
"salary": 10000 | |
}, | |
{ | |
"name": "Jane Does", | |
"performance": "high", | |
"salary": 9000 | |
} | |
] | |
const adjust_salary = (employee) => { | |
const brackets = { | |
"high": 1.2, | |
"medium": 1.03, | |
"low": 1 | |
} | |
const factor = brackets[employee.performance] | |
const current_salary = employee.salary | |
return { | |
"name" : employee.name, | |
"performance": employee.performance, | |
"salary": current_salary * factor | |
} | |
} | |
employees.map(employee => adjust_salary(employee)) | |
OUT: | |
[ | |
{ | |
"name":"John Don't", | |
"performance":"medium", | |
"salary":10300.0 | |
}, | |
{ | |
"name":"Jane Does", | |
"performance":"high", | |
"salary":10800.0 | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment