0
0
Typescriptprogramming~15 mins

String type behavior in Typescript - Mini Project: Build & Apply

Choose your learning style9 modes available
String type behavior
📖 Scenario: Imagine you are working on a simple program that handles names of fruits. You want to learn how strings work in TypeScript by creating and manipulating string variables.
🎯 Goal: You will create a string variable, add another string to it, and then display the final combined string.
📋 What You'll Learn
Create a string variable with a specific value
Create another string variable to add
Combine the two strings using the + operator
Print the combined string
💡 Why This Matters
🌍 Real World
Handling and combining text data is common in many programs, like showing names, messages, or labels.
💼 Career
Understanding string behavior is essential for any programming job that involves user input, display, or text processing.
Progress0 / 4 steps
1
Create a string variable
Create a string variable called fruit and set it to the value "Apple".
Typescript
Need a hint?

Use let to declare a variable and set its type to string.

2
Create another string variable
Create another string variable called moreFruit and set it to the value " Banana" (note the space before Banana).
Typescript
Need a hint?

Remember to include the space before Banana so the words separate when combined.

3
Combine the two strings
Create a new string variable called allFruits that combines fruit and moreFruit using the + operator.
Typescript
Need a hint?

Use the + operator to join two strings.

4
Print the combined string
Use console.log to print the value of allFruits.
Typescript
Need a hint?

Use console.log(allFruits); to show the combined string in the console.