Created
November 13, 2019 20:36
-
-
Save nkhil/6a39cbf9af7e176ed856c08f4e0c5e52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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