The Internet 11/29/11 Functions

Slides:



Advertisements
Similar presentations
CMPT 100 : INTRODUCTION TO COMPUTING TUTORIAL #5 : JAVASCRIPT 2 GUESSING GAME By Wendy Sharpe 1.
Advertisements

The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
Computer Science 103 Chapter 3 Introduction to JavaScript.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
Tutorial 10 Programming with JavaScript
11/1/06 1 Hofstra University, CSC005 Chapter 8 (Part 3) High Level Programming Languages.
Lesson15. JavaScript Objects Objects encapsulate data (properties) and behavior(methods); the properties and the methods of an object are tied together.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Functions and Objects. First Midterm exam Date: October 8, 2008 Content: Two parts: On-paper:Multiple choices On-computer: Write codes Cover everything.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Functions and Parameters. Structured Programming.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JavaScript Syntax, how to use it in a HTML document
Computer Science and Software Engineering© 2014 Project Lead The Way, Inc. HTML5 Evolving Standards JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript Assignment Statements Expressions Global Functions CST 200 JavaScript.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
CIS 375—Web App Dev II JavaScript I. 2 Introduction to DTD JavaScript is a scripting language developed by ________. A scripting language is a lightweight.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Chapter 2 Murach's JavaScript and jQuery, C2© 2012, Mike Murach & Associates, Inc.Slide 1.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
CIS 228 The Internet 11/17/11 Of Timers and Cookies.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
PHP using MySQL Database for Web Development (part II)
Introduction to Calculated Columns Variables, Conditionals, and String Manipulation PRESENTER: Cameron Blashka| Informer Implementation Specialist| April.
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
Information and Computer Sciences University of Hawaii, Manoa
Java Script Introduction. Java Script Introduction.
Web Systems & Technologies
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
Web Design II Flat Rock Community Schools
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Barb Ericson Georgia Institute of Technology May 2006
Introduction to Scripting
HTML.
Week#2 Day#1 Java Script Course
JavaScript and Ajax (Expression and Operators)
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
The Internet 12/8/11 JavaScript Review
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Variables and Expressions
JavaScript onLoad arrays
The Internet 11/15/11 Handling Data in JavaScript
The Internet 11/22/11 Conditionals and Loops
Computer Science Core Concepts
Tutorial 10 Programming with JavaScript
For this assignment, copy and past the XHTML to a notepad file with the .html extension. Then add the code I ask for to complete the problems.
Loops and Arrays in JavaScript
JavaScript: Introduction to Scripting
Hello, world!.
PHP an introduction.
CSC1401 Manipulating Pictures 2
Web Programming and Design
Programming Basics Review
Web Programming and Design
Corresponds with Chapter 5
Presentation transcript:

The Internet 11/29/11 Functions CIS 228 The Internet 11/29/11 Functions

Comments XHTML comments CSS comments JavaScript comments <!--This is an HTML comment--> CSS comments /* This is a CSS comment */ JavaScript comments // text to the end of line ignored /* Multi-line comment */ Temporary comments are useful for debugging

Assignments Form: variable = expression ; Examples: i = i+1; s = “hello world!”; b = isPrime(p) && (q < p || isPrime(q)); x = 3.1415 * gcd(15, 33); a[i] = “seat ” + i; var j = i*(i-1)/2; var v = document.getElementById(s).value; document.getElementById(s).value = 99*v;

Conditionals Conditional expressions Conditional statements cond ? expr1 : expr2 Conditional statements if ( cond ) statement statement1 else statement2

Block A sequence of statements packaged into one A block can be used anywhere a statement can { statement1 statement2 … statementn }

Arrays A collection of variables with the same name differentiated by an index Declaration: var a = new array(5); // size, 5, optional var b = [“red”, “yellow”, “blue”]; Use: var c = “color: ” + b[2]; a[2] = (a[1] + a[3]) / 2; Size: a.length

Repetition while loops for loops while ( cond ) statement var i=0 ; while (i<a.length) { a[i] = a[i]*a[i] ; i = i+1 ; } for loops for ( init ; cond ; inc ) statement for ( var i=0 ; i<a.length ; i = i+1 )

User-Defined Functions Declaration: function name (param * ,) block function fib (n) { if (n<=1) return 1; return fib(n-2) + fib(n-1); } Call (expression or statement): name (args * ,) var x = fib(17)/3; complainToUser(x, “ is not a number!”); Return statement: return expression? ; return;

JavaScript Functions Built in functions Example User defined functions Reusable chunks of code that accomplish common tasks Built in functions alert('hello world'); Displays text in a pop up window prompt('first message', 'second message'); Solicits data from user Example <body onload=“alert('hello world');”> User defined functions Bundle together small tasks into bigger ones