Created
December 1, 2015 07:03
-
-
Save SerhiiLihus/8901fc273dc39f8a39e9 to your computer and use it in GitHub Desktop.
Matches the end of the string with target string
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
// Bonfire: Confirm the Ending | |
// Author: @serhiilihus | |
// http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending?solution=function%20end(str%2C%20target)%20%7B%0A%20%20return%20(str.substr(str.length%20-%20target.length%2C%20str.length)%20%3D%3D%3D%20target%20)%3F%20true%20%3A%20false%20%3B%0A%7D%0A%0Aend(%22Bastian%22%2C%20%22n%22)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function end(str, target) { | |
return (str.substr(str.length - target.length, str.length) === target )? true : false ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment