📚 › JavaScript: make pages do things
7. Functions
Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.
A function is a named block of code you can run many times. Write it with the word function, a name, parameters in brackets and the code in braces. return sends a value back.
Functions let you write logic once and reuse it everywhere.
Ver ejemplo
function greet(name) {
return "Hello, " + name;
}
console.log(greet("Ayesha"));
✍️ Ahora te toca
Write double(x) that returns x times 2, then print double(21).