Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 890 online users. » 0 Member(s) | 887 Guest(s) Yandex, Bing, Applebot
|
Latest Threads |
SELECT statement with MS ...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:35 PM
» Replies: 0
» Views: 1,505
|
SELECT statement with the...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:31 PM
» Replies: 0
» Views: 874
|
Creating hyperlinks in HT...
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 01:23 PM
» Replies: 0
» Views: 1,252
|
What's new in HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:48 PM
» Replies: 0
» Views: 942
|
What is HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:43 PM
» Replies: 0
» Views: 846
|
Neck isometric exercises
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:44 AM
» Replies: 0
» Views: 1,197
|
Shoulder shrug
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 768
|
Neck retraction
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 754
|
Neck flexion and extensio...
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 857
|
Neck rotation
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 818
|
|
|
Exercise 0003 - Variables |
Posted by: Qomplainerz - 04-10-2022, 09:42 AM - Forum: JavaScript Tutorials
- No Replies
|
 |
Variables are some kind of drawers with captions.
The captions are a hint for what kind of stuff can be found inside the drawers.
In the case of variables it can be for example numbers or text.
The older way to declare variables in JavaScript is using the var keyword.
The newer way to declare variables in JavaScript is using the let keyword.
We will use the newer way here.
Code: let txt = "Hello, World!"
In the first example we will declare a variable, assign a value to it and show the output in a HTML document:
Code: <!DOCTYPE HTML>
<html>
<head>
<title>Variables</title>
</head>
<body>
<script>
let x = 100;
document.write(x);
</script>
</body>
</html>
In the second example we will change the value of the variable and show the output before and after the change in a HTML document:
Code: <!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script>
var x = 100;
document.write(x);
</script>
<br>
<script>
x = 42;
document.write(x);
</script>
</body>
</html>
I've put it in two script tags and added a <br> tag between them, because there might be unexpected results otherwise.
|
|
|
|