- Make two directories inside
~/buffy
:scoobies
andvamps
$mkdir scoobies vamps
- Make files in
scoobies
namedbuffy.txt
,giles.txt
andangel.txt
$touch scoobies/buffy.txt scoobies/giles.txt
- Copy
angel.txt
into thevamps
directory
$cp scoobies/angel.txt vamps/angle.txt
- Delete the
vamps
directory and everything inside it
$rm -rf vamps/
- Assign the string "Jack" to a variable called
captain
var captain = "Jack"
- Using the
captain
variable, use string concatenation to form the string "Oh Jack, my Jack!", assigning it to a variable namedphrase
var phrase = "Oh ".concat(captain).concat(", my ").concat(captain).concat("!")
var souls = 3;
var lifeRafts = 2;
- Write an
if
statement that console.logs "SOS!" if there are more souls than lifeRafts
if (souls > lifeRafts) { console.log("SOS!"); }
- Create an array named
weekend
with just 'Saturday' in it
var weekend = ["Saturday"]
- Add 'Sunday' to the end of the
weekend
array
weekend.push("Sunday")
- Add 'Friday' to the front to the front of the
weekend
array
weekend.unshift("Friday")
- Access 'Saturday' in the array and assign to a variable named
day
var day = weekend[1]
- Remove 'Friday' from the array
weekend.splice(0,1)
- Write an object literal named
brain
having a property ofenergyLevel
with a value of10
as a number
var brain = { energyLevel: 10 }
- Assign the property of
energyLevel
to a variable namedenergy
var energy = brain.energyLevel
- Add a
dream
property to thebrain
object that holds the string 'electric sheep'
var brain = { energyLevel: 10, dream: 'electric sheep', };
- Add a
dayDream
property to thebrain
object that holds the object{ lunch: ['burger', 'beer'] }
var brain = {
energyLevel: 10,
dream: 'electric sheep',
dayDream: { lunch: ['burger', 'beer'] }
,
};
- Add another element
pudding
to the lunch array inside thebrain
object
-
Write a function to return the area of a rectangle (the product of its length and its width)
-
Invoke the function with
3
and4
as arguments and save it to a variable namedresult