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 base for if condition · guptag-dev/javascript@6aedea1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • SUMMARY.md
  • comments
    • README.md
  • conditional
    • README.md
    • if.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎SUMMARY.md‎

Copy file name to clipboardExpand all lines: SUMMARY.md
+5-1Lines changed: 5 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
* [Strings](strings/README.md)
1212
* [Creation](strings/create.md)
1313
* [Concatenation](strings/concat.md)
14-
* [Length](strings/length.md)
14+
* [Length](strings/length.md)
15+
* [Conditional Logic](conditional/README.md)
16+
* [If](conditional/if.md)
17+
* [Else](conditional/else.md)
18+
* [Comparators](conditional/comparators.md)
Collapse file

‎comments/README.md‎

Copy file name to clipboardExpand all lines: comments/README.md
Whitespace-only changes.
Collapse file

‎conditional/README.md‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Conditional Logic
2+
3+
A condition is a test for something. Conditions are very important for programming, in several ways:
4+
5+
First of all conditions can be used to ensure that your program works, regardless of what data you throw at it for processing. If you blindly trust data, you’ll get into trouble and your programs will fail. If you test that the thing you want to do is possible and has all the required information in the right format, that won’t happen, and your program will be a lot more stable. Taking such precautions is also known as programming defensively.
6+
7+
The other thing conditions can do for you is allow for branching. You might have encountered branching diagrams before, for example when filling out a form. Basically, this refers to executing different “branches” (parts) of code, depending on if the condition is met or not.
8+
9+
In this chapter, we'll learn the base of conditional logic in Javascript.
Collapse file

‎conditional/if.md‎

Copy file name to clipboard
+58Lines changed: 58 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Condition If
2+
3+
The easiest condition is an if statement and its syntax is `if(condition){ do this … }`. The condition has to be true for the code inside the curly braces to be executed. You can for example test a string and set the value of another string dependent on its value:
4+
5+
```javascript
6+
var country = 'France';
7+
var weather;
8+
var food;
9+
var currency;
10+
11+
if(country === 'England'){
12+
weather = 'horrible';
13+
food = 'filling';
14+
currency = 'pound sterling';
15+
}
16+
17+
if(country === 'France'){
18+
weather = 'nice';
19+
food = 'stunning, but hardly ever vegetarian';
20+
currency = 'funny, small and colourful';
21+
}
22+
23+
if(country === 'Germany'){
24+
weather = 'average';
25+
food = 'wurst thing ever';
26+
currency = 'funny, small and colourful';
27+
}
28+
29+
var message = 'this is ' + country + ', the weather is ' +
30+
weather + ', the food is ' + food + ' and the ' +
31+
'currency is ' + currency;
32+
```
33+
34+
---
35+
36+
Fill up the value of `name` to validate the condition.
37+
38+
```js
39+
var name =
40+
41+
if (name == "John") {
42+
43+
}
44+
```
45+
46+
```js
47+
var name = "John";
48+
49+
if (name == "John") {
50+
51+
}
52+
```
53+
54+
```js
55+
assert(name == "John");
56+
```
57+
58+
---

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.