javascript endswith
snippet in javascript

javascript endswith

user3157

"Hello world".endsWith("world");//true
"Hello world".endsWith("Hello");//false

javascript check if string ends with

user9549

function endsWith(str, suffix) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

endsWith("hello young man","man");//true
endsWith("hello young man","boy");//false

endswith()

user312

var str = "Hello world, welcome to the universe.";
var n = str.endsWith("universe.");//returns true

how to find out what a string ends with in javascript

user1206

function isJS(path) {
	return /jsx?$/.test(path)
}

how to compare a string with its ending in javascript

user8504

function solution(str, ending){
  return str.indexOf(ending, str.length - ending.length) !== -1;
}