-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuseful-code.js
47 lines (37 loc) · 1.15 KB
/
useful-code.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
if(received_message.text.split(" ").includes("completed")){
var checker = received_message.text.split(" ")
function intChecker(inArray, arr2){
var mo = 0
inArray.forEach(function(ele){
if(arr2.includes(ele)){
mo = mo + 1
}
})
return mo
}
if(intChecker(checker, ["0", "1", "2", "3"]) === 1){
careDaily.findOne({sender_PSID: sender_psid}).then((doc) => {
var foundDay = doc.myDayDetails.find(function(element){
return element.day_of_year = moment().dayOfYear()
})
foundDay.daily_goals_conclusion = checker.find(function(yo){
return parseInt(yo, 10)
})
doc.save().then((doc) => {
console.log("success")
}, (e) => {
console.log(e)
})
},(err) => {
console.log(err)
})
var response
return response = {
"text" : "Good Job! Keep it up! I'll message you tomorrow morning!"
}
}else{
return undefined
}
}else{
return undefined
}