-
Notifications
You must be signed in to change notification settings - Fork 0
/
operators.js
48 lines (47 loc) · 829 Bytes
/
operators.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
//arithmetic operators
console.log(2-1);
var diff = 3-1;
console.log("diff :" +diff);
var product =7*9;
console.log("product :" +product);
var div=5/2;
console.log("div :" +div);
var mod=5%2;
console.log("Modulus :" +mod);
//increment and decrement
var a=5;
a++;
console.log(a);
var b=4;
b--;
console.log(b);
//assignment operators
var s=9;
s+=8;
console.log(s);
//Comparison operator
var s=prompt("Enter a value");
if(s==8)
console.log("True");
else
console.log("False");
//Checking if same type or not using ===
var n=5;
var m="5";
if(n===m)
console.log("Same type");
else
console.log("Different type");
//logical
var y=4;
var x=7;
if(y<=x && x>6)
console.log("Yes its true");
else if(y!=x || y<x)
console.log("This one is true");
else
console.log("False");
//Ternary operators
var k=1;
var l=2;
console.log(k>l?true:false);