[Code Parcel]
  • Home
  • Snippets
  • Become a Contributor
  • Find Instagram User ID
  • Login
  • Contact
  • Loggin to your account
Himas Rafeek
Posted on: 1 year ago
Javascript

Javascript average Function

This snippet returns the average of two or more numerical values.


                                          const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length;
average(...[1, 2, 3]); // 2
average(1, 2, 3); // 2                                          
Views: 4
Favorite0
Subscribe
Login
Notify of
Please login to comment
0 Discussions
Inline Feedbacks
View all comments

Related Snippets

What’s the best way to validate an email address in JavaScript?

Javascript

Prevent users submitting contact form if less than 2 words are entered (JavaScript)

CSS

Javascript Page bottom Visible Function

Javascript

Javascript cast Array Function

Javascript

Javascript capitalize string function

Javascript

Javascript capitalize Every Word

Javascript

Javascript byte Size Function

Javascript

Javascript bifurcate Function

Javascript

Javascript bifurcate By Function

Javascript

Javascript average By Function

Javascript

Javascript attempt Function

Javascript

Javascript array To Html List Function

Javascript

© Reserved [Code Parcel] 2022

Login

Register

Forgotten Password?

Register | Lost your password?
| Back to Login
wpDiscuz