String.prototype.startsWithintermediateconst str = 'Hello, World!'
str.startsWith('Hello') // β true
str.startsWith('World') // β false
str.startsWith('World', 7) // β trueUse startsWith() to check if a string begins with a specific prefix, with an optional start position.
The optional second argument position specifies where to start the search.
Challenge: Implement startsAtPos(str, search, pos) that checks if str starts with search at position pos.
startsAtPos('hello world', 'world', 6) // β true
startsAtPos('hello world', 'hello', 6) // β false