Check if a string starts with another string - Javascript:
//function to check if a string starts with another string
function checkString(str, start) {
// return true if the string starts with the start string
return str.startsWith(start);
}
//example
const result = checkString("Hello World", "Hello");
//output
console.log(result); //true
Top comments (0)