Simple Star Rating Using JS and Slice Method
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 😐