String.prototype.endsWithbeginnerconst str = 'Hello, World!'
str.endsWith('!') // β true
str.endsWith('World') // β false
str.endsWith('World', 12) // β trueUse endsWith() to check if a string ends with a specific suffix, with an optional end position.
Challenge: Implement hasExtension(filename, ext) that checks if a filename ends with the given extension.
hasExtension('photo.jpg', '.jpg') // β true
hasExtension('photo.png', '.jpg') // β false