Error help


hi I am receiving the error home/ccuser/workspace/learn-javascript-classes-build-a-library/app.js:30
let ratingsSum = this.ratings.reduce((currentSum,rating) => currentSum + rating, 0);
^

TypeError: this.ratings.reduce is not a function
at Book.getAverageRating (/home/ccuser/workspace/learn-javascript-classes-build-a-library/app.js:30:31)
at Object. (/home/ccuser/workspace/learn-javascript-classes-build-a-library/app.js:64:33)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

here:

this._ratings = average;

(from getAverageRating method), you set ratings to a integer. so when you call the method twice, the second time, this. ratings will be an integer, integers do not have a reduce method, that is only for array

cool so removing the line of code cleared the error

But do you also understand why?