https://github.com/farhaj499/assignment2
Assignment 2: Callbacks, Promises and Async Functions.
https://github.com/farhaj499/assignment2
async-await callback-functions promises typescript
Last synced: about 2 months ago
JSON representation
Assignment 2: Callbacks, Promises and Async Functions.
- Host: GitHub
- URL: https://github.com/farhaj499/assignment2
- Owner: Farhaj499
- Created: 2024-01-07T12:04:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-07T12:12:55.000Z (over 1 year ago)
- Last Synced: 2025-01-29T03:38:05.333Z (4 months ago)
- Topics: async-await, callback-functions, promises, typescript
- Language: TypeScript
- Homepage:
- Size: 2.54 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Assignment Callback, Promise, Async and Await
### **Question 1: Callbacks**
**Task:**
You are creating a basic calculator application. Write a TypeScript function named **`calculate`** that takes two numbers and an operation (add, subtract, multiply, or divide) as parameters. Implement a callback function to handle the calculation and display the result.### **Question 2: Promises**
**Task:**
Imagine you are building a simple quiz app. Create a TypeScript function named **`fetchQuestion`** that returns a promise. This promise should resolve with a random quiz question (string). Use the promise to display the question when it's ready.### **Question 3: Async/Await**
**Task:**
Build a TypeScript function named **`waitAndGreet`** that takes a name (string) as a parameter. This function should use async/await to simulate a delay (e.g., 2 seconds) and then display a greeting with the provided name. Call this function from within an async function and log the result.These tasks should be suitable for beginners while still covering the basics of callbacks, promises, and async/await in TypeScript.