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
1const s = 'I am going to become a FULL STACK JS Dev with Coderslang';
2
3console.log(s.endsWith('lang')); // true
4console.log(s.endsWith('LANG')); // false
1var str = "Hello world, welcome to the universe.";
2var n = str.endsWith("universe.");//returns true
1function solution(str, ending){
2 return str.indexOf(ending, str.length - ending.length) !== -1;
3}