Pseudocode Pattern
Teile einen komplexen Algorithmus in überschaubare Blöcke auf und lass die KI den Code sequentiell schreiben.
Anwendungsfall
Bei der Implementierung komplexer Logik, die Schritt-für-Schritt-Denken erfordert.
Erwartetes Ergebnis
Du schreibst zuerst die Kommentare und lässt Autocomplete den Code unter jedem Schritt ausfüllen, wenn du Enter drückst.
The Trigger
function processCheckout(cart) {
// Step 1: Calculate total price
const total = cart.reduce((acc, item) => acc + item.price, 0);
// Step 2: Apply discount if total > 100
const discount = total > 100 ? 0.1 : 0;
const finalPrice = total - (total * discount);
// Step 3: Charge the customer via Stripe API
return stripe.charges.create({ amount: finalPrice, currency: 'usd' });
}