-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath-shorthand.js
65 lines (39 loc) · 1.19 KB
/
math-shorthand.js
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
55
56
57
58
59
60
61
62
// Recap
var price1 = 31;
var price2 = 10;
var sum = price1 + price2;
var difference = price1 - price2;
var differenceReverse = price2 - price1;
var multiplication = price1 * price2;
var division = price1 / price2;
// console.log(sum);
// console.log(difference);
// console.log(differenceReverse);
// console.log(multiplication);
// console.log(division);
// Now new file starting
var doublePrice = price2 * 20;
// var newPrice = price1 + 10;
// var price1 = price1 + 20;
//if we declare a variable before, then again we don't need to declare "var", we just need to declare the name of the variable for multiple time uses
// price1 = price1 + 24
/*
we can alternatively add value to the past variable such as: price1 = price1 + 24; and price1 += 24; are the same thing means.
*/
price1 += 44; // shorthand
// price2 = price2 - 2;
price2 -= 2; // shorthand
// console.log(newPrice);
// console.log(price1);
// console.log(price2);
var age = 21;
// age = age + 1;
// age += 1; //shorthand
// If you want to increase the value of a variable by 1 and gradually..then set the following style
age++;
// console.log(age);
var love = 100;
// love = love - 1;
// love -= 1;
love--;
console.log(love);