Activity 6

1. How is a method different from a function?

2. What does the every() array method do?

3. Which method is used to check if a string starts with a specific substring?

4. How can you replace all occurrences of a substring?

5. Which method creates a date object from milliseconds?

6. What does the sqrt() method do?

7. What is a major risk of using eval()?

8. What is the purpose of the concat() string method?

9. What is a built-in JavaScript method?

10. How can you format a number to two decimal places?

Correct Answers

1. How is a method different from a function? ✅ A method is attached to a class or object.

2. What does the every() array method do? ✅ Checks if all elements pass a condition.

3. Which method is used to check if a string starts with a specific substring? ✅ startsWith()

4. How can you replace all occurrences of a substring? ✅ Use the replaceAll() method.

5. Which method creates a date object from milliseconds? ✅ Date(milliseconds)

6. What does the sqrt() method do? ✅ Returns the square root of a number.

7. What is a major risk of using eval()? ✅ Security vulnerabilities like code injection.

8. What is the purpose of the concat() string method? ✅ Combines two or more strings.

9. What is a built-in JavaScript method? ✅ A predefined function provided by JavaScript.

10. How can you format a number to two decimal places? ✅ Use the toFixed(2) method.

Instructions:

Set Up Your Development Environment

Create a Simple Calculator Interface

Implement the Functionality

Final Output

Calculator