1.10. JavaScript¶
We have come to realize that not everyone loves Python as much as we do. So we have now made it possible to write activecode examples in pure javascript as well as Python. Here is a simple example:
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
Adding a javascript example is just as easy as Python, all you need to do is add a :language:
parameter to the activecode directive.
.. activecode:: jstest1
:language: javascript
:nocodelens:
var x = 10;
var y = 11;
var z = x + y;
console.log(z);
function fact(n) {
if(n <= 1) return 1;
else {
return n * fact(n-1);
}
}
console.log(fact(10));
writeln('hello world');
Adding a javascript example is just as easy as Python, all you need to do is add a ``:language:``
parameter to the activecode directive.