Get out a piece of paper and answer the following question.
a + 3
without declaring "a" as a variable first var a;
a = 3;
var b;
b = "this is a string";
a + b + a; //what does this line print?
var a;
a = "I'm sick of this snow.";
var b;
b = "this snow.";
a  b; //what does this line print?
var a;
a = 4;
var b;
b = 4;
//if we add a+b, we get 8. How can we concatenate them?
var a;
a = 4;
a + "b" + 4 //what does this return?
var a;
a = a + 3;
a + b;
var a = 0;
while (a < 10) {
a = a + 1;
}
a < b
a is less than ba >= b
a is greater than or equal to ba == b
a is equal to ba != b
a is not equal to b ba >= b
a is greater than or equal to b
var a = 15;
var b = 2;
var c = b  a; (13)
var d = b + c; (11)
d > 12
Solution
True. c equals 13, therefore d equals 11. 11 is greater Than 12, because when dealing with negative numbers
1. var Frosted_Flakes;
2. var fr00tl00ps;
3. var else;
4. var 5pecial_K;
5. var while;
Solution
1. valid
2. valid
3. invalid
4. invalid
5. invalid
a. 1 <= 2
b. 1 > 1
c. 1 === 1
d. 1 === "1"
e. "foo" === "bar"
f. !true
g. true && false
h. true  false
Solution
a. true
b. false
c. true
d. false
e. false
f. false
g. false
h. true
var x;
x = 10;
while(x > 0) {
x = x  3;
}
x
Solution
X equals 2. Each time the loop runs, it reduces X by 3. So 10  3 = 7, 7  3 = 4, 4  3 = 1, and 1  3 = 2.
var n = 0;
while (n < 10) {
console.log(n);
n = n + 3;
}
var a = 1; while(a <= 11) { console.log(a); a = a + 2; }
var a = 0;
while ( a < 10 ) {
a = a + 1;
}
if ( 3 < 5 ) {
console.log("true");
}
var a = "hello there!";
console.log(a.length);
var a = 4;
if ( _____ ) {
console.log ("a is less than four");
} else if (_______ ){
console.log ("a is equal to four");
} else {
console.log("a is greater than four");
}
var a = 4
) and "==" is for checking equality (if (a == 4)
)
var a = 0;
var b = 5;
while (a < 10) {
if (b <= a) {
console.log(a);
}
a = a + 1;
}
var x = 3;
var y = x + x;
a. x * y
b. x !== y
c. if (x < y) {
console.log("x is smaller than y");
} else {
console.log("x is not smaller than y");
}
Solution:
a. 18
b. true
c. x is smaller than y
a. var x;
b. var School_For_Human_Rights;
c. var 123xyz;
d. var xyz123;
a. yes
b. yes
c. no
d. yes
0
1
2
4
5
6
var i = 0;
while(i < 7) {
if (i !== 3) {
console.log(i);
}
i = i + 1;
}
var anArray = ["hello", 777, true];
a. anArray[0]
b. anArray[1]
c. anArray[1] + 1
d. anArray[2]
e. !anArray[2]
a."hello"
b.777
c.778
d.true
f.false
var myarray = ["string",123,true];
no
no
no
no
yes
no
Answer
var a = 1;
while (a <= 6) {
if (a == 5) {
console.log("yes");
} else {
console.log("no");
}
a = a + 1;
}
Link to today's lab
1
2
3
5
6
7
Answer
var n = 1;
while (n <= 7) {
if (n !== 4) {
console.log(n);
}
n = n + 1;
}
a. (3 < 5) && (9 < 7);
b. var n = 3;
(n < 10)  (n > 50);
c. var x = 42;
(n <= 100) && (n >= 0);
a. n is a number equal to 10
b. n is bigger than 5
c. n is smaller than or the same size as 8
d. n is between 9 and 11
soup
soup
sandwhich
soup
var i = 0;
while (i < 4) {
if (i == 3) {
console.log("sandwhich");
} else {
console.log("soup");
}
}
var foo = function(n) {
return n;
};
var bar = foo(10);
3
4
5
6
var i = 3;
while (i < 7) {
console.log(i);
i = i + 1;
}
var i = 17;
while ( i <= 26) {
console.log('This is loop number ' + i);
i = i + 1;
}
var i = 17;
var counter = 1;
while ( i <= 26) {
console.log('This is loop number ' + counter);
counter = counter + 1;
i = i + 2;
}
i
is 17, 19, 21, 23, 25 and stops when it hits 27
var i = 12;
while (i < 100) {
console.log(i);
i = i + 1;
}
var i = 7;
while (i < 100) {
i = i + 1;
console.log(i);
}
Answer:Min: 8, Max: 100
var i = 8;
while (i <= 77) {
i = i + 3;
console.log(i);
}
yes
no
yes
no
yes
Answer
var i = 1;
while (i <= 100){
if (i % 2 == 0) {
console.log("no");
} else {
console.log("yes");
}
}
3
4
6
Answer
var a = 3;
while (a < 7) {
if (a !== 5) {
console.log(a);
}
a = a + 1;
}
2
4
8
10
Answer
var n = 2;
while (n <= 10) {
if (n !== 6) {
console.log(n);
}
}
a. x !== 5
b. x >= 10 && x <= 20
a. x is not equal to five.
b. x is a number between 10 and 20.
a. n is greater than 8
b. x is between 30 and 40
c. if y is greater than 13 print "big",
if y is smaller print "small",
if y is the same size print "unlucky"
a. n > 8
b. x >= 30 && x =< 40
c. if (y > 13) {
console.log('big');
}
if (y < 13) {
console.log('small');
}
if (y == 13) {
console.log('unlucky');
}
var i = 1;
var count = 1;
while (i <= 10) {
console.log(count);
count = count + 1;
i = i + 2;
}
var f = function(n) {
if (n < 18) {
console.log("minor");
} else if (n > 18) {
console.log("major");
} else {
console.log("on the line");
}
What gets printed out by the following?
a. f(5)
b. f(25)
c. f(18)
d. f(17)
a. minor
b. major
c. on the line
d. minor
var greetMe = function(name) {
console.log("Hello, " + name);
}
Doughtnuts!
var radiusToDiameter = function(n) {
return n*2;
}
var diameterToRadius = function(n) {
return n/2;
}
function divide(a, b) {
return a / b;
}
console.log( divide( 4, 2 ) );
console.log( divide( 2, 4 ) );
console.log( divide( 1, 0 ) );
1. 2
2. 0.5
3. Infinity
myFunction("April ", " Fools!")
#1
var myFunction = function(a, b) {
return b + a;
}
#2
var myFunction = function(a, b) {
return a + b;
}
myFunction(4, 5) > returns 10
myFunction(9, 0) > returns 10
myFunction(1, 4) > returns 6
myFunction("hi", "there") > returns "hi1there"
Solution
var myFunction = function(a,b) {
return a + 1 + b;
}
myFunction(2) > returns 4
myFunction(3) > returns 9
myFunction(10) > returns 100
myFunction(8) > returns 64

2x^2 + 3x + 5

4/3 * pi * r^3

bh/2
The gravity formula is given by the expression
Where G is a constant equal to 6.67 × 1011 Nm^{2}/kg^{2}
Written in Javascript, this looks like:
function Force (m1, m2, r) {
return (G * m1 * m2) / (r * r)
}
var a = 0;
a = 1;
console.log(a);
var b = "mama.";
b = "papa.";
b = "david bowie."
console.log(b);
var a = "Luther Vandross";
var b = "Barry White";
a = "Teddy Pendergrass"
console.log(b);
var b = function(num) {
return num + 1;
};
console.log(b);
var b = function(num) {
return num + 1;
};
console.log(b(2));
var f = function(x, y) {
return 4*x + y  1;
}
console.log(f(10, 3));
var whatDoWeWant = function(s) {
return s + " now!"
}
console.log(whatDoWeWant("15"));
f("foo") > "foofoo"
f("2") > "22"
Create a new page on your neocities site and replace all of the code on that page with the code from This Page.
Using the cheatsheet provided, add a string of text to the graphics page that you created yesterday. See https://tealstest.neocities.org/graphics.html for an example (mine says "Hello World").
Choose a topic in Computer Science that interests you. (Examples: programming in SNAP, web development/design, HTML, Javascript, graphics programming, games programming, physics simulation, hardware, etc.). Why does it interest you? What more would you like to learn about it?
For full credit, please write at least two full, wellconstructed paragraphs.
var d = new Date('3/4/2015');
When you create two date variables, you can add or subtract them. f(x) = x^2 + 5x + 7
var arr = ["hello", "goodbye", 7, true];
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
You are a robot and you want to shuffle a deck of cards. You have a couple of rules as a robot:
Work with your team to write instructions that will allow you to shuffle the deck of cards.