Count Words with Given Prefix
📖 Scenario: You are building a simple search feature for a book store's website. The website wants to count how many book titles start with a certain prefix typed by the user.
🎯 Goal: Build a TypeScript program that counts how many words in a list start with a given prefix.
📋 What You'll Learn
Create an array of strings called
words with exact book titlesCreate a string variable called
prefix with the exact prefix to searchUse a
for loop to count how many words start with prefixPrint the count as a number
💡 Why This Matters
🌍 Real World
Counting words with a prefix is useful in search engines, autocomplete features, and filtering lists in apps.
💼 Career
This skill helps in building efficient search and filtering functions in web and software development.
Progress0 / 4 steps