Build a Confirm the Ending Tool - Build a Confirm the Ending Tool

Tell us what’s happening:

Please take a look, I am getting all the correct true / false to return… However, I can’t get the lab to pass… am I missing something obvious?

Your code so far

function confirmEnding(str, target) {
    var strEnd = str.substr(-target.length);
    if (strEnd === target) {
        return "true";
    } else {
        return "false";
    }
}

console.log(confirmEnding("Bastian", "n"));
console.log(confirmEnding("Congratulation", "on"));
console.log(confirmEnding("Connor", "n"));
console.log(confirmEnding("Walking on water and developing software from a specification are easy if you both are frozen", "specification"));
console.log(confirmEnding("He has to give me a new name", "name"));
console.log(confirmEnding("Open sesame", "same"));
console.log(confirmEnding("Open sesame", "sage"));
console.log(confirmEnding("Open sesame", "game"));
console.log(confirmEnding("If you want to save our world, you must hurry. We don't know how much longer we can withstand the nothing", "mountain"));
console.log(confirmEnding("Abstraction", "action"));


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Challenge Information:

Build a Confirm the Ending Tool - Build a Confirm the Ending Tool

hello and welcome to fcc forum :slight_smile:

  • are you returning boolean or string?

happy coding :slight_smile:

Fixed and passed, thank you

1 Like