Hey guys how can i check how many li is same in html using js | Sololearn: Learn to code for FREE!

0

Hey guys how can i check how many li is same in html using js

<li>abcd</li> <li>efgh</li> <li>abcd</li> The output should be like abcd=2 , efgh=1

10/20/2021 5:47:49 AM

Deepak Kanojiya

5 Answers

New Answer

+2

Is same in what way dude? same in its content, its style?. Elaborate more on that "is same" in the Description please ... (Edit) We can use an empty object to contain frequency counters https://code.sololearn.com/WVtxBbJ3i9rF/?ref=app

+2

Guys thanks for you help this made my work easy now Ipang and Stefanoo šŸ™āœŒ

+1

You could do something like this 1. create an dictionary with a string as key and a int as value 2. save the list(from html) into a variable 3. go through the list 4. check if the item is in your dictionary if not add it to it else increase the value by one 5. print the dictionary

+1

Ipang bro šŸ’– Awesome

+1

Big Thanks MĒŸÉ–ā†»ôɖɆā±¤šŸ’‰ bro šŸ™