Skip to main content

Command Palette

Search for a command to run...

Anagram(Javascript)

Published
View as Markdown
Anagram(Javascript)
A

Hi there 👋, I am Anil Verma I am a passionate Full Stack Web Developer who is fascinated by complex engineering problems.

One string is an Anagram of another if it uses the same characters in the same quantity. ignore spaces, punctuations While validating both strings for Anagram Problem.

Ex-

isAnagram(‘rail safety.’, ‘fairy tales’) →true

isAnagram*(‘Rail SafeTy’, ‘fairy tales.’) **→true*

Let’s Solve -

Step0 → create a function, take both strings as args

Step1 → remove spaces/punctuations from both the strings

step 3 → now to validate both strings,

str1.split(“”).sort().join(“”)===str2.split(“”).sort().join(“”)