To illustrate the degree of difficulty, I put 3 div
and within them identical words, put it on purpose to add to its duplication.
<div> <div> <div> Diego Ademir Diego Maicon Diego Maicon Adriana Maicon Ademir Magda Adriana Adriana Delvair Magda Ademir Roselene Delvair Delvair Lawiny Ademir Lawiny Nicolas Lawiny Roselene Alice Nicolas Nicolas Ademir Alice Alice Júlia Júlia Ademir </div> </div> </div>
I want to go through 3% with% with% with%, and returns the total number of repetition of the name "Ademir" in div
. Here's an example with for
:
var y = ["Diego","Maicon","Ademir","Adriana","Ademir","Delvair","Lawiny","Roselene","Nicolas","Alice","Ademir"];
var objects= {};
for (var x in y) {
objects[y[x]] = objects[y[x]]!=undefined ? objects[y[x]]+1 : 1;
}
alert("Encontramos " + objects.Ademir + " repetição do nome 'Ademir'!");
Based on the given example, I want to do with alert
and add each equal word found within 3 array
, and return its total.
Remembering that for the word in which it should be searched / added it is called "Ademir".