Skip to content

Instantly share code, notes, and snippets.

@nkhil
Created November 13, 2019 20:36
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 nkhil/6a39cbf9af7e176ed856c08f4e0c5e52 to your computer and use it in GitHub Desktop.
Save nkhil/6a39cbf9af7e176ed856c08f4e0c5e52 to your computer and use it in GitHub Desktop.
// file: controller.js
const databaseUpdater = require('../model/databaseUpdater');
// ^ This is out model function that goes and updates the database.
function updateTotal(total) {
databaseUpdater({ body: total });
}
function calculateTotal(data) {
const total = data.reduce((accumulator, number) => accumulator + number, 0);
updateTotal(total);
}
module.exports = calculateTotal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment