Created
March 27, 2019 13:45
-
-
Save Chuloo/0d1de6464f68984f5d06f6a0a5b1f833 to your computer and use it in GitHub Desktop.
Last similar name
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
// List of names | |
const names = "sean, becky, liz, wale, blue, becky, john" | |
const searchItem = "becky" | |
// Find last occurrence of "becky" | |
const lastSimilarName = names.lastIndexOf(searchItem) | |
// Display result | |
console.log(lastSimilarName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment