Help me asap! getElementById(only negative numbers)
So guys i have this code here: var pinakasPinakas= [2, 43, -21, 25, 34, -9, -50, 60, 12, -3]; var sum=0; for (var i=0; i<pinakasPinakas.length; i++){ if (pinakasPinakas [i] >0){ sum=sum+pinakasPinakas[i]; } } document.getElementById("summy").innerHTML="Sum: " +sum+ ".<br>" var multi=1; for (var i=0; i<pinakasPinakas.length; i++){ if(pinakasPinakas[i] > 0){ multi=multi*pinakasPinakas[i]; } } document.getElementById("multipl").innerHTML="multi: " +multi+ ".<br>" for (var i=0; i<pinakasPinakas.length; i++){ if(pinakasPinakas[i]<0){ document.getElementById("negative").innerHTML=(pinakasPinakas[i]); // document.write(pinakasPinakas[i]) }} // My "project" is to multiply and add the positive numbers in the array and put each one of them in an "ID", which is of course in my HTML file. So that's easy and I did that above as u see. So, what's the issue? After that, I should also display the negative values just like that: in another <p id="negative"> in the html file. (-21,-9,-50,-3). When I use the getElementById method with my innerHTML nothing appears, but sometimes when I modify that a little the last negative value is displayed (only -3). When I comment it and uncomment the document.write() method all negatives numbers are displayed. Why do I face such a problem with the first method? And how can i fix my code? // thanks