- Call functions to run the code in them and get the
return
value as a result - Create functions that take a single parameter
- Create functions that take multiple parameters
In this exercise you will first call some predefined functions and then create your own functions that must return
a value based on the function requirements and the parameters supplied to the function
-
Fork this repository and clone your forked version to your machine
-
Install dependencies by running the command below while in the project's root directory:
npm ci
-
Read through the numbered comments - eg
1. Define a function...
- in the following files to understand the requirements of this exercise.src/calling-functions.js
src/creating-functions.js
src/creating-functions-multiple-args.js
(This is the extension exercise)
-
Write your code directly below the numbered comment.
-
Add
console.log()
s to get visibility on your solution and run the file with the commandnode src/calling-functions.js
etc -
See
src/example.js
for some example functions
-
To verify your solutions, run the test suite by running the
npx jasmine
command followed by the path to the corresponding test file for eachsrc/.js
file above, eg:npx jasmine spec/calling-functions.spec.js
(Core criteria)npx jasmine spec/extensions/creating-functions-multiple-args.spec.js
(Extension criteria) -
Alternatively, run:
npm test
(Core criteria)npm run test-extension
(Extension criteria) -
To begin with, almost all of the tests will fail - only the example tests will pass with a green
.
You'll see many redF
s in your console, like the image below: -
Your solution is complete when the all the red
F
s have been replaced with green.
s in your console, as shown below: