Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/data/zadanie01/sum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
108
20 changes: 19 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
//Twój kod
const fs = require("fs");

fs.readFile("./app/data/zadanie01/input.json", (err, data) => {
if (err === null) {
const parsed = JSON.parse(data);
const sum = parsed.reduce((prev, curr) => {
return prev + curr;
});
fs.writeFile("./app/data/zadanie01/sum.txt", sum, err => {
if (err === null) {
console.log("Zapisano elegancko");
} else {
console.log("Coś nie pykło z tym zapisaniem");
}
});
} else {
console.log("Coś nie bangla");
}
});
20 changes: 19 additions & 1 deletion app/zadanie02.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
//Twój kod
const fs = require("fs");

fs.readdir("./app/data/zadanie02", (err, files) => {
if (err === null) {
console.log("Działa ok, oto lista plików: ");
files.forEach(file => {
console.log(file);
fs.readFile(`./app/data/zadanie02/${file}`, "utf8", (err, data) => {
if (err === null) {
console.log(data);
} else {
console.log("Coś chyba z tym readFilem :/");
}
});
});
} else {
console.log("Nie bangla :/");
}
});