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 #4

Open
wants to merge 3 commits 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
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]
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
//Twój kod
const fs = require('fs');

fs.readFile('./data/zadanie01/input.json', 'utf8', (err, data) => {
if (err === null){
console.log('Poprawnie odczytano plik.', data);
let dataParsed = JSON.parse(data);
var sum = dataParsed.reduce((prev,curr)=>{return prev+curr})
fs.writeFile('./data/zadanie01/sum.txt', sum, err => {
if (err === null){
console.log("Sukces!");
} else {
console.log('Błąd podczas odczytu pliku!', err);
}
});
}else{
console.log('Błąd podczas odczytu pliku!', err);
}
});
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
//Twój kod
const fs = require('fs');

//Odczytaj listę plików i folderów...
fs.readdir('./data/zadanie02/', (err, files) => {
if (err === null){
files.forEach( file => {
fs.readFile(`./data/zadanie02/${file}`, 'utf8', (err, data) => {
if (err === null){
console.log(`Poprawnie odczytano plik ${file}. Dane z pliku: `, data);
} else {
console.log('Błąd podczas odczytu pliku!', err);
}
});
});
} else {
console.log('Błąd podczas listowania katalogu!', err);
}
});
27 changes: 26 additions & 1 deletion app/zadanieDnia.js
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
//Twój kod
//Twój kod

const fs = require('fs');
fs.readFile(`./data/zadanieDnia/${process.argv[2]}`, 'utf8', (err, data) => {
if (err === null){
console.log('Poprawnie odczytano plik.', data);
var letter = []
for(let i=0; i<data.length;i++){
if(i%2===0){
letter.push(data[i].toUpperCase())
}else{
letter.push(data[i].toLowerCase())
}
}
let sentence = letter.join("");
fs.writeFile(`./data/zadanieDnia/${process.argv[2]}`, sentence, err => {
if (err === null){
console.log("Sukces!");
} else {
console.log('Błąd podczas odczytu pliku!', err);
}
});
}else{
console.log('Błąd podczas odczytu pliku!', err);
}
});