The rgb() method is incomplete. Complete the method so that passing in RGB decimal values will result in a hexadecimal representation being returne...
For further actions, you may consider blocking this person and/or reporting abuse
My JavaScript solution, which would look a lot nicer if the TC39 finally added a pipeline operator.
String.prototype.padStart would handle the
addZeroes
trick for you. ;)I got really confused when the link opened in Portuguese. I had to check my VPN 😆
Whoops! Sorry about that. :P Should be fixed now.
I've modified it to use
padStart
instead of my custom function.Thanks @lffg and @avalander !
We have
padStart
now in strings to add characters to the beginning up to a certain length.Nodejs (not web):
Not necessarily actually efficient, but definitely hilarious.
General JS:
My PHP Solution
Elm
Test.
Haskell, using the word8 type to ensure the inputs are from 0-255.
My solution in PHP
Python solution, supports 1 or 3 arguments like CSS.
In C#, you don't even really need to implement a method for this, as its easily done with string interpolation;
(Useful for unique ad-hoc strings, but usually better factored out to a method anyway)
Ruby solution
In Go.
Thanks for the tip! I've mostly used string formating for dealing with point numbers in decimals. Need to explore more use cases because the syntax is indeed preferable.
I'd do this with Uint8Array