Download presentation
Presentation is loading. Please wait.
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: var myVar; var myVar = “Guzy”; var myVar = 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.