Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.

Slides:



Advertisements
Similar presentations
Intro to Javascript CS Client Side Scripting CS380 2.
Advertisements

Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Chapter 7 Strings F To process strings using the String class, the StringBuffer class, and the StringTokenizer class. F To use the String class to process.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 8 Strings.
Java Programming Strings Chapter 7.
Strings An extension of types A class that encompasses a character array and provides many useful behaviors Chapter 9 Strings are IMMUTABLE.
Session 8 JavaScript/Jscript: Objects Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
Data Structures & Algorithms
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Odds and Ends Strings (from Chapter 9) StringTokenizer.
2ex.1 Lists and Arrays. 2ex.2 Comments on exercises Always run your script with “ perl -w ” and take care of all warnings  submitted scripts should not.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Ten String Manipulation and Menus.
Lesson 3 – Regular Expressions Sandeepa Harshanganie Kannangara MBCS | B.Sc. (special) in MIT.
Chapter 06: Lecture Notes (CSIT 104) 1 Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Copyright © 2008 Prentice-Hall. All rights reserved.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
 2008 Pearson Education, Inc. All rights reserved JavaScript: Arrays.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
Copyright © 2008 Pearson Prentice Hall. All rights reserved Chapter 6 Data Tables and Amortization Tables Exploring Microsoft Office Excel 2007.
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 15 JavaScript.
M. Taimoor Khan Javascript Objects  Every data-type defined in Javascript is an object  It has a class definition for.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
Functions and Arrays. Predefined Functions eval(condition) –Evaluates (executes) JavaScript syntax –Eval returns an undefined value parseInt(string) and.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Chapter 7: Characters, Strings, and the StringBuilder.
5 1 Data Files CGI/Perl Programming By Diane Zak.
Chapter 3: Classes and Objects Java Programming FROM THE BEGINNING Copyright © 2000 W. W. Norton & Company. All rights reserved Java’s String Class.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Working with Strings. Learning Objectives By the end of this lecture, you should be able to: – Appreciate the need to search for and extract information.
Unit 12 JavaScript Arrays Instructor: Brent Presley.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC Programming I Lecture 9 September 11, 2002.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming strings.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
2.1 Scalar data - revision numeric e-14 ( = 6.35 × )‏ operators: + (addition) - (subtraction) * (multiplication) / (division)
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
1 CSE 2337 Chapter 7 Organizing Data. 2 Overview Import unstructured data Concatenation Parse Create Excel Lists.
JavaScript: Objects 1 © by Pearson Education, Inc. All Rights Reserved.
Computer Programming 2 Lab (1) I.Fatimah Alzahrani.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
Arrays and Lists. What is an Array? Arrays are linear data structures whose elements are referenced with subscripts. Just about all programming languages.
JavaScript and Ajax (JavaScript Arrays) Week 5 Web site:
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
Click to edit Master text styles Stacks Data Structure.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
Basic Objects. Math Object  Math.cos( x ), x in radians  Math.sqrt ( x )  Math.pow ( x, y )  Math.ceil( x )  etc.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 15 JavaScript.
Sorts, CompareTo Method and Strings
Introduction to Scripting
Primitive Types Vs. Reference Types, Strings, Enumerations
SAS in Data Cleaning.
Objectives Create an array Work with array properties and methods
Chapter 7: Strings and Characters
Perl Variables: Array Web Programming.
Tonga Institute of Higher Education
String and Lists Dr. José M. Reyes Álamo.
JavaScript: Objects.
String Processing 1 MIS 3406 Department of MIS Fox School of Business
Fundaments of Game Design
JavaScript: Introduction to Scripting
Working with Strings.
Introduction to Computer Science
What We Want To Do User enters: Mary Smith
Presentation transcript:

Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks

Copyright (c) 2005 Prentice-Hall. All rights reserved. 2 Objectives Use string methods Create and populate an array Sort an array Incorporate array methods Split and join strings Use multi-dimensional arrays

Copyright (c) 2005 Prentice-Hall. All rights reserved. 3 Why Would I Do This? String object – holds text  Common example – a variable that holds text String method – used to manipulate string object Array – holds multiple items of data  Element – an individual piece of data  Multidimensional array – an array stored as an element of another array

Copyright (c) 2005 Prentice-Hall. All rights reserved. 4 Using String Methods toUpperCase() – returns string in all uppercase letters toUpperCase() charAt() – returns a single character charAt() indexOf() – returns the position of a substring indexOf() substring() – extracts a substring from another string substring()

Copyright (c) 2005 Prentice-Hall. All rights reserved. 5 toUpperCase() Method Returns a string in all upper case  toLowerCase() method returns string in all lower case Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 6 charAt() Method Returns a single character  Based on specified position in string  Required argument – specified position Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 7 indexOf() Method Searches a string for a substring  Returns the location where the substring begins  Returns –1 if substring is not found lastIndexOf() method begins searching at the end of the string lastIndexOf() Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 8 lastIndexOf() Method Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 9 substring() Method Returns a substring from a larger string Returns a substring Requires one argument, the starting position  One optional argument, the ending position Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 10 Returning a Substring Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 11 Creating and Populating Arrays Each element in array represented by an index, placed within a bracket  window[1] refers to the second element in the “window” array Array() Constructor method Using numbered array elements Applying named array elements

Copyright (c) 2005 Prentice-Hall. All rights reserved. 12 array() Constructor Method Creates a new array Can specify length, or number of elements  Can also create object without specifying length Can use constructor to specify elements in array Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 13 Using Numbered Array Elements Populate by specifying index and assigning value.  Can be populated at design time or run timepopulated at design time Elements can be used in an output statement or assigned to variables. Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 14 Populate at Design Time Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 15 Applying Named Array Elements Array can contain variables of different data types Populate, update, or output elements by referring to name rather than index Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 16 Sorting Arrays sort() method reorders the contents of an array  By default, sorted in ascending order  Custom sort order can be specified Older browsers may require that a sort order be specified

Copyright (c) 2005 Prentice-Hall. All rights reserved. 17 Incorporating Array Methods pop() method returns last element in array  Also removes last element from array push() method adds element to end of array reverse() method reverses the order of all elements in an array shift() method removes first element in array  Other elements move up one position in array unShift() method adds element before the first element  Other elements move down one position in array

Copyright (c) 2005 Prentice-Hall. All rights reserved. 18 Incorporating Array Methods (cont) shift() method removes first element in array  Other elements move up one position in array unShift() method adds element before the first element  Other elements move down one position in array

Copyright (c) 2005 Prentice-Hall. All rights reserved. 19 Splitting and Joining Strings Delimiter – marks the beginning or end of a unit of data  Can be a single character or group of characters  Commas, tabs, and spaces most commonly used split() method – splits a string into an array split() join() method – joins elements in an array into a string join()

Copyright (c) 2005 Prentice-Hall. All rights reserved. 20 split() Method Splits an string into an array Splits an string  Each unit of data in string becomes an array element You must specify delimiter Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 21 Splitting a String Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 22 join() Method Joins all text elements in array into a string You must specify the character used to separate elements Return

Copyright (c) 2005 Prentice-Hall. All rights reserved. 23 Array Terminology Stack – last item added to array is first to be retrieved  A Last In, First Out (LIFO) approach Queue – first item added to array is first to be retrieved  A First In, First Out (FIFO) approach

Copyright (c) 2005 Prentice-Hall. All rights reserved. 24 Using a Multi-Dimensional Array An array stored within an array Useful with large chunks of data that need to be divided into subcategories

Copyright (c) 2005 Prentice-Hall. All rights reserved. 25 A Multi-Dimensional Array Return