I’m following an online Javascript course for beginners. One exercise is about Math.floor(), and the example given is:
get floorNum(x){
let _x = x;
_x = Math.floor(x);
return _x;
}
My question is: why not just put “return Math.floor(x)” in the function body? Why let _x = x, and then return _x? Why not just return x directly? What’s the underlying logic?
I want to learn some basic programming logic.
I tried google, but didn’t find what I want. I’m an absolute beginner.