-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubway.js
32 lines (24 loc) · 883 Bytes
/
subway.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Subway lines have a first and last element, and are comprised of nodes (or stops) with links to the elements before and after them.
*/
const DoublyLinkedList = require('./DoublyLinkedList.js');
const subway = new DoublyLinkedList();
subway.addToHead('TimesSquare');
subway.addToHead('GrandCentral');
subway.addToHead('CentralPark');
//subway.printList();
subway.addToTail('PennStation');
subway.addToTail('WallStreet');
subway.addToTail('BrooklynBridge');
subway.printList();
/*
There’s construction happening on the subway line: the Central Park and Brooklyn Bridge stops will temporarily be closed. Remove them from your list without iterating through the entire list.
*/
subway.removeHead();
subway.removeTail();
subway.printList();
/*
The Times Square station is under construction. Remove it from the list
*/
subway.removeByData('TimesSquare');
subway.printList();