MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / toHex

Function toHex

Conversions/RGBToHex.js:6–6  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

4 }
5
6 const toHex = (n) => (n || '0').toString(16).padStart(2, '0')
7
8 return `#${toHex(r)}${toHex(g)}${toHex(b)}`
9}

Callers 1

RGBToHexFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected