-
Notifications
You must be signed in to change notification settings - Fork 0
/
do-i-get-a-bonus.js
31 lines (22 loc) · 1.17 KB
/
do-i-get-a-bonus.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
// Do I get a bonus?
/*
It's bonus time in the big city! The fatcats are rubbing their paws in anticipation... but who is going to make the most money?
Build a function that takes in two arguments (salary, bonus). Salary will be an integer, and bonus a boolean.
If bonus is true, the salary should be multiplied by 10. If bonus is false, the fatcat did not make enough money and must receive only his stated salary.
Return the total figure the individual will receive as a string prefixed with "£" (= "\u00A3", JS, Go, Java, Scala, and Julia), "$" (C#, C++, Ruby, Clojure, Elixir, PHP, Python, Haskell, and Lua) or "¥" (Rust).
*/
// input -> salary (integer) & bonus (boolean)
// return -> if bonus true: return salary * 10 as string
// -> if bonus false: return normal salary as string
// return value needs an "£" added to string
// function bonusTime(salary, bonus) {
// if(bonus === true){
// return `£${salary*10}`
// }else{
// return `£${salary}`
// }
// };
const bonusTime = (salary, bonus) => bonus === false ? `£${salary}` : `£${salary * 10}`
console.log(bonusTime(120000, false)) // "£120000"
console.log(bonusTime(5000, true)) // "£50000"
// tests pass