Suggestng my solution

Hi there! Don’t really know if I am the first to suggest this, but I still want to provide my solution for Challenge Guide: Confirm the Ending.

Here I am using the .substring(indexA, indexB) method for String. It returns character values starting from indexA and ending on indexB (exclusive). Or if indexB is not provided, than it will return all values starting from indexA.

function confirmEnding(str, target) {

  return str.substring(str.length - target.length) === target;

}
1 Like
function confirmEnding(str, target) {
    let tarLength = target.length;
    let newStr = str.substring(str.length - tarLength);
    if(target == newStr){
        return true
    }else{
        return false
    }
}

confirmEnding("Bastian", "n");
1 Like