I have a function to fetch a json locally and change the data of some fields. but I have to do the test if the field is with the status code and depending on I change with the correct value for visualization in the frontend.
follow example:
$http.get("http://localteste:18888/tess").success(function (dados) {
local_locations = $.map(dados, function (dev) {
//Verifica Status da Bateria
if (dev.status) {
if (dev.status <= 10)
dev.status= "Muito Baixo";
else if (dev.status<= 25)
dev.status = "Baixo";;
else if ((dev.status== 50) || (dev.status>= 25))
dev.status= "Medio";;
else if ((dev.status== 75) || (dev.status>= 50))
dev.status= "Alto";;
else if ((dev.status== 100) || (dev.status> 75))
dev.batUseBattery = "Muito alto";
}
});
It would be more or less that, but there are many tests like this. How could I improve?