Another sip of code ?

Reminder - Javascript - Random Hexadecimal Color Function

| Comments

Sometime you need some random values for testing pieces of code for exemple, in my case some placeholders for a QML component.

I quickly wrote a javascript function to generate random HEX colors, it was so ugly I’m not going to show it here.
A friend of mine needed a similar function, so I send it to him. I guess he was shocked by how ugly that code was, that he sent me back a way more elegant one.

function randomColor() {
    return "#" + (0x1000000 + parseInt(Math.random() * 0x1000000)).toString(16).substr(-6);

Thanks Arnaud Sellier.