Skip to content

Commit 74eee7f

Browse files
committed
Check Array is all string
1 parent 8575a8a commit 74eee7f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

script.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ app.post("/", usernameExtractor,(req, res) => {
1616
return res.status(400).send("Error: Body must be a JSON array.");
1717
}
1818

19+
const CheckAllStrings = subjects.every((e) => typeof e === "string");
20+
if (!CheckAllStrings) {
21+
return res
22+
.status(400)
23+
.send("Error: Array must contain only string elements.");
24+
}
25+
26+
let response = "";
27+
1928

2029

2130
res.send(response);

0 commit comments

Comments
 (0)