Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Programming (in JavaScript)

Similar presentations


Presentation on theme: "Intro to Programming (in JavaScript)"— Presentation transcript:

1 Intro to Programming (in JavaScript)

2 What is programming, anyway?

3 Programming gives computers a series of instructions…
And it all renders down to binary (0s and 1s)!

4 Programming Languages
There are SO MANY programming languages… today we’re learning JavaScript, an easy language to get started with.

5 JavaScript Doesn’t really have anything to do with Java
Executed by web browsers (usually) GREAT language to learn Very in-demand due to growing popularity of JavaScript frameworks for front-end (user interface) and back-end (server) development

6 Let’s get started… You don’t need a code editor to write JavaScript. You can use anything, even just Notepad. We are going to create an HTML file, like we did Monday, and write the JavaScript there.

7 Instructions: Getting Started
Open Notepad Type the HTML code on the right side of this slide. Save the file as learnjs.html Change save as type to All Files Then double-click the saved file to open it in a web browser

8 Basic Processing Change your previous code to the following…
Save the file and refresh the page in your browser Let’s break it down…

9 Variables Store information to be accessed and/or processed later

10 Variables Can be used virtually anywhere in your code

11 Variable Types JavaScript variables are loosely assigned, so you don’t need to declare a variable type When you work with some other languages, this will not be the case! Common variable types: String: “this is text!” Integer: 4 Double: 4.2 Boolean: false

12 Working with Different Variable Types

13 Working with Concatenation

14 Conditional Statements
Now let’s ask the computer to make some decisions!

15 Conditional Statements
Change the number in the conditional statement

16 If… else

17 If… else if… else

18 Comparison Operators > greater than >= greater than or equal to < less than <= less than or equal to == equals !== does not equal

19 You try it! Create a variable x with a value of 11 Create a variable y with a value of 15 Write a conditional statement to check if x is greater than y. If so, output the result of x + y But, if x is less than y, output the result of y - x What is the result?

20 Loops Sometimes, we need to perform an action repeatedly while a condition is satisfied – for this, we have loops! How would you add a space between each number displayed?

21 Functions Sometimes, we want to define instructions that can be repeated multiple times…

22 Functions Or, triggered from HTML!

23 HTML Forms

24 Processing HTML Forms

25 Objects/Classes Very important programming concept
Objects are used to organize code, prevent coding errors, and define a set of functions and variables relevant only to their intended scope

26 Object Parameters Sometimes, we want to create an object with established parameters from the beginning These are created in the constructor

27 Bringing It Together…

28


Download ppt "Intro to Programming (in JavaScript)"

Similar presentations


Ads by Google