diff --git a/src/products.js b/src/products.js index 6b5b7c2..06583e4 100644 --- a/src/products.js +++ b/src/products.js @@ -6,10 +6,14 @@ function getFullName(contact) { function getProductsPurchased(contact) { const purchased = contact.purchased; - if (!purchased || !purchased.length) { + if (!purchased.length) { return "No products purchased."; } + if (purchased.length === 1) { + return purchased[0].name; + } + const result = []; for (let product of purchased) { result.push(product.name); @@ -17,3 +21,8 @@ function getProductsPurchased(contact) { return result; } + +module.exports = { + getFullName, + getProductsPurchased, +};