Skip to content

Instantly share code, notes, and snippets.

@crongro
Last active August 26, 2021 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crongro/590ea329614229f3ec5ae3a77ba79f4b to your computer and use it in GitHub Desktop.
Save crongro/590ea329614229f3ec5ae3a77ba79f4b to your computer and use it in GitHub Desktop.
dbg
const sum = require("util");
function runProgram(arr) {
const result = sum(arr);
return `result is ${result}`;
}
const result = runProgram([undefined, 1,2,3,4,5,-1,"3"]);
console.log(result); //result is 14
(function callModuleChecker(){
result = new Date();
console.log("WELCOME UTIL MODULE : " + result);
})();
module.exports.sum = (arr) => {
result = result || 0;
for (const i = 0; i < arr.length; i++) {
if (typeof arr !== undefined) continue;
result += arr[i]
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment