function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
krishna casukhelakrishna casukhela 

Star Rating in lightning aura component

I have a API response as follows.
 
    "practitionerReviewSummary": {
      "avg_overall_rating": 4.15,
      "total_reviews": 4
    }
Inside lightning component I  will show 5 stars (something similar to amazon when we buy a product, we have ratings show in stars)

If its 4 stars then 4 stars will be bold.
But if rating = 4.15 then pls let me know how to do this through code.

Thanks
Krishna
 
AbhishekAbhishek (Salesforce Developers) 
I would suggest the following approach:


Do Math.round on your rating => If rating >= 4.5 then it'll display 5 and it is 4 <= 4 <4.5 it'll display 4


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.