Skip to content

Instantly share code, notes, and snippets.

@kcooper22
Created October 2, 2015 13:25
Show Gist options
  • Save kcooper22/237816062faa744343ec to your computer and use it in GitHub Desktop.
Save kcooper22/237816062faa744343ec to your computer and use it in GitHub Desktop.
Kyle Cooper WDI Week 01 Assessment
Congratulations on your first week of WDI!
At the end of certain weeks we'll assess your progress through the week's material with a series of short questions. This gives us a data set to talk about with you during one on one meetings and code reviews.
You'll be entering these questions in by hand.
Topic
Bash _ / 4
Git _ / 3
Variables _ / 5
Arrays _ / 4
Objects _ / 3
Functions _ / 2
Write your answers in the prompts in the boxes below
Bash
Imagine the following directory structure exists at ~/titanic
titanic/
├── first_class
│ └── rose.md
├── second_class
└── third_class
└── jack.md
# Imagine your present working directory is
# $ ~/titanic
# Create a file called `sos.txt` inside `titanic`.
$ touch sos.txt
# Move `jack.md` from `third_class` to `first_class`.
$ cd third_class
$ mv jack.md cd ../first_class
# Imageine your `pwd` displayed `~/titanic/third_class`. Enter the commands to
# move up to `~/titanic` and into `second_class`.
$ cd ..
$ cd second_class
# Remove `titanic/` and everything in it.
$ rm -r titanic
Git
# Write the commands to initialize a new git repo
$ git init
# Create a new file called `readme.md`
$ touch readme.md
# Add and commit the file with the message "Initial commit"
$ git add readme.md
$ git commit -m "Initial commit"
Variables
// Assign the string "Ahab" to a variable called `captain`
// var captain = "Ahab";
// Use string concatenation to form the phrase "Oh Ahab, my Ahab!"
"Oh " + captain + ", my " + captain + "!";
var a = "a";
var b = a;
a = "c"
var c = b.toUpperCase();
// What are the current values of `a`, `b`, and `c`?
// currentValueOfA == "c"
// currentValueOfB == "a"
// currentValueOfC == "A"
Conditionals
var souls = 3;
var lifeRafts = 2;
// Write a conditional statement that console.logs "SOS!" if there are
// more souls than life rafts.
// if (souls > lifeRafts) {
// console.log("SOS!");
// }
Data structures
Arrays
// Create an array called `weekend` with just 'Friday' in it.
var weekend = ["Friday"];
// Add 'Saturday', and 'Sunday' to the array
weekend.push("Saturday");
weekend.push("Sunday");
// How would you access 'Saturday'?
weekend[1];
// Remove 'Friday from the array'
weekend.shift();
JavaScript Objects
// Create an object literal called `brain` with a property of `energyLevel`
// that points to the number value 10
var brain = {
energyLevel : 10
}
// Access the value 10 within the `brain` object
// brain.energylevel;
// Add a `dream` property to the `brain` that points to the String value
// "electric sheep"
// brain.dream = "electric sheep";
Functions
// Write a function to calculate the area of a rectangle
// (the product of its length and its width).
// var area = function(length, width){
// return length * width;
// }
// Invoke the function with 3 and 4 as arguments and
// save it to a variable
// var newarea = area(3, 4);
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment