Confirm the ending code

Tell us what’s happening:
Describe your issue in detail here.
what am i missing here?

  **Your code so far**

function confirmEnding(str, target) {
let string = str.split("")
for (let i = 0; i <= string.length; i++){
if (string[i] === target){
  return true
} return false
}
}

console.log(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/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32

Challenge: Confirm the Ending

Link to the challenge:

Remember that when a return statement executes, this exits the function. If you have a loop, putting a return statement inside the loop will prevent the loop from continuing.

1 Like

Hey there :wave::slightly_smiling_face:

To add to the above. The lesson asks you to find if a given string ends with a target value.
What does you current code return if you give it say:

confirmEnding('negative', 'n')
1 Like

true. im currently working on it