output array de-reordering filter
/ / Code to be implemented
/ / 1. If the id is duplicated, remove an item with a low level value
/ / 2. Items whose attribute acitive is true are at the top of the list
/ / 3. When the attribute acitive is the same, the level is higher
/ / 4. Returns a string of name-rating format
/ / return.
sources of topics and their own ideas
my idea is to use ForEach to repeat how to use filter filtering. Then will not, just entered the js to give me a big stew to ask the great god to analyze!
related codes
/ / the following are topics with their own conditions
const Stacks = [{
id: 1,
name: "JavaScript",
level: 1,
active: true
},{
id: 2,
name: "CSS",
level: 3,
active: false
},{
id: 3,
name: "HTML",
level: 2,
active: true
},{
id: 1,
name: "JavaScript",
level: 4,
active: true
},{
id: 4,
name: "JQuery",
level: 1,
active: false
}]
function output2 (Arr) {
}
output2 (Stacks);
/ / the result returns
/ / ["JavaScript-4","HTML-2","CSS-3","JQuery-1"];