https://www.codewars.com/kata/5b853229cfde412a470000d0
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:
Your function takes two arguments:
- current father's age (years)
- current age of his son (years)
Сalculate how many years ago the father was twice as old as his son (or in how many years he will be twice as old). The answer is always greater or equal to 0, no matter if it was in the past or it is in the future.
코드
function twiceAsOld(dadYearsOld, sonYearsOld) {
return Math.abs(dadYearsOld - 2 * sonYearsOld);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Don't give me five! (7 kyu) / JavaScript (0) | 2023.04.22 |
---|---|
[Codewars] Find the stray number (7 kyu) / JavaScript (0) | 2023.04.20 |
[Codewars] Super Duper Easy (8 kyu) / JavaScript (0) | 2023.04.19 |
[Codewars] The Hashtag Generator (5 kyu) / JavaScript (0) | 2023.04.19 |
[Codewars] Consecutive strings (6 kyu) / JavaScript (0) | 2023.04.18 |
댓글