<s>[INST] Write JavaScript code to reverse a linked list [/INST] Here is a JavaScript function to reverse a linked list:

function reverseLinkedList(head) { 
  let prev = null;
  let current = head;
  let next;

  while(current !== null) {
      next = current.next;
      current.next = prev;
      prev = current;
      current = next;
  }

  return prev;
}</s>