Javascript Arrays Ch.19. Array definition & for loop var quiz = [85,90,100,0]; // creates an array var ex = []; ex[0] = 89; // add the quiz grades quizTotal.

Slides:



Advertisements
Similar presentations
Chapter 4 Ch 1 – Introduction to Computers and Java Flow of Control Loops 1.
Advertisements

For(int i = 1; i
CSC 221: Computer Programming I Fall 2001  conditional repetition  repetition for: simulations, input verification, input sequences, …  while loops.
CSE305 – Programming Languages Daniel R. Schlegel April 25, 2011 “Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought,
Building Java Programs
Tonight’s JavaScript Topics 1 Conditional Statements: if and switch The Array Object Looping Statements: for, while and do-while.
Building Java Programs Chapter 5
1 11/27/06CS150 Introduction to Computer Science 1 Searching Arrays.
11-1 Chapter 11 2D Arrays Asserting Java Rick Mercer.
09 Non-deterministic iteration1June Non-deterministic iteration CE : Fundamental Programming Techniques.
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
11-1 Chapter 11 2D Arrays Asserting Java Rick Mercer.
Craps!. Example: A Game of Chance Craps simulator Rules – Roll two dice 7 or 11 on first throw, player wins 2, 3, or 12 on first throw, player loses 4,
Recursion in C++. Recursion Recursive tasks: A task that is defined in terms of itself. A function that calls itself. With each invocation, the problem.
DiceRoller DiceRoller (object class) and DiceRollerViewer client class: Write a DiceRoller class (similar to Yahtzee) to: Allow the person to initially.
Functions, Objects, and Programming IDIA 619 Spring 2014 Bridget M. Blodgett.
Math Class Part of the Java.lang package. This package is from object so you do not have to import the lang package. Static: Math Class is static.
Introduction to Computer Programming Math Random Dice.
Functions & Objects Flash ActionScript 3.0 Introduction to Thomas Lövgren, Flash developer
Духовні символи Голосіївського району
7/31: Math.random, more methods About DrawLine.java modifications –allow user input –draw a curve Method definitions Math.random()
1/25/2016B.Ramamurthy1 Exam3 Review CSE111 B.Ramamurthy.
Repetition loops Is a condition true? START END OF LOOP EXIT.
Creating and Using Class Methods. Definition Class Object.
DS.A.1 Algorithm Analysis Chapter 2 Overview Definitions of Big-Oh and Other Notations Common Functions and Growth Rates Simple Model of Computation Worst.
Custom Functions © Copyright 2014, Fred McClurg All Rights Reserved.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
Special Methods in Java. Mathematical methods The Math library is extensive, has many methods that you can call to aid you in your programming. Math.pow(double.
Probability and Simulation The Study of Randomness.
ROLL A PAIR OF DICE AND ADD THE NUMBERS Possible Outcomes: There are 6 x 6 = 36 equally likely.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 6 Multidimensional.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Objects, If, Routines. Creating Objects an object is a fundamental software element that has a state and a set of behaviors. Ex: bank account or student.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
7 th Grade Math Vocabulary Word, Definition, Model Emery Unit 5.
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
Looping Examples I.
Make Your Own Quiz.
Javascript Arrays.
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
Created by _____ & _____
Random Numbers while loop
int [] scores = new int [10];
Presentation transcript:

Javascript Arrays Ch.19

Array definition & for loop var quiz = [85,90,100,0]; // creates an array var ex = []; ex[0] = 89; // add the quiz grades quizTotal = 0; for( int i=0; i< quiz.length; i++) quizTotal= quizTotal + quiz[i]; quizTotal = quizTotal – quiz.min();

If else var points= 87; if points >= 90 grade = “A”; else if points>=85 grade = “A-”

Function definition Write a function that generates two random numbers between 0-10 and adds them and returns them. function addTwo() { var num1 = Math.random()*10; var num2 = Math.random()*10; var sum = num1 + num2; return sum; }

Function call A function has to be called in order to be activated. var total = addTwo();

One more function Write a function that rolls a pair of dice: if the sum > 10 return 1 Else returns 0;

Summary We studied If..else For.. Loop Function Random function