-1

I've searched enough but didn't find the solution, I want to get True for comparing these strings without converting them to lower case or uppercase. also if there is a solution if I use them as arrays, is accepted and ok for me.

const  string1 = "My dear friend"
var    string2 = "my dEar frienD"
Fereydoon
  • 71
  • 1
  • 9

1 Answers1

2

You can use localCompare() which supports case insensitive comparisons.

const  string1 = "My dear friend"
var    string2 = "my dEar frienD"

console.log(string1.localeCompare(string2, undefined, { sensitivity: 'base' }) === 0)
Red
  • 6,599
  • 9
  • 43
  • 85