Skip to content

Instantly share code, notes, and snippets.

@tofikhidayatxyz
Created February 6, 2022 01:14
Show Gist options
  • Select an option

  • Save tofikhidayatxyz/3081eae0460243214c8db8ac6f433e0b to your computer and use it in GitHub Desktop.

Select an option

Save tofikhidayatxyz/3081eae0460243214c8db8ac6f433e0b to your computer and use it in GitHub Desktop.
const firsVal = 'harum'
const secondVal = 'rumah'
const isAnagram = (firstVal, secondVal) => {
firstVal = firstVal
.toLowerCase()
.split(' ')
.join('')
.split('')
.sort()
.join('')
secondVal = secondVal
.toLowerCase()
.split(' ')
.join('')
.split('')
.sort()
.join('')
return firstVal == secondVal
}
console.log(isAnagram(firsVal, secondVal))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment