forked from youssefbm/C3Worshops
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnoncé2_Starter.js
More file actions
43 lines (35 loc) · 820 Bytes
/
Enoncé2_Starter.js
File metadata and controls
43 lines (35 loc) · 820 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
class Bookshelf {
constructor() {
this.favoriteBooks = [];
}
// TODO: Définir la méthode `addFavoriteBook(..)`
// et `printFavoriteBooks()`
}
function addFavoriteBook(bookName) {
if (!bookName.includes("Great")) {
favoriteBooks.push(bookName);
}
}
function printFavoriteBooks() {
console.log(`Favorite Books: ${favoriteBooks.length}`);
for (let bookName of favoriteBooks) {
console.log(bookName);
}
}
function loadBooks( /* .. */ ) {
// TODO: appeler fakeAjax( .. );
}
var BOOK_API = "https://fake.url/api";
// ***********************
// NOTE: Ne modifie pas cette fonction
function fakeAjax(url, cb) {
setTimeout(function fakeLoadingDelay() {
cb([
"A Song of Ice and Fire",
"The Great Gatsby",
"Crime & Punishment",
"Great Expectations",
"You Don't Know JS"
]);
}, 500);
}