nth from list - Node.js Data Structure

Node.js examples for Data Structure:List

Description

nth from list

Demo Code


function nth(list,element) {
  if (element == 0 ) {return list.value }
    console.log(list.rest,element)//from w  w  w. j  a v  a2s  .co m
  return nth(list.rest,element-1)
}

console.log(nth(arrayToList([10, 20, 30]), 1));

Related Tutorials