how can i make my string comparison work?

43 Views Asked by At

I know this is a super noob question.

I'm expecting to give a random string to player 2 and compare it to the player... I can see player2 being reassigned , however the if statement doesn't seem to work.

let player = 'paper';
let player2 = '';
let myarr = ["rock", "paper", "scissors"];
var index = Math.floor(Math.random() * 3);
player2 = myarr[index];
console.log(player2);

function compare() {
  if (player === player2)
    console.log("draw");
}
compare(); // you missed this (added by editor)

0

There are 0 best solutions below