So, I wrote my code, manually checked all cases from the task - and even though each of them returned what it should, every single tasks was marked with an x and i simply dont know why ( i know it ‘may’ not be best quality code )
function confirmEnding(str, target) {
strArr=str.split("")
diff=strArr.length-target.length
strArr.splice(0,diff)
return target==strArr.join("")
}
confirmEnding("Bastian", "n");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
Challenge: Basic Algorithm Scripting - Confirm the Ending
Link to the challenge: