<!DOCTYPE html> <html> <body> <h1>Welcome to Working code</h1> <h2>The startsWith() Method</h2> <p>startsWith() returns true if a string starts with a specified string:</p> <p id="workingcode"></p> <script> let text = "Hello world, welcome to the Working code."; let result = text.startsWith("Hello"); document.getElementById("workingcode").innerHTML = result; </script> </body> </html>
Output:
Welcome to Working code
The startsWith() Method
startsWith() returns true if a string starts with a specified string:
true
The startsWith() Method JavaScript (startsWith() returns true if a string starts with a specified string)
Expert Asked question July 18, 2023