mirror of https://github.com/01-edu/public.git
Compare commits
6 Commits
f8f5b8c9e8
...
db30dc592a
Author | SHA1 | Date |
---|---|---|
eslopfer | db30dc592a | |
eslopfer | ca0881b4c6 | |
eslopfer | 16c745ae9b | |
eslopfer | 337ee68d21 | |
eslopfer | 48473b89d4 | |
eslopfer | 27d641de15 |
|
@ -100,52 +100,52 @@ tests.push(async ({ eq, ctx }) => {
|
|||
})
|
||||
|
||||
tests.push(async ({ eq, ctx }) => {
|
||||
// test when vips answer { drink: 'beer' }
|
||||
// should create a list with 6-packs-beers and potatoes
|
||||
// test when vips answer { drink: 'iced-tea' }
|
||||
// should create a list with iced-tea-bottles and potatoes
|
||||
const answers = [
|
||||
{ answer: 'no', drink: 'beer' },
|
||||
...ctx.createAnswers(1, { answer: 'yes', drink: 'beer' }),
|
||||
...ctx.createAnswers(1, { answer: 'yes', drink: 'iced-tea' }),
|
||||
]
|
||||
await ctx.setAnswersIn({ dir: 'guests', answers })
|
||||
|
||||
const { data } = await ctx.run('guests', 'happy-beer-list.json')
|
||||
return eq(data, { potatoes: 1, '6-packs-beers': 1 })
|
||||
const { data } = await ctx.run('guests', 'happy-iced-tea-list.json')
|
||||
return eq(data, { potatoes: 1, 'iced-tea-bottles': 1 })
|
||||
})
|
||||
|
||||
tests.push(async ({ eq, ctx }) => {
|
||||
// test when vips answer { drink: 'beer' }
|
||||
// should create a list with 6-packs-beers and potatoes
|
||||
// test when vips answer { drink: 'iced-tea' }
|
||||
// should create a list with iced-tea-bottles and potatoes
|
||||
const answers = [
|
||||
{ answer: 'no', drink: 'beer' },
|
||||
...ctx.createAnswers(6, { answer: 'yes', drink: 'beer' }),
|
||||
{ answer: 'no', drink: 'iced-tea' },
|
||||
...ctx.createAnswers(6, { answer: 'yes', drink: 'iced-tea' }),
|
||||
]
|
||||
await ctx.setAnswersIn({ dir: 'guests', answers })
|
||||
|
||||
const { data } = await ctx.run('guests', 'happy-beer-pack-list.json')
|
||||
return eq(data, { potatoes: 6, '6-packs-beers': 1 })
|
||||
const { data } = await ctx.run('guests', 'happy-iced-tea-bottles-list.json')
|
||||
return eq(data, { potatoes: 6, 'iced-tea-bottles': 1 })
|
||||
})
|
||||
|
||||
tests.push(async ({ eq, ctx }) => {
|
||||
// test when vips answer { drink: 'wine' }
|
||||
// should create a list with wine-bottles and potatoes
|
||||
// test when vips answer { drink: 'sparkling-water' }
|
||||
// should create a list with sparkling-water-bottles and potatoes
|
||||
const answers = [
|
||||
...ctx.createAnswers(3, { answer: 'no', drink: 'wine' }),
|
||||
...ctx.createAnswers(5, { answer: 'yes', drink: 'wine' }),
|
||||
...ctx.createAnswers(3, { answer: 'no', drink: 'sparkling-water' }),
|
||||
...ctx.createAnswers(5, { answer: 'yes', drink: 'sparkling-water' }),
|
||||
]
|
||||
await ctx.setAnswersIn({ dir: 'guests', answers })
|
||||
|
||||
const { data } = await ctx.run('guests', 'happy-wine-list.json')
|
||||
return eq(data, { potatoes: 5, 'wine-bottles': 2 })
|
||||
const { data } = await ctx.run('guests', 'happy-sparkling-water-list.json')
|
||||
return eq(data, { potatoes: 5, 'sparkling-water-bottles': 2 })
|
||||
})
|
||||
|
||||
tests.push(async ({ eq, ctx }) => {
|
||||
// test when vips answer { drink: 'wine' }
|
||||
// should create a list with wine-bottles and potatoes
|
||||
const answers = ctx.createAnswers(8, { answer: 'yes', drink: 'wine' })
|
||||
// test when vips answer { drink: 'sparkling-water' }
|
||||
// should create a list with sparkling-water-bottles and potatoes
|
||||
const answers = ctx.createAnswers(8, { answer: 'yes', drink: 'sparkling-water' })
|
||||
await ctx.setAnswersIn({ dir: 'guests', answers })
|
||||
|
||||
const { data } = await ctx.run('guests', 'happy-wine-bottle-list.json')
|
||||
return eq(data, { potatoes: 8, 'wine-bottles': 2 })
|
||||
const { data } = await ctx.run('guests', 'happy-sparkling-water-bottles-list.json')
|
||||
return eq(data, { potatoes: 8, 'sparkling-water-bottles': 2 })
|
||||
})
|
||||
|
||||
tests.push(async ({ eq, ctx }) => {
|
||||
|
@ -365,12 +365,12 @@ tests.push(async ({ eq, ctx }) => {
|
|||
}),
|
||||
...ctx.createAnswers(6, { answer: 'yes', food: 'vegan', drink: 'water' }),
|
||||
...ctx.createAnswers(2, { answer: 'yes', food: 'veggie', drink: 'water' }),
|
||||
...ctx.createAnswers(3, { answer: 'yes', food: 'veggie', drink: 'beer' }),
|
||||
...ctx.createAnswers(11, { answer: 'yes', food: 'fish', drink: 'wine' }),
|
||||
...ctx.createAnswers(3, { answer: 'yes', food: 'veggie', drink: 'iced-tea' }),
|
||||
...ctx.createAnswers(11, { answer: 'yes', food: 'fish', drink: 'sparkling-water' }),
|
||||
...ctx.createAnswers(4, {
|
||||
answer: 'yes',
|
||||
food: 'everything',
|
||||
drink: 'beer',
|
||||
drink: 'iced-tea',
|
||||
}),
|
||||
]
|
||||
await ctx.setAnswersIn({ dir: 'guests', answers })
|
||||
|
@ -388,8 +388,8 @@ tests.push(async ({ eq, ctx }) => {
|
|||
sardines: 11,
|
||||
burgers: 2,
|
||||
kebabs: 4,
|
||||
'6-packs-beers': 2,
|
||||
'wine-bottles': 3,
|
||||
'iced-tea-bottles': 2,
|
||||
'sparkling-water-bottles': 3,
|
||||
'water-bottles': 2,
|
||||
'soft-bottles': 1,
|
||||
})
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
"code": "equal(shaker.length, 3)"
|
||||
},
|
||||
{
|
||||
"description": "shaker can make a cocktail.",
|
||||
"code": "equal(shaker(1, 'strawberry', true), '1 strawberry cocktail')"
|
||||
"description": "shaker can make a skinny milkshake.",
|
||||
"code": "equal(shaker(1, 'strawberry', true), '1 skinny strawberry milkshake')"
|
||||
},
|
||||
{
|
||||
"description": "shaker can make a milkshake.",
|
||||
"code": "equal(shaker(1, 'strawberry', false), '1 strawberry milkshake')"
|
||||
},
|
||||
{
|
||||
"description": "shaker can make multiple cocktails.",
|
||||
"code": "equal(shaker(7, 'banana', true), '7 banana cocktails')"
|
||||
"description": "shaker can make multiple skinny milkshakes.",
|
||||
"code": "equal(shaker(7, 'banana', true), '7 skinny banana milkshakes')"
|
||||
},
|
||||
{
|
||||
"description": "shaker can make multiple milkshakes.",
|
||||
|
@ -25,6 +25,6 @@
|
|||
},
|
||||
{
|
||||
"description": "shaker is shakin it right.",
|
||||
"code": "equal(shaker(1, 'vanilla', true), '1 vanilla cocktail')\nequal(shaker(1, 'mango', true), '1 mango cocktail')\nequal(shaker(2, 'banana', true), '2 banana cocktails')\nequal(shaker(2, 'chocolate', false), '2 chocolate milkshakes')\nequal(shaker(2, 'vanilla', false), '2 vanilla milkshakes')\nequal(shaker(2, 'strawberry', false), '2 strawberry milkshakes')"
|
||||
"code": "equal(shaker(1, 'vanilla', true), '1 skinny vanilla milkshake')\nequal(shaker(1, 'mango', true), '1 skinny mango milkshake')\nequal(shaker(2, 'banana', true), '2 skinny banana milkshakes')\nequal(shaker(2, 'chocolate', false), '2 chocolate milkshakes')\nequal(shaker(2, 'vanilla', false), '2 vanilla milkshakes')\nequal(shaker(2, 'strawberry', false), '2 strawberry milkshakes')"
|
||||
}
|
||||
]
|
|
@ -7,21 +7,21 @@
|
|||
As you're smart, you asked every guest of the party to precise in their answer
|
||||
the kind of drink they would enjoy and the kind of food they would die for.
|
||||
|
||||
Create a `happiness-manager.mjs` script that sort, who wants to drink what and
|
||||
Create a `happiness-manager.mjs` script that sorts, who wants to drink what and
|
||||
who wants to eat what and integrate that in your barbecue's shopping list!
|
||||
|
||||
> note that you must only consider **vips** guests, those that answerd `'yes'`
|
||||
> note that you must only consider as **VIP** guests, those that answered `'yes'`
|
||||
|
||||
The script must:
|
||||
|
||||
- Take a directory as first argument (the `guest` directory)
|
||||
- Take a file `.json` as second argument:
|
||||
- If the file already exists, it will add the informations to it. If some elements already exist in the original file, it will be replaced by new values.
|
||||
- If the file already exists, it will add the information to it. If some elements already exist in the original file, it will be replaced by new values.
|
||||
- If it doesn't, the script must handle the creation of the file.
|
||||
- Handle case when no one answered yes to the invitation:
|
||||
- `No one is coming.` has to appear in console.
|
||||
- Handle the case when no one answered yes to the invitation:
|
||||
- `No one is coming.` has to appear in the console.
|
||||
- No file is updated/created.
|
||||
- Handle cases when answers contains no "food" information, or no "drink"
|
||||
- Handle cases when answers contain no "food" information, or no "drink"
|
||||
information
|
||||
- Handle cases when no one has chosen a category (for example: no one chose to
|
||||
drink softs). This category should not appear in the final list.
|
||||
|
@ -29,24 +29,24 @@ The script must:
|
|||
You have to handle the info like this:
|
||||
|
||||
- Drinks:
|
||||
- Beers: 1 pack / 6 vips (rounded up). Expected key: `6-packs-beers`.
|
||||
- Water, wine, softs: 1 bottle / 4 vips in each category (rounded up).
|
||||
Expected keys: `wine-bottles`, `water-bottles`, `soft-bottles`.
|
||||
- Iced tea: 1 pack / 6 VIPs (rounded up). Expected key: `iced-tea-bottles`.
|
||||
- Water, sparkling water, softs: 1 bottle / 4 VIPs in each category (rounded up).
|
||||
Expected keys: `sparkling-water-bottles`, `water-bottles`, `soft-bottles`.
|
||||
- Food:
|
||||
- Veggies and vegans: 1 eggplant, 1 courgette, 3 mushrooms and 1 hummus / 3
|
||||
vips in these categories put together. Expected keys: `eggplants`,
|
||||
VIPs in these categories put together. Expected keys: `eggplants`,
|
||||
`mushrooms`, `hummus`, `courgettes`.
|
||||
- Carnivores: 1 burger per person. Expected key: `burgers`.
|
||||
- Fish lovers: 1 sardine per person. Expected key: `sardines`.
|
||||
- Omnivores: 1 chicken+shrimps+pepper kebab / person. Expected key: `kebabs`.
|
||||
- Bonus: you'll add 1 potatoe per person (all categories put together).
|
||||
- Bonus: you'll add 1 potato per person (all categories put together).
|
||||
Expected key: `potatoes`.
|
||||
|
||||
The infos have to be formated like this in the `.json` file:
|
||||
The info has to be formated like this in the `.json` file:
|
||||
|
||||
```js
|
||||
{
|
||||
"key": 1 // according to actual number associated to the elem
|
||||
"key": 1 // according to actual number associated to the element
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -27,24 +27,24 @@ the string `happy` or not. The possibilities are becoming limitless...
|
|||
### Instructions
|
||||
|
||||
As Rick's robot, you are continuing your training to add yourself new ... skills
|
||||
(I could have said funtions). You want now to become a robot bartender.
|
||||
(I could have said functions). You want now to become a robot barista.
|
||||
|
||||
Define the function `shaker` which will take as arguments:
|
||||
|
||||
- `quantity`, which will be variable of type `Number`
|
||||
- `fruit`, which will be a `String`
|
||||
- `alcohol`, which will be a `Boolean`
|
||||
- `diet`, which will be a `Boolean`
|
||||
|
||||
`shaker` must return a `String`. Look at the examples below to understand how
|
||||
`shaker` must mix its ingredients:
|
||||
|
||||
```js
|
||||
console.log(shaker(1, 'strawberry', true))
|
||||
//'1 strawberry cocktail'
|
||||
//'1 skinny strawberry milkshake'
|
||||
console.log(shaker(2, 'chocolate', false))
|
||||
//'2 chocolate milkshakes'
|
||||
console.log(shaker(2, 'strawberry', true))
|
||||
//'2 strawberry cocktails'
|
||||
//'2 skinny strawberry milkshakes'
|
||||
console.log(shaker(1, 'chocolate', false))
|
||||
//'1 chocolate milkshake'
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue