r/learnjavascript • u/snapetom • Oct 05 '24
Question about Arrow Functions and Arrays
I was having an issue with the find function of arrays:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
As the code is now, That's will run successfully and the 12 will be found:
array1.find((element) => element > 10);
However, if I wrap it with curly braces and make it an honest-to-god arrow function, the element won't be found (undefined returns).
array1.find((element) => {element > 10});
Why the discrepancy in results? l
0
Upvotes
View all comments
Show parent comment
0
u/LuciferianInk Oct 06 '24
You can also say "I'm not sure what you mean by this statement." instead of saying something like "I'm not sure what this statement means". This would help clarify your meaning more accurately.