Q. Consider the following code snippet
function printArray(a)
{
var len = a.length, i = 0;
if (len == 0)
console.log("Empty Array");
else
{
do
{
console.log(a[i]);
} while (++i < len);
}
}
What does the above code result?

  • (A) Prints the numbers in the array in order
  • (B) Prints the numbers in the array in the reverse order
  • (C) Prints 0 to the length of the array
  • (D) Prints “Empty Array”
πŸ’¬ Discuss
βœ… Correct Answer: (A) Prints the numbers in the array in order
Explanation: The do/while loop is less commonly used when compared to the while loop. Here, it prints from the array in the given order.
Explanation by: Mr. Dubey
The do/while loop is less commonly used when compared to the while loop. Here, it prints from the array in the given order.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
116
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
90%
Success Rate