Reputation: 1277
I want to create a function allow to compare some elements like accélérer, Accelerer, ACCELERER...etc
and return True as result (if we have the same base letter).
example:
compare('accélérer','ACCELERER') // will be true
compare('accélérer','accelerer') // will be true
compare('accélérer','test') // will be false
thanks
Upvotes: 0
Views: 101
Reputation: 4806
Use localeCompare, try this:
const compare = (a, b) => !a.localeCompare(b, 'en' , { sensitivity: 'base'})
console.log(compare('accélérer','ACCELERER'))
console.log(compare('accélérer','accelerer'))
console.log(compare('accélérer','test'))
Upvotes: 4