question 1. Inside of a console.log(), create a random number with Math.random(), then multiply it by 100.
answer 1. console.log(Math.floor(Math.random()) * 100); is wrong but showed as correct
answer 2. console.log(Math.random() * 100); is correct and showed as correct
Both show as correct. This was confusing for me.
What Math.floor() essentially does is drops everything after the decimal point. It takes a float, and returns an integer. In my examples, the code following the > is input, and the line below is the output.
If you pass Math.floor() an integer, it will return that same integer.
String is also a built-in object. You can find its methods (including .trim()) here. Look at the far left column. Click the link called String.prototype.trim().
Maths is a language, and like any language that is foreign to us, including programming languages will have a steep learning curve to begin with. Chances are that if it is easy then we are not being challenged, and likely won’t learn much. It should be hard. It is not insurmountable, though, and we don’t need to be rocket scientists or quantum mechanics mathematicians.
We get a tremendous leg up when we explore maths and sciences, especially physics independent of programming. It just depends how deeply we wish to get immersed in the study of data, information, or other scientific pursuits.
Even game development involves maths of varying degrees. The key is to know what sort of project we can take on given our level of understanding of maths. Most of us have by the age of 13 a basic level of maths, namely arithmetic. It is usually around that age we begin to study algebra and the more analytical side of geometry. Bear down and do the work. The learning will come. Set aside your fear (which is usually based on a false assumption) and pour yourself into it.
I have a question that is causing slight confusion within me:
The objects that we are taught are built into JS - such as console and Math, they aren’t following the same rules both being an object as far as I can tell. This may seem insignificant or the reason may be going over my head, but -
Why is the object ‘console’ executed with a lower case letter while the ‘Math’ object has an upper case letter? is there a specific rule to this that we should look out for?