Skip to content
Open

Done #22

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
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/Node.js_challenge_dzien_2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
10 changes: 5 additions & 5 deletions app/data/zadanieDnia/test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You Don't Know JS: ES6 & Beyond
Foreword
yOu dOn't kNoW Js: Es6 & BeYoNd
fOrEwOrD

Kyle Simpson is a thorough pragmatist.
kYlE SiMpSoN Is a tHoRoUgH PrAgMaTiSt.

I can't think of higher praise than this. To me, these are two of the most important qualities that a software developer must have. That's right: must, not should. Kyle's keen ability to tease apart layers of the JavaScript programming language and present them in understandable and meaningful portions is second to none.
[https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20%26%20beyond/foreword.md]
i cAn't tHiNk oF HiGhEr pRaIsE ThAn tHiS. tO Me, ThEsE ArE TwO Of tHe mOsT ImPoRtAnT QuAlItIeS ThAt a sOfTwArE DeVeLoPeR MuSt hAvE. tHaT'S RiGhT: mUsT, nOt sHoUlD. kYlE'S KeEn aBiLiTy tO TeAsE ApArT LaYeRs oF ThE JaVaScRiPt pRoGrAmMiNg lAnGuAgE AnD PrEsEnT ThEm iN UnDeRsTaNdAbLe aNd mEaNiNgFuL PoRtIoNs iS SeCoNd tO NoNe.
[hTtPs://gItHuB.CoM/GeTiFy/yOu-dOnT-KnOw-jS/BlOb/mAsTeR/Es6%20%26%20BeYoNd/fOrEwOrD.Md]
22 changes: 21 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
//Twój kod
//Twój kod
const fs = require('fs');

fs.readFile('./data/zadanie01/input.json', 'utf8', (err, data) => {
if (err === null){
const arr = JSON.parse(data);
const result = arr.reduce((acc, num) => {
return acc + num
});
console.log(result);
fs.writeFile('./data/zadanie01/sum.txt', '108', err => {
if (err === null) {
console.log('zapisano')
} else {
console.log('Błąd podczas zapisu pliku!', err);
}
})
} else {
console.log('Błąd podczas odczytu pliku!', err);
}
});
46 changes: 45 additions & 1 deletion app/zadanie02.js
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
//Twój kod
//Twój kod
const fs = require('fs');
const path = require('path');
const folderPath = './data/zadanie02';

// fs.readdir('./data/zadanie02', (err, files) => {
// if (err === null) {
// console.log('Lista plików:');
// files.forEach(file => {
// console.log(file);
// // try {
// // const data = fs.readFileSync(file)
// // console.log(data)
// // } catch (err) {
// // console.error(err)
// // }
// fs.readFile(file, 'utf8', (err, data) => {
// if (err === null) {
// console.log(data);
// } else {
// console.log('Błąd podczas odczytu pliku!', err);
// }
// });
// });
//
// } else {
// console.log('Błąd podczas listowania katalogu!', err);
// }
//
// });

const filesLinks = fs.readdirSync(folderPath).map(fileName => {
return path.join(folderPath, fileName)
});

filesLinks.forEach(file => {
fs.readFile(file, 'utf8', (err, data) => {
if (err === null) {
console.log(data);
} else {
console.log('Błąd podczas odczytu pliku!', err);
}
})
})

22 changes: 21 additions & 1 deletion app/zadanieDnia.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
//Twój kod
//Twój kod
const fs = require('fs');

const alternativeCase = string => string.split('')
.map((c,i) => i & 1 ? c.toUpperCase() : c.toLowerCase()).join('');

fs.readFile('./data/zadanieDnia/test.txt', 'utf8', (err, data) => {
if (err === null){
// console.log(data);
const edited = alternativeCase(data);
fs.writeFile('./data/zadanieDnia/test.txt', edited, err => {
if (err === null) {
console.log('zapisano', edited);
} else {
console.log('Błąd', err);
}
})
} else {
console.log(err);
}
});