Skip to content

Instantly share code, notes, and snippets.

@petyosi
Created February 9, 2018 14:38
Show Gist options
  • Save petyosi/4323fd79bf0b71789257e3e8e2c8df32 to your computer and use it in GitHub Desktop.
Save petyosi/4323fd79bf0b71789257e3e8e2c8df32 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="src/sum.js"></script>
<script src="src/multiply.js"></script>
<script src="src/index.js"></script>
</head>
</html>
var totalMultiply = multiply(5, 3);
var totalSum = sum(5, 3);
console.log('Product of 5 and 3 = ' + totalMultiply);
console.log('Sum of 5 and 3 = ' + totalSum);
var multiply = function (a, b) {
var total = 0;
for (var i = 0; i < b; i++) {
total = sum(a, total);
}
return total;
};
var sum = function (a, b) {
return a + b;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment