diff --git a/README.md b/README.md index c8d2d5c..26e69b8 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,39 @@ 1. Make two directories inside `~/buffy`: `scoobies` and `vamps`


+## Answer +mkdir scoobies +mkdir vamps + 2. Make files in `scoobies` named `buffy.txt`, `giles.txt` and `angel.txt`


+## Answer +cd scoobies +touch buffy.txt +touch giles.txt +touch angel.txt + 3. Copy `angel.txt` into the `vamps` directory

+## Answer +cp /angel.txt ./vamps 4. Delete the `vamps` directory and everything inside it

+## Answer +rm /vamps ### JS Variables 1. Assign the string "Jack" to a variable called `captain`

+## Answer +var captain = 'Jack'; 2. Using the `captain` variable, use string concatenation to form the string "Oh Jack, my Jack!", assigning it to a variable named `phrase`

- +var phrase = '"Oh ' + captain + ',' + ' my ' + captain + '!"'; ### JS Conditionals ```js @@ -33,46 +49,77 @@ var lifeRafts = 2; 1. Write an `if` statement that console.logs "SOS!" if there are more _souls_ than _lifeRafts_

- +## Answer +if (souls > lifeRafts) { + var say = "okay"; +} else { + var say = "SOS!" +} +console.log(say); ### Data Structures - JS Arrays 1. Create an array named `weekend` with just 'Saturday' in it

+## Answer +var weekend = ['Saturday']; 2. Add 'Sunday' to the end of the `weekend` array

+weekend.push('Sunday'); 3. Add 'Friday' to the front to the front of the `weekend` array

+weekend.unshift('Friday'); 4. Access 'Saturday' in the array and assign to a variable named `day`

+var day = weekend[1]; 5. Remove 'Friday' from the array

+weekend.shift() ### Data Structures - JS Objects 1. Write an object literal named `brain` having a property of `energyLevel` with a value of `10` as a number

+var brain = { + energyLevel: 10; +} 2. Assign the property of `energyLevel` to a variable named `energy`

+var energy = brain.energyLevel 3. Add a `dream` property to the `brain` object that holds the string 'electric sheep'

+brain.dream = 'electric sheep'; 4. Add a `dayDream` property to the `brain` object that holds the object `{ lunch: ['burger', 'beer'] }`

+brain.dayDream = { lunch: ['burger', 'beer'] }; 5. Add another element `pudding` to the lunch array inside the `brain` object

+dayDream.lunch = 'pudding'; ### JS Functions 1. Write a function to return the area of a rectangle (the product of its length and its width)

+var area = function (length, width) { + return length * width; +} +var perimeter = function (length, width) { + return 2 * (length + width); +} +console.log(area + perimeter); + 2. Invoke the function with `3` and `4` as arguments and save it to a variable named `result` -

\ No newline at end of file +

+ +var result = function (3, 4) { + +} \ No newline at end of file