Driver code
var head = newNode ( 5 ) ; head = insert ( head , 4 ) ; head = insert ( head , 3 ) ; head = insert ( head , 2 ) ; head = insert ( head , 1 ) ; printList ( head ) ; document . write ( " " ) ; head = reverseList ( head ) ; printList ( head ) ;