Skip to content
Avio Lines
EasyJavaScriptPractice mode: untimed, 3 hints

Payment amount

formatAmount(payment) returns a payment's amount for display, like "₹499.00". The payments API sends amount as an integer number of paise (100 paise = 1 rupee).

The code has exactly one planted bug. Reproduce it with the tests, fix it with the smallest change, then submit.

Visible tests

  1. a normal payment

    • formatAmount({"id":"pay_1","amount":49900,"currency":"INR"}) → "₹499.00"
  2. zero

    • formatAmount({"id":"pay_1","amount":0,"currency":"INR"}) → "₹0.00"

Hints 0/3

    // The payments API sends amounts in paise (100 paise = 1 rupee), as an integer:
    //   { "id": "pay_1", "amount": 49900, "currency": "INR" }
    // formatAmount returns the amount for display, like "₹499.00".
    function formatAmount(payment) {
      return "₹" + payment.amount.toFixed(2);
    }
    

    Ctrl/⌘+Enter runs, Ctrl/⌘+Shift+Enter submits. In the editor, Ctrl+M switches Tab to moving focus.

    Run works without an account. Log in to submit against the hidden tests and track your accuracy per bug type.

    Ready for pressure? Try a timed set: six snippets, 20 minutes, no hints.