-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (50 loc) · 1.53 KB
/
index.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
const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const PORT = process.env.PORT || 5000
express()
.use(express.static(path.join(__dirname, 'public')))
.use(bodyParser.json())
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs')
.get('/', (req, res) => res.status(200).json({"Status": "Working"}))
.post('/bfhl', (req, res) => {
console.log(req.body.data)
let arra = req.body.data
let num = [];
let alphabet =[];
// Change the user id as per user name and DOB
let user_id = 'vijendra nagar_02082001'
let email=`[email protected]`
let rollNo = `0827IT191129`
// Check whether the given array contains numeric elements or not
let stat=false
arra.forEach((ele) => {
// Check if the number is even or odd
if(typeof(ele)==="number"){
console.log(`${ele} is number`)
num.push(ele)
stat=true
} else {
console.log(`${ele} is alphabet`)
alphabet.push(ele)
stat=true
}
})
if(stat){
res.status(200).json({
"is_success": stat,
"user_id": user_id,
"email": email,
"roll_number":rollNo,
"numbers": num,
"alphabets": alphabet
})
} else {
res.status(200).json({
"is_success": stat,
"user_id": user_id
})
}
})
.listen(PORT, () => console.log(`Listening on ${ PORT }`))