Skip to content

Farhaj499/Assignment2

Repository files navigation

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.

About

Assignment 2: Callbacks, Promises and Async Functions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published