-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (28 loc) · 873 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// function wrapping(gifts) {
// const wrapped = [];
// for (let i = 0; i < gifts.length; i++) {
// let gift = gifts[i];
// let wrap = '*'.repeat(gift.length + 2);
// wrapped.push(`${ wrap }\n*${ gift }*\n${ wrap }`);
// }
// return wrapped;
// }
// function wrapping(gifts) {
// return [...gifts.map(gift => {
// let wrap = '*'.repeat(gift.length + 2);
// let giftWrapped = `${ wrap }\n*${ gift }*\n${ wrap }`;
// return giftWrapped;
// })];
// }
// acore: 132
function wrapping(gifts) {
return [...gifts.map(gift => {
let wrap = '*'.repeat(gift.length + 2);
let giftWrapped = [wrap, `*${gift}*`, wrap].join('\n');
return giftWrapped;
})];
}
module.exports = wrapping;
const gifts = ['book', 'game', 'socks'];
const wrapper = wrapping(gifts);
console.log(wrapper);