Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🟦 TypeScript Problem Solving

A collection of TypeScript problem-solving exercises completed during a conceptual TypeScript session.

This project focuses on practicing important TypeScript concepts such as type annotations, interfaces, union types, arrays, functions, conditional logic, and object handling.


📚 Problems Included

This project contains solutions for the following 9 TypeScript problems:

1️⃣ Ticket Price Calculator

Determines the ticket price based on a person's age.

Concepts used:

  • Function parameters
  • Type annotations
  • Conditional statements
  • Return types

2️⃣ Stock Status Checker

Checks the available stock quantity and returns an appropriate stock status.

Examples include:

  • Out of Stock
  • Almost Sold Out
  • Available
  • In Stock

Concepts used:

  • Conditional statements
  • Comparison operators
  • Function return types

3️⃣ User Profile Formatter

Uses a User interface to format user information into a readable profile message.

User information includes:

  • Name
  • Age
  • City

Concepts used:

  • Interfaces
  • Object types
  • Functions
  • Template literals

4️⃣ Shopping Cart Total Calculator

Calculates the total price of products inside a shopping cart.

Each product contains:

  • Name
  • Price

The solution uses the reduce() method to calculate the total.

Concepts used:

  • Arrays
  • Object types
  • reduce()
  • Type annotations

5️⃣ Student Result Calculator

Calculates a student's average marks and determines whether the student has passed or failed.

The returned result includes:

  • Student name
  • Average marks
  • Result status

Concepts used:

  • Interfaces
  • Arrays
  • reduce()
  • Conditional logic
  • Object return types

6️⃣ Role Permission Checker

Checks whether a user role has permission to edit.

Available roles include:

  • admin
  • editor
  • viewer

Concepts used:

  • Union types
  • Boolean return values
  • Conditional logic

7️⃣ Product Finder

Finds products based on a selected category.

The solution uses the filter() method to return matching products.

Concepts used:

  • Interfaces
  • Arrays
  • filter()
  • Function parameters

8️⃣ Patient Status Checker

Determines the status of different types of patients.

Patient types include:

  • General patient
  • Emergency patient

Emergency patients also include different emergency levels.

Concepts used:

  • Interfaces
  • Union types
  • Type narrowing
  • Conditional statements

9️⃣ Transaction Processor

Processes banking transactions such as:

  • Deposit
  • Withdrawal

The function also checks whether the account has sufficient funds for a withdrawal.

Concepts used:

  • Union types
  • Object types
  • Conditional logic
  • Multiple return types

🧠 Concepts Practiced

This project demonstrates the use of:

  • Type annotations
  • Function parameter types
  • Function return types
  • Interfaces
  • Union types
  • Arrays
  • Objects
  • Conditional statements
  • Template literals
  • reduce()
  • filter()
  • Type narrowing
  • Boolean values
  • TypeScript configuration

📁 Project Structure

ts-problem/
│
├── src/
│   ├── 1.getTicketPrice.ts
│   ├── 2.getStockStatus.ts
│   ├── 3.formatUserProfile.ts
│   ├── 4.calculateCartTotal.ts
│   ├── 5.getStudentResult.ts
│   ├── 6.canEdit.ts
│   ├── 7.findProducts.ts
│   ├── 8.getPatientStatus.ts
│   ├── 9.processTransactions.ts
│   └── hello.ts
│
├── dist/
│
└── tsconfig.json

About

A collection of TypeScript problem-solving exercises covering core concepts, types, interfaces, arrays, and conditional logic.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages