I'm trying to write a function to find the smallest value in linkedlist using javascript. However, my code doesn't seem to work. I guess there's something wrong with the while loop. My code as follows:
function find_smallest(ll){
var i = ll;
var smallest = i.data;
while(i){
if(i.data<smallest){
smallest = i.data;
}
i.next;
}
return i.data;
}