Created
February 27, 2023 13:53
-
-
Save seanwiseman/33b8599421e12ec627cc63c837b0c6db to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* | |
| We need a function called `calculateTotal` that will accept an array of numbers, then add them all up and return the total. | |
| `hint` - maybe take a look at https://www.w3schools.com/js/js_loop_forin.asp . | |
| Here are some examples that sound work: | |
| Example 1: | |
| const items = [ | |
| 10, | |
| 25, | |
| 35, | |
| ] | |
| > calculateTotal(items) | |
| 70 | |
| -------------- | |
| Example 2: | |
| const items = [ | |
| 5.5, | |
| 100, | |
| 34, | |
| ] | |
| > calculateTotal(items) | |
| 139.5 | |
| -------------- | |
| Example 3: | |
| const items = [ | |
| 25, | |
| 100, | |
| -10, // this could be a discount | |
| ] | |
| > calculateTotal(items) | |
| 115 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment