-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrayDemo.js
51 lines (33 loc) · 924 Bytes
/
ArrayDemo.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
var names = ['HCL', 'TCS','Infosys', 'WIPRO', 'Infosys'];
var result = names.indexOf('Infosys');
console.log(result);
var result = names.lastIndexOf('Infosys');
console.log('Position', result);
var userNames = ['Ashok', 'Anand', 'Satya', 'Richa'];
var result = userNames.map(function (name) {
return "Welcome " + name;
});
console.log(result);
var users = new Map();
users.set(1,{ 'Name': 'Anand', 'Gender': 'Male' });
users.set(2,{ 'Name': 'Rosy', 'Gender': 'Female' });
users.set(3,{ 'Name': 'Jayanath', 'Gender': 'Male' });
//for (let [key,value] of users)
//{
//console.log(value);
//}
userArray=[];
for (let obj of users.values())
{
userArray.push(obj);
console.log(obj);
}
result=userArray.map(function(obj)
{
if(obj.Gender=='Male')
return "Mr."+obj.Name;
else
return "Ms."+obj.Name;
});
console.log(result);