This project is a dynamic and interactive restaurant ordering app, built as a key module in the Scrimba Frontend Developer Career Path. It simulates a real-world food ordering experience, allowing users to browse a menu, add items to their cart, see a running total, and complete their order through a payment modal.
This is a single-page application built with plain HTML, CSS, and JavaScript. It's fully responsive and focuses on clean, efficient JavaScript to manage the application's state and user interactions. The goal was to build a realistic and functional user interface from scratch, without relying on any frameworks.
- HTML5
- CSS3
- JavaScript (ES6+)
This project was a significant step up in complexity and taught me several advanced front-end development concepts:
-
DOM Manipulation & Dynamic Rendering: I learned to dynamically generate HTML content from a JavaScript array of objects (
data.js) to render the restaurant's menu. This involved extensive use ofdocument.getElementByIdandinnerHTMLto create an interactive user interface. -
State Management: I managed the application's state using a single
ordersarray as the source of truth. All user actions, like adding or removing items, directly manipulate this array, which then triggers a re-render of the UI, ensuring the view is always in sync with the data. -
Complex Array Methods: I gained deep experience with advanced array methods.
find()was used to locate specific items in both the menu data and the orders array.findIndex()andsplice()were used together to correctly implement the "remove" functionality.- I learned why
filter()wasn't the right tool for removing a single instance of an item.
-
Advanced Logic for State Updates: The biggest challenge was implementing the item grouping feature. This required:
- Restructuring Data: Changing the data structure of items in the
ordersarray to include aquantityproperty. - Conditional Logic: Writing "add/update" logic that first checks if an item already exists in the order. If it does, it increments the quantity; otherwise, it adds a new object to the array.
- Dynamic Rendering: Updating the
renderOrder()function to display quantities and calculate line totals (price * quantity), ensuring the UI accurately reflects the complex state.
- Restructuring Data: Changing the data structure of items in the
-
Event Delegation: I used a single event listener on the
documentto efficiently manage all user clicks. By usinge.target.dataset, I could determine which button (add,remove,complete order) was clicked, making the code cleaner and more performant than adding multiple individual event listeners. -
Debugging CSS & HTML Quirks: I debugged complex CSS layout issues caused by conflicting styles and learned about HTML specification quirks, such as why
maxlengthdoes not work on an<input type="number">and how to solve it usingtype="text"andinputmode="numeric".
To run this project locally:
- Clone the repository:
git clone https://github.com/Ayoubxpy/restaurant-ordering-app.git
- Navigate to the project directory:
cd restaurant-ordering-app - Open the
index.htmlfile in your web browser.
This project was built as part of the Scrimba Frontend Developer Career Path. I'm grateful to the Scrimba team and community for their incredible learning platform.
If you are interested in learning to code with Scrimba, you can use my affiliate link to get a 20% discount on their Pro courses: https://scrimba.com/?via=u42a23be