Skip to content

Commit 1bec0b1

Browse files
author
reenakesavan
committed
new file
0 parents  commit 1bec0b1

22 files changed

Lines changed: 1416 additions & 0 deletions

‎Functions.js‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
// func declaration
3+
function demo1(name1)// paramter passed normally
4+
5+
{
6+
console.log("this is",name1);
7+
8+
}
9+
10+
demo1("leela")// argument to parameter name1
11+
12+
// function declaration can be hosited and it is dynamic
13+
detail("hello",12,"ckc") // hoisting
14+
function detail(name2,age,native) // paramter passing
15+
16+
{
17+
console.log("this is",name2);
18+
console.log("this is",age); //
19+
console.log("this is",native);
20+
}
21+
detail("reeena",6,"che") // variable passing/input
22+
detail("shalu",10,"villivaklkam")
23+
24+
// func expression means storing function in one varibale
25+
let electronic=function (cost,type) // passing and storing parameter in variable electronic
26+
{
27+
console.log("My Cost is",cost ,"and My Type",type);
28+
29+
}
30+
electronic(300,"Fan")
31+
32+
// arrow function
33+
34+
let movie=(name,ticket,snacks)=>
35+
{
36+
console.log("movie is name is ", name ,"and total cost is",(ticket+snacks));
37+
38+
}
39+
movie("leo",100,100)
40+
41+
//IIFE
42+
//create and execute at same place
43+
44+
(function()
45+
{
46+
console.log("hello");
47+
48+
})
49+
() //
50+

‎Intro.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
console.log("javacript");
2+
3+
4+
//print the output
5+
6+
console.log("java");

‎Task3.js‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Func declaration finding area
2+
function area(length,width)
3+
{
4+
console.log("Area:",(length*width));
5+
6+
}
7+
area(10,10)
8+
9+
// func expression finding area
10+
let Area2=function(length2,width2)
11+
{
12+
console.log("Area2:",(length2*width2));
13+
}
14+
Area2(10,10)
15+
// arrow func finding area
16+
let area3=(length3,width3)=>
17+
{
18+
console.log("Area3:",(length3*width3));
19+
20+
}
21+
area3(10,10)
22+
23+
// func declarationFinding percent of subjects
24+
25+
function percentage(tamil,english,science,chemistry,maths)
26+
{
27+
console.log("percentage is ",(tamil+english+science+chemistry+maths)/500*100);
28+
}
29+
percentage(90,90,90,90,90)
30+
31+
// func expression
32+
33+
let percentage1=function(tamil1,english1,science1,chemistry1,maths1)
34+
{
35+
console.log("percentage1 is",(tamil1+english1+science1+chemistry1+maths1)/500*100);
36+
}
37+
percentage1(90,90,90,90,90)
38+
39+
// arrow function
40+
41+
let percentage2=(tamil2,english2,science2,chemistry2,maths2)=>
42+
{
43+
console.log("percentage2 is",(tamil2+english2+science2+chemistry2+maths2)/500*100);
44+
}
45+
percentage2(90,90,90,90,90)
46+
47+
// IIFE
48+
(
49+
function(len,wid)
50+
{
51+
console.log("areaiif is",(len*wid));
52+
53+
}
54+
)
55+
(10,10)

‎arraymethods.js‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
let arr=["one",2,"three",4,"five"]// index starts from 0
2+
3+
console.log(arr[4]);
4+
arr[3]="four";
5+
console.log(arr);
6+
7+
let fruit=["apple","orange","banana","kiwi","guva"]
8+
fruit.push("grape"); // inserrt elemet last
9+
console.log(fruit);
10+
fruit.pop(); // remove
11+
console.log(fruit);
12+
fruit.shift(); // inserrt elemet first
13+
console.log(fruit);
14+
fruit.unshift("plum"); // inserrt elemet
15+
console.log(fruit);
16+
17+
// slice
18+
console.log(fruit.slice(2,4));// slice add next value index
19+
console.log(fruit.slice(-3,-1)); // negative
20+
21+
//splice
22+
fruit.splice(2,0,"cherry"); // add
23+
console.log(fruit);
24+
fruit.splice(3,1,"tomato"); // update
25+
console.log(fruit);
26+
fruit.splice(4,1,); // remove
27+
console.log(fruit);
28+
29+
// sort reverse
30+
//let fruit=["apple","orange","banana","kiwi","guva"]
31+
console.log(fruit.reverse());// reverse order
32+
33+
console.log(fruit.sort()); //alphabetical order
34+
console.log(fruit.reverse());
35+
36+
//concat index
37+
38+
let fruits=["apple","pomo","banana"]
39+
let one =[1,1,2,3,4,5,1,2]
40+
console.log(one.indexOf(1)); // 1 start index 0 1 end index 6
41+
console.log(one.lastIndexOf(1));
42+
43+
console.log(fruits.concat(one));// combine 2 string
44+
45+
// array method
46+
47+
// map method first get the value check the condition and store it in new array
48+
49+
let num=[1,2,3,4,5,6,7,8,9,10] // iterated through each value
50+
51+
let mul=num.map((el)=>el*5)
52+
53+
console.log(mul);
54+
55+
56+
57+
// filter method store new value in new array based on filter of condition
58+
let num1=[1,2,3,4,5,6,7,8,9,10]
59+
let even=num1.filter((el)=>el%2 ===0)
60+
console.log(even);
61+
62+
63+
// find the largest value in array
64+
65+
let num3=[1,2,4,5,78,97]
66+
67+
for(let i=0;i<num3.length;i++)
68+
69+
{
70+
71+
}
72+
73+
let num2=[1,2,3,4,7,10,25,32,56,78,12,75,45]
74+
let divisablebytwoandfive=num2.filter((el)=> el%2===0 &&el%5===0)
75+
console.log(divisablebytwoandfive);
76+
77+
78+
79+
80+
// reduce method it give single output
81+
82+
let sum=num.reduce((acc,el)=>acc+el,10) // 10 save in accumulator
83+
console.log(sum);
84+
85+
86+
//
87+
88+
89+

