On Rock, Paper, Scissors task, exercise 5,
Create a new function named getComputerChoice
with no parameters. Inside its block, utilize Math.random()
and Math.floor()
to get a whole number between 0 and 2. Then, depending on the number, return
either 'rock'
, 'paper'
, or 'scissors'
.
so I wrote this code:
function getComputerChoice() {
const randomNumber = Math.floor(Math.random()*3);
switch (randomNumber) {
case 0:
return 'rock';
case 1:
return 'paper';
case 2:
return : 'scisscors';
};
}
I got error. The project walkthrough shows that he used function expression not this âfunction declarationâ but I donât understand why this is wrong?