how to compare a string with its ending in javascript
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
function solution(str, ending){
return str.indexOf(ending, str.length - ending.length) !== -1;
}
Also in JavaScript:
- Javascript program printing the lyrics to the 99 bottles of beer song web
- faker javascript name escape apostrophe
- generate an array of random numbers javascript
- nsenter
- how to make an alphabet in javascript
- refresh after delete in express
- get value in tag with id JS
- rubik's cube algorithm in javascript
- connect nodejs to mariadb
- local storage
- flatten an array javascript
- creating a 2d array in js
- $.post javascript
- multidimensional array javascript
- how to add onclick event in javascript
- cannot find module @babel/compat-data/data/corejs3-shipped-proposals
- XJavascript:$.ge
- jquery remove option from select by value
- js catch all images errors
- angular generat model
- sendfile express syntax
- js shuffle array
- Javascript string compression
- check uncheck vanila js