Why async and await are needed
📖 Scenario: Imagine you want to get some information from the internet, like the weather or news. Sometimes, this takes time. Your program should not stop and wait but keep doing other things. This is where async and await help.
🎯 Goal: You will create a simple program that shows how async and await make it easy to wait for information without stopping everything else.
📋 What You'll Learn
Create a function called
getData that returns a promise simulating a delayCreate a variable called
message with a string valueCreate an
async function called showData that uses await to wait for getDataPrint the
message and the result from getData💡 Why This Matters
🌍 Real World
Many apps get information from the internet or slow devices. Using <code>async</code> and <code>await</code> helps keep apps smooth and responsive.
💼 Career
Understanding <code>async</code> and <code>await</code> is important for web developers, especially when working with APIs, databases, or any task that takes time.
Progress0 / 4 steps