Message Generator updating - code refacto to bring function outside fs.readFile

This commit is contained in:
gauvainboiche
2025-07-16 11:26:28 +02:00
parent 91d16c960c
commit e2f07067d0
2 changed files with 5 additions and 7 deletions

View File

@@ -1,5 +1,3 @@
a
abaissa
abaissable
abaissables

View File

@@ -1,5 +1,8 @@
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) {
console.error("Erreur de lecture du fichier :", err);
return;
@@ -30,7 +33,4 @@ fs.readFile("./dictionnaire_fr.txt", "utf8", (err, data) => {
randomMessage.pop();
// Join the words into a single string
console.log(`${randomMessage.join(" ")}.`);
});
}