scrimba
JS color tool
Display Color From User Hex Input
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Display Color From User Hex Input
AboutCommentsNotes
Display Color From User Hex Input
Expand for more info
index.js
run
preview
console
//CHALLENGE
//Get a reference to hexInput and inputColor DOM elements
//Create a keyup event handler for hexInput
//Check if hex color is valid
//If hex color is valid, update the background color of inputColor

const isValidHex = (hex) => {
if(!hex) return false;

const strippedHex = hex.replace('#', '');
return strippedHex.length === 3 || strippedHex.length === 6;
}

Console
true
,
false
,
true
,
true
,
true
,
false
,
/index.html
-4:18