找出这段生成式支付重试代码中的语义缺陷。
JavaScript
async function createPayment(payment) {
for (let attempt = 0; attempt < 3; attempt += 1) {
try {
return await fetch("https://payments.example/charges", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payment),
});
} catch (error) {
if (attempt === 2) throw error;
}
}
}