‎callback.js‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
// callback
3+
function orderfood(input)
4+
{
5+
setTimeout(() => {
6+
console.log("ordered food is done");
7+
input()
8+
}, 3000);
9+
}
10+
11+
function eatfood()
12+
{
13+
setTimeout(() => {
14+
console.log("eat food is done");
15+
16+
}, 2000);
17+
}
18+
19+
orderfood(eatfood) // callback is used to call one function call as parameter of other function to covert 2 function in syncronous
20+
21+
// callbackhell
22+
23+
function brush (b)
24+
{
25+
setTimeout(() => {
26+
console.log("time take for brush is 2000");
27+
b()
28+
}, 2000);
29+
}
30+
function bath (a)
31+
{
32+
setTimeout(() => {
33+
console.log("time take for bath is 2000");
34+
a()
35+
}, 2500);
36+
}
37+
function ready (c)
38+
{
39+
setTimeout(() => {
40+
console.log("time take for ready is 1500");
41+
c()
42+
}, 1500);
43+
}
44+
function relax (d)
45+
{
46+
setTimeout(() => {
47+
console.log("time take for relax is 500");
48+
d()
49+
}, 500);
50+
}
51+
function eat ()
52+
{
53+
setTimeout(() => {
54+
console.log("time take for eat is 2500");
55+
56+
}, 2500);
57+
}
58+
59+
60+
brush()
61+
bath()
62+
ready()
63+
relax()
64+
eat()
65+
/*brush(()=>{
66+
bath(()=>{
67+
ready(()=>{
68+
relax(eat)
69+
})
70+
})
71+
72+
})*/

‎callbacktask.js‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
function launchapplication (b)
2+
{
3+
setTimeout(() => {
4+
console.log("Application opened");
5+
b()
6+
}, 500);
7+
}
8+
function Login (a)
9+
{
10+
setTimeout(() => {
11+
console.log("Login with valid user name and password");
12+
a()
13+
}, 1500);
14+
}
15+
function searchitem (c)
16+
{
17+
setTimeout(() => {
18+
console.log("Product is searched");
19+
c()
20+
}, 2000);
21+
}
22+
function reviewproduct (d)
23+
{
24+
setTimeout(() => {
25+
console.log("Product is reviewed");
26+
d()
27+
}, 3000);
28+
}
29+
function Addtocart (e)
30+
{
31+
setTimeout(() => {
32+
console.log(" Product is added to cart");
33+
e()
34+
}, 3500);
35+
}
36+
function Placeorder (f)
37+
{
38+
setTimeout(() => {
39+
console.log(" Product send for order");
40+
f()
41+
}, 200);
42+
}
43+
function Payment (g)
44+
{
45+
setTimeout(() => {
46+
console.log(" Payment initaited to place order");
47+
g()
48+
}, 100);
49+
}
50+
function Success ()
51+
{
52+
setTimeout(() => {
53+
console.log(" Product order ");
54+
55+
}, 300);
56+
}
57+
58+
launchapplication(()=>{
59+
Login(()=>{
60+
searchitem(()=>{
61+
reviewproduct(()=>{
62+
Addtocart(()=>{
63+
Placeorder(()=>{
64+
Payment(Success)
65+
66+
})
67+
68+
})
69+
70+
})
71+
})
72+
})
73+
74+
})

‎class.js‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
class Details // detail is class name and it should be in pascal notation
2+
3+
{
4+
5+
name="reena"; //properties
6+
role="qa";
7+
8+
demo() // methods
9+
{
10+
console.log("My name is",this.name,"my role is ",this.role);
11+
12+
}
13+
}
14+
15+
let one= new Details // object
16+
one.demo() // to cs
17+
let two= new Details
18+
console.log(two.name);
19+
console.log(two.role);
20+
21+
22+
23+
// class using constructor
24+
25+
class Movie{
26+
constructor(name1,actname)
27+
{
28+
this.name1=name1 // define properties inside constructor
29+
this.actname=actname
30+
}
31+
mov()
32+
{
33+
console.log("movie name is",this.name1);
34+
console.log(("actname is:",this.actname));
35+
36+
37+
}
38+
}
39+
40+
let movie1= new Movie("leo","vijay")
41+
movie1.mov()
42+

0 commit comments

Comments
 (0)