-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.js
More file actions
90 lines (58 loc) · 1.93 KB
/
array.js
File metadata and controls
90 lines (58 loc) · 1.93 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
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
// Array Type
// push - at the end add any value
// pop - removes the end value in array
// shift removes the last value of array
// un shit - add any values in the array
// splice () - // variable name.splice(index,splice num.value){}
// splice numbers are - 0 and 1 ( 0 is the )
// sort in acceding order it will sort alphabets and give like aar av (first aar)
let a = [10,20,30,40,50]
a.push(60,70)
console.log(a);
let b = [10,20,30,40,50]
a.pop()
console.log(b);
let c = [10,20,30,40,50]
c.shift()
console.log(c);
// shift
let d = [10,20,30,40,50]
d.unshift(8,9)
console.log(d);
// splice
let days = ["sunday", "monday","tuesday", "thrusday", "friday", "saturday"]
days.splice(3,0, "wednesday")
console.log(days);
let dayss = ["sunday", "monday","tuesday", "thrusday", "friday", "saturday"]
dayss.splice(3,1, "wednesday")
console.log(dayss);
// sort
let abc = ["guava", "apple", "mango"]
console.log(abc.sort());
// reverse need to add 3 types split, reverse and joint
let rev = "yadsendew"
console.log(rev.split("").reverse("").join(""));
// Task DO your name = Rijesh hsejir
let rev = "hsejiR"
console.log(rev.split("").reverse("").join(""));
// Task
// input : Hello Happy World output : HellowHappyWorld
var a = "Hello"
var b = "Happy"
var c = "World"
console.log(a+b+c);
var task = "Hello Happy World"
console.log(task.replaceAll(" ",""));
// task I am learning Java script
// output : Java script learning am I
//let reverse = "I am learning Java Script"
//console.log(reverse.replaceAll("I am learning Java Script", "Javascript learning am I"));
let rev = "I am learning JavaScript"
console.log(rev.split(" ").reverse().join(" "));
// pratice
let arr = [1,6,44,8,33,9,46]
console.log(arr.sort((a,b)=> b-a) [1]);
console.log(`second largest number ${arr[1]}`);
let abc = "Rijesh is praticing playwright"
console.log(abc.split("").reverse("").join(""));
//QS : how to reverse this from back side as first