Hi all,
I’m struggling for a long time to find the code with the use of Math.min() and Math.max() on this step. For now, I managed to get the result using an if statement, but I would really love to understand how to do using this instead. I’ve been searching the internet for a long time now, but I can’t seem to find a definite solution. Could someone help me with it? I’m supposed to use it using spread syntax and I found this formula but I can’t seem to make it work:
function getMaxOfArray(numArray) {
return Math.max.apply(null, numArray);
}
This is how I made step 25 work for now using an If statement (In .addRating()
, make sure input is between 1
and 5
):
addRating(value){
if(value < 1 || value > 5) {
console.log('Error! Please rate between 1 and 5')
} else {
this.ratings.push(value);
}
}