
문자열이 특정 문자열, 문자로 시작하는지 확인하는 메소드
true, 일치하지 않으면 false를 반환한다.const str = "Hello"
const item1 = "Hel"
const item2 = "He"
const item3 = "Lee"
console.log(str.startsWith(item1)); // true
console.log(str.startsWith(item2)); // true
console.log(str.startsWith(item3)); // false
문자열이 특정 문자열, 문자로 끝나는지 확인하는 메소드
true, 일치하지 않으면 false를 반환한다.const str = "Hello"
const item1 = "Hel"
const item2 = "llo"
console.log(str.endsWith(item1)); // false
console.log(str.endsWith(item2)); // true
const my_string = "banana";
const is_suffix = "nan";
function solution(my_string, is_suffix) {
return my_string.endsWith(is_suffix) ? 1 : 0;
}