missymae
KPCKevin Powell - Community
•Created by snxxwyy on 9/28/2024 in #front-end
functions with return
when writing a function, the instructions inside are done in order; and yes, the return statement is what the function will send back when it completes, the return value. It's optional.
in JS you can write functions in multiple ways. Here you also use an arrow function, which automatically returns a value - unless it's an {object} in braces, in which case it needs the . So you can remove the braces and return from the map and have the same result with
or you can rewrite the whole works as a const and use arrow functions to avoid writing any returns and have something like this
The best way to learn the patterns is just use them and mess around, see what works and what breaks.
10 replies