-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_arithmetic_operators.js
More file actions
54 lines (42 loc) · 1.13 KB
/
Copy path03_arithmetic_operators.js
File metadata and controls
54 lines (42 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Project: cc_javascript_intro
* File: 03_arithmetic_operators.js
* Author: nico
* Created: 2016-02-20
*
* Description:
* JavaScript file to illustrate the minimal basics of the JavaScript scripting language.
* This file illustrates different arithmetic operations in JavaScript.
*/
function js03_arithmeticOperations() {
// initialization
var x = 42;
var y = 23;
// declaration
var sum;
var difference;
var product;
var quotient;
var remainder;
// arithmetic operators
//
// addition
sum = x + y;
printTextAndValue("Sum: ", sum);
// subtraction
difference = x - y;
printTextAndValue("Difference: ", difference);
// multiplication
product = x * y;
printTextAndValue("Product: ", product);
// division
quotient = x / y;
printTextAndValue("Quotient: ", quotient);
// modulo
remainder = x % y;
printTextAndValue("Remainder: ", remainder);
}
// A function to print some text and a value, as handed over in the function's parameters.
function printTextAndValue(text, value) {
console.log(text + " " + value);
}