What command would you use to clone a remote repository? →
# clone a remote repo
git clone https://your_username/your-repository-name.git
What is the command to show a remote repo? →
# show remote repositories
git remote -v
# The output should look something like...
# origin https://bzuckerman@github.com/bzuckerman/lab-08-prep.git (fetch)
# origin https://bzuckerman@github.com/bzuckerman/lab-08-prep.git (push)
...continued...
What command would you use to configure your cloned repository with your name and email? →
# configure it with your name and email
git config user.name "your name"
git config user.email "your@email.address"
What’s are the commands that you would use for making, saving and sharing changes? Let’s start with just making the change and prepping it to be saved. →
# (make changes)
# show the exact, line-by-line changes that you've made
git diff --color
# check on the status of your changes
git status
# stage your changes / prep them to be saved
git add --all
# check your staged changes using git status again
git status
# (continued...)
Saving and sending to the remote repository →
# save them, make sure you remember your comment by using -m!
git commit -m 'my message'
# show a history of your changes
git log --color (show your changes so far)
# send to your remote repository
git push origin master
What kind of file and what set up do we have write in order to start a new JavaScript program? →
We have to create a bare bones web page, an .html file:
<!DOCTYPE html>
<html>
<body>
<script>
// your JavaScript goes here!
</script>
</body>
</html>
Your code goes within the script tags!
What’s a value and what’s a data type? →
What are some data types that we know? →
A value’s data type determines how that value behaves when used in functions or transformed/combined with operators.
Numbers can be positive or negative rational numbers, like 23, -42 and 3.14. However, there are also some special values that are numbers. →
What’s a string, and give an example of a string literal →
A string is an ordered sequence of characters. You can tell that a value is a string if it is surrounded by single or double quotes:
"Surrounded by quotes!"
What kind of data type is this? → "5"
"When numbers are surrounded by quotes they are strings!"
How do we write a backslash, quote, tab or a new line in a string? →
"\\"
"\""
"\t"
"\n"
What’s a boolean value? →
A boolean value is a data type with only two possible values:
true
false
What’s an operator and what are some examples of operators? →
We learned one operator that works on strings. What was it? →
string concatenation, or +, is an operator that takes two strings and joins them:
"hello " + "there"
What is the result of this expression? →
"1" + "1"
11
Name some comparison operators that return boolean values… →
Name some logical operators that allow you to combine boolean values. →
You can create boolean expressions with comparison and logical operators. What is the value that results from the following expressions? →
24 !== "hello"
5 === "5"
true && false
false || true
true
false
false
true
false && true || true
false && (true || true)
5 < 2 || 8 > 20
var login = "albert";
var password = "secret";
login === "albert" && password === "secret"
true
false
false
true
There’s one more logical operator, not.
! true
! (5 > 10)
! (true && true)
false
true
false
Unary Operators only have a single operand to the right:
What’s the operator that gives back the type of a value? →
typeof - gives the type of a value (Number, String, etc.)
Again, typeof is:
What would we get with this code: →
typeof -12
typeof "98.6"
typeof (20 === 20)
typeof NaN
What’s a function? What’s a function call? What are arguments? →
How do you call or execute a function? →
prompt("What is your name?")
JavaScript comes with many built-in functions. We know three; what are they and what do they do? →
What type of value does prompt always return? What type of value does parseInt always return? →
Remember that the function prompt gives back a value. To retain that value, you have to hold it in a variable:
var answer = prompt("Yes or no!?");
Curly braces denote statements of code that are grouped together. Everything within the curly braces below is considered part of the if statement. Blocks of code must start and end with curly braces…
... {
// code wrapped by curly braces
}
What kind of statement would we use to execute code if a condition is true? →
An if statement…
if (some_boolean_expression) {
// do stuff here if expression is true
}
What kind of statement would we use to execute code one branch of code if a condition is true and another branch of code otherwise? →
if (some_boolean_expression) {
// do stuff here if expression is true
} else {
// do stuff here if expression is false
}
What kind of statement would we use to execute multiple branches of code based on multiple chained conditions? →
Use if / else if statements
if (boolean_expression_1) {
// do stuff here if expression 1 is true
} else if (boolean_expression_2) {
// do stuff here if expression 2 is true
} else if (boolean_expression_3) {
// do stuff here if expression 3 is true
}
What construct do we use if we want to execute a block of code multiple times without writing it multiple times? →
A for loop consists of the keyword, for, and three parts, separated by a semicolon, contained within parentheses:
You can use the variable that you declare in the initialization within your for loop!
// initialization
// | condition
// | | afterthought/increment
// | | |
for(var i = 0; i <= 5; i = i + 1) {
console.log(i);
}
Create a for loop that counts from 0 up to and including 9 by 3’s? →
for(var i = 0; i <= 9; i = i + 3) {
console.log(i);
}