🎁 Join my channel to get access to perks:
In today’s video, you’re going to learn about two string methods, indexOf and lastIndexOf, and know the difference between them.
indexOf is used to get the index of the first occurrence of a searched string in a given string, and lastIndexOf is used to get the index of the last occurrence of the searched string.
const str = “The code is not working, the code is buggy.”;
console.log(str.indexOf(“code”)); // logs : 4
console.log(str.lastIndexOf(“code”)); // logs : 30
Both indexOf and lastIndexOf take in a second parameter called position, and it’s simply the index you want to start the search for your “search string”.
🌍 Social Media Links.
◾ Facebook : https://www.facebook.com/Code.Explained.Official
◾ Twitter : https://twitter.com/code_explained
◾ Instagram : https://www.instagram.com/Code.Explained.Official/
◾ GitHub : https://github.com/CodeExplainedRepo
💲 Suppport the Channel
Paypal : https://paypal.me/CodeExplained
Buy Me a Coffee: https://www.buymeacoffee.com/CodeExplained