Last active
August 29, 2015 14:28
-
-
Save razorthink-com/ce3f607eb5168df4bc5a 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
var Employees = [{ | |
id: 0, | |
name: "sandeep", | |
skills: [ "Javascript", "Angular" ], | |
experience: 2, // add later | |
salary: 100 | |
}, | |
{ | |
id: 1, | |
name: "Abhishek", | |
skills: [ "Java", "Angular", "CouchDB" ], | |
experience: 2, // add later | |
salary: 200 | |
}, | |
{ | |
id: 2, | |
name: "Amith", | |
skills: [ "Java", "Spark", "Cassandra" ], | |
experience: 2, // add later | |
salary: 100 | |
}]; | |
var Companies = [{ | |
name: "Razorthink", | |
employees: [ 0, 1, 2 ] | |
}]; | |
var Domains = { | |
testing: [ "Selenium", "JUnit" ], | |
backend: [ "Java", "NodeJS", "Cassandra", "Spark" ], | |
frontend: [ "Javascript", "HTML", "CSS", "Angular" ] | |
}; | |
var MODEL = { | |
employees: [], | |
companyCost: 0, | |
backend: [] | |
} | |
/*Get all employees of Razorthink who do not know javascript*/ | |
function getEmployees(){ | |
for(var i=0;i<Companies.length;i++){ | |
if(Companies[i].name == "Razorthink"){ | |
var employeeList = Companies[i].employees; | |
for( var j=0; j<employeeList.length; j++ ){ | |
for(var k=0; k<Employees.length; k++){ | |
if(employeeList[j] == Employees[k].id){ | |
// console.log("employeeList:"+employeeList[j]); | |
if(Employees[k].skills.indexOf("Javascript") <= -1){ | |
console.log("In pushing", Employees[k].name +" having skills"+Employees[k].skills.toString()) | |
MODEL.employees.push(Employees[k]); | |
MODEL.companyCost += Employees[k].salary; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
getEmployees(); | |
console.log(JSON.stringify(MODEL.employees)); | |
console.log(MODEL.companyCost); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment