Created
December 1, 2025 19:35
-
-
Save ikotse-code/d61e4063144612b5f87124ee4b1f8d1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Assignment #2 | |
| //Task1 | |
| //Create class | |
| class Person { | |
| firstName: string; | |
| lastName: string; | |
| } | |
| //Create instance 1 | |
| const person1 = new Person(); | |
| person1.firstName = "Anna"; | |
| person1.lastName = "Miller"; | |
| console.log(person1.firstName, person1.lastName); | |
| console.log(person1); | |
| //Create instance 2 | |
| const person2 = new Person(); | |
| person2.firstName = "Bob"; | |
| person2.lastName = "Kuller"; | |
| console.log(person2.firstName, person2.lastName); | |
| console.log(person2); | |
| //Task2 | |
| //Create class | |
| class Book { | |
| title: string; | |
| author: string; | |
| pages: number; | |
| constructor(title: string, author: string, pages: number) { | |
| this.title = title; | |
| this.author = author; | |
| this.pages = pages; | |
| } | |
| } | |
| //Create instance with values | |
| const book1 = new Book("ABC", "John Doe", 5); | |
| console.log(book1.title, book1.author, book1.pages); | |
| console.log(book1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment