This is a JavaScript functions workshop designed for Nayland College students and first-year NMIT Digital Technology students. It includes interactive coding exercises, peer programming, visualizations, and automated feedback — using only JavaScript.
By the end of this workshop, students will be able to:
- Declare and invoke functions
- Use parameters and return values
- Differentiate between global and local scope
- Work with callback functions
- Understand function hoisting
- Visualize function execution using console and canvas
- Collaborate effectively using peer coding practices
.
├── starter/ # Hands-on files for students to implement logic from scratch
├── completed/ # Solutions used by CI (hidden from main branch)
├── tests/ # Jest tests to verify student logic
├── .github/
│ └── workflows/
│ └── test.yml # GitHub Actions CI workflow
├── package.json # Project setup with Jest configured
├── .gitignore # Prevents completed/ from being committed in main
└── README.md # Full learning guide and instructions
This workshop encourages collaboration using the Driver–Navigator method:
- Driver: Types the code and runs it
- Navigator: Reads the instructions, guides the logic, and helps debug
- Switch roles every 10–15 minutes
- One student in each pair should fork this repository
- Then go to their fork’s Settings → Manage access
- Add their partner as a collaborator using GitHub username or email
- Both students can now pull, push, and commit code in the same fork
Tip: If you're coding remotely, use screen sharing or VS Code Live Share to collaborate in real time
See PEER_CODING.md for instructions on forking, inviting collaborators, and using the Driver–Navigator method.
Each .js file in the starter/ folder contains a function name and comments with TODO instructions. Your job is to write the full logic from scratch using the function signature and provided guidance.
You will use JavaScript to complete each exercise based on real-world logic involving objects, arrays, and workflows.
| File | Topic | Key Concepts |
|---|---|---|
| 01_basics.js | Object Properties | Declaring and accessing objects |
| 02_parameters.js | Summing Values | Function parameters and loops |
| 03_scope.js | Variable Scope | Global vs Local variables |
| 04_callbacks.js | Discount Calculation | Higher-order functions, callbacks |
| 05_animation.js | Console Rocket | Loops, string manipulation |
| 06_workflow_console.js | Shopping Cart Steps | setTimeout, step iteration |
| 07_workflow_canvas.js | Browser Visualization (Canvas) | Canvas API, animation steps |
| 08_hoisting.js | Hoisting Demonstration | Execution order, var vs let |
Each file in the starter/ folder:
- Provides only the function name
- Includes TODO comments describing what to implement
- Requires you to write all logic yourself
- Uses
module.exportsso your code can be tested automatically
Example: In
starter/02_parameters.js, you must write a function that takes an array of numbers and returns their total. You are expected to create the loop, accumulate the sum, and return the result.
You can test your work anytime using:
npm testMake sure you have the following installed:
- Node.js (version 18 or higher): https://nodejs.org/
- A modern code editor (such as Visual Studio Code)
- A browser (for canvas-based exercises)
Each student should fork this repository to create their own copy on GitHub.
- Click the “Fork” button at the top right of this page.
- Open your terminal and clone your fork:
git clone https://github.com/your-username/function-flow-js.git cd function-flow-js
npm installThis project uses Jest and GitHub Actions to automatically test your code and provide feedback.
Before running automated tests, it's highly recommended that you run your code manually to understand its behavior.
- Write your code in the appropriate file inside the
starter/folder. - Run your code manually using Node.js to check output and debug:
node starter/filename.js
npm testTests will provide instant feedback for each activity. Only complete one activity at a time.
- You write your code in
starter/files - Tests in
tests/compare your code to the correct version fromcompleted/ - The
completed/folder is not in the main branch, but is pulled by GitHub Actions from a separate branch namedsolutions
Note: You do not need access to the
completed/folder to complete this workshop. Simply write your code in thestarter/files, run the tests, and improve your solution based on the feedback.
GitHub Actions will automatically:
- Run all tests on each push or pull request
- Fetch the
completed/folder from thesolutionsbranch - Display results in the Actions tab
This ensures consistency and fairness in assessment.
- Start with
01_basics.jsand move through the activities in order. - Use the Driver–Navigator pattern consistently in every session.
- After completing each activity, run
npm testto verify your solution. - Make at least three attempts before referring to any solution.
- Discuss your approach with peers before requesting hints or help.
If you're stuck or unsure:
- Ask your coding partner first and review the instructions together.
- Double-check your function names, parameters, and return values.
- Use
console.log()to debug your code step by step. - Reach out to your instructor, teaching assistant, or mentor.
- Use online resources like MDN or JavaScript documentation as a last resort.
Remember: making mistakes is part of the learning process.
- Make sure you're in the project directory
- Try deleting
node_modulesand reinstalling:rm -rf node_modules npm install
- Double-check that your function is exported correctly using
module.exports - Review the function name and parameters
- Run the file manually using
node starter/filename.jsto debug
- That is intentional. It's used only in the CI system and hidden from student view
This project is licensed under the Apache License 2.0.
You are free to use, modify, and distribute this material for educational and non-commercial purposes, provided proper attribution is given.