i wanted to confirm the existence of the target at the end of the string using decremented For loop :
function confirmEnding(str, target) {
let x = target.length - 1;
for(let i = str.length-1 ; i >= 0; i--){
while(x >= 0){
if(str[i] === target[x]){
x--;
}else{
return false;
}
return true;
}
}
}
confirmEnding("Bastian", "n");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Challenge: Basic Algorithm Scripting - Confirm the Ending
Link to the challenge: