Create a Function to Convert JS Numbers into CSS Hex Colors

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

JavaScript numbers and CSS hexadecimal numbers don't play very well together. You can solve this with a conversion function that takes the number, converts it to a string, then pads the string with the necessary zeroes at the start using padStart.