Reputation: 83
I'm currently learning Javascript and they want me to build a Rock, paper and scissors game.
Here's the code I have so far:
let computerPlay = (array) => {
return array[Math.floor(Math.random() *
array.length)]
}
const array = (["Rock", "Paper", "Scissors"])
console.log(computerPlay(array))
let singleRound = (playerSelection,
computerSelection) => {
if ( playerSelection == "rock" || playerSelection
== "Paper" ||
playerSelection == "scissors") {
computerSelection = computerPlay
} else if (playerSelection == null) {
"Canceled"
}
}
let playerSelection = prompt("What do you
select?")
const computerSelection = computerPlay()
Thank You
Upvotes: 0
Views: 271
Reputation: 4277
Function Definition:
let computerPlay = (array) => { //... }
Calling The Funciton:
Remember computerPlay
requires an array
as a parameter when you call it.
computerPlay(YOUR_ARRAY_HERE);
Upvotes: 2