Prep, Review

Quick Rundown of Git Commands

Git - Setting up Repositories

What command would you use to clone a remote repository?

# clone a remote repo
git clone https://github.com/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://github.com/bzuckerman/lab-10-prep.git (fetch)
# origin  https://github.com/bzuckerman/lab-10-prep.git (push)

...continued...

Git - Setting up Repositories 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"

Git - Saving and Sharing Changes

What’s are the commands that you would use for making, saving and sharing changes?

# (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...)

Git - Saving and Sharing 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

Functions

What’s a function? What’s a function call? What are arguments?

Calling Functions

How do you call or execute a function?

prompt("hello") is a function call

When you see parentheses - ( )’s - after a function name, that function is being called or executed

Built-in Functions

JavaScript comes with many built-in functions. We know four; what are they and what do they do?

Some Functions Return Values

What type of value does prompt always return? What type of value does parseInt always return?

Using Prompt With Variables

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!?");

Conditionals

Blocks of Code

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
} 

Conditionals…

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
}

Conditionals Continued

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
}

If / Else If

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
}

If / Else If

Usage

Repeat That Again?

What construct do we use if we want to execute a block of code multiple times without writing it multiple times?

For Loop Dissected

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!

For Loop Parts

//    initialization
//    |        condition
//    |        |       afterthought/increment
//    |        |       |
for(var i = 0; i <= 5; i = i + 1) {
	console.log(i);
}

Square 1 Through 10

Create a for loop that prints out the square of every number from 1 through 10

for(var i = 1; i <= 10; i = i + 1) {
	console.log(i * i);
}