1"Hello world".endsWith("world");//true
2"Hello world".endsWith("Hello");//false
1function endsWith(str, suffix) {
2 return str.indexOf(suffix, str.length - suffix.length) !== -1;
3}
4
5endsWith("hello young man","man");//true
6endsWith("hello young man","boy");//false
7