Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 403
cooldude101 Avatar asked Jul 23 '20 20:07

cooldude101


1 Answers

  1. Check type of each variable

    typeof string1 === typeof string2
    
  2. Check 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}`))
    
  4. Check unicode of each character:

    console.log([...string1].map((char,i) => [char, char.codePointAt(0),string2.codePointAt(i)]))
    
like image 58
TheMaster Avatar answered Nov 14 '22 12:11

TheMaster