javascript word start with
snippet in javascript

javascript word start with

user7798

const str = "Saturday night plans";
const res = str.startsWith("Sat");
console.log(res); //> true

javascript string starts with

user9901

//checks if a string starts with a word
function startsWith(str, word) {
    return str.lastIndexOf(word, 0) === 0;
}
startsWith("Welcome to earth.","Welcome"); //true