-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
59 lines (46 loc) ยท 1.63 KB
/
test.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
52
53
54
55
56
57
58
59
var animals = ['๐ช','๐ซ','๐ฆ','๐ฆ','๐ฆฅ','๐ฆจ','๐','๐','๐ฆ','๐','๐ฟ','๐ฆ','๐','๐ข','๐','๐','๐','๐','๐','๐','๐','๐','๐ฆ','๐ฆ','๐ฆ','๐','๐','๐
,','๐','๐','๐ฉ','๐โ๐ฆบ','๐ฆฎ','๐ฆง','๐ฆ','๐,','๐','๐ฆ','๐ฆ','๐ฆฆ','๐ฆ','๐ฌ','๐ณ','๐','๐','๐ ','๐ก','๐ฆ','๐ฆ','๐','๐ฆ','๐ฆ','๐ฆ','๐','๐ฆ','๐ฆ
','๐ฆข','๐ฆ','๐ฆฉ','๐ฆ','๐ฆ','๐ง','๐ฆ','๐ฆ','๐','๐','๐','๐','๐ฆ','๐ท'];
var userObjects = []
function createNewEmoji() {
let animalArrLength = animals.length
let randIdx = Math.floor(Math.random() * animalArrLength);
let thisNewUserEmoji = animals[randIdx]
return thisNewUserEmoji
}
// console.log('thisNewUserEmoji', thisNewUserEmoji)
userObjects.push({
name: 'john',
emoji: '๐ช'
})
userObjects.push({
name: 'bob',
emoji: '๐ฆ'
})
userObjects.push({
name: 'mary',
emoji: '๐'
})
userObjects.push({
name: 'sue',
emoji: '๐ข'
})
console.log(userObjects);
// find user in db
if (userObjects.find(o => o.name === 'bob')) {
// assign an emoji
console.log('sssss')
let johnsEmoji = userObjects.find(o => o.name === 'bob').emoji
console.log('johnsEmoji', johnsEmoji)
}
// if (userObjects.includes("john")) {
// console.log('yes john exits')
// } else {
// console.log('NO john exits')
// console.log(userObjects.includes("john"))
// }
let arr = [
{ name:"string 1", value:"this", other: "that" },
{ name:"string 2", value:"this", other: "that" }
];
let obj = arr.find(o => o.name === 'string 1');
console.log(obj);
console.log(arr.find(o => o.name === 'string 1'));