Function syntax question

Hi everybody! I have a quick question about this exercise if someone could help me:

const numbers = [2, 7, 9, 171, 52, 33, 14]

const toSquare = num => num * num

// Write your code here:
const squareNums = array => {

This particular one is giving me an error however, when I remove the brackets it turn to “correct”
Why are the brackets wrong in this particular one?

Which brackets are you referring to? There are a number of ways we can write that function.

Guess answering a question with a question is not for the OP. Okay, how about,

Where is the return keyword?

Note that when the curly braces are removed it becomes a concise body function where the return is implicit. Within braces, we must revert to ES5 function rules, where return is explicit.

Got it! Thank you so much!

1 Like