1 / 11

Stephen Delaney sdelaney@skokielibrary

Stephen Delaney sdelaney@skokielibrary.info. JavaScript Basics. Review: Working With Numbers Doing math in JavaScript The random challenge. Types of Numbers Integers 10, -8, 2787382 Floating point numbers 3.14, -10.6454 Scientific notation 5.7e+4 => 57000. Is this a number?

krhodes
Télécharger la présentation

Stephen Delaney sdelaney@skokielibrary

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Stephen Delaney sdelaney@skokielibrary.info • JavaScript Basics

  2. Review: Working With Numbers • Doing math in JavaScript • The random challenge

  3. Types of Numbers Integers • 10, -8, 2787382 Floating point numbers • 3.14, -10.6454 Scientific notation • 5.7e+4 => 57000

  4. Is this a number? var greatNumber = ‘10’ *Introducing typeOf()

  5. What are these for? • += • -= • *= • /= var score = 10 score += 7 17

  6. What’s the difference between? • parseInt() • parseInt(10.6) 10 • parseFloat() • parseFloat(10.6) 10.6

  7. What do these mean? • NaN • Not a Number • DRY • Don’t Repeat Yourself

  8. What do these do? Math.round() • Math.round(10.6)  11 Math.floor() • Math.floor(10.6)  10 Math.ceil() • Math.ceil(10.6)  11

  9. What does this do? Math.random() • Floating number, from 0 (inclusive) to 1 (exclusive)

  10. Challenge: Write the code to generate a random number between 1 and 10. Math.floor(Math.random() * 10) + 1

  11. Questions?

More Related