The goal of this coading exam is to quickly get you off the ground eith the array method every().there is a selection going on for the civil service sector candidates have to participate in x number of events and, the condidates who score more than 75 points in every event will be selectedgiven candidatesList as input,it contains objects with the name of the condidate and an array consisting of points achieved in each event by the condidate.filter the condidates who have scored more than 75 points in every event
log the array consisting of the names of the selected candidates in the console
i/p:the i/p will be a siongle line containing an array with names of the selected candidates
constraints:keys of objects should be given in quotes
input:
[{'name':'Blake Hodges','points':[76,98,88,84]},{'name':'James Anderson','points':[0,98,12,33]},{'name':'Matthew Norton','points':[89,67,83,93]}]
output:
['Blake Hodges']
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<script>
let arr = [
{'name':'Blake Hodges','points':[76,98,88,84]},
{'name':'James Anderson','points':[0,98,12,33]},
{'name':'Matthew Norton','points':[89,67,83,93]}
];
everyArr(arr);
function everyArr(arr) {
let resArr = [];
arr.map(item => {
(item.points).every(point => point > 75) ? resArr.push(item.name) : '';
})
console.log(resArr);
}
</script>
</body>
</html>
Comments
Leave a comment