const characterCount = (str, char) => { return str.split(char).length - 1}
const divisionColors = total => {
let totalNum = Number.parseInt(total)
let res = []
for (let i = 1; i <= totalNum;i++){
let r = (i % 3) == 0 ? Math.ceil(255-255/totalNum*i) : Math.ceil(Math.random()*255)
let g = (i % 3) == 1 ? Math.ceil(255-255/totalNum*i) : Math.ceil(Math.random()*255)
let b = (i % 3) == 1 ? Math.ceil(255-255/totalNum*i) : Math.ceil(Math.random()*255)
res.push('rgb('+r + ',' + g + ',' +b +')')
}
return res
}
console.log(characterCount('asdfasdfweqrwersdfa', 'a'))
let divisions = 12
let colors = divisionColors(divisions)
for(let i=0;i< divisions; i++){
document.write('<div style="margin:0.56rem;background-color:'+colors[i]+';width:30px;height:20px;"> </div>')
//document.write('<div style="background-color:rgb(233,120,56);width:30px;height:20px;"> '+i+'</div>')
}
console.log(colors)
console