Extend hex color

    0

    0

    Giovanny Gongora

    Codiga's TypeScript Recipes

    Extends a 3-digit color code to a 6-digit color code.

    const extendHex = (shortHex: string) =>
      '#' +
      shortHex
        .slice(shortHex.startsWith('#') ? 1 : 0)
        .split('')
        .map(x => x + x)
        .join('');
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.