In javascript
const toHex = (c) => { const toHex = (c) => { const hex = Math.max(0, Math.min(255, c)).toString(16); return hex.length == 1 ? `0${hex}` : hex; }; const rgb = (r, g, b) => { return `#${toHex(r)}${toHex(g)}${toHex(b)}`; }; rgb(255, 255, 255) // #ffffff rgb(255, 255, 300) // #ffffff rgb(0,0,0) // #000000 rgb(148, 0, 211) // #9400d3 rgb(-20,275,125) // #00ff7d rgb(255,255,255) // #ffffff
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In javascript