Please enable JavaScript to use CodeHS

CodeHS Glossary

Function JavaScript

A function is a way to teach Karel a new word. Functions should do one thing, and should be written like a command. They are named in lowerCamelCase. For example, we could teach karel to move to the wall with a function like function moveToWall(){ while(frontIsClear()){ move(); } } We use functions when we want to look for patterns in the code.