Good afternoon, I am trying to make a method that tells me the number of elements an Array has that starts with "RT:"
For this I have developed the following code:
public getRowsRTs(idProyecto){
    this.twitterService.getTargets().subscribe((data) => {
        this.Twitter = data;
    });
   let countRT = this.Twitter.filter( tweet => tweet.message.startsWith("RT:")).length;
   return countRT;
    }
}
Here, data returns all the Documents that Mongo extracts, and puts them in the Twitter Array that I have defined at the beginning of the component. Within this Array each element has different attributes, such as _id, message, date ... I want you to tell me how many of those documents, the message value, begins with RT: and to return it to me, this code , it does not give me any problem, but it does not give me absolutely nothing, I do not know if someone could help me.
 
     
    