Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140788

Array object value not counting up in js

$
0
0

I have a problem of some of my object values in my array do not show correct in my html site, it only shows the last number of the array in every .When i make a console log it shows the correct numbers its just in the table it wont do it. it did work before but now i doest not and i do not know what i did that ruined my code. I hope for some quick help that works. Website

function metric(tryk){
    for (var i = 0; i < death_row.length; i++) {
    if (tryk === "metric"){ 
        var testMetric = death_row[i].height;
    }
    if (testMetric === null){
        death_row[i].height = 0;
        death_row[i].weight = 0;
    } else{
        var klip1 = death_row[i].height.slice(0,1);

        var klip2 = death_row[i].height.slice(3,death_row[i].height.indexOf("'",i+2));
        var klip2tal = Number(klip2);
        //console.log(klip2);
        var regn1 = klip1 * 12;
        var regn2 = regn1 + klip2tal;
        var regn3 = regn2 * 2.54;
        console.log(regn3);

        var vaegt = death_row[i].weight/2.2046;
        console.log(vaegt);
    };
};

var tabel2 = "<table>";
    for (var i = 0; i < death_row.length; i++) {
        tabel2+="<tr>";
        tabel2+="<td>"+death_row[i].first_name +""+ death_row[i].last_name+"</td>";
        tabel2+="<td>"+death_row[i].age_at_execution+"år"+"</td>";
        tabel2+="<td>"+regn3+"</td>";
        tabel2+="<td>"+vaegt+"</td>";
        tabel2+="</tr>";
    }
    tabel2+="</table>";
document.getElementById("test").innerHTML = tabel2;
}; 
<div id="test"></div><div id="test2"></div>

Viewing all articles
Browse latest Browse all 140788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>