-
Make two directories inside
~/buffy
:scoobies
andvamps
:
mkdir scoobies mkdir vamps -
Create files in
scoobies
namedbuffy.txt
andangel.txt
:
touch buffy.txt touch angel.txt -
Copy
angel.txt
into thevamps
directory:
cp ~/buffy/scoobies/angel.txt ~/buffy/vamps -
Delete the
vamps
directory and everything inside it:
rm -rf ~/buffy/vamps
-
Assign the string "Ahab" to a variable named
captain
:
let captain = "Ahab"; -
Using the
captain
variable instead of the text "Ahab", use string concatenation to form the string "Oh Ahab, my Ahab!", assigning it to a variable namedphrase
:
let phrase = ("Oh " captain + ", my Ahab!");
var souls = 3;
var lifeRafts = 2;
- Assuming the above variables, write an
if
statement that console.logs "SOS!" if there are moresouls
thanlifeRafts
(no need to write a function, just theif
statement please):
if (souls > lifeRats){ console.log("SOS!"); }
-
Create an array named
weekend
with just a string 'Saturday' in it:
let weekend = ["Saturday"]; -
Add the string 'Sunday' to the end of the
weekend
array:
push.weekend[] = "Sunday"; -
Now add the string 'Friday' to the front of the
weekend
array:
weekend[0] = "Friday"; -
Using square bracket notation, access 'Saturday' in the
weekend
array and assign to a variable namedday
(Note: the array has three days in it as this point):
let day = weekend[1]; -
Remove 'Friday' from the array:
pop.weekend[0]; -
Loop through the
weekend
array and for each element in it, print"Woohoo! It's finally <day name>"
-
Write an object literal named
brain
having a property with a key ofenergyLevel
and a numeric value of10
:
let brain { energyLevel: 10; } -
Assign the value of the property
energyLevel
to a variable namedenergy
:
let energy = brain.energyLevel; -
Add a
dream
property to thebrain
object that holds the string 'electric sheep':
brain.dream = "electric sheep:"
-
Write a function named
computeArea
that has two parameters,length
&width
, and returns the area of a rectangle (the product oflength
andwidth
): -
Invoke the
computeArea
function with3
and4
as arguments and save the returned result to a variable namedarea
: -
Write a function
findMax
that takes in 1 paramater, an array of numbers, and returns the highest number in that array.