Function

Function image
In programming, a function is a reusable block of code.

Think of it like a cardboard box on a production line with a simple name written on the side like “tie knot” - this function accepts a ribbon and produces the same ribbon with a particular kind of knot tied in it. Other functions might not accept any input, but produce an output of a similar format over and over again, or accept an optional input. The most important thing to remember is that functions should be re-usable and best practice follows that functions should only do one thing, making the code easier to maintain and test.

There are two types of functions - ones built into the programming language you are using like .split(" ") in TypeScript which can be applied to a string to split it by its input (in this case a space, making the function split by word), and ones you define yourself. Every function you define must have a unique name.
TestBash Brighton 2025 image
On the 1st & 2nd of October 2025 we're back in Brighton for TestBash: the largest software testing conference in the UK
Explore MoT
Plymouth Meetup image
Tue, 14 Oct
Second Plymouth Software QA and Testing Meetup Group in Southway
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
This Week in Testing image
Debrief the week in Testing via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.