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)
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
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);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdf5b15e2-e6d6-41f9-adf4-8004644211b0%2Fb035312a-0e49-4a7d-a3f6-ce3d80998bf4%2F39b7dr5_processed.jpeg&w=3840&q=75)
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)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdf5b15e2-e6d6-41f9-adf4-8004644211b0%2Fb035312a-0e49-4a7d-a3f6-ce3d80998bf4%2F34plai_processed.jpeg&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education