forked from israaothman/JsDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
115 lines (71 loc) · 1.75 KB
/
app.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// data types
// int => Numbers => 1 5 9 120595
// string => "test" 'test' `test` "10"
// double => 2.5 3.66
// boolean => true false
// variables
var username = "Esra";
username = "Esraa";
var age = 28;
var password; // decleration
password = "as656asxcd" // inistialization
// ES6 EcmaScript6
let username2 = "Ahmad";
username2= "Mohammad";
const pi = 3.14 ;
/* const pi;
pi = 3.14;
Uncaught SyntaxError: Missing initializer in const declaration */
// outputs :
console.log("this is the username : " , username);
let x = 5;
let y = 10;
console.log(x+y);
document.write("<p> Ahmad </p>");
document.write("<p> " + username2 + "</p>"); //concatenation
// ES6
document.write(`<p> name: ${username2} <br> age : ${age} </p> `);
// popup boxes
// alert
// alert("Welcome to our class");
// prompt
// let name = prompt("Enter your name :)");
// alert(`Welcome ${name}`);
// confirm
// HomeWork
// functions
// block of code I can use more than one time
// function decleration
function funName () {
// code
}
// function execution
funName();
function greating(){
let username = prompt("Whta's your name ? ");
alert(`Welcome ${username}`);
}
// greating();
// greating();
// console.log(greating());
// let num1 = prompt("Enter the first number ");
// let num2 = prompt("Enter the second number ");
// console.log( "type of num1 before",typeof num1);
// num1 = parseInt(num1);
// console.log( "type of num1 after",typeof num1);
function summation(a,b){
a = parseInt(a);
b = parseInt(b);
let result = a + b ;
return result;
}
// console.log(summation(num1,num2));
summation(1,"6");
// ES6
// arrow function
// =>
const sub = (a,b) => {
return a-b;
}
console.log(sub(5,1));
console.log(sub(50,11));