javascript
Functions
JavaScript has a classic way to write functions:
function triple(n) {
return n * 3;
}
...and a shorter one, called an arrow function:
const triple = (n) => n * 3;
Both do the same thing. The curly braces { } mark what's inside the function (in Python it was the indentation).
Your mission
- Write a function
double(n)that returnsntimes 2. - Write a function
greet(name)that returns`Hello, ${name}!`.
Try one with each style!