From 949a48d5769de5d26d1274df2789aee994672ccd Mon Sep 17 00:00:00 2001 From: Andrea Mele Date: Fri, 21 Sep 2018 12:59:35 +1000 Subject: [PATCH] checkpoint_Andrea --- checkpoint.md | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 checkpoint.md diff --git a/checkpoint.md b/checkpoint.md new file mode 100644 index 0000000..6644684 --- /dev/null +++ b/checkpoint.md @@ -0,0 +1,136 @@ +# Week 1 Assessment + +### Bash (Terminal) + +#### Assume your present working directory is `$ ~/buffy` + +1. Make two directories inside `~/buffy`: `scoobies` and `vamps` +


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


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

+- Copy angel.txt vamps/ + +4. Delete the `vamps` directory and everything inside it +

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

+ +- 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 pharase = captain + ", my Jack!" + +### JS Conditionals +```js +var souls = 3; +var lifeRafts = 2; +``` + +1. Write an `if` statement that console.logs "SOS!" if there are more _souls_ than _lifeRafts_ +

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

+ + 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 +

+ +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 = 'electrinc 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 +

+ +.lunch.push('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(b,h) { + return = (b * h) +} + + + +2. Invoke the function with `3` and `4` as arguments and save it to a variable named `result` +

+ + +var area = function(b,h) { + return = (b * h) +} + +var result = area; + +area(3,4)