javascript anagram check
JavaScript
const areAnagram = (str1, str2) => str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
// Examples
areAnagram('listen', 'silent'); // true
areAnagram('they see', 'the eyes'); // true
areAnagram('node', 'deno'); // truefunction isAnagram(stringA, stringB) {
// Sanitizing
stringA = stringA.toLowerCase().replace(/[\W_]+/g, "");
stringB = stringB.toLowerCase().replace(/[\W_]+/g, "");
// sorting
const stringASorted = stringA.split("").sort().join("");
const stringBSorted = stringB.split("").sort().join("");
return stringASorted === stringBSorted;
}function anagram(name, words) {
name = name.toLowerCase().split('').sort().join('').trim();
words = words.join('').toLowerCase().split('').sort().join('');
return name === words;
}
Also in JavaScript:
- Title
- hexstring to rgb array js
- Category
- JavaScript
- Title
- datatables server side
- Category
- JavaScript
- Title
- grapejs html editor
- Category
- JavaScript
- Title
- how to make a vowel counter in javascript
- Category
- JavaScript
- Title
- angularjs socket.io
- Category
- JavaScript
- Title
- clear the console while in strict mode
- Category
- JavaScript
- Title
- for each python json
- Category
- JavaScript
- Title
- how to make a factorial function in javascript
- Category
- JavaScript
- Title
- contains substring javascript
- Category
- JavaScript
- Title
- document.ready()
- Category
- JavaScript
- Title
- focus js
- Category
- JavaScript
- Title
- how to parse json
- Category
- JavaScript
- Title
- html hide till button click
- Category
- JavaScript
- Title
- html decode javascript
- Category
- JavaScript
- Title
- async await javascript stack overflow
- Category
- JavaScript
- Title
- angular observable subscribe and unsubscribe
- Category
- JavaScript
- Title
- fix your timestep javascript
- Category
- JavaScript
- Title
- express get query params from url
- Category
- JavaScript
- Title
- filtering json array in javascript
- Category
- JavaScript
- Title
- how to validate an email address in javascript
- Category
- JavaScript
- Title
- check if string is datestring javascript
- Category
- JavaScript
- Title
- autocomplete typeahead ajax
- Category
- JavaScript
- Title
- access to static file nodejs
- Category
- JavaScript
- Title
- how to make javascript function consise
- Category
- JavaScript
- Title
- flask get summernote text
- Category
- JavaScript
- Title
- emmet jsx visual studio
- Category
- JavaScript
- Title
- how to send a command in js
- Category
- JavaScript
- Title
- convert object to json javascript
- Category
- JavaScript
- Title
- how to make a inventory in js
- Category
- JavaScript
- Title
- how to clear radio field in jquery
- Category
- JavaScript
- Title
- javascript ajax request
- Category
- JavaScript
- Title
- array vowels js
- Category
- JavaScript
- Title
- get start of day javascript
- Category
- JavaScript
- Title
- indexing string in javascript
- Category
- JavaScript
- Title
- eval in js
- Category
- JavaScript
- Title
- how run dockerfile
- Category
- JavaScript
- Title
- is forEach sync js
- Category
- JavaScript
- Title
- how to english paragraph matching in javascript
- Category
- JavaScript
- Title
- iterate object javascript
- Category
- JavaScript
- Title
- how to validate date in react
- Category
- JavaScript
- Title
- insert into specific array index that has a value existing on that index
- Category
- JavaScript
- Title
- interceptor in angular 8
- Category
- JavaScript
- Title
- import react dom
- Category
- JavaScript
- Title
- banking program deposit and withdrawal using ajax call
- Category
- JavaScript
- Title
- Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. javascript
- Category
- JavaScript
- Title
- .filter js
- Category
- JavaScript
- Title
- check if function exists javascript
- Category
- JavaScript
- Title
- how to remove session data on tab close in redux\
- Category
- JavaScript
- Title
- javascript array unique values
- Category
- JavaScript
- Title
- equal to or more than javascript
- Category
- JavaScript
- Title
- get selected option value
- Category
- JavaScript
- Title
- c# httpclient post json stringcontent
- Category
- JavaScript
- Title
- get radio button value javascript
- Category
- JavaScript
- Title
- how to run mocha tests on asynchronous functions in script
- Category
- JavaScript
- Title
- closure javascript
- Category
- JavaScript
- Title
- array javascript django
- Category
- JavaScript
- Title
- convert base64 to uint8array javascript
- Category
- JavaScript
- Title
- how to transpose json data
- Category
- JavaScript
- Title
- array of images javascript
- Category
- JavaScript
- Title
- array length javascript
- Category
- JavaScript
- Title
- for each js
- Category
- JavaScript
- Title
- is javascript object oriented
- Category
- JavaScript
- Title
- if condition in class angular 8
- Category
- JavaScript
- Title
- butonc click jquery
- Category
- JavaScript
- Title
- check if date equal js
- Category
- JavaScript
- Title
- how to test fetch
- Category
- JavaScript
- Title
- function prototype javascript
- Category
- JavaScript
- Title
- html table to excel javascript
- Category
- JavaScript
- Title
- How can I refresh a page with jQuery
- Category
- JavaScript
- Title
- javascript check empty property
- Category
- JavaScript
- Title
- firefox extension make ajax request
- Category
- JavaScript
- Title
- How to insert an element after another element in JavaScript without using a library
- Category
- JavaScript
- Title
- iframe loader jquery
- Category
- JavaScript
- Title
- get value javascript
- Category
- JavaScript
- Title
- javascript class click event
- Category
- JavaScript
- Title
- javascript ajax
- Category
- JavaScript
- Title
- delete session javascript
- Category
- JavaScript
- Title
- getrect javascript
- Category
- JavaScript
- Title
- dynamic for loop react
- Category
- JavaScript
- Title
- deparam javascript
- Category
- JavaScript
- Title
- cannot use getidtoken if null
- Category
- JavaScript
- Title
- expresiones ternarias javascript
- Category
- JavaScript
- Title
- how to do bubble sort in javascript
- Category
- JavaScript
- Title
- how to setstate in parent in child component in react native
- Category
- JavaScript
- Title
- Javascript compare two objects
- Category
- JavaScript
- Title
- graal.js javascript array in java
- Category
- JavaScript
- Title
- discord.js command prompt notification
- Category
- JavaScript
- Title
- change title react
- Category
- JavaScript
- Title
- get href attribute javascript
- Category
- JavaScript
- Title
- clone javascript object
- Category
- JavaScript
- Title
- how to displayan inteiger to a tenth in javascript
- Category
- JavaScript
- Title
- How do I get Month and Date of JavaScript in 2 digit format
- Category
- JavaScript
- Title
- dropzone csrf codeigniter
- Category
- JavaScript
- Title
- angular lifecycle hooks
- Category
- JavaScript
- Title
- cortar elemento y pegar en otro lugar jquery
- Category
- JavaScript
- Title
- Adding and Deleting html Elements
- Category
- JavaScript
- Title
- display none js
- Category
- JavaScript
- Title
- how to make a var and sprite in javascript
- Category
- JavaScript
- Title
- angular attach component to body
- Category
- JavaScript
- Title
- Encoding and Decoding Base64 Strings in Node.js
- Category
- JavaScript