title: changing number to star with data of php and with javascript
body: <p>In the design I am doing, some data (numbers: 3.2 - 4 - 4.7 - 2.7) is taken from the backend and given to me in the PHP loop <code>&lt;? Php the_field ('rating');?&gt;)</code>.</p>
  <p>These numbers (3.2 - 4 - 4.7 - 2.7) must be converted to stars.</p>
  <p>I used the following code I got from address <a href="https://codepen.io/tutsplus/pen/ayKZNL" rel="nofollow noreferrer">enter link description here</a>, but it still does not work properly.</p>
  <p>According to the image I posted, in the design done in <a href="https://codepen.io/tutsplus/pen/ayKZNL" rel="nofollow noreferrer">enter link description here</a>, ratings in the stars-inner class are converted to width, but in the code, I wrote this does not happen.
  <a href="https://i.stack.imgur.com/b7ZyF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b7ZyF.png" alt="enter image description here" /></a>.</p>
  <p>Do you think the code I sent is problematic in terms of syntax?</p>
  <p>Thank you in advance for your cooperation.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var ratings = [...document.querySelectorAll('.ratings')].map(o =&gt; o.innerText).join('\n');
  console.log(ratings);
  
  
  for(const rating in ratings) {  
    for (let i = 0; i &lt; ratings.length; i++) {
       const starPercentage = ratings[rating] / starTotal * 100;
       console.log(starPercentage);
  
       const starPercentageRounded = `${(Math.round(starPercentage / 10) * 10)}%`;
       console.log(starPercentageRounded);
  
       const goldStar = document.querySelector(`.${rating} .stars-inner`);
       console.log(goldStar);
  
       goldStar.style.width = starPercentageRounded; 
       console.log(starPercentageRounded)
    }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>table {
    margin: 0 auto;
    text-align: center;
    border-collapse: collapse;
    border: 1px solid #d4d4d4;
    font-size: 20px;
    background: #fff;
  }
  
  table th, 
  table tr:nth-child(2n+2) {
    background: #e7e7e7;
  }
   
  table th, 
  table td {
    padding: 20px 50px;
  }
   
  table th {
    border-bottom: 1px solid #d4d4d4;
  }     
  
  .stars-outer {
    display: inline-block;
    position: relative;
    font-family: FontAwesome;
  }
  
  .stars-outer::before {
    content: "\f006 \f006 \f006 \f006 \f006";
  }
  
  .stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
  }
  
  .stars-inner::before {
    content: "\f005 \f005 \f005 \f005 \f005";
    color: #f8ce0b;
  }
  
  .attribution {
    font-size: 12px;
    color: #444;
    text-decoration: none;
    text-align: center;
    position: fixed;
    right: 10px;
    bottom: 10px;
    z-index: -1;
  }
  .attribution:hover {
    color: #1fa67a;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /&gt;
  &lt;table&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
      //wordpress code
        &lt;td&gt;&lt;p class="ratings"&gt;&lt;?php the_field('rating'); ?&gt;&lt;/p&gt;&lt;/td&gt;
        &lt;td&gt;
          &lt;div class="stars-outer"&gt;
            &lt;div class="stars-inner"&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;a class="attribution" href="http://fontawesome.io/"&gt;&lt;i class="fa fa-font-awesome"&gt;&lt;/i&gt; fontawesome.io&lt;/a&gt;
  
  
  //html code in inspector
  &lt;div&gt; 3.2 &lt;/div&gt;
  
  &lt;div&gt; 4 &lt;/div&gt;
  
  &lt;div&gt; 4.7 &lt;/div&gt;
  
  &lt;div&gt; 2.7 &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>