I have a variable named "classes" and basically, it contains classes like (apples,orange,grapes,mango) and this is coming from a txt file and being stored in a variable. The elements are printed on the webpage,but I want to assign each element in the set a different colour and I cant use random() because it will keep changing after i refresh the page, what I want to achieve is assigning random colours to each element in the Set and then the colours should become static and shouldn't keep changing after that.
Can someone please help how to achieve this either through html,css,or javascript.I am a beginner and I have to achieve this task fast.
Thank you
...
<p id="classname" ></p>
#classname{
text-align: right;
}
classes = annotationline[8];
//pushing the elements in an array
classarray.push(classes);
//removing duplicates
classset=new Set(classarray);
console.log(classset);
//printing it
text = "";
classset.forEach (function(value) {
text += value + "<br>";
})
document.getElementById("classname").innerHTML = text;
classarray.length = 0;
})
...