Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

Check if a string starts with another string in Javascript

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


Enter fullscreen mode Exit fullscreen mode

Top comments (0)