-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmar18task.js
More file actions
153 lines (119 loc) · 2.78 KB
/
mar18task.js
File metadata and controls
153 lines (119 loc) · 2.78 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// get last 3 char
let str="Playwright"
console.log(str.substring(7,10));
// replace c-->C
let str1="chennai city center"
console.log(str1.replaceAll("c","C"));
// word count of string
let str2="hi i am javascript"
let char1=str2.split(" ");
console.log(char1.length);
// empty arr
let arr=[]
arr.push(10); // insert elements
arr.push(20);
arr.push(30);
arr.push(40);
arr.push(50);
console.log(arr);
arr.pop(); // remove last element
console.log(arr);
arr.unshift(5); // insert element at first
console.log(arr);
arr.shift();
console.log(arr);
// reverse string
let word="abinaya"; // string cannot be directly reversed first need to split in array and array can be reversed
console.log(word.split("").reverse().join(""));
//palindrome
let word1="malayalam";
console.log(word1);
let word2=word1.split("").reverse().join("")
console.log(word2);
if (word1==word2)
{
console.log("Palindrome");
}
else if (word1!==word2)
{
console.log("Not Palindrome");
}
//"Apple" => string start as vowel
function vowel (str)
{
let str1 =str.toLowerCase();
console.log(str1);
if (str1.includes("a")||str1.includes("e")||str1.includes("i")||str1. includes("o")||str1.includes("u"))
{
console.log("string contains vowel");
}
else
{
console.log("string doesn't contain vowel");
}
}
vowel("apple")
///////////
function vowel1 (str1)
{
let vow ="aeiouAEIOU"
if (vow.includes(str1[0]))
{
console.log(str1,"string starts from vowel");
}
else
{
console.log(str1,"string not a vowel");
}
}
vowel1("rat")
// task employee details
let employeedetails=(name,basicsalary,bonus,deduction)=>
{
let salary= basicsalary+bonus+deduction;
console.log("Name:",name);
console.log("Totalsalary:" ,salary);
if (salary>50000)
{
console.log("Remarks:High Salary");
}
else if (salary>=30000 && salary <=50000)
{
console.log("Remarks:Medium Salary");
}
else if (salary<30000)
{
console.log("Remarks:Low Salary");
}
else
{
console.log("error");
}
}
employeedetails("Reena",15000,5000,3000)
///////// task pizza order system
let pizza=(name1,size,quantity)=>
{
let smallprice=100;
let mediumprice=200;
let largeprice=300;
let totalamount= 0;
if (size=="small")
{ totalamount=smallprice*quantity
} else if (size=="medium")
{ totalamount=mediumprice*quantity
} else if (size=="large")
{ totalamount=largeprice*quantity
}
else
{
console.log("error");
}
console.log("Name:",name1);
console.log("Size:",size);
console.log("Quantity",quantity);
console.log("Amount:",(totalamount));
}
pizza("PannerPizza","small",2)
pizza("onionpizza","medium",2)
pizza("capsicumpizza","large",2)