From ffdedabc2201326aaeed5834989b49bfbf732f46 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 2 Jul 2024 14:58:09 +0200 Subject: [PATCH] =?UTF-8?q?code.js=20:=20renvoi=20indice=20homonymes=20ave?= =?UTF-8?q?c=20tableau=20d'objets=20en=20param=C3=A8tre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/code.js b/code.js index ba97e78..b5614b2 100644 --- a/code.js +++ b/code.js @@ -221,23 +221,13 @@ function verif(chaine, nom) { } // ------------------------------------------------------------------------ -// faire un tableau des « homonymes » de chaine +// faire un tableau d'indice des « homonymes » de chaine +// tab est un tableau d'objets (nom, numero) // ------------------------------------------------------------------------ -function homonymes(chaine, tab) { - let homos = [] - for (const e of tab) { - if (normaliser(e).includes(chaine)) { - homos.push(e); - } - } - return homos; -} - -// idem en renvoyant les indices function indonymes(chaine, tab) { let homos = []; for (let i = 0 ; i < tab.length; ++i) { - if (normaliser(tab[i]).includes(chaine)) { + if (normaliser(tab[i].nom).includes(chaine)) { homos.push(i); } }