Variables and Data Types

Slides:



Advertisements
Similar presentations
JavaScript Arrays Arrays allow us to store lists of items Arrays are created with square brackets:  var a = []; // an empty array  var b = [10]; // an.
Advertisements

Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
JAVASCRIPT TIPS. REMEMBER JAVASCRIPT IS VERY, VERY CASE SENSITIVE.
 What I learned from doing this project was, Surface Area. We had to find the total surface area of the cars, break down the car into shapes and find.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Doing Numbers and Doing Mathematics By Jim Hogan University of Waikato School Support Services.
Numbers © Copyright 2014, Fred McClurg All Rights Reserved.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Variables and Data Types Data (information we're going to store) – Numbers – Text – Dates What types of data can JavaScript process? How do we store it?
Distributive Property with Partial Products Method of Multiplication Multiplying 2-digit by 2-digit Numbers.
CSCE 102 – Chapter 11 (Performing Calculations) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
JavaScript VARIABLES AND DATA TYPES. OUTPUT WITHOUT ALERT OR FORM CONSOLE.LOG();
Random Numbers. Are a series of numbers that have no pattern to them Ex) 7, 31, 4, 9, 8, 99… Random Numbers are used in… - Computer Games - Lotteries(6-49)
Let’s not leave anything to chance. How that process to generate random numbers takes places requires some complicated statistics that are outside the.
Creating and Using Class Methods. Definition Class Object.
JavaScript Functions. CSS Inheritance Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector.
Math Problem -- ages Making your own variable equation to solve a math riddle.
Expressions and Data Types Professor Robin Burke.
Understanding Objects. value Example: txtFirstName. The dot notation is the key that opens the door to the house. Properties room Methods room Events.
Show me what you know! Page 47 Gerald scored 4 points and then 8 points. How many more points does he need to have a total of 15 points? Page 50 LouAnne.
 Collection of statements that can be invoked as a unit  Can take parameters  Can be used multiple times  Can call without knowing what they do or.
Copyright © 2009 Pearson Education, Inc. Chapter 16 Random Variables.
I can’t hear you through the static
Coding Class with codeacademy.
Predefined Functions Using the JavaScript Documentation
Learning to Program D is for Digital.
Variables and Data Types
JavaScript functions.
Programming the Web using XHTML and JavaScript
Iterative Constructs Review
JavaScript: Functions
CSC 110 – Fluency in Information Technology Chapter 20: The random function and Chaos Dr. Curry Guinn.
JavaScript Functions.
A290 TOOLS IN COMPUTING: JAVASCRIPT
CS005 Introduction to Programming
Console.
The Math class The java.lang.Math class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square.
JavaScript Functions B. Ramamurthy 11/22/2018.
Javascript: variables and parameters
JavaScript Functions.
Random Numbers In today’s lesson we will look at:
Lesson 16: Functions with Return Values
Numerical Functions & Tricks
Probability And Expected Value ————————————
Javascript Game Assessment
Reviewing key concepts
Programming in JavaScript
Dry run Fix Random Numbers
Topics discussed in this section:
Random Data ICS2O.
Random number generators
Programming in JavaScript
Probability And Expected Value ————————————
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Lesson 2.
Only a Game.
Programming in JavaScript
Programming in JavaScript
JavaScript objects, functions, and events
For loops Taken from notes by Dr. Neil Moore
Agenda Warmup Lesson 1.9 (random #s, Boolean variables, etc)
JavaScript functions.
Random Sampling using RAN#
Computer Science I: Get out your notes.
7-2 Multiplying powers with the same base.
Writing to the Page Formatting Forms
GCSE Computing.
Intro to Programming (in JavaScript)
Random Sampling using RAN#
Standard Deviation.
Presentation transcript:

Variables and Data Types JavaScript Variables and Data Types

Holding information

Holding information Computer doesn’t understand values It knows about locations: “cubby holes” Takes locations and does what you tell it: read, write, add

A = B + C; example Cubby Hole 2: add this value Cubby Hole 3: place it here A = B + C; Cubby Hole 1: take this value

Defining CUBBY HOLES They are called variables Define them Give them values Take values from them

= means “takes the value of” A = B + C; A takes the value of B+C

Changing Information A = A + C; Cubby Hole 2: add this value Cubby Hole 1: replace the old value A = A + C; Cubby Hole 1: take this value

To DEFINE var anyName; Defines a variable called anyName Case-sensitive Can be any type of value var aNumber = 1; aNumber is a number Starts with a value of 1

VALUES

Random Numbers

Why random numbers? Variability Different results Examples Display one of ten pictures Display one of five quotations Play a game of chance All built on a random number!

Can computers really create random numbers? Computers do as they are told So how can they do something random? They can’t! But we can tell them to find a number that changes often! Needs to not have an easily recognized pattern Pseudo-random Number Generator Options? Time!

Getting a random number Math.random() Returns a value between 0 and 1 One of a series of mathematical functions members of a collection called Math each are prefixed by “Math.”

What if you don’t want 0-1? Change range? Multiply Not start at 0? Add Integers only? Round Floor Ceiling

Using JavaScript

Class Plan Today: jsfiddle Thursday After break Output Console.log for helping ourselves Alerts for “final” results Thursday Create “functions” that can be called from the onclick Output still alerts After break Ability to read from forms and write to the page