https://www.codewars.com/kata/51f2d1cafc9c0f745c00037d
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:
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
solution('abc', 'bc') // returns true
solution('abc', 'd') // returns false
코드
function solution(str, ending){
const end = str.slice(str.length - ending.length);
if(end === ending) return true;
return false;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] A Needle in the Haystack (8 kyu) / JavaScript (0) | 2023.01.04 |
---|---|
[Codewars] Beginner - Lost Without a Map(8 kyu) / JavaScript (0) | 2023.01.03 |
[Codewars] Moving Zeros To The End (5 kyu) / JavaScript (0) | 2022.12.31 |
[Codewars] Is n divisible by x and y? (8 kyu) / JavaScript (0) | 2022.12.30 |
[Codewars] Keep Hydrated! (8 kyu) / JavaScript (0) | 2022.12.29 |
댓글