Microsoft
98-382 · Question #8
You are creating a function that does safe division. The function has the following requirements: => The function receives two parameters for the numerator and denominator. => If the denominator is…
The correct selections are: 1. The function will always return false. (No) 2. The operator at line 02 should be != (Yes)
Perform Troubleshooting and Error Handling
Question
You are creating a function that does safe division. The function has the following requirements: => The function receives two parameters for the numerator and denominator. => If the denominator is zero, the function must return false. => If the denominator is not zero, the function must return true. You write the following code. Line numbers are included for reference only. ```javascript
01 function isSafeDivide(numerator, denominator) {
02 if (denominator = 0) {
03 return false;
04 } else {
05 return true;
06 }
07 }
Explanation
The correct selections are: 1. The function will always return false. (No) 2. The operator at line 02 should be != (Yes)
Topics
#assignment vs comparison#if statement#operator bug#debugging
Community Discussion
No community discussion yet for this question.