0
import './Product.css'

function Product({ title, image, price, rating }) {
  return (
      <div className="product">
          <div className="product__info">
              <p>{title}</p>
              <p className="product__price">
                  <small>$</small>
                  <strong>{price}</strong>
              </p>
              <div className="product__rating">
                  {Array(rating)
                      .fill()
                      .map((_, i) => (
                          <p></p>
                      ))}
              </div>
          </div>
          <img src={image} alt=' ' />
          <button>Add to Basket</button>
      </div>
  )
}

export default Product;

Well I was going through a Youtube Tutorial of a Project. I don't understand what does the statement {Array(rating).fill().map(_, i)=>(<p>*<p>))} does. I know what fill() does individually and what map() does individually. However I don't understand the _ parameter passed in the map function. And when I try to sum up all that is happening I am unable to grasp what is happening and how. If anybody will need any more code, let me know. Thank You.

Anagh Basak
  • 137
  • 8

0 Answers0