Check if starts with

Last update in 9/2019

This post is in draft stage. You can help me finish it on GitHub.

It's as easy as calling startsWith() or endsWith() methods on JavaScript string prototype.

As an example we can use string similar to this.

const string = 'Hey, have a great day!'

And check if string is question with simple function.

const isQuestion = str => {
return str.endsWith('?')

When we pass example string to this function it will, of course, return false.

isQuestion(string) // false

You can use startsWith() same way.

Resources #