OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

code cannot print the thing asked for in the if statement [duplicate]

  • Thread starter Thread starter 4zac
  • Start date Start date
4

4zac

Guest
I have written code where there are two arrays, one consists of different sets and the other one consists of only three numbers. I've written an if statement where if the content of both of the arrays matches together (which it does) it will print "Matched". But nothing is getting printed on the console. Please help


Code:
const winning_ps = [
  [1, 2, 3],
  [2, 3, 4],
  [5, 1, 2],
  [7, 8, 9],
  [11, 12, 12]
];
const usr_ps = [5, 1, 2];

if (usr_ps === winning_ps[2]) {
  console.log("Matched");
}

<p>I have written code where there are two arrays, one consists of different sets and the other one consists of only three numbers. I've written an if statement where if the content of both of the arrays matches together (which it does) it will print "Matched". But nothing is getting printed on the console. Please help</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const winning_ps = [
[1, 2, 3],
[2, 3, 4],
[5, 1, 2],
[7, 8, 9],
[11, 12, 12]
];
const usr_ps = [5, 1, 2];

if (usr_ps === winning_ps[2]) {
console.log("Matched");
}</code></pre>
</div>
</div>
</p>
 
Top