본문 바로가기
알고리즘/Codewars

[Codewars] Do I get a bonus? (8 kyu) / JavaScript

by fluss 2023. 2. 16.

https://www.codewars.com/kata/56f6ad906b88de513f000d96

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

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).

 

코드

function bonusTime(salary, bonus) {
 return bonus ? '£' + salary * 10 : '£' + salary;
}

댓글