Tell us what’s happening:
please help i cant pass 5 & 6 tried several methods
Your code so far
function confirmEnding(str1,str2){
if(str1.includes(str2)){
return true
}else{
return false
}
}
console.log(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Build a Confirm the Ending Tool - Build a Confirm the Ending Tool
function confirmEnding(str1, str2) {
let ans = str1.trim().split(/\s+/)
if (str1.includes(str2) && ans[ans.length - 1].includes(str2)) {
return true
} else {
return false
}
}
console.log(confirmEnding("Connor", "n"))
question 5 cant pass
the test that is failing says that the confirmEnding(“Conner”, “n”)) should return false
But your function is returning true?
yh i tried different methods i dont know what to do
can you describe your algorithm to me in your own words?
(how did you plan to accomplish this task?)
i’m looking for a way to validate question 5 without affecting the others but it always interfare with the other questions
can you describe your overall algorithm? How did you hope to solve this?
i wanna know if my whole code is wrong or if am just missing a step
i understand that you want to know if your code is wrong. But before that, you should tell us what you were trying to do. (what is the algorithm)
You must have had some plan when you wrote this? Please describe it.
like if the method i’m presently using can’t lead to the correct code
in your own words, describe your method (that is called an algorithm).
Once you have described it, we can help you further.
ok when the code is =
if(str1.includes(str2){
return true else return false.
it passes a certain number and when it is
if(str2.includes(str1){}.
it pass the other remaining but i dont know how to make it pass both at once.i tried this=
if(str1.includes(str2) && str2.includes(str1)){}.
but didnt pass
function confirmEnding(str1, str2) {
let ans = str1.trim().split(/\s+/)
if (str1.includes(str2) && ans[ans.length - 1].includes(str2)) {
return true
} else {
return false
}
}
console.log(confirmEnding("Connor", "n"))
in this code i made a word count and compared the last words it passed all but number 5 bcs number 5 just wants the comparism of the last letter
i think you haven’t understood my question yet.
I’m asking you to describe your algorithm in your own words.
So here’s an example of an algorithm I wrote that describes how to check if a string has a certain letter in it.
Given a string called str and another str called char, I need to first:
loop through every character in the string
compare the current character to the one given to me in char
if the current character is the exact same as the one given to me in char I should return true (this means I found the character)
if the current character is NOT the same, then I should keep looping
eventually the loop will end when I reach the end of the string called str
at this point since the loop ended, this means I did not find the character I was looking for and I should return false.
Now that i’ve given this example, can you, in your own words, describe your algorithm?
mod edit code removed to avoid spoilers
dont bother i passed it
1 Like
hbar1st
August 11, 2025, 12:58am
17
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Get Help > Ask for Help button located on the challenge.
The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
Thank you.