Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mapfilter(array, pred){
- let acc = [];
- for(let e of array){
- let a = pred(e);
- if(a !== null) acc.push(a);
- }
- return acc;
- }
- const tags = [
- { name: "Linux", score: .6 },
- { name: "Open Source", score: .7 },
- { name: "Bash", score: .9 },
- { name: "Shell", score: .8 },
- { name: "Awk", score: .2 },
- { name: "Sed", score: .3 },
- ];
- let nameOfTagIfHighScore = (tag) => tag.score > 0.5 ? tag.name : null;
- let result = mapfilter(tags,nameOfTagIfHighScore);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement