Rock, Paper, Scissors math not defined

I’m working on the Rock, Paper, Scissors exercise and keep getting a “math is not defined at getComputerChoice” error.

console.log(‘hi’);

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
console.log(‘Error!’);
}
};

const getComputerChoice = () => {
const randomNumber = math.floor(math.random() * 3);
switch (randomNumber) {
case 0:
return ‘rock’;
case 1:
return ‘paper’;
case 2:
return ‘scissors’;
}
};

console.log(getComputerChoice());

is what I have up to this point. Any help would be appreciated. Thanks

Math in Javascript is written with a capital M:

Math.floor(Math.random() * 3);
2 Likes

That worked, thanks.

I could’ve sworn in a past exercise I was able to use lowercase with math. Been a minute since I was in the Javascript lesson.