Skip to content

Instantly share code, notes, and snippets.

@ikotse-code
Created December 1, 2025 19:35
Show Gist options
  • Select an option

  • Save ikotse-code/d61e4063144612b5f87124ee4b1f8d1a to your computer and use it in GitHub Desktop.

Select an option

Save ikotse-code/d61e4063144612b5f87124ee4b1f8d1a to your computer and use it in GitHub Desktop.
//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