Last active
February 13, 2019 09:08
-
-
Save shapkarin/32f6fba435cbb8d3f5c2 to your computer and use it in GitHub Desktop.
test task redundancy remix)
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 salary = employees.reduce(function (result, employee) { | |
return result + (employee.sex === 'female') ? employee.salary : false /*or 0*/; | |
}, 0); | |
console.log(salary); |
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 rand = function(min, max) { | |
return (Math.random() * (max - min + 1) + min)^0; | |
}, | |
employees = [], check = ''; | |
for (var i = 0; i <= 10; i++){ | |
employees.push( | |
{ | |
salary: rand(50,150) * 1000, | |
sex: rand(0,1) ? 'female' : 'male' | |
} | |
); | |
} | |
employees.forEach(function(employe){ | |
check += employe.sex === 'female' ? '+' + employe.salary : ''; | |
}); | |
console.log(check.substring(1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment