I am trying to set a text color based off my background color here is the code I have to create a random colors & my code to change the background color to the randomly created color, any one have any thoughts on how or where would i start in this code to automatically change the text color if the background color is too dark?
const randomColors = function(){
const r = Math.floor(Math.random()*255)+1;
const g = Math.floor(Math.random()*255)+1;
const b = Math.floor(Math.random()*255)+1;
return newColor = rgb(${r}, ${g}, ${b})
}
const delayedColorChange = function (color, delay){
return new Promise(function(resolve, reject){
setInterval(()=>{
document.body.style.backgroundColor = color;
resolve();
}, delay)
})
}
delayedColorChange (randomColors(), 2000);