0

I have some JavaScript that uses isIntegar, I understand I need to add polyfill but am confused on how to do this with my code.

IE dose not currently like my code

My code

 if (!Number.isInteger(averageRatingResult)) {
            for (var j = 0; j < averageRatingResult; j++) {
                if (averageRatingResult - j < 1) {
                    averageRating += '<i class="fa fa-star-half rating-stars" aria-hidden="true"></i>';
                }
                else {
                    averageRating += '<i class="fa fa-star rating-stars" aria-hidden="true"></i>';
                }
            }
        }
        else {
            for (var j = 0; j < averageRatingResult; j++) {
                averageRating += '<i class="fa fa-star rating-stars" aria-hidden="true"></i></span>';
            }
        }

Error I am getting

SCRIPT438: Object doesn't support property or method 'isInteger' ratingswigetcontent.js (21,9)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Benjamin Oats
  • 573
  • 1
  • 8
  • 25

1 Answers1

0

Maybe something simpler like this will do

if (averageRatingResult === parseInt(averageRatingResult, 10))

Depends more on what your potential value it can be

Endless
  • 34,080
  • 13
  • 108
  • 131