Answer to Question #296275 in HTML/JavaScript Web Application for chethan

Question #296275

the goal of this coding exam is to quickly get off you the ground with the array method every().

input

  • the input will be single line containing an array of objects candidatesList

output

  • the output should be single line containing an array with names of the selected candidates.


input1

[{'name': 'Blake Hodges', 'points':[76, 98, 88, 84]},[{'name': 'James Anderson', 'points':[0, 98, 12, 33]},[{'name': 'Matthew Norton', 'points':[89, 67, 83, 93]}

output1

['Blake Hodges]


function readLine() {

 return inputString[currentLine++];

}


function main() {

 const candidatesList = JSON.parse(readLine().replace(/'/g, '"'));


/* Please do not modify anything above this line */

  

 // Write your code here

}


1
Expert's answer
2022-02-14T06:38:00-0500
function readLine() {
    return inputString[currentLine++];
}

function main() {

    const candidatesList = JSON.parse(readLine().replace(/'/g, '"'));

    /* Please do not modify anything above this line */

    // Write your code here
    const candidates = candidatesList.filter((candidate) => {
        if (candidate.points.every((point) => point > 75)) return candidate
    }).map((candidate) => candidate.name)

    console.log(candidates)
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS