I am new to development and am trying to do something fairly simple. I have a list of travel related transactions in a JSON file and I created a basic grouping of these transactions based on their cost (i.e. if the transactions total less than $300, the travel_rank becomes 'Below Average'). I also want to apply some font conditions as well though. For example, if the travel_rank is 'Below Average', I'd like to color this green (less spending is better). How might I go about doing that? Here is the code I am currently using to identify the rank.
let travel_rank = []
if (total_travel_transactions < 300)
{
travel_rank = 'Below Average'
}
else if (total_travel_transactions > 600)
{
travel_rank = 'Above Average'
}
else
travel_rank = 'Average'
An additional question I have is what if I want to create this rank 10x over for other categories such as entertainment, groceries, dining out, etc. It doesn't seem like the best method is to just copy and paste this code 10x over although perhaps if they all have different input parameters that might make the most sense? Or maybe there's something I can do with list of parameters that I can read in once?
Aucun commentaire:
Enregistrer un commentaire