Whoa, and I just looked again and saw that you’re declaring variables in the global scope that get modified inside the callback functions.
var filteredRatings =[];
let data="";
let str="";
let d = "";
In functional programming you should never do this. Functions should create no side effects such as modifying variables outside their scope, they should only produce some output depending solely on their input.