https://www.codewars.com/kata/55f9bca8ecaa9eac7100004a
Codewars - Achieve mastery through coding practice and developer mentorship
Coding practice 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:
Clock shows h hours, m minutes and s seconds after midnight.
Your task is to write a function which returns the time since midnight in milliseconds.
Example:
h = 0
m = 1
s = 1
result = 61000
Input constraints:
- 0 <= h <= 23
- 0 <= m <= 59
- 0 <= s <= 59
설명:
시계는 자정 이후 h 시간, m분, s초를 보여줍니다.
자정 이후의 시간을 밀리 초로 반환하는 함수를 작성하세요.
예시:
h = 0
m = 1
s = 1
result = 61000
입력 제한:
- 0 <= h <= 23
- 0 <= m <= 59
- 0 <= s <= 59
풀이
h, m, s를 각각 밀리 초로 바꾼 다음 더해서 반환해주었다.
코드
function past(h, m, s){
h = h * 60 * 60 * 1000;
m = m * 60 * 1000;
s = s * 1000;
return h + m + s;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Find Maximum and Minimum Values of a List (8 kyu) / JavaScript (0) | 2022.10.26 |
---|---|
[Codewars] How good are you really? (8 kyu) / JavaScript (0) | 2022.10.25 |
[Codewars] Last digit of a large number (5 kyu) / JavaScript (0) | 2022.10.23 |
[Codewars] Volume of a Cuboid (8 kyu) / JavaScript (0) | 2022.10.22 |
[Codewars] Extract the domain name from a URL (5 kyu) / JavaScript (0) | 2022.10.21 |
댓글