Q:

Write a JavaScript program to extend a 3-digit color code to a 6-digit color code

0

Write a JavaScript program to extend a 3-digit color code to a 6-digit color code.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const extend_Hex = shortHex =>
  '#' +
  shortHex
    .slice(shortHex.startsWith('#') ? 1 : 0)
    .split('')
    .map(x => x + x)
    .join('');

console.log(extend_Hex('#03f'));
console.log(extend_Hex('05a'));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now