edyt

Developerprompt

Document It

Add a docstring or doc comment to code.

نمونه‌ی ورودی

function formatPrice(cents, currency = "USD", locale = "en-US") {
  if (!Number.isInteger(cents)) throw new TypeError("cents must be an integer");
  return new Intl.NumberFormat(locale, { style: "currency", currency }).format(cents / 100);
}

نتیجه‌ی Edyt

/**
 * Formats a price in cents to a currency string based on the specified locale.
 *
 * @param {number} cents - The amount in cents, which must be an integer.
 * @param {string} [currency="USD"] - The currency code (e.g., "USD", "EUR").
 * @param {string} [locale="en-US"] - The locale to format the currency string.
 * @returns {string} The formatted currency string.
 * @throws {TypeError} If cents is not an integer.
 */
function formatPrice(cents, currency = "USD", locale = "en-US") {
  if (!Number.isInteger(cents)) throw new TypeError("cents must be an integer");
  return new Intl.NumberFormat(locale, { style: "currency", currency }).format(cents / 100);
}

روی هر متنی، در هر برنامه‌ای اجرایش کنید

متن را انتخاب کنید، میان‌برتان را بزنید و این پرامپت را انتخاب کنید. نتیجه همان‌جا ظاهر می‌شود. بدون کپی و پیست، بدون تب مرورگر.

پرامپت Document It | Edyt | Edyt