Set value
to the sum of the numbers stored in the data
property of the linked list provided in list
. Form of list:
var cell2 = { data: 4, next: null };
var cell1 = { data: 3, next: cell2 };
document.write("<td><pre>"+str(testAA[i][nArgs])+"</pre></td>");
<html>
<script>
function sumThemUp(list) {
var value;
// ADD CODE UNDER THIS LINE
return value;
}
var testAA = [
[{data:1, next:null},1],
[{data:1, next:{data:5, next:null}},6],
[{data:1, next:{data:5, next:{data:7, next:null}}},13]
];
function cloneTree(obj) {
if (obj === null)
return null;
if (typeof obj !== "object")
return obj;
var newobj = {};
for (var prop in obj) {
newobj[prop] = cloneTree(obj[prop]);
}
return newobj;
}
var argAAS = [];
for (var i=0;i<testAA.length;i++) {
argAAS.push( [] );
for (var j=0;j<testAA[i].length-1;j++) {
argAAS[i].push( str(testAA[i][j]) );
}
}