From the course: JavaScript: Best Practices for Functions and Classes
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Create functions - JavaScript Tutorial
From the course: JavaScript: Best Practices for Functions and Classes
Challenge: Create functions
(upbeat music) - [Instructor] Ready to test and implement best practices in creating functions? It's time for a challenge. My start code includes a function that takes in array as an argument and returns a string based on the maximum value found in that array. I use a nested array .reduce method to find the maximum value in that array. My code works but the function has several issues that make it more complex and harder to read than it should be. You'll implement best practices for functions throughout the code in the app.js file. You'll also add rules as appropriate to .ESLintrc.js to check for issues. This exercise should take you about 10 minutes. When you're done, join me in the next video and I'll walk you through how I approached it.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Use function expressions instead of declarations6m 20s
-
(Locked)
Don't use the new keyword to construct functions2m 39s
-
(Locked)
Leave parameter values untouched3m 2s
-
(Locked)
Use arrow syntax for anonymous functions1m 36s
-
(Locked)
Rely on implicit return only when obvious3m 26s
-
(Locked)
Challenge: Create functions53s
-
(Locked)
Solution: Create functions5m 29s
-
-
-
-
-
-