# Quiz 4 High-order Functions

Given the following array,

```javascript
type Book = {
  title: string,
  author: string,
  year: number,
  genres: string[],
};
const books: Book[] = [
  {
    title: "1984",
    author: "George Orwell",
    year: 1949,
    genres: ["Fiction", "Dystopia"],
  },
  {
    title: "The Great Gatsby",
    author: "F. Scott Fitzgerald",
    year: 1925,
    genres: ["Fiction", "Tragedy"],
  },
  {
    title: "To Kill a Mockingbird",
    author: "Harper Lee",
    year: 1960,
    genres: ["Fiction", "Drama"],
  },
  {
    title: "Brave New World",
    author: "Aldous Huxley",
    year: 1932,
    genres: ["Fiction", "Dystopia"],
  },
  {
    title: "Moby Dick",
    author: "Herman Melville",
    year: 1851,
    genres: ["Fiction", "Adventure"],
  },
];
```

- Your task is to implement the following functions using only high-order functions such as `.sort()`, `.some()`, `.filter()`, `.flatMap()`, `.map()`, and `.reduce()`.
- Solutions utilizing traditional for-loops or `.forEach()` will not be accepted.

1. **Sort the books** by their publication year in descending order (newest first), and log the result using `console.log`.

2. Use **Array.some()** to check if any book was published after the year 1950, and log the result using `console.log`.

3. Create a new array containing only the books that belong to the "Dystopia" genre, and log the result using `console.log`.

4. Create a flattened list of all genres from the books, and log the result using `console.log`.

5. **Create a new array of strings** for books that are classified as "Dystopia" and were published after the year 1940. Each string should be in the format: `"The book {title}, published in {year}."`, and log the result using `console.log`.

6. Calculate the total number of books that were published before the year 1950, and log the result using `console.log`.

Test your solutions on [typescriptlang.org](https://www.typescriptlang.org/play?#code/C4TwDgpgBAQg9nA1lAvFA3gWAFBSsAS2ABsIAuKAZ2ACcCA7AcwBoc8BDAV2AAs4aK1Ok1a4oICOwFR6nALYAjCDVF5GEejQiVBtBowDaAXVEBfANw4AxnHrUoChIh2wnx1FANsM3vIRLkUABEAIwAnAAcACxBqnhQXLz8FEEA4hD86lAA8jQA7hDExLG+4pLS4VFhcWoaWi4GQQBiBFaEtrHBACIg1HBgBOxBJt6mcVhifkSkKQAqPNCpWuzAUKkrlAogJZMJ3HzSzQB0UADKNsCrLcAAXuo07MQAJjvxZVIU4QBMAKw1UOpNNoKI0Wm0CB1mMFZg91E9tiMxGNvBM3v4ZtC4FAANIEIoJKAAWTgVkQ+gUBBoL3+iQOKQAElJIDQoAAZCAQV7xCQfKDhABsAAZ-oD6iDmq12vROkEug85ENEXhkWJUfF0YEgjAHgA3aAAOQgeSgAHV+M8uRx9slggBBZ5wTiUKD0zgAD1I23+PIqYQAzF8RXVgZ4JeDId1esB+oNhnEVXg1VMAiliVsoF1WohLXskod6coFfQiYUdXjSDmfZ8Ij8QkGgQ0w1KZbannr6MBOFo46NREZzEA):
