Simple Star Rating Using JS and Slice Method
![Simple Star Rating Using JS and Slice Method](https://nimapm.com/wp-content/uploads/2022/06/New-Project-6-1-1-1024x576.jpg)
Wow, just was exploring internet to learn new things about JavaScript and found a piece of code that really is wonderful. I thought it will be great if I share the snippet with you:
const rating = stars => '✮✮✮✮✮✩✩✩✩✩'.slice(5 - stars , 10 - stars);
With Slice method we can extract part of the string and this method returns the extracted part in a new string also does not change the original string.
Note that The first argument is started from 0, the second argument is started from 1 😐