CodeJavaScript + p5.js · ⌃ Space for hints
Draft saved locallyJavaScript · Spaces: 2
Live preview move your pointer inside
Create and Call a Function
A custom function gives a group of statements a name. Define one with function name() { ... }, then run it by calling name();. For example: function wave() { circle(100, 100, 30); } creates the function, while wave(); runs it. In this mission, move the existing badge drawing commands into a new function instead of copying them.
Learn more
01
Your mission
Move the badge drawing commands into a new function named drawBadge, then call drawBadge() from draw() so the badge looks the same.
- Create
function drawBadge() { ... }containing the existing badge drawing statements. - Remove those badge drawing statements from
draw(). - Call
drawBadge();insidedraw()after the background is drawn.
Mission complete Run sketch