Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript Basics Stephen Delaney sdelaney@skokielibrary.info.

Similar presentations


Presentation on theme: "JavaScript Basics Stephen Delaney sdelaney@skokielibrary.info."— Presentation transcript:

1 JavaScript Basics Stephen Delaney

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

3 Types of Numbers Integers 10, -8, Floating point numbers 3.14, 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.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?


Download ppt "JavaScript Basics Stephen Delaney sdelaney@skokielibrary.info."

Similar presentations


Ads by Google