diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/data/sum.txt b/app/data/sum.txt new file mode 100644 index 0000000..91498a5 --- /dev/null +++ b/app/data/sum.txt @@ -0,0 +1 @@ +1,2,7,20,56,22 \ No newline at end of file diff --git a/app/data/zadanie01/sum.txt b/app/data/zadanie01/sum.txt index e69de29..615088b 100644 --- a/app/data/zadanie01/sum.txt +++ b/app/data/zadanie01/sum.txt @@ -0,0 +1 @@ +108 \ No newline at end of file diff --git a/app/data/zadanieDnia/test.txt b/app/data/zadanieDnia/test.txt index 47c17e3..0bcff2e 100644 --- a/app/data/zadanieDnia/test.txt +++ b/app/data/zadanieDnia/test.txt @@ -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] \ No newline at end of file +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] \ No newline at end of file diff --git a/app/zadanie01.js b/app/zadanie01.js index 8c20173..57c2725 100644 --- a/app/zadanie01.js +++ b/app/zadanie01.js @@ -1 +1,25 @@ -//Twój kod \ No newline at end of file +const fs = require('fs'); + +fs.readFile('../app/data/zadanie01/input.json', 'utf8', (err, data) => { + if (err === null){ + console.log('Poprawnie odczytano plik.', data); + let arr = JSON.parse(data); + function sum (x){ + let y= 0; + for (i=0; i { + if (err === null){ + console.log('Zapisano sumę poprawnie!'); + } else { + console.log('Błąd podczas zapisu sumy w pliku!', err); + } + }); + + } else { + console.log('Błąd podczas odczytu pliku jSON!', err); + } +}); \ No newline at end of file diff --git a/app/zadanie02.js b/app/zadanie02.js index 8c20173..1c226d9 100644 --- a/app/zadanie02.js +++ b/app/zadanie02.js @@ -1 +1,19 @@ -//Twój kod \ No newline at end of file +const fs = require('fs'); + +fs.readdir('../app/data/zadanie02', (err, files) => { + if (err === null){ + files.forEach(file => { + fs.readFile('../app/data/zadanie02/'+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); +} +}); \ No newline at end of file diff --git a/app/zadanieDnia.js b/app/zadanieDnia.js index 8c20173..d62cc71 100644 --- a/app/zadanieDnia.js +++ b/app/zadanieDnia.js @@ -1 +1,52 @@ -//Twój kod \ No newline at end of file +const fs = require('fs'); + +function TrAwKa(fileName) { + fs.readFile(fileName, 'utf8', (err, data) => { + if (err === null) { + let text = ''; + for (let i = 0; i < data.length; i++) { + if (i % 2 !== 0) { + + text += data[i].toUpperCase(); + } + else { + text += data[i].toLowerCase(); + } + } + return fs.writeFile(fileName, text, err => { + if (err === null) { + console.log('Plik został zmieniony w nieskoszoną TrAwKę:' + '\n\n' + text); + } else { + console.log("błąd zapisu", err); + } + }) + } else { + console.log('Błąd podczas odczytu pliku!', err); + } + }); +} + +TrAwKa(process.argv[2]); + +// //version 2: +// const fs = require('fs'); +// function TrAwKa(fileName) { +// fs.readFile(fileName, 'utf8', (err, data) => { +// if (err === null) { +// let text = ''; +// [...data].forEach((e, i) => { +// text += (i % 2 === 0) ? e.toUpperCase() : e.toLowerCase(); +// }); +// fs.writeFile(fileName, text, err => { +// err === null? console.log('Plik został zmieniony w nieskoszoną TrAwKę:' +'\n\n'+ text) : console.log('Błąd zapisu pliku') +// }) +// } else { +// console.log('Błąd odczytu pliku') +// } +// }); +// } +// TrAwKa(process.argv[2]); + + + +