JSE1: Module 6 Test Answers (JavaScript Essentials 1)

JavaScript Essentials 1 – JSE1: Module 6 Test Answers

1. Which of the following is a syntax error?

  • Attempting to call a non-existent function.
  • Attempting to modify the value of a constant.
  • Attempting to read a value from a variable that we have not previously declared.
  • Missing parenthesis ending a condition in an if statement.

2. Analyze the code below:

"let x = 10";
console.log(x);

What exception will be thrown as a result of its execution attempt?

  • TypeError
  • RangeError
  • SyntaxError
  • ReferenceError

3. Where can we find in the debugger the information about the currently called functions in our program?

  • In the call stack window.
  • In the console.
  • We do not have access to such information.
  • In the watch window.

4. Logical errors that we make while writing a program are not indicated by the interpreter. Why?

  • It results from the default settings of the interpreter, although we can modify these settings so that logical errors are also pointed out.
  • The interpreter does not indicate errors while the program is running, because it detects them before the program runs (it does not allow the program to run).
  • The interpreter ignores logical errors, because they do not affect the result of the program in any way.
  • The interpreter is unable to identify logical errors because they are not related to either the syntax or the semantics of the JavaScript language.

5. Using the debugger, we insert a breakpoint in the code at which, after running the program, we stop. In the debugger, we find a Step button among the step-by-step operation options. What does pressing it do?

  • Exactly one instruction immediately after the breakpoint will be executed and the program will be paused again.
  • The program will execute to the end or to the next breakpoint.
  • The program will be restarted from the first instruction.
  • The program will be executed to the end, regardless of whether there are more breakpoints in the rest of the code or not.

6. Analyze the following code:

let x 10;
console.log(x);

What exception will be thrown as a result of its execution attempt?

  • RangeError
  • SyntaxError
  • ReferenceError
  • TypeError

7. Analyze the following code:

const x = 10;
x = 20;

What exception will be thrown as a result of its execution attempt?

  • ReferenceError
  • TypeError
  • RangeError
  • SyntaxError

8. We want to measure how long a certain piece of code executes. In order to do so, it is enough to:

  • precede the fragment with the command console.time("start") and end with console.time("end").
  • precede the fragment with the command console.timeStart("counter") and end with console.timeEnd("counter").
  • precede the fragment with the command timeStart() and end with timeEnd().
  • aprecede the fragment with the command console.time("counter") and end with console.timeEnd("counter").

9. What is the name of the place where program code execution is halted?

  • exitpoint
  • pausepoint
  • breakpoint
  • stoppoint

10. Analyze the following code:

try {
    ocnsole.log("start");
} catch (error) {
    console.log("error");
}
console.log("end");

What will happen as a result of its execution?

  • The following words will appear in the console: "start", "end".
  • The console will display the words "start", "error", "end" on successive lines.
  • The operation of the program will be interrupted and the console will display the default message "Uncaught ReferenceError: ocnsole is not defined".
  • In the console, there will appear in successive lines the words "error", "end".

11. Analyze the following code:

try {
    ocnsole.log("start");
} catch (error) {
    console.log("error");
} finally {
    console.log("end");
}

What will happen as a result of its execution?

  • The following words will appear in the console: "start", "end".
  • The words "start", "error", "end" will appear in the console on successive lines.
  • The word "error" will appear in the console.
  • The following words will appear in the console: "error", "end".

12. Analyze the following code:

const x = 10;
onsole.log(x);
x += 10;

What exception will be thrown as a result of its execution attempt?

  • SyntaxError
  • ReferenceError and TypeError
  • ReferenceError
  • TypeError

13. Analyze the following code:

try {
    console.log("start");
} catch (error) {
    console.log("error");
} finally {
    console.log("end");
}

What will happen as a result of its execution?

  • The following words will appear in the console: "start", "end".
  • The following words will appear in the console: "error", "end".
  • The words "start", "error", “end” will appear in the console on successive lines.
  • The word "error" will appear in the console.

14. Analyze the following code:

let x = 10;
ocnsole.log(x);

What exception will be thrown as a result of its execution attempt?

  • RangeError
  • TypeError
  • ReferenceError
  • SyntaxError

Leave a Reply

Your email address will not be published. Required fields are marked *