As an expert in prompt engineering, your task is to optimize the following prompt for…
- User
As an expert in prompt engineering, your task is to optimize the following prompt for clarity, effectiveness, and precision. Begin by identifying any ambiguities, redundant language, or areas for improvement. Refactor the prompt using advanced prompt engineering techniques, such as:
- Role Assignment: Specify an appropriate role or perspective for the model to adopt.
- Chain-of-Thought (CoT): Encourage the model to think through steps logically if necessary.
- Self-Consistency: Ensure that the prompt is clear enough to produce reliable results across multiple outputs.
- Contextual Prompting: Include any background context that may improve understanding.
After making improvements, briefly explain your choices to demonstrate the optimizations. Here is the prompt to optimize:
---prompt-start---
This page implements a product comparison table/selector for Sony home theatre products. Here's a breakdown of its functionality:
Layout & Structure: Shows a title "Choose Your Perfect Home Theatre Product" Displays up to 3 product columns side by side Each product has an image, name, and buttons (Buy/Learn More) Features are listed in rows, with feature names in the leftmost column Interactive Features: Users can change products using dropdown selectors at the top Each selector allows switching between available products Products that are already selected in other columns are disabled in the dropdowns When a product is selected: The product image updates Buy/Learn More buttons update with correct links Feature values update in the column Products maintain their order in columns Responsive Design: Shows 3 columns on large screens (≥1024px) Shows 2 columns on smaller screens Features sidebar becomes fixed width on extra large screens (≥1280px) Adapts button layout based on screen size Responsive spacing and typography Data Handling: Product and feature data is loaded from data.json Features can be boolean (showing checkmarks) or text values Product data includes links for Buy/Learn More buttons Data is passed to client-side JavaScript for dynamic updates The page essentially creates an interactive product comparison tool that helps users compare different Sony home theatre products side by side.
Can you rewrite whole javascript code but better and more readable without breaking the current functionality? ---prompt-end---
- Assistant
Optimized Prompt
Role Assignment: You are a skilled JavaScript developer tasked with refactoring the existing code for a product comparison tool.
Context: The current implementation is a web page featuring a dynamic comparison table for Sony home theatre products. It includes functionalities for selecting products, dynamically updating display information, responsive design for various screen sizes, and loading product data from a JSON file.