yeah exactly. Not from this function.
In summary: ‘return’ passes a value from your function to the calling code, which you can use.
required in Getters
not used in Setters
your call in any other function (in accordance to your program’s needs)
In this case, if you had wanted to know the new length of the rating array, and you needed to store that in a variable, like:
let newSize = speed.addRating(3);
would print the increased size of the array to the console; it would do that because you had done:
in your addRating() function.
It didn’t break anything that you didn’t use the returned value. It just wasn’t needed.
My advice: If you don’t need to return a value, then don’t write ‘return’ - and for your own sanity it might be best not to use it! (like when you come back to your code and wonder to yourself why is it returning a value, and where are you using that in your code? is it needed? will i break something if i remove it?). Use as needed.
Hope it helps.