Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RatingStar(fiveStar, fourStar, threeStar, twoStar, oneStar) {
- this.fiveStar = fiveStar;
- this.fourStar = fourStar;
- this.threeStar = threeStar;
- this.twoStar = twoStar;
- this.oneStar = oneStar;
- this.rating = 0;
- }
- RatingStar.prototype.percentage = function(sumFiveStar, sumFourStar, sumThreeStar, sumTwoStar, sumOneStar) {
- let persensFiveStar = 0
- let persenFourStar = 0
- let persenThreeStar = 0
- let persenTwoStar = 0
- let persenOneStar = 0
- let fiveStarLength = sumFiveStar.toString().length
- let fourStarLength = sumFourStar.toString().length
- let threeStarLength = sumThreeStar.toString().length
- let twoStarLength = sumTwoStar.toString().length
- let oneStarLength = sumOneStar.toString().length
- if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 2 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 5) {
- persensFiveStar = `${Math.floor((sumFiveStar / 100))}%`
- persenFourStar = `${Math.floor((sumFourStar / 100))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 100))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 100))}%`
- persenOneStar = `${Math.floor((sumOneStar / 100))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 5 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 6) {
- persensFiveStar = `${Math.floor((sumFiveStar / 1000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 1000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 1000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 1000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 1000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 6 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 7) {
- persensFiveStar = `${Math.floor((sumFiveStar / 10000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 10000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 10000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 10000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 10000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 7 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 8) {
- persensFiveStar = `${Math.floor((sumFiveStar / 100000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 100000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 100000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 100000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 100000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 8 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 9) {
- persensFiveStar = `${Math.floor((sumFiveStar / 1000000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 1000000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 1000000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 1000000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 1000000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 9 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 10) {
- persensFiveStar = `${Math.floor((sumFiveStar / 10000000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 10000000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 10000000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 10000000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 10000000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 10 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 11) {
- persensFiveStar = `${Math.floor((sumFiveStar / 100000000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 100000000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 100000000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 100000000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 100000000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 11 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 12) {
- persensFiveStar = `${Math.floor((sumFiveStar / 1000000000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 1000000000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 1000000000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 1000000000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 1000000000))}%`
- } else if(
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) >= 12 ||
- (fiveStarLength || fourStarLength || threeStarLength | twoStarLength || sumTwoStar || oneStarLength) < 13) {
- persensFiveStar = `${Math.floor((sumFiveStar / 10000000000))}%`
- persenFourStar = `${Math.floor((sumFourStar / 10000000000))}%`
- persenThreeStar = `${Math.floor((sumThreeStar / 10000000000))}%`
- persenTwoStar = `${Math.floor((sumTwoStar / 10000000000))}%`
- persenOneStar = `${Math.floor((sumOneStar / 10000000000))}%`
- } else {
- persensFiveStar = '100%'
- persenFourStar = '100%'
- persenThreeStar = '100%'
- persenTwoStar = '100%'
- persenOneStar = '100%'
- }
- return { persensFiveStar, persenFourStar, persenThreeStar, persenThreeStar, persenTwoStar, persenOneStar}
- }
- RatingStar.prototype.setRating = function() {
- // calculate rating
- const sumFiveStar = this.fiveStar.reduce((a, c) => a + c, 0)
- const sumFourStar = this.fourStar.reduce((a, c) => a + c, 0)
- const sumThreeStar = this.threeStar.reduce((a, c) => a + c, 0)
- const sumTwoStar = this.twoStar.reduce((a, c) => a + c, 0)
- const sumOneStar = this.oneStar.reduce((a, c) => a + c, 0)
- // get count people give rating star
- const countFiveStart = this.fiveStar.length + 1
- const countFourStart = this.fourStar.length + 1
- const countThreeStart = this.threeStar.length + 1
- const countTwoStart = this.twoStar.length + 1
- const countOneStart = this.oneStar.length + 1
- // mutiply rating with diference rating star
- const multiplyFiveStar = Math.floor(sumFiveStar) * 5
- const multiplyFourStar = Math.floor(sumFourStar) * 4
- const multiplyThreeStar = Math.floor(sumThreeStar) * 3
- const multiplyTwoStar = Math.floor(sumTwoStar) * 2
- const multiplyOneStar = Math.floor(sumOneStar) * 1
- // sum rating
- const ratingStarBeforeSum = Math.floor(sumFiveStar + sumFourStar + sumThreeStar + sumTwoStar + sumOneStar)
- const ratingStarAfterSum = (multiplyFiveStar + multiplyFourStar + multiplyThreeStar + multiplyTwoStar + multiplyOneStar)
- const totalPeopleGiveRating = (countFiveStart + countFourStart + countThreeStart + countTwoStart + countOneStart)
- // percentage rating by length count
- const persen = this.percentage(sumFiveStar, sumFourStar, sumThreeStar, sumTwoStar, sumOneStar)
- const totalRating = +parseFloat((ratingStarAfterSum / ratingStarBeforeSum)).toFixed(1)
- return {
- fiveStar: {
- persen: persen.persensFiveStar,
- peopleGiveRating: countFiveStart
- },
- fourStar: {
- persen: persen.persenFourStar,
- peopleGiveRating: countFourStart
- },
- threeStar : {
- persen: persen.persenThreeStar,
- peopleGiveRating: countThreeStart
- },
- twoStar: {
- persen: persen.persenTwoStar,
- peopleGiveRating: countTwoStart
- },
- oneStar: {
- persen: persen.persenOneStar,
- peopleGiveRating: countOneStart
- },
- totalPeopleGiveRating,
- totalRating
- }
- }
- RatingStar.prototype.getRating = function() {
- const data = this.setRating()
- if(data.totalRating > 0 && data.totalRating == 1 && data.totalRating < 2) {
- this.rating = 1
- } else if(data.totalRating > 1 && data.totalRating == 2 && data.totalRating < 3) {
- this.rating = 2
- } else if(data.totalRating > 2 && data.totalRating == 3 && data.totalRating < 4) {
- this.rating = 3
- } else if(data.totalRating > 3 && data.totalRating == 4 && data.totalRating < 5) {
- this.rating = 4
- } else if(data.totalRating > 4 && data.totalRating == 5 && data.totalRating >= 5) {
- this.rating = 5
- } else if(data.totalRating > 0 && data.totalRating < 1) {
- this.rating = 1.5
- } else if(data.totalRating > 1 && data.totalRating < 2) {
- this.rating = 2.5
- } else if(data.totalRating > 2 && data.totalRating < 3) {
- this.rating = 3.5
- } else if(data.totalRating > 3 && data.totalRating < 4) {
- this.rating = 4.5
- } else if(data.totalRating > 4 && data.totalRating < 5) {
- this.rating = 5.5
- } else {
- rating = 'tidak ada rating'
- }
- return Object.assign(data, {ratingStar: this.rating})
- }
- // example dummy data
- const fiveStar = [5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 5, 5, 5, 5, 5, 5, 5, 5 , 5, 5,
- 5, 5, 5, 5, 5, 5 , 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1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5,
- 1.5, 1.5 ,1, 1.5, 1.5, 1, 1, 1, 1, 1.5]
- const data = new RatingStar(fiveStar, fourStar, threeStar, twoStar, oneStar)
- console.log(data.getRating())
- // output
- // {
- // fiveStar: { persen: '24%', peopleGiveRating: 481 },
- // fourStar: { persen: '16%', peopleGiveRating: 391 },
- // threeStar: { persen: '7%', peopleGiveRating: 253 },
- // twoStar: { persen: '3%', peopleGiveRating: 172 },
- // oneStar: { persen: '4%', peopleGiveRating: 381 },
- // totalPeopleGiveRating: 1678,
- // totalRating: 3.9,
- // ratingStar: 4.5
- // }
Add Comment
Please, Sign In to add comment