KoduFCC
November 15, 2024, 12:14am
1
Tell us what’s happening:
I’m having trouble with this question. I don’t understand where to locate the .endsWith().
Your code so far
function confirmEnding(str, target) {
return str;
}
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/130.0.0.0 Safari/537.36
Challenge Information:
Basic Algorithm Scripting - Confirm the Ending
Please show us the code you have tried to write so far.
KoduFCC
November 15, 2024, 12:27am
3
Here it is:
function confirmEnding(str, target) {
if (str.endsWith(target)) {
return str;
}
}
Trying this, I get it all wrong.
Your code should not use the built-in method .endsWith()
to solve the challenge.
You can’t use .endsWith()
. You need to mimic the behavior of .endsWith()
.
KoduFCC
November 15, 2024, 12:35am
5
Oh, I should’ve read the instructions. But could you please give me some hints?
What does endsWith()
do? You need to code that
How do you return the last char of a string?
KoduFCC
November 15, 2024, 11:13pm
7
endsWith() checks if a string ends with a specified sequence of characters - returns true if this requirement is met, returns false otherwise. Bracket notation is another way of returning a string.
These are question you need to answer for yourself, not for me, it’s not a test or anything.
Are you able to code that now? Please let us know if you have any questions.