0

I hope you can help me in this mind blowing problem I have:

Well, I have 2 different arrays (cam and existentes). The [2] value of existentes is the same string than the 1 value of cam. But when I try to compare existentes [2] == cam [1] it returns a False.

enter image description here

1 Answers1

1

Solution:

You are comparing two arrays: [Remarketing] == [Remarketing] while you should be comparing two strings Remarketing == Remarketing:

existentes[2][0]==cam[1][0]

Minimal Reproducible Example:

  const ar1 = ["Remarketing"];
  const ar2 = ["Remarketing"];
  console.log(ar1==ar2); // returns false
  console.log(ar1[0]==ar2[0]); // returns true

In case you had arrays with multiple elements you wanted to compare, then you can read this post on how to compare two arrays in JavaScript:

How to compare arrays in JavaScript?

Marios
  • 26,333
  • 8
  • 32
  • 52