Currently, I am engaged in developing a function that is responsible for extracting the text of elements post utilizing a filter feature. Upon inspecting the displayed text output, it appears that the elements are being retrieved successfully; nonetheless, I find myself grappling with comprehending JavaScript promises. Notably, 'activeFilters' has been designated as a variable.
this.verifyColorFilterFunctional = function(color) {
var bool = true;
activeFilters.count().then(function (count) {
var amt = count - 1;
for (var i = 0; i < amt; i++){
activeFilters.get(i).getText().then(function(text) {
bool = (color === text);
console.log(bool);
});
if (!bool) {
break;
}
}
});
return expect(bool).to.become(true);
};
Upon scrutiny, I have observed that while the console.log accurately prints out 'true' and 'false', there exist two discrepancies. Firstly, when 'false' is determined, the execution fails to halt as intended within the specified if statement. Additionally, an error 'typeError: true is not a thenable' surfaces, leading me to believe that although the logic seems sound in my rationale, it does not align with JavaScript's interpretation. Any assistance or guidance on this matter would be immensely appreciated.