I have 2 identical strings, they appear identical in the debugger (and Logger.log), but when I do string1 === string2
it returns false. How can I debug this?
One of the string is a google drive file name, and one of the string is from a google sheet cell. I'm guessing there's an invisible character in one of the string but I have no way to see it.
Check type
of each variable
typeof string1 === typeof string2
Check length
of each string
string1.length === string2.length
Loop through each character:
[...string1].every((char,i) => char === string2[i] || console.info(`Unequal character at ${i}`))
Check unicode of each character:
console.log([...string1].map((char,i) => [char, char.codePointAt(0),string2.codePointAt(i)]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With