Home / Javascript Tips Generated By ChatGPT / Using String.startsWith and String.endsWith in Javascript Check if a string starts or ends with a specific substring. Source Code let text = 'Hello, world!'; console.log(text.startsWith('Hello'), text.endsWith('world!'));