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...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
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.
You have attempted 1 of 3 activities on this page