Hi, I’m struggling to find a way to explicitly determine what the end of str1 is, which is leading my output to return true on “connor”, simply because it contains the letter “n”. I know it should return false as the last letters aren’t identical.
I’ve tried lastIndexOf(), slice(), indexOf() and substring(), all of which create some of the solution but don’t compare the exact string.
I’d like to somehow compare the last letters of the string dynamically.
It doesn’t work because there’s nothing in it to check whether str1 and str2 are identically formatted rather than just whether they include the same letters.
Okay then… To check whether the phrase you have written down, matches the end of my phrase I gave you. You need to look carefully at the letters of the end of the phrase, to see if they match yours.
in the email checker lab using indexOf(“@”) worked, but this won’t apply as the string could be anything and any length. So how can you determine whether something is both there and in the right order?
It’s piecing it together that I’m finding tricky. So I now know how to find the string length, but if I then check if they’re both equal, it will say no if the string length isn’t the same
Yes, using slice. Thanks, I now know what to do. Select str1, but only the amount of str2.length (from the end of the string). Then compare that with str2.
I just need to figure out how to do it as the behaiviour with .length and .slice seems a little quirky. Thank you for you help