deno.land / x / masx200_leetcode_test@10.6.5 / apply-discount-to-prices / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export default function discountPrices( sentence: string, discount: number,): string { return sentence.split(" ").map((s) => { if (!s.startsWith("$")) return s; if (s.length === 1) return s; const num = Number(s.slice(1)); if (Number.isNaN(num)) return s;
return "$" + (num * (1 - discount / 100)).toFixed(2); }).join(" ");}
masx200_leetcode_test

Version Info

Tagged at
a year ago