https://www.codewars.com/kata/557cd6882bfa3c8a9f0000c1
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:
You ask a small girl,"How old are you?" She always says, "x years old", where x is a random number between 0 and 9.
Write a program that returns the girl's age (0-9) as an integer.
Assume the test input string is always a valid string. For example, the test input may be "1 year old" or "5 years old". The first character in the string is always a number.
코드
function getAge(inputString){
return Number(inputString.split(' ')[0]);
}
다른 사람의 좋았던 풀이
function getAge(inputString){
return Number(inputString.split(' ')[0]);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Simple Fun #176: Reverse Letter (7 kyu) / JavaScript (0) | 2023.02.03 |
---|---|
[Codewars] Count characters in your string (6 kyu) / JavaScript (0) | 2023.02.02 |
[Codewars] Sum of the first nth term of Series (7 kyu) / JavaScript (0) | 2023.01.31 |
[Codewars] Return to Sanity (8 kyu) / JavaScript (0) | 2023.01.30 |
[Codewars] Remove anchor from URL (8 kyu) / JavaScript (0) | 2023.01.29 |
댓글