Processing Equivalent of JavaScript Functions?


I've had some experience with JavaScript, and it uses functions in a traditional way to modularize code, so it is reusable. In JavaScript, if I wanted a function to add two numbers and print the result to the console, I'd have something like this:

function myAdder(a, b) {
    var c;
    c = a + b;

Then later on I'd call it like this:

var n1 = prompt("Enter first number");
var n2 = prompt("Enter second number");

myAdder(n1, n2);

What's the equivalent of this in Processing?

Many thanks /Jason



Sign In or Register to comment.