My thread variable contains 3 different elements. I want to create a For loop that iterates on these three objects.
threads: BehaviorSubject<{[key: string]: Thread }> = new BehaviorSubject({});
Here is my function:
searchUser(): Observable<Thread> {
this.searchArrayThreads = [];
let element = document.getElementById('chat-window-input');
return this.threads.map((threadDictionary: {[key: string]: Thread}) => {
for( let key in threadDictionary ) {
console.log("key", threadDictionary[key]);
if(threadDictionary[key].participants[0].name.startsWith(str)) {
return threadDictionary[key];
}
}
});
}
This function only works once. In her first call, she is iterating the 3 elements. Then it iterates just on the last element.