New JavaScript coder here, self taught. Learning for fun and very confused along the way.
Anyway when I check my code on the browser, “null” comes up for “computerSelection”. Here is my code:
let choices = ["Rock", "Paper", "Scissors"];
function getComputerChoice(){
let choice = choices[Math.floor(Math.random())];
let computerSelection = (choices[choice]);
return computerSelection
}
How do I go about doing this properly so that it works?
I tried programming it in the way I thought was correct with variables in the function and I expected it to return a choice of rock, paper or scissors. Instead, all I get is “null” :/