Created
August 27, 2016 11:44
-
-
Save asm-jaime/9c6a3b96890cdd94b79a154430057ba0 to your computer and use it in GitHub Desktop.
best learner in school, without sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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