1 / 8

JavaScript Loops

JavaScript Loops. 17 April 2014. Creating Content . Putting Content within Tags. General form: c ontext.element.attribute form- name . input - id .value form- name . img - id .src document.getElementById (“ id ”). innerHTML. Loops . Looping. Want to be able to do things more than once

celine
Download Presentation

JavaScript Loops

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaScript Loops 17 April 2014

  2. Creating Content

  3. Putting Content within Tags General form: context.element.attribute form-name.input-id.value form-name.img-id.src document.getElementById(“id”).innerHTML

  4. Loops

  5. Looping • Want to be able to do things more than once • Basic: • for(vari=initial; while-clause; increment) { statement; } • Example: loop.html

  6. Looping through an array • Attribute of an array: length • Because first entry is 0, loop while < length

  7. Nesting Loops • When you need to work with two or more numbers • Examples • Creating a table • Computing the area of a range of rectangles • …

  8. While • Want to end the loop based on some condition • Need to be changing something to cause it to end Test first: while (condition) { statements; } Test last: do{ statements; } while(condition);

More Related