GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add article about conditional comparators · ptagell/javascript@b35db41

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • conditional
    • comparators.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎conditional/comparators.md‎

Copy file name to clipboard
+46Lines changed: 46 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Comparators
2+
3+
Lets now focus on the conditional part:
4+
5+
```javascript
6+
if (country === "France") {
7+
...
8+
}
9+
```
10+
11+
The conditional part is the country followed by the three equal signs (`===`). Three equal signs mean that the condition tests if the variable country has the value you test against but also the correct variable (data)type. You can test conditions with double equal signs, too, but that would mean that `if(x == 5)` would be true for x being 5 and x being “5”. Depending on what your program is doing, this could make quite a difference.
12+
13+
Other conditional test:
14+
15+
* ```x > a```: is x bigger than a?
16+
* ```x < a```: is x less than a?
17+
* ```x <= a```: is x less than or equal to a?
18+
* ```x != a```: is x not a?
19+
* ```x```: does x exist?
20+
21+
22+
---
23+
24+
Add a condition to change the value of `a` to 10 if `x` is bigger than 5.
25+
26+
```js
27+
var x = 6;
28+
var a = 0;
29+
30+
31+
```
32+
33+
```js
34+
var x = 6;
35+
var a = 0;
36+
37+
if (x > 5) {
38+
a = 10;
39+
}
40+
```
41+
42+
```js
43+
assert(a == 10);
44+
```
45+
46+
---

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.