Elias Sjögreen Elias Sjögreen - 2 months ago 17x
Node.js Question

Check if string contains word at start of string

I am starting to learn a little bit more advanced js and i want to check if string contains a word at the start of the line.
Something like this would be good!:

var string = "Hello world";
if (string.contains("Hello", start) == true)


Very easy Method:

var str = "Hello World";

if (str.startsWith("Hello")){
    do stuff;

You could also make two arrays and compare the single letters using a for loop, slightly more creative :D