Skip to content

Instantly share code, notes, and snippets.

@Nalini1998
Nalini1998 / Build a Library
Created April 19, 2023 21:14
Build a Library Project: Books-‘N-Stuff carries three different types of media: books, CDs, and movies. In this project you will create a parent class named Media with three subclasses: Book, Movie, and CD.
// Created by Nalini Vo from Vietnam
// Requires:
**1. Book**
**Properties**: Author (string), title (string), pages (number), isCheckedOut (boolean, initially false), and ratings (array, initially empty).
**Getters**: All properties have a getter
**Methods**: .getAverageRating(), .toggleCheckOutStatus(), and .addRating()
**2. Movie**
**Properties**: Director (string), title (string), runTime (number), isCheckedOut (boolean, initially false), and ratings (array, initially empty)
**Getters**: All properties have a getter
**Methods**: .getAverageRating(), .toggleCheckOutStatus(), and .addRating()
@Nalini1998
Nalini1998 / Chaining Multiple Promises
Last active April 19, 2023 21:18
JAVASCRIPT PROMISES: One common pattern we’ll see with asynchronous programming is multiple operations which depend on each other to execute or that must be executed in a certain order. We might make one request to a database and use the data returned to us to make another request and so on! Let’s illustrate this with another cleaning example, w…
Chaining Multiple Promises
firstPromiseFunction()
.then((firstResolveVal) => {
return secondPromiseFunction(firstResolveVal);
})
.then((secondResolveVal) => {
console.log(secondResolveVal);
});
--------------------