https://www.codewars.com/kata/568d0dd208ee69389d000016
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:
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you.
You will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some good offers.
Every day you rent the car costs $40. If you rent the car for 7 or more days, you get $50 off your total. Alternatively, if you rent the car for 3 or more days, you get $20 off your total.
Write a code that gives out the total amount for different days(d).
코드
function rentalCarCost(d) {
let total = d * 40;
return d >= 7 ? total - 50 : d >= 3 ? total - 20 : total;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Rot13 (5 kyu) / JavaScript (0) | 2023.02.12 |
---|---|
[Codewars] Area or Perimeter (8 kyu) / JavaScript (0) | 2023.02.11 |
[Codewars] Write Number in Expanded Form (6 kyu) / JavaScript (0) | 2023.02.09 |
[Codewars] Testing 1-2-3 (7 kyu) / JavaScript (0) | 2023.02.08 |
[Codewars] The highest profit wins! (7 kyu) / JavaScript (0) | 2023.02.07 |
댓글