nerdexam
Microsoft

98-382 · Question #14

How should you complete the code? To answer, select the appropriate code segments in the answer area. NOTE: Each correct selection is worth one point. You are given a partial JavaScript function…

The provided image shows four dropdowns within the safeRoot(a, b) function structure. The red boxes on page 3 indicate the correct selections for each dropdown: 1. First dropdown (nested inside if (a >= 0){): The correct selection is if (b % 2 == 0){ 2. Second dropdown…

Implementing Flow Control

Question

How should you complete the code? To answer, select the appropriate code segments in the answer area. NOTE: Each correct selection is worth one point. You are given a partial JavaScript function safeRoot(a, b) and need to fill in the missing parts within the provided if/else structure:

Explanation

The provided image shows four dropdowns within the safeRoot(a, b) function structure. The red boxes on page 3 indicate the correct selections for each dropdown:

  1. First dropdown (nested inside if (a >= 0){): The correct selection is if (b % 2 == 0){
  2. Second dropdown (following return Math.pow(a, 1 / b); and starting a new conditional block): The correct selection is } else {
  3. Third dropdown (nested inside a block that precedes return "Result is an imaginary number";): The correct selection is if (a >= 0){
  4. Fourth dropdown (nested inside the final else block): The correct selection is } else {

Note: The fragmented presentation of the code structure with multiple return statements and disconnected else blocks makes it difficult to reconstruct a single, logically coherent JavaScript function based solely on the provided snippets. The explanation lists the correct selections for each dropdown as indicated by the answer key.

Topics

#if/else#functions#Math.sqrt#conditional logic

Community Discussion

No community discussion yet for this question.

Full 98-382 Practice