DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • Project 1: The Performance-First Dashboard
  • Project 2: Accessible Video Player
  • Project 3: Markdown Blog Engine
  • Project 4: Browser-Based Code Editor
  • Project 5: Multi-Tab Whiteboard
  • Project 6: Infinite Scroll Image Gallery
  • Project 7: Recipe Optimizer & Converter
  • Project 8: Budget Tracker with Charts
  • Project 9: Typing Speed Test
  • Project 10: Weather App with Time-Travel
  • Project 11: CSS Grid Layout Builder
  • Project 12: Password Vault (Frontend Only)
  • Project 13: Kanban Board (Trello Clone)
  • Project 14: Quiz App with Leaderboard
  • Project 15: Habit Tracker (GitHub Style)
  • Project 16: E-commerce Product Page
  • Project 17: Unit Converter (Expert Mode)
  • Project 18: Music Visualizer
  • Project 19: Flashcard Learning App
  • Project 20: Custom Form Validator
  • Project 21: Virtual Terminal
  • Project 22: Pomodoro Timer (Focus Pro)
  • Project 23: SVG Path Editor
  • Project 24: Movie Database Matchmaker
  • Project 25: Interactive Resume / Portfolio
  • Project 26: Recipe Scraper UI
  • Project 27: Crypto Tracker (Real-Time)
  • Project 28: Find My Pet (PWA)
  • Project 29: Markdown-to-Slide Tool
  • Project 30: Browser Health Dashboard
← From Beginner to Expert in Fundamentals of Frontend

Project 7: Recipe Optimizer & Converter

40 min read
String ParsingFraction MathUnit ConversionWake Lock APIPrint CSSTouch-Friendly UI

📋 Project Brief

Build a recipe scaling and unit conversion tool designed for both professional and home cooks. The app parses ingredient strings (e.g., "1/2 cup of milk"), performs mathematical transformations on fractional quantities, and converts between Metric and Imperial systems. The UI must be touch-friendly and highly legible for use in kitchen environments.

🎯 Learning Objectives

  • Parse complex natural-language strings into structured data (fractions, units, ingredients)
  • Perform accurate arithmetic on fractional values
  • Build unit conversion systems with ratio-preserving logic
  • Use the Wake Lock API to prevent screen dimming
  • Create print-optimized CSS for clean paper output

✅ Feature Requirements

Feature 1: Smart Scaling

Acceptance Criteria:

  • A "Servings" slider adjusts all ingredient quantities proportionally
  • Default recipe is for 4 servings; user can scale from 1 to 20
  • Fractional results must be displayed as readable fractions (e.g., "¾" not "0.75")
  • Scaling must handle edge cases: "a pinch of salt" should remain unchanged
  • Quantities must round to practical kitchen measurements (no "0.3333 cups")

Feature 2: Unit Conversion

Acceptance Criteria:

  • Toggle between Metric (grams, ml, °C) and Imperial (oz, cups, °F)
  • Conversion must be accurate for: weight (g↔oz), volume (ml↔cups↔tbsp↔tsp), temperature (°C↔°F)
  • The selected unit system must persist in localStorage
  • Handle ingredient-specific conversions (1 cup of flour ≠ 1 cup of sugar by weight)

Feature 3: Wake Lock ("No-Sleep" Mode)

Acceptance Criteria:

  • A toggle button activates the Screen Wake Lock API
  • While active, the screen will not dim or lock
  • Show a visual indicator (e.g., a small icon) when Wake Lock is active
  • Gracefully handle browsers that don't support the API
  • Automatically release the lock when the user navigates away

Feature 4: Print-Optimized CSS

Acceptance Criteria:

  • A @media print stylesheet removes all buttons, navigation, and UI chrome
  • Only the recipe title, ingredients list, and instructions are printed
  • Font sizes are optimized for paper (12-14pt body text)
  • The print layout fits on 1-2 pages maximum

Feature 5: Ingredient Strikethrough

Acceptance Criteria:

  • Each ingredient has a checkbox next to it
  • Checking it applies a strikethrough and dims the text
  • A "Hide Completed" toggle removes checked ingredients from view entirely
  • Checked state persists during the session

📊 String Parsing Requirements

Input StringExpected Parsed Output
"1/2 cup of milk"{ quantity: 0.5, unit: "cup", ingredient: "milk" }
"2 large eggs"{ quantity: 2, unit: null, ingredient: "large eggs" }
"a pinch of salt"{ quantity: null, unit: "pinch", ingredient: "salt" }
"1 1/2 tbsp olive oil"{ quantity: 1.5, unit: "tbsp", ingredient: "olive oil" }
"350°F"{ quantity: 350, unit: "°F", ingredient: null }

🧪 Testing Checklist

  • Unit test string parser with all edge cases from the table above
  • Unit test scaling math (especially fraction rounding)
  • Unit test unit conversions (g↔oz, ml↔cups, °C↔°F)
  • Integration test: changing servings updates all ingredients
  • Print preview must match acceptance criteria

🚀 Stretch Goals

  • Add a "Shopping List" export that combines ingredients from multiple recipes
  • Implement a timer system for each cooking step
  • Add nutritional information calculation per serving
  • Voice control: "Hey, what's the next step?" using the Web Speech API

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.