I have passed all of the required items, and am working at the end of the challenge (task 25) where it suggests several new things to practice. On the third bullet point, it says “In .addRating(), make sure input is between 1 and 5.” I have watched the tutorial video and in it he suggests using Math.min() and Math.max() to limit the input range on addRating(), and after doing some research I am still not sure how to actually limit the input range from 1 to 5.
So far I have the method as:
addRating(value) {
this.ratings.push(value);
}
but I am not sure what to put below to limit the range. Is anyone able to help me with this? Thank you in advance.
I’m scratching my head as to how or why we would use array methods to test if a value is in range. The methods find the smallest and largest values in an array, which has nothing to do with range except to describe the numerical distance between smallest and largest.
Yes, although there is a lot more code in here so there could have been something else wrong that I’m not noticing. Here’s the error:
Output:
/home/ccuser/workspace/learn-javascript-classes-build-a-library/app.js:43
class Book extends Media {
^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
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)
also, I did have the closing brace but forgot to paste it there
It was the extra } I was missing! I was accounting for the closing } for the method, but not the Media class. Thank you for your help, it worked this time!