# Build a Device Loan Ledger - Build a Device Loan Ledger

**URL:** <https://forum.freecodecamp.org/t/build-a-device-loan-ledger-build-a-device-loan-ledger/801264>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 28, 2026, 3:57pm UTC](https://forum.freecodecamp.org/t/build-a-device-loan-ledger-build-a-device-loan-ledger/801264 "2026-09-28T15:57:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ambradnum](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ambradnum/32/241667_2.png) [@ambradnum](https://forum.freecodecamp.org/u/ambradnum)\
**Post date:** [September 28, 2026, 3:57pm UTC](https://forum.freecodecamp.org/t/build-a-device-loan-ledger-build-a-device-loan-ledger/801264/1 "2026-09-28T15:57:41Z")

</div>

### Tell us what’s happening:

I think my listOverdueDevices function is working correctly. I tested it with `console.log(listOverdueDevices(equipmentLedger, '11/28/2026'));` and got back what I think is the correct data.  
But tests 18 - 20 are failing

Please advise

### Your code so far

```js
// Provided Ledger
const equipmentLedger = {
  "1": { type: "PC", status: "CheckedOut", borrower: { name: "John Smith", email: "john@acme.org" }, dueDate: "11/30/2025" },
  "2": { type: "Laptop", status: "CheckedIn", borrower: { name: "", email: "" }, dueDate: "" },
  "3": { type: "Laptop", status: "CheckedOut", borrower: { name: "Jane Doe", email: "jane@acme.org" }, dueDate: "10/31/2025" },
  "4": { type: "iPad", status: "CheckedIn", borrower: { name: "", email: "" }, dueDate: "" }
};

const checkoutDevice = (ledger, assetTag, borrower) => {
  if (!Object.hasOwn(ledger, [assetTag])) {
    return { ledger: ledger, message: `assetTag ${assetTag} not found` };
  }
  if (ledger[assetTag].status === "CheckedOut") {
    return { ledger: ledger, message: `assetTag ${assetTag} already checked out` };
  }
  const newL = JSON.parse(JSON.stringify(ledger));
  const name = borrower.name;
  newL[assetTag].borrower.name = name;
  newL[assetTag].borrower.email = borrower.email;
  newL[assetTag].status = "CheckedOut";

  return { ledger: newL, message: `assetTag ${assetTag} checked out by ${name}` };
}

const checkinDevice = (ledger, assetTag) => {
  if (!Object.hasOwn(ledger, [assetTag])) {
    return { ledger: ledger, message: `assetTag ${assetTag} not found` };
  }
  const newL = JSON.parse(JSON.stringify(ledger));
  newL[assetTag].borrower.name = "";
  newL[assetTag].borrower.email = "";
  newL[assetTag].dueDate = "";
  newL[assetTag].status = "CheckedIn";

  return { ledger: newL, message: `assetTag ${assetTag} checked in` };
}

const dateFromString = str => {
  const e = str.split("/");
  return Number(e[2] + e[0].padStart(2, "0") + e[1].padStart(2, "0"));
}

const listOverdueDevices = (ledger, today) => {
  const retArr = [];
  const todayDate = dateFromString(today);

  const ledger2 = {};
  for (const dev in ledger) {
    if (ledger[dev].status === "CheckedOut" && dateFromString(ledger[dev].dueDate) < todayDate) {
    ledger2[dev] = ledger[dev];
    }
  }
  const arr = Object.entries(ledger2);
  arr.sort((a, b) => dateFromString(a[1].dueDate) - dateFromString(b[1].dueDate));
  for (const dev in arr) {
    retArr.push({[arr[dev][0]]: arr[dev][1]});
  }
  return retArr;
}

const serializeLedger = (ledger) => JSON.stringify(ledger)

const loadLedger= (json) => JSON.parse(json)

console.log(listOverdueDevices(equipmentLedger, '11/28/2026'));

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:156.0) Gecko/20100101 Firefox/156.0`

### Challenge Information:

Build a Device Loan Ledger - Build a Device Loan Ledger

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-v9/lab-device-loan-ledger/lab-device-loan-ledger)**
>
> Learn to Code for Free

GitHub Link: [freeCodeCamp/curriculum/challenges/english/blocks/lab-device-loan-ledger/69f0a37c3bf194a7c9c62492.md at main · freeCodeCamp/freeCodeCamp · GitHub](https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lab-device-loan-ledger/69f0a37c3bf194a7c9c62492.md)

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [September 28, 2026, 5:11pm UTC](https://forum.freecodecamp.org/t/build-a-device-loan-ledger-build-a-device-loan-ledger/801264/2 "2026-09-28T17:11:37Z")

</div>

Hi @ambradnum,

Please take another look at the instructions:

> …implement a `listOverdueDevices(ledger, today)` function that takes a ledger object _and returns an array of the device objects_ that are overdue

Are you asked to also return an object key from the equipment ledger?

Happy coding

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [October 26, 2026, 3:41pm UTC](https://forum.freecodecamp.org/t/build-a-device-loan-ledger-build-a-device-loan-ledger/801264/3 "2026-10-26T15:41:57Z")

</div>

Closed on October 26, 2026, 3:41pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
