1 / 17

Introduction to Programming (in JavaScript)

Introduction to Programming (in JavaScript). David Stotts Computer Science Department UNC Chapel Hill. The Big Six (6) Data Abstraction. 0. data ( types, simple information ) 1. data storage ( variables, assignment ) 2. data retrieval ( expressions, evaluation )

jubal
Download Presentation

Introduction to Programming (in JavaScript)

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. Introduction to Programming(in JavaScript) David Stotts Computer Science Department UNC Chapel Hill

  2. The Big Six(6) Data Abstraction 0. data (types, simple information) 1. data storage (variables, assignment) 2. data retrieval (expressions, evaluation) 3. repetition (loops) 4. decision making (conditionals) 5. procedure abstraction (functions) 6. data abstraction (arrays) 7. objects: all-the-above, wrapped up

  3. We have been studying Arrays

  4. We have seen “for loops” as access patterns

  5. Loop Body Contains any valid statements… • assignment • conditionals for (i=0; i<length; i++) { sum = sum + grade[ i ] ; if (grade[i]>90) { aCount = aCount + 1; } }

  6. What if loop body contains… Another complete loop?

  7. Loops in Loops • We call them “nested ” loops

  8. Nested For Loops for (i=0; i<length; i++) { . . . for (k=i; k<length; k++) { . . . } . . . } inner loop, enclosed in outer outer loop, enclosing

  9. Anyone from DC? This is the fabulous Capital Beltway...

  10. Capital Beltway • A.K.A...

  11. The “Inner Loop”

  12. and the “Outer Loop”

  13. Inner and Outer Loops

  14. Nested For Loops for (i=0; i<length; i++) { . . . for (k=i; k<length; k++) { . . . } . . . } inner loop outer loop

  15. Nested For Loops for (i=0; i<length; i++) { . . . for (k=i; k<length; k++) { . . . } . . . } many inner iterations inner loop outer loop 1 outer iteration

  16. A Note on Indentation Formatting is CRITICAL for comprehension for (i=0; i<length; i++) { sum = sum + grade[ i ] ; if (grade[i]>90) { aCount= aCount + 1; } else { bfCount= bfCount + 1; } total += 1; }

  17. A Note on Indentation Indent, block structure, be consistent for (i=0; i<length; i++) { sum = sum + grade[ i ] ; if (grade[i]>90) { aCount= aCount + 1; } else { bfCount++; } total += 1; }

More Related