Created
June 3, 2016 09:40
-
-
Save yashikagarg13/a8a6a51cea7176106a78b828973cd36b to your computer and use it in GitHub Desktop.
This file contains 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"; | |
var R = require("ramda"); | |
var hackerrankResults = [ | |
{hackerrank: 90, name: "Maria", category: "Frontend", vetted: true, rate: "1000"}, | |
{hackerrank: 20, name: "Maria", category: "Frontend", vetted: true, rate: "1000"}, | |
{hackerrank: 100, name: "Maria", category: "Frontend", vetted: true, rate: "1000"}, | |
{hackerrank: 100, name: "Galina", category: "Frontend", vetted: true, rate: "2000"}, | |
{hackerrank: 95, name: "Olga", category: "Frontend", vetted: true, rate: "3000"}, | |
{hackerrank: 65, name: "Ira", category: "Frontend", vetted: true, rate: "3000"}, | |
{hackerrank: 100, name: "Vika", category: "Frontend", vetted: false, rate: "1000"}, | |
{hackerrank: 100, name: "Nadya", category: "Backend", vetted: false, rate: "1000"}, | |
]; | |
//let isVetted = function(user) {return user.vetted}; | |
let isVetted = R.propEq("vetted", true); | |
let isCategoryAsDefined = category => R.propEq("category", category); | |
//let result = R.filter(isFrontend, hackerrankResults); | |
let result = R.pipe( | |
R.filter(R.allPass([isVetted, isCategoryAsDefined("Backend")])) | |
)(hackerrankResults); | |
console.log('result:', result); | |
// Try to do | |
// 1. create isCategoryAsDefined predicate function | |
// 2. Try to remove double looping in example above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment