Skip to content

Instantly share code, notes, and snippets.

@Natalia-NK
Created May 17, 2025 17:45
Show Gist options
  • Save Natalia-NK/de52509228154218760885612137f231 to your computer and use it in GitHub Desktop.
Save Natalia-NK/de52509228154218760885612137f231 to your computer and use it in GitHub Desktop.
Homework_03_NK
//task1
class Person{
firstName: string;
lastName: string;
}
// TODO: Create instance 1
const person1 = new Person();
person1.firstName = "Anna";
person1.lastName = "Miller";
console.log(person1);
//task2
class Book{
title: string;
author: string;
pages: number;
constructor(title: string, author: string, pages: number) {
this.title = title;
this.author = author;
this.pages = pages;
}
}
//TODO: Create an instance with values
const book1 = new Book("MyWork", 'my', 56);
console.log(book1);
//task 1
// temperature converter
function convertToFahrenheit(celsius: number): number {
const result = (celsius * 9 / 5) + 32;
return result;
}
//Task 2
//Greeting Generator
function greetUser(firstName: string, lastName: string): string {
const result = 'Hello, '+ firstName +' '+ lastName;
return result;
}
//task 3
//Rectangle Area Calculator
function calculateArea(width: number, height: number): number {
const result = (width * height);
return result;
}
//task 4
//simple sum
function addNumbers(simpleA: number, simpleB: number): number {
const result = (simpleA + simpleB);
return result;
}
console.log(convertToFahrenheit(25));
console.log(greetUser('Anna', 'Miller'));
console.log(calculateArea(4,5));
console.log(addNumbers(10,15));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment