I’m missing just one thing that is how can I add that the test should target the last letter
and the whole last word and the last part of the last word all together I have just one last test to finish this challenge.
(please guide me) thanks
function confirmEnding(str, target) {
// pushing the last word into lastWord
let lastWord = [];
let letters = str.split(" ");
lastWord.push(letters[letters.length - 1]);
//making the regexp
let reg = RegExp((target));
let result = reg.test(lastWord);
if (result) {
return true;
} return false;
}
confirmEnding("Connor", "n") // it should be false am getting true
ok one last thing just tell me should i be looping and pushing letters then check it or like poping more than one letter or I should be slicing or splicing the last word by the length of the target parameter
Whichever you prefer! You could use a loop to build up the string you’ll use to check, or you could use slice (or other string methods) to do the same, or you could find some way to append $ to the regular expression you were trying above.