Driver code
var head = newNode ( 10 ) ; head . next = newNode ( 20 ) ; head . next . next = newNode ( 10 ) ; head . next . next . next = newNode ( 30 ) ; head . next . next . next . next = newNode ( 40 ) ; head . next . next . next . next . next = newNode ( 10 ) ; head . next . next . next . next . next . next = newNode ( 60 ) ; document . write ( " " ) ; printList ( head ) ; var key = 10 ; moveToEnd ( head , key ) ; document . write ( " " ) ; printList ( head ) ;