-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathez.ts
30 lines (25 loc) · 817 Bytes
/
ez.ts
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
import fs from "fs";
const checkIfEz = (word: string): boolean => {
return word.endsWith('ez');
}
const wordFinder = () => {
// Import words.txt and use it to check each word if word ends with "ez" add it to string.
const words = fs.readFileSync('words.txt', 'utf8').split('\n');
let result = '';
for (const word of words) {
if (checkIfEz(word)) {
result += word + '\n';
}
}
fs.writeFileSync('ez.txt', result);
}
const wordCommar = () => {
// Import words.txt and use it to check each word if word ends with "ez" add it to string.
const words = fs.readFileSync('ez.txt', 'utf8').split('\n');
let result = '';
for (const word of words) {
result += word + ', ';
}
fs.writeFileSync('ez_comma.txt', result);
}
wordCommar();