1

Which is a more efficient code snippet ? Code 1 : for(var num=10;num>=1;num--) { document.writeln(num); } Code 2 : var num=10; while(num>=1) { document.writeln(num); num++; }

Correct Answer: Code 1

Make the most of this question

This page focuses on one JavaScript MCQs question from Programming. After checking the answer, return to the topic list to practice more or run a timed set.

JavaScript MCQs MCQ: Which is a more efficient code snippet ? Code 1 : for(var num=10;num>=1;num--) { document.writeln(num); } Code 2 : var num=10; while(num>=1) { document.writeln(num); num++; } | Extra Education