Download presentation
Presentation is loading. Please wait.
1
We are starting to program with JavaScript
We are starting to program with JavaScript. Here are a series of examples. Once you have opened them, you can see the HTML code by viewing the course.
2
This is the first example
This is the first example. It writes on the document or screen and it brings up an alert.
3
The alert, pops up a screen with what is inside the parenthesis
The alert, pops up a screen with what is inside the parenthesis. Again it is a literal and that is what appeared in the alert box.
4
This is the second example, it has a prompt that asks the user for input.
5
I define the memory variables I am using in the program.
message appears above the box where the user enters information. Then I write on the document the contents of the parenthesis which is ans. I write the contents of the memory variable ans.
6
First I write the literal "The answer is" and then I write what is stored in the memory variable ans.
7
in concatenated. When I made sure I had numbers, it added.
Note that JavaScript is case sensitive so it has to be written as parseFloat with a capital F and parseInt with a capital I.
8
This is parseInt. When I want to skip down to the next line, I can document write the html <br>. I put it inside quotes and it then uses the <br> and writes the line.
11
A single = means assign. In the calculation I multiply or divide firstnum and secondnum and assign the answer to ans.
12
Note this means that an end if is not needed because I tell it everything I want to do if I execute the if and everything I want to do if I execute the else.
15
it is a /.
17
the second if and wrote out the 0 for ans.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.