Help please. I keep on getting the error color_picker.js:58 Uncaught ReferenceError: colors is not defined at generateColors (color_picker.js:58:25)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Help please. I keep on getting the error color_picker.js:58 Uncaught ReferenceError: colors is not defined at generateColors (color_picker.js:58:25)
function generateColors () {
alert ("Replace this with code that adds a random color to each unlocked box.")
let color
for (let i=0; i< colors.length; i++) {
let box Id = "lock-"+i
let boxElement = document.getElementById (boxId);
}
if (boxElement && !isLocked [i]) {
let newColor = getRandomColorArray();
boxElement.style.backgroundColor= newColor;
let fontColor = getFontColor (newColor);
boxElement.style.color= fontColor;
function getFont Color (color) {
let rgb= hexToRgb (color);
let brightness
}
} else {
=
if (brightness >0.5) {
return "black"
(0.299* rgb.r+0.587+ rgb.g+0.114* rgb.b)/255;
return "white";
function hexToRgb (hex) {
hex hex.replace(/^#/, '')
let bigint-parseInt (hex, 16);
Transcribed Image Text:function generateColors () { alert ("Replace this with code that adds a random color to each unlocked box.") let color for (let i=0; i< colors.length; i++) { let box Id = "lock-"+i let boxElement = document.getElementById (boxId); } if (boxElement && !isLocked [i]) { let newColor = getRandomColorArray(); boxElement.style.backgroundColor= newColor; let fontColor = getFontColor (newColor); boxElement.style.color= fontColor; function getFont Color (color) { let rgb= hexToRgb (color); let brightness } } else { = if (brightness >0.5) { return "black" (0.299* rgb.r+0.587+ rgb.g+0.114* rgb.b)/255; return "white"; function hexToRgb (hex) { hex hex.replace(/^#/, '') let bigint-parseInt (hex, 16);
"use strict";
// DO NOT EDIT THIS CODE
// A boolean array storing whether each color is locked (true) or not (false).
// E.g., if isLocked[2] is false, then color 2 is not locked.
let isLocked = [false, false, false, false, false];
// DO NOT EDIT THIS CODE
// Calls the generateColors () function once when the page loads.
generateColors ();
function clickColor (boxIndex) {
let lock= "lock-"+ String (boxIndex)
if (isLocked [boxIndex] === false) {
document.getElementById (lock).innerHTML= "locked";
isLocked [box Index] =true
}
}
else if(isLocked [boxIndex] ===true) {
}
";
document.getElementById(lock).innerHTML= "
isLocked [boxIndex]=false
console.log (isLocked.toString())
function colorArrayToCSS (colorArray) {
let numl=colorArray [0]
let num2= colorArray [1]
let num3=colorArray[2]
let color = "rgb"+" ("+numl+", "+num2+","+num3+") "
return color;
console.log (color)
Transcribed Image Text:"use strict"; // DO NOT EDIT THIS CODE // A boolean array storing whether each color is locked (true) or not (false). // E.g., if isLocked[2] is false, then color 2 is not locked. let isLocked = [false, false, false, false, false]; // DO NOT EDIT THIS CODE // Calls the generateColors () function once when the page loads. generateColors (); function clickColor (boxIndex) { let lock= "lock-"+ String (boxIndex) if (isLocked [boxIndex] === false) { document.getElementById (lock).innerHTML= "locked"; isLocked [box Index] =true } } else if(isLocked [boxIndex] ===true) { } "; document.getElementById(lock).innerHTML= " isLocked [boxIndex]=false console.log (isLocked.toString()) function colorArrayToCSS (colorArray) { let numl=colorArray [0] let num2= colorArray [1] let num3=colorArray[2] let color = "rgb"+" ("+numl+", "+num2+","+num3+") " return color; console.log (color)
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Multithreading Methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education