Rocks paper scissors game

Hi, I had to build a simple rock paper scissors game on Javascript for an assignment. Still I’m not able to make it work. Could someone give me a hint on where it is failing? Code below.

let playerPlay = prompt(Rock, paper or scissors)
const choices = [null, rock, paper, scissors];
let number;
let play;
let result;
let value;
function computerPlay(choices, number, play, result){
number = (Math.floor(Math.random()*3)+1);
play = choices[number];
result= play;
return result;
}
value = computerPlay(choices, number, play, result)
console.log(value)

let computerScore = 0;
let playerScore = 0;

if (playerPlay.toLowerCase() == rock && (value == rock){
console.log (It's a tie )
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == rock && (value == paper){
console.log (Computer wins)
computerScore++
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == rock && (value == scissors){
console.log (Player wins)
playerScore++
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == paper && (value == rock){
console.log (Player wins)
playerScore++
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == paper && (value == paper){
console.log (It's a tie )
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == paper && (value == scissors){
console.log (Computer wins)
computerScore++
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == scissors && (value == rock){
console.log (Computer wins)
computerScore++
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else if (playerPlay.toLowerCase() == scissors && (value == paper){
console.log (Player wins)
playerScore++
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}
else (playerPlay.toLowerCase() == scissors && (value == scissors){
console.log (It's a tie )
console.log (Player score = playerScore)
console.log (Computer score = computerScore)
}

Can you please put your code into an online shareable editor such as CodePen, jsFiddle, or Glitch?
It’s hard to read it like that…

on codepen i get an error “Sorry you cannot post a link to that host.”.
https://jsfiddle.net/jcito14/wnje2br9/4/

You have few syntax errors (follow the red dots in the left to the code in jsfiddle):
In the if statements you have to surround the condition with rounded parentheses.
For example,
replace this:

if (playerPlay.toLowerCase() == `rock`) && (value == `rock`){

with:

if ((playerPlay.toLowerCase() == `rock`) && (value == `rock`)){

In addition, the syntax for strings concatenation is to use the plus character (+).
For example:

let name = firstName + " " + lastName;

In your code, replace this:

console.log (`Player score =` playerScore)

with:

console.log (`Player score =` + playerScore)

also, its better to put “;” at the end of every statement.

I see that you use backticks for strings (`). It’s used for string interpolation in javascript. If you don’t use string interpolation it’s better to use quotes ( ') or double quotes (") for string literals.

One more comment is about the equality test. In general it’s better to use the === operator which compares the types and the values of it’s operands. Read more on it here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness

One more tip is to start with few lines of code that works, test it and then add few more and test again, etc…

I have been taking a look over the script you posted, and I would say it is has its fair number of errors, which would prevent from JS from executing it. Like what @Rafael_Green was saying about using the correct syntax in all the right places.
I would like to mention that this would also apply to strings in concole.logs(). please remember to check () {} [] ‘’.
I honestly feel like my english teacher saying go back and punctuate it properly but really thats what your script needs is proper punctuation and syntax.

If you want or ever need help please do join our Discord Server