Unit 4 - Lesson 2
Variables Investigate
To do: October 28
On the whiteboards:
1) What are the two meanings of the + sign?
2) Write two different expressions which include a + sign for which the meanings of the + sign are different.
Output in Code Studio App Lab
There are two commands that allow you to print output:
1) The write() command will print output onto the app screen.
2) The console.log() command will print output in the Debug Console window.
Expressions
What is the output?
1) console.log("Happy " + "Halloween" );
2) console.log( 1 + 4 + "hey");
3) console.log( "hey" + 4 + 2 );
4) console.log( 1 + 4 + 2);
5) console.log("Go" + "Astros" + "!");
Expression: a combination of operators and values that evaluates to a single value
Variable: holds one value at a time
Assignment Operator: allows a program to change the value represented by a variable
Lesson 1 - Wrap Up
01 pow ← 1 + 2
pow
3
← OR =
Unit 4 Lesson 2 - Activity
Variables Investigate
Unit 4 Lesson 2 - Activity
Lesson 2 Bubble 2
Do This:
Unit 4 Lesson 2 - Activity
Lesson 2 Bubble 3
Do This:
Unit 4 Lesson 2 - Activity
Adding a Watcher
Unit 4 Lesson 2 - Activity
Lesson 2 Bubble 3
Do This:
Unit 4 Lesson 2 - Activity
Lesson 2 Bubble 4
Do This:
Unit 4 Lesson 2 - Activity
Lesson 2 Bubble 5
Do This:
Unit 4 Lesson 2 - Activity
Lesson 2 Bubble 6
Do This:
Unit 4 Lesson 2 - Activity
Counter Pattern with Event
Name | Code (Block) | Code (Text) |
Counter Pattern with Event | | var myVar = 0; onEvent("id", "click", function() { myVar = myVar + 1; }); |
Unit 4 Lesson 2 - Activity
Variable with String Concatenation
Name | Code (Block) | Code (Text) |
Variable with String Concatenation | | var myString = "rock"; var myOtherString = "roll"; var myStory = myString + " and " + myOtherString; |
Homework