Created
April 10, 2017 12:55
-
-
Save AlessioNovi/7ff9c1e7de5e50ed6430e52a22c12b07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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