Loops Quiz 4

Ace your homework & exams now with Quizwiz!

what are loops good for?

Performing calculations that require iterations. -OR- Generating repetitive text. Sometimes that text is HTML. Tags like these can often be generated with a loop: •<table> rows •<select> options •<ul> items •<ol> items.

How many lines of code can go in the code block of a JavaScript for loop?

You can include as many lines of code as you want inside of the for loop.

What's a loop?

a block of code that repeats for a specified number of iterations

Syntax

for (counter initialization; condition; increment expression ) { statements }

(the numbers 10 to 1)

for (let i = 10; i >= 1; i--) { console.log(i); }

write some "for" loops that write the following series: (the numbers 1 to 10)

for (let i = 1; i <= 10; i++) { console.log(i); }

•(the numbers 5 to 30, counting by 5)

for (let i = 5; i <= 30; i += 5) { console.log(i); }

Different kinds of loops

•for•for/in•for/of•while•do/while


Related study sets

Chapter 4: Learning and Transfer of Training

View Set

Anatomy: Heart anatomy and physiology

View Set

Hunter's Ed - Unit 2/ parts 1 and 2

View Set

OCE1001 FSU Final Exam All Chapters

View Set

ECON 136 Business Strategies Final MC

View Set