Skip to content

Instantly share code, notes, and snippets.

@AlessioNovi
Created April 10, 2017 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlessioNovi/7ff9c1e7de5e50ed6430e52a22c12b07 to your computer and use it in GitHub Desktop.
Save AlessioNovi/7ff9c1e7de5e50ed6430e52a22c12b07 to your computer and use it in GitHub Desktop.
function confirmEnding(str, target) {
var Newtarget = target.substring(-1);
var newString = str.substr(-1); // if i input str.substr(-1 -3); it will pass this test but fails the first one as expected
if (Newtarget.length > 1 ) { //OMG is this cheating the FCC test??
newString = str.substr(-1 -3);
}
if (newString == Newtarget) {
return true;
}
return false;
}
confirmEnding("Open sesame", "same");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment