I’ve noticed one of the coding questions seems to be a little too easy to pass and I believe it could be fixed with a simple additional question.
consider this code
function confirmEnding(str, target) {
for (let i = target.length, j = 0; i > 0; i--, j++) {
if (str[str.length-i] == target[j]) {
return true;
} else {
return false;
}
}
}
// an actual test
confirmEnding("Open sesame", "same");
This code will pass all the tests provided, even though, when the target is changed to for example “sage” it returns
true
true
false
true
I think a test should be added with some incorrect middle letters such as
confirmEnding("Open sesame", "sage");
testing if each individual letter is correct.
Let me know what you think or if I’m being silly!