Functions call functions js
function addfunc(a, b) {
return a + b;
// standard long function
}
addfunc = (a, b) => { return a + b; }
// cleaner faster way creating functions!
/*
Write a function sum that takes an array of numbers and
returns the sum of these numbers.
Write a function mean that takes an array of numbers and
returns the average of these numbers.
The mean function should use the sum function.
*/
function sum (arr) {
let suma = 0;
for (let i = 0; i < arr.length; i++) {
let num= parseInt(arr[i]);
suma += num;
}
return suma;
}
function mean (arr) {
let average = sum(arr) /arr.length;
return average;
}
Also in JavaScript:
- jest mock call
- random function javascript
- how to use fa-icon in angular
- jquery toggle function
- array sort by alphabetical javascript
- check textbox value on ng-change value == in angular
- conditional style react
- remove character at index
- js date remove am and pm
- close browser tab using jquery
- how to make a var and sprite in javascript
- java script hash
- Node Js templates
- trim first character in javascript
- colors in node js console
- add element to array javascript
- jquery hasclass
- remove from set javascript
- find the missing value in an integer array javascript
- how to clone an object
- map with async
- preventive vs reactive
- toLocalString
- javascript function that console ogs after 3 seconds