Just kidding! A compiler?! You can run it in your own browser!
But, I’ve found this website: Playcode.io. It has all I want, a minimalistic dark theme and a clean console. You can run the code wherever you want, but I encourage you to use Playcode, everything is just nicer.
Enough introduction, let’s dive right in!
So the factorial function takes a Natural number
n, and returns the product between all the Naturales numbers that are between 1 and
n, like this:
5 //1*2*3*4*5 120
The average function is a well known one. It takes an array of numbers, sums them and divides that sum by the length of the initial array. Here’s an example:
[1,5,8,4] //(1+5+8+4)/4 4.5
Did you solve them already? Try a different approach! Making more than one solution will strengthen your knowledge, giving you some flexibility when facing problems. And that’s key when programming.
Here are the solutions.