how to find out what a string ends with in 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
function isJS(path) {
return /jsx?$/.test(path)
}function solution(str, ending){
return str.indexOf(ending, str.length - ending.length) !== -1;
}
Also in JavaScript:
- javascript create array of object keys
- arrow function in javascript
- events in javascript
- update angular materia;
- fetch is not defined amazon-cognito-identity-js
- nodejs http server
- how to collect keys using lodash javascript
- node read file
- inser js
- javascript - get the filename and extension from input type=file
- js string does not contain
- javascript get random string
- js find all custom window properties
- jquery get link href value
- javascript find a prime number
- bind in javascript
- shopware 5 subscribe to theme collect javascript
- how to append value to input field using jquery
- foreach break js
- dart map to json string
- professional react projects
- rest parameter javascript
- json.stringify parameters
- javascript create object empty