Skip to content

Commit fce6b7a

Browse files
author
Carlos Green
committed
List
1 parent 6b489bd commit fce6b7a

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

Chapter3Lists/chap3_1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,5 @@ names.prev();
146146
console.log(names.getElement(), 'getElement');
147147

148148
console.log(names.toString(), 'toString');
149+
150+
module.exports = List

Chapter3Lists/chap3_2.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
var movies = createArr("films.txt");
1+
const fs = require("fs")
2+
const List = require('./chap3_1')
3+
4+
function createArr(file) {
5+
console.log(file, 'file')
6+
var arr = fs.readdir(`${file}`, (err, files) => {
7+
if (err) throw err
8+
return files.split('\n').forEach((e) => {
9+
e = e.trim()
10+
console.log(e)
11+
})
12+
})
13+
}
14+
15+
var movies = createArr('./films.txt');
216
var movieList = new List();
317
var customers = new List();
18+
419
for (var i = 0; i < movies.length; ++i) {
520
movieList.append(movies[i]);
621
}
22+
723
print("Available movies: \n");
824
displayList(movieList);
925
checkOut("Jane Doe", "The Godfather", movieList, customers);
1026
print("\nCustomer Rentals: \n");
11-
displayList(customers);
27+
displayList(customers);

Chapter3Lists/films.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
1. The Shawshank Redemption
2+
2. The Godfather
3+
3. The Godfather: Part II
4+
4. Pulp Fiction
5+
5. The Good, the Bad and the Ugly
6+
6. 12 Angry Men
7+
7. Schindler’s List
8+
8. The Dark Knight
9+
9. The Lord of the Rings: The Return of the King
10+
10. Fight Club
11+
11. Star Wars: Episode V - The Empire Strikes Back
12+
12. One Flew Over the Cuckoo’s Nest
13+
13. The Lord of the Rings: The Fellowship of the Ring
14+
14. Inception
15+
15. Goodfellas
16+
16. Star Wars
17+
17. Seven Samurai
18+
18. The Matrix
19+
19. Forrest Gump
20+
20. City of God

0 commit comments

Comments
 (0)