Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- const heroes = [];
- arr.forEach((el) => {
- const parts = el.split(/\s*\/\s*/);
- const [name, level] = parts;
- let items = [];
- if (parts.length > 2) {
- items = parts[2].split(', ');
- }
- const hero = { name, level: Number(level), items };
- heroes.push(hero);
- });
- console.log(JSON.stringify(heroes));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement