0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>In order to write universal programs, we had to learn the following:</p>
1
<p>In order to write universal programs, we had to learn the following:</p>
2
<ol><li>get previously unknown data,</li>
2
<ol><li>get previously unknown data,</li>
3
<li>save this data to variables for further use,</li>
3
<li>save this data to variables for further use,</li>
4
<li>process data or perform<em>operations</em>on them.</li>
4
<li>process data or perform<em>operations</em>on them.</li>
5
</ol><p>We are now done with the first two items. Let’s proceed to operations now. Take a look at this command:</p>
5
</ol><p>We are now done with the first two items. Let’s proceed to operations now. Take a look at this command:</p>
6
50 + 100;<p>This is an operation. It consists of an operation sign, +, and two<em>operands</em>, 50 and 100.</p>
6
50 + 100;<p>This is an operation. It consists of an operation sign, +, and two<em>operands</em>, 50 and 100.</p>
7
<p>The sign defines what is going to happen to the operands. In the command above, we use a plus sign, which means that it’s an addition operation and the operands will be added up. The command will return the addition result, 150.</p>
7
<p>The sign defines what is going to happen to the operands. In the command above, we use a plus sign, which means that it’s an addition operation and the operands will be added up. The command will return the addition result, 150.</p>
8
<p>Addition is a <em>binary</em>operation since it only works with two operands. Binary operations are the most commonplace ones. However, there are unary operations with just one operand and ternary operations with three operands.</p>
8
<p>Addition is a <em>binary</em>operation since it only works with two operands. Binary operations are the most commonplace ones. However, there are unary operations with just one operand and ternary operations with three operands.</p>
9
<p>We can use variables as operands:</p>
9
<p>We can use variables as operands:</p>
10
breakfastCalories + dinnerCalories; milkInGrams * 0.5; 50 + waterInGrams;<p>Different operations can be performed on different types of operands, so it’s important to understand the types of data stored in variables. The console.log() command really helps here.</p>
10
breakfastCalories + dinnerCalories; milkInGrams * 0.5; 50 + waterInGrams;<p>Different operations can be performed on different types of operands, so it’s important to understand the types of data stored in variables. The console.log() command really helps here.</p>
11
<p>Let’s practice on numerical operations. Here are some of them:</p>
11
<p>Let’s practice on numerical operations. Here are some of them:</p>
12
Addition+Subtraction-Multiplication*Division/
12
Addition+Subtraction-Multiplication*Division/