Home > database >  Add "end" to rock, paper, scissors game and use styles on vars
Add "end" to rock, paper, scissors game and use styles on vars

Time:06-09

I have finished a rock, paper and scissors exercise and implemented some DOM event, it's a very simple script but I'm almost happy with it. Well, now I'm having two issues and I don't know how to get the logic on them.

  1. First question is, I would like set an end game, like max. 5 rounds then game stops / resets, but I can't think of any solution to get to it, I was thinking on using a for loop but I don't know where should I use it, maybe I shouldn't use the userScore and computerScore on the playGame function but I can't tell it for sure. Could someone please tell me how should I proceed?

  2. Second question is, in my $icons constant I have set the 3 emojis, I would like to make them bigger so it would fit better on "The machine chooses.." text, but I also don't know how to, I was thinking on adding CSS styles (font-size) through JS on the DOM but I don't know where to start.

// Global DOM variables
const $selectBtn = document.querySelectorAll("[data-selector]");
const $displayUserScore = document.querySelector("#user-score");
const $DisplayComputerScore = document.querySelector("#computer-score")
const $showScore = document.querySelector("h5");
const $icons = ["           
  • Related