Variables store data in a computer's memory for later use.
All data in a variable has a data type.
var n = 42; var m = 4.2; var o = 0.42;
var s = "Hello, world!"; var t = "ILLINOIS"; var u = "14"; // 14, as a String
var f = function(arg1) { return (arg1 + 1); }; // Function call: f(3) var g = function(arg1, arg2) { return arg1 * arg2; }; // Function call: g(4, 5)
var a = [1, 2, 3, 4, 5]; var b = ["Hello", "World"]; var c = [10, "after", 11, "o'clock"];
var x = getSomeValue(); if (x < 10) { ... }
var x = getSomeValue(); if (x < 10) { ... } else { ... }
for (var i = 0; i < 10; i++) { ... // Runs 10 times ... }
var f = function(a, b, c, d) { ... };
var d = 0; for (var i = 0; i < 5; i++) { d = d + i; }A) 0
var k = 17; var a = [3, 4, 5]; for (var i = 0; i < a.length; i++) { k = k – a[i]; }
A) 2
B) 3
C) 4
D) 5
E) 6
var cart = [ 8.50, 52.49, 31.99 ];
Get _____% off orders of $ __________ or more!
OR
Get _____% off orders of $ __________ or more!
var calculate = function (cart) { }
console.log("Hello, world!");
var s = "Hello"; var l = s.length; // 5 var c = s[1]; // "e" var c2 = s.charAt(4); // "o" var a = [2, 4, 6, 8, 10]; var len = a.length; // 5 var n = a[2]; // 6
var s = "Hello, world!"; var x = s.length;
var a = [2, 4, 6, 8, 10]; var y = a.length;
var s2 = "Hello, world!"; var z = s2.charAt(4); // Same as s2[4]
102 = 100 | 101 = 10 | 100 = 1 -------------|------------|---------- Place | | Value: 100 | 10 | 1 | | Digit: 1 | 2 | 3 + +
102 = 100 | 101 = 10 | 100 = 1 -------------|------------|---------- Place | | Value: 100 | 10 | 1 | | Digit: 2 | 1 | 3 + +
Our number system uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. We call this system base 10 or the decimal number system.
Computers use the digits 0 and 1. We call this system base 2 or the binary number system.
22 = | 21 = | 20 = -------------|------------|---------- Place | | Value: | | | | Digit: 1 | 0 | 1 + +
22 = | 21 = | 20 = -------------|------------|---------- Place | | Value: | | | | Digit: 1 | 0 | 1 + +
We call a single binary digit a bit.
It stores either the value 0 or 1.
Eight bits make up one byte.
0000 00002 == 010
1111 11112 == 25510
In a computer, colors are represnted by an array of three bytes:
red, green, and blue.
(Primary colors of light)