Bootcamp
Search…
2.POCE.1: Command Line Colour Converter

Introduction

  1. 1.
    Create a command-line app to convert hex-code colours to RGB-code colours and vice versa.
  2. 2.
    Begin with the starter code repo here.
  3. 3.
    Remember to work on a forked copy and submit a pull request once done.

Base

Implement hex to RGB conversion. You can use the mathematical conversion in this Stack Overflow answer. The focus of this exercise is to learn to build command line apps and not the math for conversions.

Sample Command

node index.js '#ffffff'

Sample Output

rgb(255,255,255)

Comfortable

Implement RGB to hex conversion.

Sample Command

Note the quotes around the RGB input to escape parentheses characters.
node index.js rgbhex 'rgb(255,255,255)'

Sample Output

#ffffff

More Comfortable

  1. 1.
    Convert input colours to HSL format.
  2. 2.
    Convert any input colour format to the other two colour formats. E.g. RGB input can convert to both hex and HSL.
  3. 3.
    Auto-detect the input colour format in the #2 app.

Reference Solution

Click here to see the reference solution.