Potwierdź końcowe-javascript
function confirmEnding(str, target) {
return str.slice(-target.length) === target
}
confirmEnding("Bastian", "n");
Angry Alpaca
function confirmEnding(str, target) {
return str.slice(-target.length) === target
}
confirmEnding("Bastian", "n");
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
let re = new RegExp(target + "$", "i");
return re.test(str);
}
console.log(confirmEnding("Bastian", "n"));