From the course: JavaScript: Best Practices for Functions and Classes

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Create functions

Solution: Create functions - JavaScript Tutorial

From the course: JavaScript: Best Practices for Functions and Classes

Start my 1-month free trial

Solution: Create functions

(upbeat music) - [Teacher] The JavaScript code for this challenge contains a couple different functions. We've got the projection function here and then we've got an anonymous call back to array.reduce. So first off, I noticed that my projection function is using a function declaration and I want to use a function expression because it's a best practice. So first off, I'll throw in the ESLint rules that will flag that for me. And the first one's going to be func-style and it's going to be an array which is error and expression. And I'll also throw in no-new-func here. We don't have a new constructor going on here but I'm going to throw in the rule just because I can, because it's a good practice to have that getting flagged for me in case I ever do it on accident or in case I inherit some code that does it. So now everything is in red, everything is underlined and that's because I'm using this function declaration.…

Contents