Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dzień 2 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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.

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.

270 changes: 270 additions & 0 deletions .idea/workspace.xml

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

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]
14 changes: 13 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
//Twój kod
//Twój kod
const fs = require('fs');

fs.readFile('./data/zadanie01/input.json', 'utf8', (err, data) => {
if (err === null){
console.log('Poprawnie odczytano tablicę:', data);
const arr = JSON.parse(data);
let sum = arr.reduce(function (a, b) {return a + b;}, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Też może być const.

console.log(`Suma elementów w talicy to: ` + sum);
} else {
console.log(`Błąd...`, err)
}
});
14 changes: 13 additions & 1 deletion app/zadanie02.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
//Twój kod
//Twój kod
const fs = require('fs');

fs.readdir('./data/zadanie02/', (err, files)=>{
if (err === null){
console.log('Lista plików:');
files.forEach(file => {
console.log(file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brakuje odczytu zwartości pliku.

});
} else {
console.log(`Błąd...`, err)
}
})
23 changes: 22 additions & 1 deletion app/zadanieDnia.js
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
//Twój kod
//Twój kod
const fs = require('fs');

fs.readFile('./data/zadanieDnia/test.txt', 'utf8', (err, data) => {
if (err === null){
let text = data;
let res = text.split('').map(function(v,i){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Najlepsze rozwiązanie.

return i%2 === 0 ? v.toLowerCase():v.toUpperCase()
});
console.log(res.join(''));
fs.writeFile('./data/zadanieDnia/test.txt', res.join(''), err => {
if (err === null){
console.log('Zapisano poprawnie!');
} else {
console.log('Błąd podczas zapisu pliku!', err);
}
});

} else {
console.log(`Błąd...`, err)
}
});