← Back to challenges

Adding Elements to the End of a Singly Linked List

JavaScriptHarddata_structuresalgorithmsarrays

Instructions

Create a method in a LinkedList class called push that adds an element to the end of the linked list and returns the added element. The LinkedList class is created for you.

Examples

push(1) ➞ 1

push(2) ➞ 2

push(3) ➞ 3

Notes

Element is a positive integer.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.