My task involves dynamically creating <p>
elements within a div based on the contents of my codeArray
, which can vary in size each time. Instead of hard-coding these elements, I have devised the following method:
for(i=1;i<codeArray.length;i++){
if(factArray[i] != 0){
let para = document.createElement('p');
let node = document.createTextNode(codeArray[i] + " = " + factArray[i]);
para.appendChild(node);
let element = document.getElementById('leftModal');
element.appendChild(para);
}
}
One challenge I am facing is how to make the first part of the string (before '=') appear bold while keeping the second part (factArray[i]) in normal font weight. Is there a solution for achieving this formatting?