78. convert HEX color to RGBA

JavaScript
Is this helpful ?

medium  - accepted / - tried

Suppose you write some CSS code, you need to set colors. You can choose hexadecimal notation #fff or Functional notation rgba(255,255,255,1).

Can you write a function to convert hexadecimal notation to functional notation?

hexToRgb('#fff')
// 'rgba(255,255,255,1)'
  1. Alpha channel should have maximum 2 digits after decimal point, round up if needed.
  2. Don't forget to do input validation

Let's try to solve this problem within 10 mintues.

Discuss(10)