0
0
Javascriptprogramming~15 mins

Why operators are needed in Javascript - See It in Action

Choose your learning style9 modes available
Why Operators Are Needed
📖 Scenario: Imagine you have some numbers and words, and you want to combine or compare them. Operators help you do this easily, like adding prices or checking if two things are the same.
🎯 Goal: You will create simple examples using operators to add numbers, join words, and compare values. This will show why operators are useful in programming.
📋 What You'll Learn
Create two number variables with exact values
Create two string variables with exact values
Use the addition operator to add the two numbers
Use the concatenation operator to join the two strings
Use the equality operator to compare the two numbers
💡 Why This Matters
🌍 Real World
Operators are used in everyday programming to calculate totals, combine text, and make decisions.
💼 Career
Understanding operators is essential for any programming job because they are the building blocks of logic and calculations.
Progress0 / 4 steps
1
Create number variables
Create two variables called num1 and num2 with values 10 and 5 respectively.
Javascript
Need a hint?

Use const to create variables and assign the numbers 10 and 5.

2
Create string variables
Create two variables called str1 and str2 with values 'Hello' and 'World' respectively.
Javascript
Need a hint?

Use single quotes to create string variables.

3
Add numbers using + operator
Create a variable called sum that adds num1 and num2 using the + operator.
Javascript
Need a hint?

Use the plus sign + to add numbers.

4
Join strings and compare numbers
Create a variable called greeting that joins str1 and str2 with a space using the + operator. Then create a variable called isEqual that checks if num1 is equal to num2 using the === operator. Finally, print sum, greeting, and isEqual.
Javascript
Need a hint?

Use + to join strings with a space. Use === to compare numbers. Use console.log() to print.