1 / 6

Variables

Variables. Here we go. How does a computer remember things?. To make our programs remember things, we store information as “variables” Work the same way as variables in math go x = 5; x = 20; bestName = “ Guzy ”;. Computers have memory? .

moshe
Download Presentation

Variables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Variables Here we go

  2. How does a computer remember things? • To make our programs remember things, we store information as “variables” • Work the same way as variables in math go • x = 5; • x = 20; • bestName = “Guzy”;

  3. Computers have memory? • Each variable stores its value in MEMORY, in a reserved spot of a specific size • Different variable types require different memory sizes • So we must DECLARE a variable to reserve the spot before we can use it to store information

  4. Variable types • INTEGER- Integer numbers, positive AND negative. But no decimals. • STRING- Stores words, names, even novelty license plates like “1WOOO1” • CHAR- Characters, single letters, or number, or symbols. • FLOAT or DOUBLE- Decimals, take up a huge amount of space compared to integers • BOOLEAN- True or False values (more on this another time)

  5. Special quirk of javascript • Is what we call “Loosely typed”, we make variables without stating what type they are • You can declare a variable, and give it any type later on • To declare a variable: • varmyVar; • varmyVar = “Guzy”; • varmyVar = new String;

  6. TO DO • Declare 6 variables at the top • Make 3 of each: INTEGER, STRING in the INIT section of the code, using names and made up grades • Display on the screen using the fillText command the following: • Each name with the corresponding grade, 1 line per person • Calculate the average

More Related