Driver code
var head = null ; head = insertEnd ( head , getNode ( 1 ) ) ; head = insertEnd ( head , getNode ( 2 ) ) ; head = insertEnd ( head , getNode ( 3 ) ) ; head = insertEnd ( head , getNode ( 4 ) ) ; head = insertEnd ( head , getNode ( 5 ) ) ; document . write ( " " ) ; display ( head ) ; head = reverse ( head ) ; document . write ( " " ) ; display ( head ) ;