# Quiz 3 TypeScript Basics

Given the following array,

```javascript
let books = [
  { title: "1984", author: "George Orwell", pages: 328 },
  { title: "The Great Gatsby", author: "F. Scott Fitzgerald", pages: 180 },
  { title: "To Kill a Mockingbird", author: "Harper Lee", pages: 281 },
  { title: "Brave New World", author: "Aldous Huxley", pages: 264 },
  { title: "The Catcher in the Rye", author: "J.D. Salinger", pages: 234 },
];
```

Complete the following tasks in TypeScript:

1. Typing an Object

   Create a TypeScript `interface` or `type` named `Book` to describe the structure of the objects within the `books` array.

2. Copy Elements

   Copy the last 2 objects from the array `books`, and `console.log` the result.

3. Replace Elements

   In the books array, replace the 3rd object with two new objects `{ title: "The Hobbit", author: "J.R.R. Tolkien", pages: 310}` and `{title: "Pride and rejudice", author: "Jane Austen", pages: 432};`, and `console.log` the updated `books`.

   ```javascript
   let a = { title: "The Hobbit", author: "J.R.R. Tolkien", pages: 310 };
   let b = { title: "Pride and Prejudice", author: "Jane Austen", pages: 432 };
   ```

4. Iterate Over Object Properties

   Use for-loop to `console.log` only the property names and values of each object in `books` where the property's data type is number.

5. Consider the following code:

   ```javascript
   let book1 = books[0];

   let book2 = { title: "1984", author: "George Orwell", pages: 328 };

   console.log(book1 == book2);

   console.log(book1 === book2);
   ```

   What will be the output of the two console.log() statements?

6. what is the result of the following code?

   ```javascript
   let favoriteBooks = [];

   favoriteBooks.push(books[1].title);

   favoriteBooks.push(books[3].title);

   favoriteBooks.pop();

   console.log(favoriteBooks);
   ```

7. Splitting an Array into Two Parts with Destructuring and the Spread Operator

   Write a function `splitIt` that takes any `Book` array as input, splits it into two parts: the first two elements and the rest, and returns both parts. Test your function using code below.

   ```javascript
   const [firstTwo, theRest] = splitIt(books);
   console.log("First Two Books:", firstTwo);
   console.log("The Rest of the Books:", theRest);
   ```

Test your solutions on [typescriptlang.org](https://www.typescriptlang.org/play?#code/DYUwLgBARg9jDWBnCBeCBtAsAKAhA3hGAJZigBcEARAIwCcAHACxUA0EAhgK5gAWMAJ0pUA4iEEBzEBADyAgO4hgwNhAAOHKYkoBmAEwMIAX1Y48hEmRDCAKr2kiBIDpBEvEUAJ6rufQcIAxADoIAGUAYxgwSADSAC8pAQ5gABNVDS1KGgYABmNTXAIiUgpqGxgIAGliZU4IAFkYcPhiADsJKGIBNPZffiFqAAkOATUQAQgAGRAQdM0QbQgDGnyzIstSqgAhJIA3aQA5EHkIAHVBVJ8efuEAQVSYLmRBrgAPUG92DIXKPQA2JirQoWErWMr2CAAYRc4XsEzaRAhACVPLNetd-NQAFJBAAiIVCyTaiTmmSWOkBJhwAF0ANxAA):
