Forked from anonymous/bonfire-confirm-the-ending?solution=function%20end(str%2C%20target)%20%7B%0A%20%20%2F%2F%20%22Never%20give%20up%20and%20good%20luck%20will%20find%20you.%22%0A%20%20%2F%2F%20--%20Falcor%0A%0A%20%0A%20%20var%20length%20%3D%20target.length%3B%0A%20%20va
Last active
November 26, 2015 01:33
-
-
Save twhite96/93a3a6e615cf9d8e4409 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/twhite96 's solution for Bonfire: Confirm the Ending
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: @twhite96 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending?solution=function%20end(str%2C%20target)%20%7B%0A%20%20%2F%2F%20%22Never%20give%20up%20and%20good%20luck%20will%20find%20you.%22%0A%20%20%2F%2F%20--%20Falcor%0A%0A%20%0A%20%20var%20length%20%3D%20target.length%3B%0A%20%20var%20isEqual%20%3D%20target%20%3D%3D%3D%20str.substr(-length)%3B%0A%20%20%20return%20isEqual%3B%0A%20%20%20%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) { | |
// "Never give up and good luck will find you." | |
// -- Falcor | |
var length = target.length; | |
var isEqual = target === str.substr(-length); | |
return isEqual; | |
} | |
end("Bastian", "n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment