Tell us what’s happening:
Describe your issue in detail here.
i am comparing a string[index] to anotherstring[index] but it return true while it should return false
**Your code so far**
function confirmEnding(str, target) {
debugger;
let count = 0;
for(let i = target.length; i > 0; i-- ){
let st = str.length - target.length;
let t = i - target.length;
if(str[st] === target[t]); // there is a problem with this compare
console.log(`${str[st]} was equal to ${target[t]}`)
// OUTPUT: r was equal to n
// This is superConfusing
count++;
}
return count === target.length ? true : false;
}
confirmEnding("Connor", "n");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0
Challenge: Confirm the Ending
Link to the challenge: