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