Exercise 1: Functions, statements

Functions, statements

Let's begin with something simple: in Javascript functions are powerful tools. We can declare them once and give them multiple uses.

However, when you learn a new language you will run into a little detail: it has a different syntax And this case is not the exception! Will it be really difficult to learn the new syntax? Let's see our first function in Javascript.

function doble(number) {
   return 2 * number;
}

As you can see, the parentheses in the return are not necessary, and we must end the last line with a semicolon ;.

Let's see if you are getting it right: write a function half that takes a number and returns its half. Have in mind that the division operator in Javascript is /.

You must sign in before submitting your solutions

Oops, your solution didn't work

  • Check that your program does not have recursion or an infinite loop
  • Check that you have an internet connection
  • Wait a while and try again

We are processing you solution

Please press F5 if results are not displayed after a few seconds