Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / es5.js
Last active July 25, 2024 20:25
Convert Hex Color to rgba with opacity
/**
* ECMA2015
*/
function convertHex(hexCode, opacity = 1){
var hex = hexCode.replace('#', '');
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}