plus minus js
function plusMinus(arr) { let positives = 0, negatives = 0, zeros = 0; const len = arr.length || 0; if (len > 0 && len <= 100) { arr.map((elem, key) => { if (elem > 0) { positives++; } else if (elem < 0) { negatives++; } else { zeros++; } return elem; }); } console.log((positives / len) || 0); console.log((negatives / len) || 0); console.log((zeros / len) || 0); }
Also in JavaScript:
- loop json object android java
- ajax call
- javascript get first property of object
- javascript use strict
- express limit based on ip
- javascript jqgrid events afterShowForm
- destructure array javascript
- how to update node js version
- js library for checking if two shapes overlap
- react-google-maps satelite
- find a string in an array javascript
- javascript slice
- javascript format number with commas
- alpine js
- express jwt
- jquery table header agnostic of scroll
- nesting in Jinja2 expressions
- jquery how to get Id of child in div
- parseint array javascript
- change the color of toast toastr js
- javscript insert element after another
- js conditional key
- how display same paragraph in all pages of website in js
- how to install node js in ubuntu