JavaScriptJavaScript

JavaScriptJavaScript

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

data verification while loop

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (31)

Section 1

(31 cards)

data verification while loop

Front

sticks user in a loop until they enter a valid value

Back

purpose of for loops

Front

counting loops

Back

posttest loop

Front

The condition is tested after the loop code runs. The code will always run at least once.

Back

array.length()

Front

returns the number of elements in the arrays (will be one more than the highest index)

Back

array.sort()

Front

puts array in alphabetical order to sort numbers: array.sort(function (a,b){return a-b})

Back

best way to write a while loop condition?

Front

as end value ex. while (!(course='END'))

Back

script that you want to execute immediately typically goes... functions go...

Front

in the body... in the head

Back

submit function uses this code

Front

document.getElementById('x').value

Back

traversing array loop structure

Front

for(var x=0; x<names.length; x++) {...loop body...} The loop body can do any number of things, such as: Output the information: document.write(names[x]); Assign information: names[x] = window.prompt("Enter a name"); Search for a value: if(names[x] == "Joe Smith") Keep a running total: sum+=studentGrades[x];

Back

purposes of while loops

Front

counting, sentinal, data verification

Back

conditions structure

Front

if() {} else {}

Back

traversing JavaScript array

Front

looking at each element in an array typically uses a for loop purposes: finding total, searching

Back

array.push()

Front

adds new element to end of array

Back

creating an array using a form/input boxes

Front

<input type='text' name='childName[]'/>

Back

continue

Front

sends control immediately to the top of the loop

Back

lifespan of things that get declared inside a loop

Front

only exists in that loop so you should declare them outside a loop instead

Back

while loop structure

Front

must initialize prior to the loop, update inside the body var y=1 while (y<=10) {document.write(y+"<br/>"); y++}

Back

input methods

Front

window.prompt() form using <button onclick='[submit function]'> to submit

Back

break

Front

will immediately send control to the code following the loop

Back

return

Front

gives you the info so you can use it (whereas document.write() just writes it down) to not ignore the return, store it in a variable

Back

purpose of do while loops

Front

data verification (no need to do priming read because it's a posttest loop)

Back

4 parts of a loop

Front

1. declare/initialize the loop control variable 2. condition 3. loop control update or alteration 4. body

Back

array.indexOf()

Front

tells index of where you might find that value

Back

biggest mistake people make while programming

Front

not planning one hour of planning can save hours of coding code and test in pieces -> make sure input and output work first

Back

do... while loop structure

Front

var x=1; do {document.write(); x++;} while (x<=10)

Back

output methods

Front

document.write() window.alert() innerHTML to put it inside of block text element

Back

pretest loop

Front

tests the condition before it executes; if a condition is initially false, code never executes for and while loops are both pretest loops

Back

array.unshift()

Front

adds new element to beginning of array

Back

for loop structure

Front

for (var x=1; x<11; x++) {}

Back

sentinal while loop

Front

continues until certain value (sentinal) is entered loop control variable is altered using user input since while loop is pretest, we need a starting value -> ask the user for input BEFORE the loop starts (priming read)

Back

parallel arrays

Front

using multiple 1D arrays to store information about related topics same index in each array refers to same object ex. firstName[0] and lastName[0] refer to the same person DO NOT SORT THEM

Back