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.
- Module of 5
- Sum of 1 over n
- 1 to 10 times tables
- Array sorting
- Shopping discounts
- Higher profit
- Older than 17
- Age groups
- N times table
- Transactions
Description (work in progress).
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):
- Solve it with prompts and alerts (don't touch the DOM);
- Render your app in the DOM (finally);
- Set up a notification system using validation;
- Fake a client server communication;
- Make use of object oriented JS;
- Set up build tools.
Good luck and have fun!
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.
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).
Print the complete times tables from 1 to 10 using nested loops.
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.
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.
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.
Ask the age of 5 people and count how many of them are 18 or older.
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.
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.
Record 3 transactions paid by cash or credit, then report totals by payment type, the overall total, and the installment value for credit transactions.
Feel free to file an issue or submit a PR!
Place to share helpful links (work in progress).
Drop me a message on LinkedIn!
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!