Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Third solution in Clear category for [old] The Ship Teams by vincent.tscherter
"use strict";
function twoTeams(sailors) {
let out = [ [], [] ];
for (let s in sailors) out [+!(sailors[s]<20 || sailors[s]>40)].push(s);
return out.map(i=>i.sort());
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(twoTeams({
'Smith': 34,
'Wesson': 22,
'Coleman': 45,
'Abrahams': 19
}))
// These "asserts" are used for self-checking and not for an auto-testing
assert.deepEqual(twoTeams({
'Smith': 34,
'Wesson': 22,
'Coleman': 45,
'Abrahams': 19
}), [
['Abrahams', 'Coleman'],
['Smith', 'Wesson']
])
assert.deepEqual(twoTeams({
'Fernandes': 18,
'Johnson': 22,
'Kale': 41,
'McCortney': 54
}), [
['Fernandes', 'Kale', 'McCortney'],
['Johnson']
])
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
Sept. 2, 2018
Comments: