How to debug identical strings that do not equal in google app script?

Viewed 255

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.

1 Answers
  1. Consider type of each variable

    typeof string1 === typeof string2
    
  2. Consider length of each string

     string1.length === string2.length
    
  3. Loop through each character:

     [...string1].every((char,i) => char === string2[i] || console.info(`Unequal character at ${i}`))
    
Related