An open API service indexing awesome lists of open source software.

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.

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.