Activity 5

1. What is a real-world example of using functions?

2. How do you integrate functions with HTML?

3. How can you call a function in JavaScript?

4. How do you define a basic JavaScript function?

5. What happens if no return value is specified?

6. What is required when defining a function?

7. What determines if a variable is local or global?

8. What is the main purpose of a function in JavaScript?

9. How do you handle errors in a function call?

10. What is an advantage of modular functions?

Correct Answers

1. What is a real-world example of using functions? ✅ Validating form inputs in HTML.

2. How do you integrate functions with HTML? ✅ Use HTML events like onLoad.

3. How can you call a function in JavaScript? ✅ By using its name followed by parentheses.

4. How do you define a basic JavaScript function? ✅ Using the function keyword.

5. What happens if no return value is specified? ✅ The function returns undefined.

6. What is required when defining a function? ✅ A name, parentheses, and a code block.

7. What determines if a variable is local or global? ✅ The place where it is declared.

8. What is the main purpose of a function in JavaScript? ✅ To organize code into reusable segments.

9. How do you handle errors in a function call? ✅ Use conditional checks before calling functions.

10. What is an advantage of modular functions? ✅ They make debugging easier.

Instructions:

Set Up Your Development Environment

Change Background Color Using JavaScript

Final Output

Change Background

Select a color to change the background