FBISE, NCP & NBF-aligned resources for Classes 9–12
Browse by Class
Browse by Type
Computer Chapter 3 : Topic 5.5
Invoke functions and check return values
1 / 5
A student writes a JavaScript function that returns the sum of two numbers and then calls it to display the result. What is the main purpose of invoking the function in this context?
Reasoning: Invoking a function runs its code and allows the programmer to check whether the returned value is correct.
2 / 5
In JavaScript, a function calculateArea(length, width) returns a value. Which code correctly checks the returned result for correctness?
Reasoning: Calling the function inside console.log displays the returned value, allowing verification of correctness.
3 / 5
A programmer invokes a function multiple times with different inputs and compares the returned outputs. What concept is being applied?
Reasoning: Calling a function with different inputs helps test whether it produces correct outputs in all cases.
4 / 5
A student writes a function that returns a boolean value and then uses an if statement to check the result. What is being tested?
Reasoning: Using the returned value in a condition helps verify whether the function logic is correct.
5 / 5
Why is it important to use function return values when testing JavaScript code instead of only printing inside the function?
Reasoning: Return values allow functions to be tested, reused, and verified independently from their internal implementation.
Your score is
Restart quiz