-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray-exists.js
44 lines (34 loc) · 904 Bytes
/
array-exists.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
function bestfriends(friends){
if(Array.isArray(friends)==false){
return 'provide an array'
}
let max = friends[0];
for(const friend of friends){
if(friend.length>max.length){
max = friend;
}
}
return max;
}
const friends =['farhana','nimki','adrita','tirtho','turkiministhan'];
const bigBuddy = bestfriends(1113);
console.log(bigBuddy);
if(friends.indexOf('adrita')!=-1){
console.log('adrita exits');
}
if(friends.includes('nimki')){
console.log('nimki exits');
}
/* function bestFriend(friendNames){
let max = friendNames[0];
for(element of friendNames){
// console.log(element);
if(element.length > max.length){
max=element;
}
}
return max;
}
console.log(bestFriend(['nim','Farhana','binte','THasan','Tazakistan']));
let namesIs ="Tazakistan";
console.log(namesIs.length); */