-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.js
63 lines (52 loc) · 1.29 KB
/
utils.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
60
61
62
63
const translate_city = (city) => {
/**
* @summary This function translates the city in romanian
* @param {String} city
*
* @returns {String} city
*/
if (!city) return "";
// Populate this object with the cities that need translation
const cities = {
bucharest: "Bucuresti",
cluj: "Cluj-Napoca",
};
if (cities[city.toLowerCase()]) {
return cities[city.toLowerCase()];
} else {
return city;
}
};
const replace_char = (sentence, chars = [], charToReplace = "") => {
/**
* @summary This function replaces the characters in a sentence
* @param {String} sentence
* @param {Array} chars
* @param {String} charToReplace
*
* @returns {String} new sentence
*/
let new_sentence = sentence;
sentence.split("").forEach((char) => {
if (chars.includes(char)) {
new_sentence = new_sentence.replace(char, charToReplace);
}
});
return new_sentence;
};
const get_jobtype = (sentence) => {
/**
* @summary This function finds the job type in a sentence
* @param {String} sentence
*
* @returns {String} job type
*/
const job_types = ["remote", "hybrid"];
const jobType = job_types.filter((type) => sentence.includes(type));
return jobType;
};
module.exports = {
translate_city,
replace_char,
get_jobtype,
};