-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscript.js
57 lines (44 loc) · 1.56 KB
/
script.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
document.getElementById("jobForm").addEventListener("submit", function (event) {
event.preventDefault();
const company = document.getElementById("company").value;
const description = document.getElementById("description").value;
const resultDiv = document.getElementById("result");
const companyError = document.getElementById("companyError");
const descriptionError = document.getElementById("descriptionError");
//clear previous error messages
companyError.textContent = "";
descriptionError.textContent = "";
let isValid = true;
if (company.trim() === "") {
companyError.textContent = "Company is required";
isValid = false;
}
if (description.trim() === "") {
descriptionError.textContent = "Description is required";
isValid = false;
}
if (!isValid) return;
const result = verifyJobPosting({ company, description });
resultDiv.textContent = result;
});
function verifyJobPosting(jobPosting) {
if (!verifyCompany(jobPosting.company)) {
return "Company not verified. Be cautious.";
}
if (verifyJobDescription(jobPosting.description)) {
return "Job description contains suspicious phrases.";
}
return "Job posting seems legitimate!";
}
function verifyCompany(companyName) {
const trustedCompanies = ["Google", "Microsoft", "Amazon"];
return trustedCompanies.includes(companyName);
}
function verifyJobDescription(description) {
const suspiciousPhrases = [
"work from home",
"quick money",
"no experience required",
];
return suspiciousPhrases.some((phrase) => description.includes(phrase));
}