String StartsWith and EndsWith in JavaScript
The following are a simple implementation checking whether a string starts with a prefix or ends with a suffix in JavaScript. Here we use indexOf() method of JavaScript String object. Syntax: string.indexOf(search, start) Parameters: search is the string to search …