The goal of this coding exam is to quickly get you off the ground with the array method every ()
There is a selecting going on for civil service centre candidates have to participate in a number of events and the candid pose quotes more than 75 points in every event will be selected
Given candidateList as input it contains objects with name of the candidate and array consisting of poet attitude in each given by the candidate
Write a JS program to,
. Filter the candidates who have score more than 75 points in every event.
. Log the consisting of names of the selected candidates in the console
Input:
. The input will be a single line containing an array of objects candidatesList
Constraints
.keys object should be given in quotes
Sample input
[{'name:'blake,'points':[76,98,88,84]},{'name':'james','points':[098,12,33]},]
Output
[Blake]
function filterCandidates(arr){
const result = [];
arr.forEach(obj => {
if(obj.points.every(x => x >= 75)){
result.push(obj.name)
}
});
console.log(result);
return result
}
let arr = [{'name':'blake', 'points':[76,98,88,84]},{'name':'james','points':[098,12,33]},];
filterCandidates(arr);
Comments
Leave a comment