JSFiddle - React, Tailwind, and code Playground

JavaScript

/**
 * ******************************************************************************************
 * Check if the colors are correct
 * ******************************************************************************************
 */

// Select the check button
const $checkButton = document.getElementById("mixColors");
const $mixedColorBlock = document.querySelector("#mixedColor .colors-block");

$checkButton.addEventListener("click", () => {
  // Check if the selected colors are 3
  if (selectedColors.length !== 3) {
    alert("Please select 3 colors!");
    return;
  }

  const mixedColor = mixColors(selectedColors);
  const correctColor = mixedCorrectColor.style.backgroundColor;
  const $score = document.getElementById("score");

  $mixedColorBlock.style.backgroundColor = mixedColor;
  if (mixedColor === correctColor) {
    $score.innerHTML = parseInt($score.innerHTML) + 1;
    // Start the game again
    selectedColors.length = 0;
    colorsArray = genRandomColorsArray(5);
    // Display the correct color
    mixedCorrectColor.style.backgroundColor = mixColors(colorsArray);
    // Shuffle the colors array and display them
    colorsArray = shuffleAndRenderColors();

    $mixedColorBlock.style.backgroundColor = "";

    // Reset the input colors
    inputColorBlocks.forEach((block) => (block.style.backgroundColor = ""));

    // Reset the mixed color
    $mixedColorBlock.style.backgroundColor = "";
  }
});