-3

I have sentence

red brake is true guineas they took over there piece of the city 20 years after an rishman couldn't get a job we had.

I want to extract all the words with bold tag in a separate array. For example, from the above line I want this:

["guineas", "rishman", "city"]

How can I get it?

charlietfl
  • 170,828
  • 13
  • 121
  • 150
EdG
  • 2,243
  • 6
  • 48
  • 103
  • Where do you get the input from? An HTML element? – XCS Oct 28 '18 at 22:28
  • 1
    Please show what you have tried. Stackoverflow isn't a free code writing service or a *"how to"* tutorial service. The various steps of this are relatively easy to research and basic research is expected here. See [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – charlietfl Oct 28 '18 at 22:28
  • 1
    minus 1 for needless swearing and no effort on the part of the op – andrew Oct 28 '18 at 22:28
  • This is actually a very good question and it is no simple matter. It is a the heart of libraries like JQuery. Many of you THINK it is a simple thing and you'd be wrong, please, If you don't know the answer you should not down vote. – DogBot Oct 28 '18 at 22:59
  • @DogBot what??? This is quite trivial with only a little bit of research. As for it being a good question, it is not. A good question would include code attempts to solve the issue. – charlietfl Oct 28 '18 at 23:10
  • @charlietfl please show us how. It is a good question because it's relevant, timely and very useful to all JavaScript developers. Even if it does not have every SO "guidleline" for a "good question". The real question is how to iterate over an HTMLcollection and that is not trivial at all. But the op obviously does not know that, and like him many more, in answering the question you will help thousands that will ask the question the same way. We cannot be so stuck up that we cannot remember how difficult it has been for us a t some point just to find out what to ask. – DogBot Oct 28 '18 at 23:22
  • @DogBot there are many 100's if not 1000's of questions already that contain loops iterating through NodeLists. There is nothing here that can not be ***easily*** researched to at least get to a code starting point. Asking a question here should not be the first point of researching an issue....it should be the last – charlietfl Oct 28 '18 at 23:25
  • @charlietfl I come here first always. I 100% sure if the OP had any Idea about NodeLists he would not even have the question, and That is the point. how do you expect him to know what he does not know. just give him a pointer. Dont discourage nuebies. I answered by pointing hi in the right direction so that others who ask the same way will now be enlightened. Comon' man. chill – DogBot Oct 28 '18 at 23:32
  • @DogBot you are missing the point and should read the link I posted in my first comment. Would appear you are new here and still aren't sure how this site is supposed to work. I'm not saying that in any sort of belittling way....just being real – charlietfl Oct 28 '18 at 23:34
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/182693/discussion-between-dogbot-and-charlietfl). – DogBot Oct 28 '18 at 23:35
  • I don't think I have added a trivial question @charlietfl. I didn't get any way to get the solution. – EdG Oct 29 '18 at 05:22
  • @ApurvG your solution is here: https://stackoverflow.com/questions/22754315/for-loop-for-htmlcollection-elements – DogBot Oct 29 '18 at 14:53

1 Answers1

-1

You are iterating through an HTMLcollection. Using a library like JQuery makes this easy. But to understand the issue and for a pure JavaScript solution see this thread:

For loop for HTMLCollection elements

DogBot
  • 528
  • 1
  • 6
  • 15