In C it is pretty common to see conditional debugging output. I was just wondering, is this sort of pattern common in JS as well?
const DEBUG = true;
function arrProd(arr, n) {
if (DEBUG) console.log("DEBUGGING - Function: arrProd");
let prod = 1;
if (DEBUG) console.log(" prod = " + prod);
for (let i=0; i < n; i++) {
prod *= arr[i];
if (DEBUG) console.log(" prod = " + prod);
}
if (DEBUG) console.log("DEBUGGING - Function return: " + prod);
return prod;
}
let myProd = arrProd([1, 2, 3], 3);