Skip to content

Repository files navigation

Javascript exercise list

This repository is intended to showcase my abilities, oops, publish some Javascript exercises that I've got to do in college [UPDATE 4/22/19: I've modified (and I'm modifying) them a little bit to make things interesting]. Since there's a LOT of them, I'll be adding each one as I solve along with their descriptions. With this, I hope that who's learning JS too find it useful.

Disclaimer: Don't worry about supporting legacy browsers just yet. You can learn how to transpile to ES5 later.

Table of contents

  1. Module of 5
  2. Sum of 1 over n
  3. 1 to 10 times tables
  4. Array sorting
  5. Shopping discounts
  6. Higher profit
  7. Older than 17
  8. Age groups
  9. N times table
  10. Transactions

Quick start

Description (work in progress).

Exercises

I didn't set up difficulty levels for each one because they can be improved almost indefinitely. If you don't know how to approach each problem or want to apply all the JS concepts that you're learning, I suggest the following progressive workflow (that's what I'm doing by the way):

  1. Solve it with prompts and alerts (don't touch the DOM);
  2. Render your app in the DOM (finally);
  3. Set up a notification system using validation;
  4. Fake a client server communication;
  5. Make use of object oriented JS;
  6. Set up build tools.

Good luck and have fun!

1. Module of 5

Print every number between 1000 and 2000 that leaves a remainder of 5 when divided by 11. A warm-up with loops and the modulo operator.

2. Sum of 1 over n

Ask the user for a positive integer n and compute the sum S = 1/1 + 1/2 + ... + 1/n, printing the whole equation along with the result. Validate the input first (not a number, not an integer, not positive).

3. 1 to 10 times tables

Print the complete times tables from 1 to 10 using nested loops.

4. Array sorting

Fill a 5×4 matrix (5 groups of 4 numbers) from user input and display each group along with its indexes — an exercise about navigating nested arrays.

5. Shopping discounts

Register 3 clients (name and money spent), apply a 10% discount for purchases under 1000 or 15% otherwise, and show a per-client summary with the discount and final total.

6. Higher profit

Given a series of price/quantity options with fixed expenses, compute the profit of each one, show them all in a table, and find the most profitable option.

7. Older than 17

Ask the age of 5 people and count how many of them are 18 or older.

8. Age groups

Collect people's ages, classify each person into one of five age brackets, then show the number of people per group and the percentage of people in the first and last groups.

9. N times table

An interactive page: type a number into the form and its 1-to-10 times table is rendered instantly. Invalid input triggers styled error/warning messages — this one covers events, DOM manipulation and a small notification system based on validation.

10. Transactions

Record 3 transactions paid by cash or credit, then report totals by payment type, the overall total, and the installment value for credit transactions.

Contributing

Feel free to file an issue or submit a PR!

Further reading

Place to share helpful links (work in progress).

Contact

Drop me a message on LinkedIn!

Thanks

A huge thank you for who's read this and probably took the time to either view my code or solve the exercises. You're awesome!

About

This repo is intended to showcase my abilities, oops, publish some Javascript exercises that I've got to do in college.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages