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, and Java), "$" (C#, C++, Ruby, Clojure, Elixir, PHP and Python, Haskell, Lua) or "„" (Rust).
This challenge comes from A.Partridge on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (10)
Here's an F# version of the function without obvious args, and really without any multiplication;
But it works...
QBasic!
Ruby:
lol, haven't used Ruby in a while so I wanted to be sure (though, now that you mention it, implicitly converting to string in interpolation makes sense :)
Clever on adding a zero!
Untested PHP attempt:
JS Quick and dirty :)
In Go.
Python:
Obtuse, but fun!
Clearly, F# doesn't pay well enough.