This is a bit late to be of use to the original question, but good luck to anyone who may find this useful. :)
I am a CS college student and I play with KACS a lot.
The original Processing language is a subset of Java, however there is a javascript version called processing.js. The Khan Academy CS sandbox uses the processing.js library, but the sandbox itself uses plain old javascript - though there several steps that the code goes through before it is rendered in the output window on the right.
In other words the code is taken from a document editor on the left, in text form, then mulled over and injected into a sandboxed running environment on the right. The sandbox curates the environment to combine a subset of native javascript and processing.js functions (which themselves come in the form of javascript from the processing.js library).
random(a, b)
is not Math.random()
but rather a processing.js helper function which itself uses Math.random
to give a result between a and b.
There's a bit more to it (particularly lint, some minor technical details of the KACS running environment and a few helper functions that are specific to the KACS environment and not part of processing.js), but if you want to set up your own sandbox to work kinda like what the KA sandbox does, you can download processing.js here. I made a quick and dirty sandbox by using the following code in a plain text file I named sandbox.html.
<html><head><script src="processing.min.js"></script></head><body><canvas id="output-canvas"></canvas><script>var sketch = function (processing){with(processing){size(400, 400);background(255);
// example
// fill(255, 0, 0);
// ellipse(0.5*width, 0.5*height, 100, 50);
// your code here
}};var p = new Processing(document.getElementById("output-canvas"), sketch);</script></body></html>
Then put the above file in the same folder as processing.min.js, just type your code where it says // your code here
, save and open the file.
Documentation to a full list of Procesing functions is here.
Enjoy!