Hey guys, I thought I knew how to write a for loop but I guess it’s wrong. Each time I try to play the console logs the same result 5 times. Any help with this?
I may be looking at this wrong, but it appears you are picking the computer selection once before the game starts (and setting it as a constant to boot). You need to reselect a new selection in each round. So you’re
const computerSelection = computerPlay();
should be in the loop somewhere, and also it should not be a constant since it is expected to change each round. Better yes, put the assignment of computerSelection inside the computerPlay() function and pass the function into playround. It also appears you’re playRound() function is looking for two parameters, but when you call it from inside the loop, you are not passing any parameters.
Best thing to do is move player and computer selection into their own complete functions that returns the result, then when you call playRound, have it call functions those functions by passing them as parameters,