BIT116: Scripting Functions.

Slides:



Advertisements
Similar presentations
Application Day: Branching Adventure.  Quiz  Let's look at the schedule  Branching Adventure - explanation  Branching Adventure – work time 2.
Advertisements

Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
If you do a “Key Word” search for ‘motor bikes’ you will get a response like this. This means that there were no matches for the term you were looking.
Decomposing A Program Into Functions. 2 3 Program/Function Decomposition.
Solving Rubik's Cube By: Etai Nativ.
HERMESでのHard Exclusive生成過程による 核子内クォーク全角運動量についての研究
yaSpMV: Yet Another SpMV Framework on GPUs
Chapter 6 并发:死锁和饥饿 Operating Systems: Internals and Design Principles
What is Chemistry? Chemistry is: the study of matter & the changes it undergoes Composition Structure Properties Energy changes.
The new Estimands concept – an introduction and a worked example
Measuring Wealth and Wealth Inequality
Use z-score as a standardized value for comparisons
Formation of the Dam Body
Method to promote adhesion of DLC thin film on silicon substrate
The French Forest Sector Model 2.0 (FFSM++)
“Devil is in the nuances” (Duran, 2017)
Pricing products: Approaches and strategies
Introduction to Deep Learning
Chemistry 130 Dr. John F. C. Turner 409 Buehler Hall
Assessing Reading Ningtyas Orilina A, M.Pd.
Chapter 10. Cluster Analysis: Basic Concepts and Methods
+ = ? Mergeable Summaries Ke Yi HKUST Pankaj Agarwal (Duke)
PHysics of music Lecture 2:.
Waves Test Review How do you find the amplitude of a pendulum?
Introduction to Data Science Lecture 4 Stats and Featurization
Gluonium content of the h'
Radar Sources Researched by Islam Ayman
Physical Pharmacy Najmadin H Mohammad.
Business of Platforms, Networks, and Two-sided Markets
Navigating Your Casio Calculator
Using Statistics for Better Business Decisions
Modules 17 & 20 Math Practice 3 in Action - Reasoning and Sense Making
Causation.
What this is NOT What this IS - CLARIFICATION -.
Operator Generic Fundamentals Basic Electricity - Part 2
Sand Mine Particulate Analysis
Next Generation Carbon Nanotube Based Electronic Design
Certified Google Educator, Level 1
BASIC FUNCTIONALITIES OF GOOGLE DRIVE
Statistical Relational UAI 2012
US History I Mr. Matt Mirabito
Clustering in light neutron-rich nuclei
SITE AERIAL/SCISSOR LIFT TRAINING
Combination: Tsunami Early Warning System
GCI for Disaster Virtual Workshop
Computer Graphics Lecture 29 Mathematics of Lighting and Shading - III Taqdees A. Siddiqi
1 INTRODUCTION - Q2KFortran2_11
Multiscale techniques
THEORY OF METAL MACHINING
26th International Conference on
Adnan Quadri & Dr. Naima Kaabouch Optimization Efficiency
MAGNESIUM Mg At. No. 12 Atomic Mass: 24
Monday.
Fridge, Microwave, and stove included Eat, sleep, and enjoy your stay
Queen Elizabeth She was born on 7 September 1533 at Greenwich Palace. Her birth was possibly the greatest disappointment of her father's life. He had wanted.
Ice hockey.
PLANNING FOR AUSTRALIAN FOOTBALL
Cover by the cast of Glee.
Introduction to Calculus 1: RATE OF CHANGE and FIRST PRINCIPLES
Semester I: Study Guide
Semester I: Study Guide
Reading a Ruler Objective: KNOW HOW TO USE A RULER PROPERLY.
BIT116: Scripting Loops.
Reading a Ruler Objective: KNOW HOW TO USE A RULER PROPERLY.
BIT116: Scripting Functions.
BIT116: Scripting Functions.
1-4 & 1-5: Counting on a number line
BIT116: Scripting Arrays.
Arrays: Iteration Working through an array algorithmically.
Presentation transcript:

BIT116: Scripting Functions

Arrays – Patterns For Usage

Arrays – Patterns: 1 Item At A Time

Pattern: 1-at-a-time Some array problems can be solved by considering each item, one by one, without thinking about the rest of the array Examples: Print each item Find a particular item in the array (or determine that it's not present) For these we just need to use the 'iterate through the array pattern' Let's look at the 'Print each item' example (

Here's what the 'main' / on click handler looks like: function GetUserInput( ) { var numAsInput = $("#num1").val(); var num = Number( numAsInput ); if( isNaN(num) ) { $("#output").html( "Error! " + numAsInput + " is not a number!"); throw new Error(numAsInput + " is not a number!"); } return num; $(document).ready( function() { $("#functionDemo").click( function() { var num = GetUserInput(); var spaced = SpaceNumberOut(num); SetOutput( spaced ); }); Notice that each function has a single, well-defined purpose

Pattern: 1-at-a-time Some array problems can be solved by considering each item, one by one, without thinking about the rest of the array Examples: Print each item Find a particular item in the array (or determine that it's not present) Single-item pattern print each item Find a particular item EXERCISES print matching items?

No slides today The lecture will be recorded and posted to OneDrive for your later reference.