ngaukonojane / JAVASCRIPTone

0 stars 0 forks source link

Assignment Feedback #1

Open evansmwendwa opened 6 years ago

evansmwendwa commented 6 years ago

Your code does not address the question by any means.

I don't want to see this

function listArray(array) {
  var list = 0;
  for (var i = array.length - 1; i >= 0; i--)
    list = {value: array[i], rest: list};
  return list;
}

function nth(list, n) {
  if (!list)
    return undefined;
  else if (n == 0)
    return list.value;
  else
    return nth(list.rest, n - 1);
}

console.log(nth(listArray([100, 40, 20]), 1));

const v = (list,n) => (nth(listArray([100, 40, 20]), 1));
evansmwendwa commented 6 years ago

Update your code on this repository so that we can continue the discussion here.

Some feedback: We are not converting any array to a list. We just need a function to get nth element if any array we pass to it