Skip to content
Snippets Groups Projects
Commit 6311261e authored by Martin Lehoux's avatar Martin Lehoux
Browse files

resoud le sproblèmes de données manquantes

parent d0b3a585
Branches
No related tags found
No related merge requests found
......@@ -16,11 +16,17 @@ function search(word, users) {
const result = [];
users.forEach(user => {
if (
user.nom.toLowerCase().includes(word) ||
user.prenom.toLowerCase().includes(word) ||
user.surnom.toLowerCase().includes(word)
(user.nom && user.nom.toLowerCase().includes(word)) ||
(user.prenom && user.prenom.toLowerCase().includes(word)) ||
(user.surnom && user.surnom.toLowerCase().includes(word))
) result.push(user);
else if (word.split(" ").every(part => user.nom.toLowerCase().includes(part) || user.prenom.toLowerCase().includes(part) || user.surnom.toLowerCase().includes(part))) result.push(user);
else if (word.split(" ").every(part => {
return (
(user.nom && user.nom.toLowerCase().includes(part)) ||
(user.prenom && user.prenom.toLowerCase().includes(part)) ||
(user.surnom && user.surnom.toLowerCase().includes(part))
)
})) result.push(user);
});
return result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment