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 };

javascript programming
exercise: functions 07

x
    document.write("<td><pre>"+str(testAA[i][nArgs])+"</pre></td>");
 
1
<html>
2
<script>
3
4
// ADD YOUR FUNCTION UNDER THIS LINE
5
6
7
8
var tailA = { next: null };
9
var cellA2 = { data: 2, next: tailA };
10
var cellA1 = { data: 5, next: cellA2 };
11
var headA = { next: cellA1 };
12
13
var tailB = { next: null };
14
var cellB3 = { data: 2, next: tailB };
15
var cellB2 = { data: 7, next: cellB3 };
16
var cellB1 = { data: 6, next: cellB2 };
17
var headB = { next: cellB1 };
18
19
var tailC = { next: null };
20
var cellC3 = { data: 45, next: tailC };
21
var cellC2 = { data: 33, next: cellC3 };
22
var cellC1 = { data: 12, next: cellC2 };
23
var headC = { next: cellC1 };
24
25
var tailD = { next: null };
26
var cellD3 = { data: 9, next: tailD };
27
var cellD2 = { data: 9, next: cellD3 };
28
var cellD1 = { data: 9, next: cellD2 };
29
var headD = { next: cellD1 };
30
 
31
var testAA = [
32
  [headA,5],
33
  [headB,7],
34
  [headC,45],
35
  [headD,9]
36
];