Write a function named contains
that takes an argument named list
, which is the head of a linked list, and value
, which is a number, and returns true if the list contains a cell containing that value, and false otherwise. Code to construct an example linked list in the form used in the tests is given below.
var tail = { next: null };
var cell2 = { data: 12, next: tail };
var cell1 = { data: 45: next: cell2 };
var head = { next: cell1 };