function generateRandomColors(num) {
var colors = [];
for (var i = 0; i < num; i++) {
var red = Math.floor(Math.random() * 256);
var green = Math.floor(Math.random() * 256);
var blue = Math.floor(Math.random() * 256);
var color = red + ", " + green + ", " + blue;
if (!colors.includes(color)) {
colors.push(color);
} else {
i--;
}
}
return colors;
}
generateRandomColors(2)
function generateRandomHexColor(num) {
var colors = [];
for (var i = 0; i < num; i++) {
var hex = Math.floor(Math.random() * 16777216).toString(16);
while (hex.length < 6) {
hex = "0" + hex;
}
var color = "#" + hex;
if (!colors.includes(color)) {
colors.push(color);
} else {
i--;
}
}
return colors;
}
generateRandomHexColor(2)