Developerprompt
Document It
Add a docstring or doc comment to code.
Beispieltext
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);
}Ergebnis von 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);
}Führ das auf jedem Text aus, in jeder App
Markiere Text, drück dein Tastenkürzel und wähl diesen Prompt. Das Ergebnis erscheint direkt an Ort und Stelle. Kein Kopieren und Einfügen, kein Browser-Tab.