end of string in html code example
Example 1: endswith()
var str = "Hello world, welcome to the universe.";
var n = str.endsWith("universe.");//returns true
Example 2: how to compare a string with its ending in javascript
function solution(str, ending){
return str.indexOf(ending, str.length - ending.length) !== -1;
}