Write a function named max
that takes an argument named list
, which is the head cell of a linked list in the form below and returns the largest number in the data field of any cell.
var tail = { next: null };
var cell2 = { data: 12, next: tail };
var cell1 = { data: 45: next: cell2 };
var head = { next: cell1 };
document.write("<td><pre>"+str(testAA[i][nArgs])+"</pre></td>");
<html>
<script>
// ADD YOUR FUNCTION UNDER THIS LINE
var tailA = { next: null };
var cellA2 = { data: 2, next: tailA };
var cellA1 = { data: 5, next: cellA2 };
var headA = { next: cellA1 };
var tailB = { next: null };
var cellB3 = { data: 2, next: tailB };
var cellB2 = { data: 7, next: cellB3 };
var cellB1 = { data: 6, next: cellB2 };
var headB = { next: cellB1 };
var tailC = { next: null };
var cellC3 = { data: 45, next: tailC };
var cellC2 = { data: 33, next: cellC3 };
var cellC1 = { data: 12, next: cellC2 };
var headC = { next: cellC1 };
var tailD = { next: null };
var cellD3 = { data: 9, next: tailD };
var cellD2 = { data: 9, next: cellD3 };
var cellD1 = { data: 9, next: cellD2 };
var headD = { next: cellD1 };
var testAA = [
[headA,5],
[headB,7],
[headC,45],
[headD,9]
];