const liArray = [5.6, 8.7, 1.3, 10, 56];
const parentElement = document.getElementById("myDiv");
liArray.forEach((currentValue, index) => {
var elm = document.createElement('p');
elm.innerHTML = `${index + 1}. ${currentValue}`;
parentElement.appendChild(elm);
});
<div id="myDiv"></div>
i have this code that creates a new paragraph element for every item in the array so the result will be :
1. 5.6
2. 8.7
3. 1.3
4. 10
5. 56
but i want to automaticaly add round bracket ()
to the lowest and highest number when creating the elements so the created elements will be like this
1. 5.6
2. 8.7
3. (1.3)
4. 10
5. (56)
how can i do this?