JS do.. while loops

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

(Javascript) Code the first line of a do...while loop.

do {

(Javascript) Code the first 3 lines of a do...while loop that alerts the counter, i. The counter has already been initialized.

do { alert(i); i++;

(Javascript) Code a do...while loop that runs 12 times and does nothing. The counter i has already been declared and assigned 0.

do { i++; } while (i <= 11); or do { i++; } while (i < 12);

(Javascript) Code a do...while loop that adds i to tot with each iteration. Use i > 0 as the loop limiter. var tot = 0; var i = 10;

do { tot = tot + i; i--; } while (i > 0);

(Javascript) How many times will the alert be displayed? Type a numeral. var i = 0; do { alert(i); i++; } while (i < 0);

*1* A do...while loop runs *at least once* no matter what the loop-limiter says.

(Javascript) Code the statement that needs to run above this line of code. do { alert(i); i++;

var i = 0;

(Javascript) Using a *do...while* loop, code an alert that loops 3 times, alerting the value of the counter each time.

var i = 0; do { alert(i); i++; } while (i <= 2);

(Javascript) What is the last character of a do...while loop?

;

(Javascript) Code a *do...while* loop that looks for "pig" in the array. When it finds it, an alert displays saying, "Found it!" Use the length of the array as the loop limiter. Break out of the loop when "pig" is found. var animals = ["horse", "ox", "cow", "pig", "duck"];

var i = 0; do { if (animals[i] === "pig") { alert("Found it!"); break; } i++; } while (i < animals.length);

(Javascript) Code a *do...while loop* that alerts the counter with each iteration. Begin with the statement that initializes the counter. Run the loop as long as you like.

var j = 0; do { alert(j); j++; } while (j <= 10);

(Javascript) What is the nonspace character that always precedes the *while* clause in a *do...while* loop?

}


Set pelajaran terkait

CCI Severe Service Drag® Valves

View Set

Chapter 02: Community-Based Nursing Practice (3)

View Set

Glial Cells and Misc. Nervous Tissue Histology

View Set