Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

If-else statements for rock, paper, scissors game isn't returning the result that's supposed to return in js ?

By M.K. Verma · 3 May 2022

If-else statements for rock, paper, scissors game isn't returning the result that's supposed to return in js ?

You are calling the random function twice instead of using the same cached value.

console.log(computerPlay());
let computerSelect = computerPlay();

The results should match if you only invoke the function once and store the value.

const computerSelect = computerPlay();
console.log(computerSelect);