- Navigate to this directory in your terminal.
- Run
npm install --global jest
if you have not yet done so to install the testing library. - Preferably in a full-screen terminal, run
jest --watch-all
to start testing.
You'll be working in main.test.js
, creating the variables and functions needed, according to the specifications given in the Tasks section below. Check your terminal for feedback on which aspect of the problem you have yet to complete!
- Please do not call the functions; just declare them! You can call them to check for your own testing purposes, but then either delete or comment out the line. (Because our test code runs your function and modifies the global variables, checking if the variable has been changed to the value we'd expect, if you're calling your function and changing it ALSO, the test code will change the value a second time and, when it goes to check the value, it will not be what the test code is expecting.)
- If you are asked to define a variable in terms of another, do not recalculate the value of that variable. For example, if
x = 5
, andy = 6
, andz
is supposed to be the sum ofx
+y
, do NOT sety
to equal11
directly. Use thex
andy
variables directly in that calculation instead.
Let's start by creating our variables so that we can manipulate them later on with functions. Create those variables at the top of your file, OUTSIDE of any functions.
- Create a variable named
x
and assign to it the value3
. - Create a variable named
y
and assign to it the value10
. - Create a variable called
squareTheNumber
and assign to it the value of4
. - Create a variable called
greeting
and assign to it the string 'hello'. - Create a variable called
firstName
and assign to it the string of your name. - Create a variable called
callStatus
and assign to it the string 'ringing'.
Now let's make these variables useful by writing some functions!
- Create a function named
double
and have it double the value ofx
. - Create a function named
triple
and have it triple the value ofy
. - Create a function named
square
and have it square the value ofsquareTheNumber
. - Create a function named
beNice
and have it change the value of greeting to the string 'hello' plus your name using the value of the variablefirstName
. You can include other characters if you wish to make it look like a nice sentence. - Create a function named
changeName
and have it change the value offirstName
to the string 'Danger'. - Create a function named
hangUp
and have it change the value ofcallStatus
to the string 'call ended'.