Skip to content

Instantly share code, notes, and snippets.

@aatifbandey
Created June 24, 2021 16:51
Show Gist options
  • Save aatifbandey/94acab7f632739163c8da29af2e00853 to your computer and use it in GitHub Desktop.
Save aatifbandey/94acab7f632739163c8da29af2e00853 to your computer and use it in GitHub Desktop.
let employees = [
{
id: 1,
email: '[email protected]',
firstName: 'First1',
lastName: 'Last1',
},
{
id: 2,
email: '[email protected]',
firstName: 'First2',
lastName: 'Last2',
},
{
id: 3,
email: '[email protected]',
firstName: 'First3',
lastName: 'Last3',
},
];
const _ = require('lodash');
function paySalary(call) {
let employeeIdList = call.request.employeeIdList;
_.each(employeeIdList, function (employeeId) {
console.log("Employeed Id", employeeId);
let employee = _.find(employees, { id: employeeId });
console.log(employee);
if (employee != null) {
let responseMessage = "Salary paid for ".concat(
employee.firstName,
", ",
employee.lastName);
call.write({ message: responseMessage });
}
else{
call.write({message: "Employee with Id " + employeeId + " not found in record"});
}
});
call.end();
}
exports.paySalary = paySalary;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment