js获取table中的子节点,样式为text的值,数据全部找出,但是多了个undefined,求解

<form>
    <p>1.批量提交数据</p>
    <div>
        <input type="button" value="增加产品"  onclick="addRowTwo();" />
    </div>
    </br>
    <div>
        <table id="table1">
            <tr id="dataTable">
                <td>产品ID</td>
                <td>产品名称</td>
                <td>产品价格</td>
            </tr>
        </table>
    </div>
    </br>
    <div>
        <input type="submit" value="保存" onclick="save();" />
    </div>

    </br>
</form>

js:

function addRowTwo(){
var t = document.getElementById("table1");
var row = t.insertRow(t.rows.length);
for(var j=0;j<3;j++){
var cell1 = row.insertCell(j);
var i = document.createElement("input");
i.type="text";
i.style.width="120";
cell1.appendChild(i);
}
}
function save(tr) {
var r = new Array();
var table = document.getElementById("table1");
var items = document.getElementById("table1").getElementsByTagName("tr");
for(var i=1;i<table.rows.length;i++){
for(var j=0;j<3;j++){
var child = items[i].cells[j].childNodes[0];
if(child && child.type=="text"){
r[i-1]+=child.value+"\n";
}
}
alert(r[i-1]);
}

图片说明

r没有初始化,r[0]是undefined