Skip to content

Commit 3b2a242

Browse files
committed
converted 'operators' code to the new convention
1 parent f32a974 commit 3b2a242

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

page/javascript-101/operators.md

+26-18
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ attribution: jQuery Fundamentals
44
---
55
Basic operators allow you to manipulate values.
66

7-
<javascript caption="Concatenation">
7+
``` js
8+
// Concatenation
89
var foo = 'hello';
910
var bar = 'world';
1011
console.log(foo + ' ' + bar); // 'hello world'
11-
</javascript>
12+
```
1213

13-
<javascript caption="Multiplication and division">
14+
``` js
15+
// Multiplication and division
1416
2 * 3;
1517
2 / 3;
16-
</javascript>
18+
```
1719

18-
<javascript caption="Incrementing and decrementing">
19-
The pre-increment operator increments the operand before any further processing.
20+
``` js
21+
// Incrementing and decrementing
22+
// The pre-increment operator increments the operand before any further processing.
2023
// pre-increment
2124
var i = 1;
2225
console.log(++i); // => 2
@@ -27,41 +30,45 @@ The post-increment operator increments the operand after processing it.
2730
var i = 1;
2831
console.log(i++); // => 1. This is because i was processed first
2932
console.log(i); // => 2. This is because the operand was incremented after processing in the previous step.
30-
</javascript>
33+
```
3134

3235
## Operations on Numbers & Strings
3336

3437
In JavaScript, numbers and strings will occasionally behave in ways you might
3538
not expect.
3639

37-
<javascript caption="Addition vs. Concatenation">
40+
``` js
41+
// Addition vs. Concatenation
3842
var foo = 1;
3943
var bar = '2';
4044
console.log(foo + bar); // 12. uh oh
41-
</javascript>
45+
```
4246

43-
<javascript caption="Forcing a string to act as a number">
47+
``` js
48+
// Forcing a string to act as a number
4449
var foo = 1;
4550
var bar = '2';
4651

4752
// coerce the string to a number
4853
console.log(foo + Number(bar));
49-
</javascript>
54+
```
5055

5156
The Number constructor, when called as a function (like above) will have the
5257
effect of casting its argument into a number. You could also use the unary plus
5358
operator, which does the same thing:
5459

55-
<javascript caption="Forcing a string to act as a number (using the unary-plus operator)">
60+
``` js
61+
// Forcing a string to act as a number (using the unary-plus operator)
5662
console.log(foo + +bar);
57-
</javascript>
63+
```
5864

5965
## Logical Operators
6066

6167
Logical operators allow you to evaluate a series of operands using AND and OR
6268
operations.
6369

64-
<javascript caption="Logical AND and OR operators">
70+
``` js
71+
// Logical AND and OR operators
6572
var foo = 1;
6673
var bar = 0;
6774
var baz = 2;
@@ -72,7 +79,7 @@ bar || foo; // returns 1, which is true
7279
foo && bar; // returns 0, which is false
7380
foo && baz; // returns 2, which is true
7481
baz && foo; // returns 1, which is true
75-
</javascript>
82+
```
7683

7784
Though it may not be clear from the example, the `||` operator returns the value
7885
of the first truthy operand, or, in cases where neither operand is truthy,
@@ -83,7 +90,7 @@ truthy.
8390
Be sure to see the section called “Truthy and Falsy Things” for more
8491
details on which values evaluate to true and which evaluate to false.
8592

86-
<div class="note" markdown="1">
93+
<div class="note">
8794
You'll sometimes see developers use these logical operators for flow control
8895
instead of using if statements. For example:
8996

@@ -106,7 +113,8 @@ comfortable with what it means and how you can expect it to behave.
106113
Comparison operators allow you to test whether values are equivalent or whether
107114
values are identical.
108115

109-
<javascript caption="Comparison operators">
116+
``` js
117+
// Comparison operators
110118
var foo = 1;
111119
var bar = 0;
112120
var baz = '1';
@@ -123,4 +131,4 @@ foo === parseInt(baz); // returns true
123131
foo > bim; // returns false
124132
bim > baz; // returns true
125133
foo <= baz; // returns true
126-
</javascript>
134+
```

0 commit comments

Comments
 (0)