Olamiposi-cloud-coder / forLoopChallenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tips Calculator Challenge

Welcome to the Tips Calculator Challenge! In this challenge, you'll be working on creating a tips calculator using JavaScript. You'll create an array of test bill values, calculate tips and totals for each bill, and then calculate the average of all the totals.

Challenge Details

  1. Create Test Bills: Create an array called bills containing 10 test bill values.

  2. Create Empty Arrays: Create two empty arrays called tips and totals to store the calculated tips and totals respectively.

  3. Calculate Tips and Totals: Create a calcTip function to calculate the tips and total values (bill + tip) for every bill value in the bills array using a for loop to perform the calculations.

  4. Calculate Average: Create a calcAverage function which takes an array called arr as an argument. The function will calculate the average of all numbers in the parsed array. Then call this function with the totals array.

Usage

  1. Clone the repository to your local machine: git clone https://github.com/Olamiposi-cloud-coder/forLoopChallenge.git

  2. Open the index.js file and implement the calcTip and calcAverage functions based on the challenge details.

  3. Run the code to see the calculated tips, totals, and the average total logged to the console.

Example Output

Here's an example of how the output might look:

yaml

Copy code

  • Tips: [5, 7, 3, ...]
  • Totals: [25, 37, 19, ...]
  • Average Total: 30.5

Resources

MDN Web Docs: Array MDN Web Docs: for loop

Author

[Olamiposi-CLoud] - [https://github.com/Olamiposi-cloud-coder]

Feel free to contribute to the project by providing feedback, suggestions, or improvements via pull requests.

Happy coding!

About


Languages

Language:JavaScript 52.8%Language:HTML 27.7%Language:CSS 19.4%