Tell us what’s happening:
I know from the solutions that it can be solved with slice method. But here, my code is true. I wonder why it didn’t pass the test. Could someone explain me how it happened?
**Your code so far**
function confirmEnding(str, target) {
let a = str;
let b = target;
console.log(a);
console.log(b);
let c = a.substring(a.length - b.length);
console.log(c);
return a === c;
}
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification");
console.log("____________________________");
confirmEnding("Congratulation", "on");
console.log("____________________________");
confirmEnding("He has to give me a new name", "name");
console.log("____________________________");
confirmEnding("Open sesame", "same");
console.log("____________________________");
confirmEnding("Abstraction", "action");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
.
Challenge: Confirm the Ending
Link to the challenge: