Activity 2
Correct Answers
1. What does let allow in JavaScript? ✅ Block scope
2. What does the typeof operator return for null? ✅ object
3. How many primitive data types are there in JavaScript? ✅ 7
4. Which is a correct way to declare a string in JavaScript? ✅ All of the above
5. Which operator is used to compare both value and type? ✅ ===
6. Which data type can store true/false values? ✅ Boolean
7. What does the + operator do in JavaScript? ✅ Adds numbers and concatenates strings
8. Which data type is used for text in JavaScript? ✅ String
9. What happens when a const variable is reassigned? ✅ It throws an error
10. What happens if you declare a variable using let inside a block? ✅ It has block scope
Instructions:
Set Up Your Development Environment
- Open your preferred code editor (e.g., VS Code, Sublime Text, or Notepad++).
- Create a new file and save it with the
.htmlextension (e.g., Activity2.html).
Understanding JavaScript Operators
- Use JavaScript to demonstrate different types of operators:
- Arithmetic Operators
- Comparison Operators
- Logical Operators
- Assignment Operators
- Use
alert()andconsole.log()to display the results.
Final Output
- ✅ A webpage that runs JavaScript code demonstrating operators.
- ✅ Results should be displayed in an **alert box** and console.
- ✅ Use buttons to execute specific operations.