Message Generator updating - code refacto to bring function outside fs.readFile
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
a
|
|
||||||
à
|
|
||||||
abaissa
|
abaissa
|
||||||
abaissable
|
abaissable
|
||||||
abaissables
|
abaissables
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
fs.readFile("./dictionnaire_fr.txt", "utf8", (err, data) => {
|
|
||||||
|
fs.readFile("./dictionnaire_fr.txt", "utf8", parseFile);
|
||||||
|
|
||||||
|
function parseFile(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error("Erreur de lecture du fichier :", err);
|
console.error("Erreur de lecture du fichier :", err);
|
||||||
return;
|
return;
|
||||||
@@ -30,7 +33,4 @@ fs.readFile("./dictionnaire_fr.txt", "utf8", (err, data) => {
|
|||||||
randomMessage.pop();
|
randomMessage.pop();
|
||||||
// Join the words into a single string
|
// Join the words into a single string
|
||||||
console.log(`${randomMessage.join(" ")}.`);
|
console.log(`${randomMessage.join(" ")}.`);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user