samedi 25 juin 2022

Unable to get a random string selection from my JavaScript array using the Math.Random function [duplicate]

I am trying to get a random input for my rock paper scissors game, but the console just returns 0 every time I call the function.

function computerPlay() {
    options = ["rock", "paper", "scissors"]
    let computerSelection = Math.floor(Math.random(options.length));
    console.log(computerSelection);
}



Aucun commentaire:

Enregistrer un commentaire