compare string camelcase and lowercase javascript
var name1 = "Taylor Johnson";
var name2 ="taylor johnson";
//convert to lowercase for case insensitive comparison
if(name1.toLowerCase() === name2.toLowerCase()){
//names are the same
}
str.toUpperCase() === str || str.toLowerCase() === str;function sameCase(str) {
return /^[A-Z]+$/.test(str) || /^[a-z]+$/.test(str);
}var haystack = "A. BAIL. Of. Hay.";
var needle = "bail.";
var needleRegExp = new RegExp(needle.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), "i");
var result = needleRegExp.test(haystack);
if (result) {
// Your code here
}
Also in JavaScript:
- adding to array js
- read json file in typescript
- random number in js
- fullscreen electron
- how to make modules structure like lodash
- random item from array javascript
- get erquest jquery
- javascript keydown
- get contents between tags javascript
- javascript get last n characters of string
- function to create an element javascript
- change the color of text in javascript
- js scroll to bottom
- js set datetime
- chess.js
- print in node js
- loading screen fivem js
- remove whitespace javascript
- vue js getter
- discord js message
- how to make a javascript for loop
- django csrf token in javascript
- usestate() react
- javascript null check