Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- factory = (arr) => {
- let bakeIt = arr.pop();
- let batches = arr;
- let sorted = []
- batches.forEach(elem => {
- sorted.push([elem.split('#'), elem.split('#').map(Number).reduce((a, b) => a + b), elem.split('#').map(Number).reduce((a, b) => a + b) / elem.split('#').length, elem.split('#').length])
- });
- sorted = sorted.sort((a, b) => b[2] - a[2])
- .sort((a, b) => b[1] - a[1])
- .filter(elem => elem[1] === sorted[0][1])
- .filter(elem => elem[2] === sorted[0][2])
- .sort((a, b) => a[3] - b[3])
- console.log(`Best Batch quality: ${sorted[0][1]}`);
- console.log(sorted[0][0].join(' '));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement