# randomColor()

{% tabs %}
{% tab title="randomColor()" %}
```javascript
// ⭐️ examples:
//    • randomColor()
//    • randomColor(0.5)         // random color with alpha = 0.5
export function randomColor(alpha) {

    const [r,g,b] = [
        randomInt(0,255), 
        randomInt(0,255), 
        randomInt(0,255)
    ];
    
    return `rgb(${r} ${g} ${b}${alpha >=0 ? ` / ${alpha}` : ''})`;
}
```
{% endtab %}

{% tab title="⬆️ 需要" %}
* [randomInt()](../../../js/val/prim/num/random/randomint)
{% endtab %}
{% endtabs %}
