---
id: 6734c10a327760a665b7d5b9
title: Step 13
challengeType: 1
dashedName: step-13
---

# --description--

In the next few steps, you'll work on a function that will allow you to update the catalog when you sell plants.

Create a function named `sellPlants` that takes three arguments: a plant object, the pot size and the number of pots to sell, in this order.

When the specified number of pots is greater then the available pots, make your function return `Not enough <pot-size> size pots for <item-name>. Only <pot-number> left.`. Replace `<pot-size>` with the pot size, `<pot-number>` with the remaining pots for that size, and `<item-name>` with the scientific name of the plant followed by a space and the name of the cultivar wrapped between single quotes.

To test that everything works, log the result of calling your `sellPlants` function with the `ballerina` object, `"small"`, and `25` to the console. 

# --hints--

You should not modify your `catalog` map.

```js
const testCatalog = new Map();
testCatalog.set(ballerina, { small: 20, medium: 15, large: 12 });
testCatalog.set(prettyPolly, { small: 31, medium: 14, large: 24 });
testCatalog.set(willowVale, { small: 3, medium: 5, large: 0 });
testCatalog.set(hidcote, { small: 33, medium: 13, large: 18 });
testCatalog.set(imperialGem, { small: 19, medium: 35, large: 28 });
testCatalog.set(royalCrown, { small: 40, medium: 22, large: 9 });
assert.deepEqual(catalog, testCatalog);
```

You should have a function named `sellPlants`.

```js
assert.isFunction(sellPlants);
```

Your `sellPlants` function should take three arguments.

```js
assert.lengthOf(sellPlants, 3);
```

`sellPlants(ballerina, "small", 25)` should return `Not enough small size pots for Lavandula stoechas 'Ballerina'. Only 20 left.`.

```js
assert.equal(sellPlants(ballerina, "small", 25), "Not enough small size pots for Lavandula stoechas 'Ballerina'. Only 20 left.")

// prevent hardcoding
assert.equal(sellPlants(hidcote, "large", 95), "Not enough large size pots for Lavandula angustifolia 'Hidcote'. Only 18 left.")

assert.equal(sellPlants(royalCrown, "medium", 95), "Not enough medium size pots for Lavandula dentata 'Royal Crown'. Only 22 left.")
```

You should log `sellPlants(ballerina, "small", 25)` to the console.

```js
assert.match(__helpers.removeJSComments(code), /console\s*\.\s*log\s*\(\s*sellPlants\s*\(\s*ballerina\s*,\s*("|')small\1\s*,\s*25\s*\)\s*\)/);
```

`sellPlants(ballerina, "small", 10)` should return `undefined`.

```js
assert.isUndefined(sellPlants(ballerina, "small", 10));
// prevent hardcoding
assert.isUndefined(sellPlants(hidcote, "large", 5));
assert.isUndefined(sellPlants(royalCrown, "medium", 5));
```

# --seed--

## --seed-contents--

```js
const ballerina = {
    commonName: "Spanish lavender",
    scientificName: "Lavandula stoechas",
    cultivar: "Ballerina"
}

const prettyPolly = {
    commonName: "Spanish lavender",
    scientificName: "Lavandula stoechas",
    cultivar: "Pretty Polly"
}

const willowVale = {
    commonName: "Spanish lavender",
    scientificName: "Lavandula stoechas",
    cultivar: "Willow Vale"
}

const hidcote = {
    commonName: "English lavender",
    scientificName: "Lavandula angustifolia",
    cultivar: "Hidcote"
}

const imperialGem = {
    commonName: "English lavender",
    scientificName: "Lavandula angustifolia",
    cultivar: "Imperial Gem"
}

const royalCrown = {
    commonName: "French lavender",
    scientificName: "Lavandula dentata",
    cultivar: "Royal Crown"
}

const catalog = new Map();
catalog.set(ballerina, { small: 20, medium: 15, large: 12 });
catalog.set(prettyPolly, { small: 31, medium: 14, large: 24 });
catalog.set(willowVale, { small: 3, medium: 5, large: 0 });
catalog.set(hidcote, { small: 33, medium: 13, large: 18 });
catalog.set(imperialGem, { small: 19, medium: 35, large: 28 });
catalog.set(royalCrown, { small: 40, medium: 22, large: 9 });
--fcc-editable-region--

--fcc-editable-region--
console.log(catalog)
```
