Skip to content

Instantly share code, notes, and snippets.

@asm-jaime
Created August 27, 2016 11:44
Show Gist options
  • Save asm-jaime/9c6a3b96890cdd94b79a154430057ba0 to your computer and use it in GitHub Desktop.
Save asm-jaime/9c6a3b96890cdd94b79a154430057ba0 to your computer and use it in GitHub Desktop.
best learner in school, without sort
"use strict";
const shool_rating = [
"Вова Петькин 2 2 3",
"Митька Залупкин 2 2 2",
"Антон Газенвагович 5 5 3",
"Антон Залупкин 2 2 3",
"Вова Залупкин 2 4 3",
"Вова Петькин 3 3 2"
];
const best_learner = {
three: [],
two : [],
one : [],
};
shool_rating.forEach((l) => {
switch([...l].filter((e) => e === "2").length){
case 1 : best_learner.one.push(l); break;
case 2 : best_learner.two.push(l); break;
case 3 : best_learner.three.push(l); break;
};
});
console.log(best_learner);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment