Guest Search and Confirmation with filter, find, and includes
Implement the guest search module for Nexo's developer meetup by combining filter(), find(), String.includes(), and Array.includes().
JavaScriptBeginnerWith Nexo
arrays · filter-find-includes · strings
Statement
Your mission
To organize the Código con Criterio developer meetup, Nexo needs a check-in module capable of running three distinct queries across the event lists: filtering all guests whose name contains a partial search string, finding the first record that exactly matches a target name, and checking whether that person appears on the guest list and on the confirmed attendance list.
Implement the solve(input) function, which receives a JSON object with four properties:
invitados: array of 0 to 100 non-empty strings (1 to 40 characters), with possible duplicate names.
busqueda: non-empty string of 1 to 40 characters for partial search.
nombreExacto: non-empty string of 1 to 40 characters for exact search.
confirmados: array of 0 to 100 non-empty strings (1 to 40 characters).
Search rules:
coincidencias: use filter() to get all names in invitados that contain busqueda via String.prototype.includes(), distinguishing uppercase and lowercase and preserving order and duplicates.
cantidadCoincidencias: number of elements in coincidencias (coincidencias.length).
primerInvitadoExacto: use find() to locate the first occurrence in invitados whose name is strictly equal (===) to nombreExacto; if none exists, return null (never undefined).
existeInvitadoExacto: use Array.prototype.includes() to check whether nombreExacto is present in invitados.
estaConfirmado: use Array.prototype.includes() to check whether nombreExacto appears in confirmados (confirmation is independent of whether the name appears in invitados).
totalInvitados: total length of invitados (invitados.length, including duplicates).
Return a JSON object with those exact six properties: coincidencias, cantidadCoincidencias, primerInvitadoExacto, existeInvitadoExacto, estaConfirmado, and totalInvitados.
Rules and constraints
You must use filter(), find(), and includes() for their respective operations.
Do not use for, while, or for...of loops, reduce(), map(), sort(), Set, recursion, classes, or helper functions.
Do not mutate the original arrays, remove duplicates, or normalize letter casing.