0

I have been making a brute-force 4-digit code breaker, but have run into some issues. After some debugging, I found out that ['0','0','0','1']==['0','0','0','1'] evaluates to false for some reason. Why is this and how can I make it true?

['0','0','0','1']==['0','0','0','1'] evaluates to false

Edit: I am using repl.it to make this code breaker.

Ateur Games
  • 79
  • 1
  • 11
  • Because array is an object and here you are comparing the reference rather than the value. JSON.stringify(['0','0','0','1'])==JSON.stringify(['0','0','0','1']) will return true in javaScript. – Durgesh Pal Dec 13 '19 at 16:55
  • Also this SO post: [why-doesnt-equality-check-work-with-arrays](https://stackoverflow.com/q/30820611/4003419) – LukStorms Dec 13 '19 at 16:57

0 Answers0