OLLEO-DIGITAL / Jervis-Tetch

A Simon game variant influenced by Jervis Tetch, the villain from the DC Batman comic series
GNU General Public License v3.0
2 stars 0 forks source link

Create initial sequence generator/randomizer #19

Open LionOnTheWeb opened 1 year ago

LionOnTheWeb commented 1 year ago

Overview

Create a function that generates a sequence based on the predefined colors array. See ChatGPT response in the comment below

Tasks

LionOnTheWeb commented 1 year ago

ChatGPT response for reference:

const gameBoard = document.querySelector('#game-board');
const colors = ['red', 'green', 'blue', 'yellow'];
let computerSequence = [];
let playerSequence = [];
let level = 1;

function generateRandomSequence(level) {
  for(let i = 0; i < level; i++) {
    const randomIndex = Math.floor(Math.random() * 4);
    computerSequence.push(colors[randomIndex]);
  }

 return computerSequence
}

console.log(generateRandomSequence(1));