Skip to content

andrewgodman/checkpoint1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Week 1 Assessment

Bash (Terminal)

Assume your present working directory is $ ~/buffy

  1. Make two directories inside ~/buffy: scoobies and vamps


$mkdir scoobies vamps

  1. Make files in scoobies named buffy.txt, giles.txt and angel.txt


$touch scoobies/buffy.txt scoobies/giles.txt

  1. Copy angel.txt into the vamps directory

$cp scoobies/angel.txt vamps/angle.txt

  1. Delete the vamps directory and everything inside it

$rm -rf vamps/

JS Variables

  1. Assign the string "Jack" to a variable called captain

var captain = "Jack"

  1. 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 ".concat(captain).concat(", my ").concat(captain).concat("!")

JS Conditionals

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

var weekend = ["Saturday"]

  1. Add 'Sunday' to the end of the weekend array

weekend.push("Sunday")

  1. Add 'Friday' to the front to the front of the weekend array

weekend.unshift("Friday")

  1. Access 'Saturday' in the array and assign to a variable named day

var day = weekend[1]

  1. Remove 'Friday' from the array

weekend.splice(0,1)

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 }

  1. Assign the property of energyLevel to a variable named energy

var energy = brain.energyLevel

  1. Add a dream property to the brain object that holds the string 'electric sheep'

var brain = { energyLevel: 10, dream: 'electric sheep', };

  1. Add a dayDream property to the brain object that holds the object { lunch: ['burger', 'beer'] }

var brain = { energyLevel: 10, dream: 'electric sheep', dayDream: { lunch: ['burger', 'beer'] }, };

  1. Add another element pudding to the lunch array inside the brain object

JS Functions

  1. Write a function to return the area of a rectangle (the product of its length and its width)

  2. Invoke the function with 3 and 4 as arguments and save it to a variable named result

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published