Update linkedlist.ts

otherwise it works only on the first and the last element