javascript string ends with

JavaScript
"Hello world".endsWith("world");//true
"Hello world".endsWith("Hello");//falsefunction endsWith(str, suffix) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

endsWith("hello young man","man");//true
endsWith("hello young man","boy");//false
var str = "Hello world, welcome to the universe.";
var n = str.endsWith("universe.");//returns trueconst s = 'I am going to become a FULL STACK JS Dev with Coderslang';

console.log(s.endsWith('lang'));             // true
console.log(s.endsWith('LANG'));             // falsefunction solution(str, ending){
  return str.indexOf(ending, str.length - ending.length) !== -1;
}
Source

Also in JavaScript: