We have declared an array let animals = [“dog”, “cat”, “hamster”];. We want to temporarily comment out the element “cat”, and to do this, we can modify the declaration as follows:

  • Post author:
  • Post category:Q&A
  • Reading time:1 min read
  • Post last modified:March 15, 2025

We have declared an array let animals = ["dog", "cat", "hamster"];. We want to temporarily comment out the element "cat", and to do this, we can modify the declaration as follows:

  • let animals = ["dog", "hamster"];
  • let animals = ["dog", #"cat",# "hamster"];
  • let animals = ["dog", //"cat",// "hamster"];
  • let animals = ["dog", /*"cat",*/ "hamster"];
Answers Explanation & Hints:

In JavaScript, you can use the /* */ syntax for multiline comments. By placing the /* before the element you want to comment out and the */ after it, you effectively turn that part of the code into a comment.

Therefore, modifying the declaration of the animals array as shown above will temporarily comment out the element “cat”, resulting in an array with only the elements “dog” and “hamster”.

For more Questions and Answers:

JavaScipt Essentials 1 (JSE) | JSE1 – Module 2 Test Exam Answers Full 100%