More JavaScript B. Ramamurthy 5/7/2019.

Slides:



Advertisements
Similar presentations
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Advertisements

Chapter 17 Fundamental Concepts Expressed in JavaScript.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fundamental Concepts Expressed in JavaScript Get with the Program lawrence.
CS1061 C Programming Lecture 5: Building Blocks of Simple Programs A. O’Riordan, 2004.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
JavaScript, Fourth Edition
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
Chapter 17 Fundamental Concepts Expressed in JavaScript.
String Escape Sequences
A First Book of ANSI C Fourth Edition
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
Control Structures A control structure is simply a pattern for controlling the flow of a program module. The three fundamental control structures of a.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
CS346 Javascript -3 Module 3 JavaScript Variables.
Conditional Statement Chapter 8. Conditional Statements Are statements that check an expression then may or may not execute a statement or group of statement.
Python Conditionals chapter 5
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Strings See Chapter 2 u Review constants u Strings, concatenation and repetition 1.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 JavaScript.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Basic Scripting & Variables Yasar Hussain Malik - NISTE.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Random Functions Selection Structure Comparison Operators Logical Operator
IST 210: PHP Logic IST 210: Organization of Data IST2101.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Java Programming Fifth Edition
Chapter 2 Variables.
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
“Under the hood”: Angry Birds Maze
Fluency with Information Technology
Overview: Programming Concepts
Variables and Primative Types
Scope, Objects, Strings, Numbers
Expressions and Control Flow in JavaScript
JavaScript.
JavaScript: Control Statements.
Chapter 17 JavaScript.
An overview of Java, Data types and variables
Chapter 3: Introduction to Problem Solving and Control Statements
Introduction to JavaScript
Programming Funamental slides
INFO/CSE 100, Spring 2005 Fluency in Information Technology
T. Jumana Abu Shmais – AOU - Riyadh
CMSC 202 Java Primer 2.
INFO/CSE 100, Spring 2006 Fluency in Information Technology
Chapter 2: Introduction to C++.
“Under the hood”: Angry Birds Maze
Topics Designing a Program Input, Processing, and Output
Relational Operators.
Topics Designing a Program Input, Processing, and Output
PROGRAM FLOWCHART Selection Statements.
Tutorial 10: Programming with javascript
An Introduction to Programming with C++ Fifth Edition
Javascript Chapter 19 and 20 5/3/2019.
Chapter 2 Variables.
Programming Basics Review
Presentation transcript:

More JavaScript B. Ramamurthy 5/7/2019

Programming Concepts Programming is the act of formulating an algorithm or program A systematic means of solving a problem Write functions and statements to solve a problem.

Programming Concepts This chapter introduces the following programming concepts: Names, values, and variables Declarations Data types, numbers, string literals, and Booleans Assignment Expressions Conditionals

Variable Declaration Statement var area, radius; This command declares that two identifiers (area, radius) will be used as variables Here is a single variable declaration var grade; var points;

Initializing a Declaration Sometimes there is an initial value for identifiers JavaScript allows setting the initial value as part of the declaration This is called initializing the variable Declaring variables with initial values is written as: var taxRate = .088; var balanceDue = 60.50;

Three Basic Data Types of JavaScript There are three types of data in JavaScript programs that will be used in this book: numbers, strings, and Booleans

Strings To use double quotes in a string, enclose the string in single quotes: var answer = “This is cse111” If our string contains single quotes, enclose it in double quotes: var book = "Great Gatsby" Since the apostrophe is commonly used in possessives and contractions, use double quotes as the default

Escape Mechanisms For JavaScript, the escape symbol is the backslash (\) The escape sequences are converted to the single characters they represent when stored in the computer’s memory \t tab \b backspace \n newline

The Assignment Statement If variables are to change values in an algorithm or program, there should be a command to do so The assignment statement changes a variable’s value An assignment statement has three parts that always occur in this order: <variable> <assignment symbol> <expression>;

The Assignment Statement <variable> <assignment symbol> <expression>; <variable> is any declared variable in the program <assignment symbol> is the language’s notation for the assignment operation <expression> is a kind of formula telling the computer how to compute the new value Like any other statement, an assignment statement is terminated by a semicolon. JavaScript’s <assignment symbol> is the equal sign (=), and you’ve already seen the assignment operation as the initializer for variable declarations.

The Assignment Statement The assignment statement is terminated by a semicolon JavaScript’s <assignment symbol> is the equal sign (=)

if Statements and Their Flow of Control if (waterTemp < 32) waterState = "Frozen"; The <Boolean expression> is called a predicate It is evaluated, resulting in a true or false outcome If the outcome is true, the <then-statement> is performed If the outcome is false, the <then-statement> is skipped

if Statements and Their Flow of Control if (waterTemp < 32) waterState = "Frozen"; Writing the <then-statement> indented on the following line is common practice Programmers write the <then-statement> indented on the following line to set it off The indent emphasizes its conditional nature

if/else Statements The <Boolean expression> is evaluated first If the <Boolean expression>’s outcome is true: The <then-statement> is executed The <else-statement> is skipped If the <Boolean expression>’s outcome is false: The <then-statement> is skipped The <else-statement> is executed

Summary In basic programming, you now understand the following: There are three JavaScript data types of interest to us—numbers, strings, and Booleans—and we can build expressions to compute values of these types. As a rule, all programming statements are executed one after another, starting at the beginning. The conditional statements are the exception. JavaScript’s two conditional forms are if and if/else. These allow statements to be executed depending on the outcome of a Boolean expression called a predicate.

General format of JS program alert(“connected”); // Make sure html file links Variables representing the problem’s data Functions that process the data and provide the result of analysis to html to display 5/7/2019