JavaScript Lingo: Math
JavaScript's Math object overview, as well as a brief heads-up on floating-point formula.
There is a static object named 'Math' in JS with many built in properties and methods.
You'll want to investigate this further whenever you're manipulating numbers. Check here before writing your own functions, because they may already be defined here.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
Examples include Math.random() which will return a random number in a given range and Math.round() which will round the input to the nearest integer. I used Math.random() when I built the random quote generator for the Free Code Camp zipline.
When you're working with numbers, you should also be aware that JS has an interesting attribute called "floating-point format". Depending on the amount of numbers, the size of those numbers, and the number of computations, JS may return something that is inaccurate by .00004. There are ways around this, and in general it doesn't pose issues, but it's something you should be aware of in the event you run into some problems that aren't making sense.
Other Videos By freeCodeCamp.org
2015-08-24 | Chrome Dev Tools: Console Tab |
2015-08-24 | Chrome Dev Tools: Audits Tab |
2015-08-24 | Chrome Dev Tools: Resources Tab |
2015-08-24 | Chrome Dev Tools: Memory Tab |
2015-08-24 | Chrome Dev Tools: Timeline Tab |
2015-08-24 | Chrome Dev Tools: Sources Tab |
2015-08-24 | Chrome Dev Tools: Network Tab |
2015-08-24 | Chrome Dev Tools: Elements Tab |
2015-08-23 | JavaScript Lingo: Regular Expressions |
2015-08-23 | JavaScript Lingo: Loops |
2015-08-23 | JavaScript Lingo: Math |
2015-08-23 | JavaScript Lingo: Manipulating Data |
2015-08-23 | JavaScript Lingo: Finding and Indexing Data in Arrays |
2015-08-23 | |
2015-08-23 | JavaScript Lingo: Variables & camelCase |
2015-08-23 | JavaScript Lingo: Value Types |
2015-08-23 | JavaScript Lingo: MDN and Documentation |
2015-07-17 | Computer Basics 17: How Routers and Packets work |
2015-07-17 | Computer Basics: Chips and how Moore's Law works |
2015-07-17 | Computer Basics 15: Analog vs Digital and how File Compression works |
2015-07-17 | Basejump: Build a Pinterest Clone |