This is an example of how we can pass function as an argument in JavaScript. script.js var years = [1940, 1925,1957,2000,1928]; function arrayCal(arr, fn){ var arrValues = []; for(var i =0; i < arr.length ; i++){ arrValues.push(fn(arr[i])); } return arrValues;…
JavaScript number formatting
With JavaScript single function we can format number like we want for example in example this formatNumber function add comma and dot according to number pass in function see the demo for more info. script.js function formatNumber(num){ var num,dec, numSplit;…