diff --git a/app/test.js b/app/test.js index dffc25d..381dc92 100644 --- a/app/test.js +++ b/app/test.js @@ -1 +1,3 @@ -console.log('Wygląda na to, że wszystko działa :)'); \ No newline at end of file +console.log('Wygląda na to, że wszystko działa :)'); +console.log("druga linijka"); +console.log(process); \ No newline at end of file diff --git a/app/zadanie01.js b/app/zadanie01.js index 8c20173..308c491 100644 --- a/app/zadanie01.js +++ b/app/zadanie01.js @@ -1 +1,7 @@ -//Twój kod \ No newline at end of file +//Twój kod + +console.log("Moje imię i nazwisko"); + +setTimeout(()=>{ + console.log("wita się z Node.js!"); +}, 5000); \ No newline at end of file diff --git a/app/zadanie02.js b/app/zadanie02.js index 8c20173..b06a2e1 100644 --- a/app/zadanie02.js +++ b/app/zadanie02.js @@ -1 +1,33 @@ -//Twój kod \ No newline at end of file +//Twój kod + +const array_to_write = []; + +array_to_write[4] = "Node.js"; +array_to_write[1] = "się"; +array_to_write[0] = "Witam"; +array_to_write[6] = "i korzystam"; +array_to_write[5] = "w konsoli"; +array_to_write[7] = "z funkcji czasu!"; +array_to_write[2] = "z"; +array_to_write[3] = "programem"; + +array_to_write.forEach((text, time) => { + writeText(text, time); +}); + + +/** + * @text string + * @time integer (seconds) + */ + +function writeText(text, time) { + if (Number.isInteger(time) && time >= 0) { + setTimeout(() => { + console.log(text); + }, time * 1000); + } + else { + console.log("Czas musi być liczbą dodatnią"); + } +} \ No newline at end of file diff --git a/app/zadanie03.js b/app/zadanie03.js index 8c20173..0e695e2 100644 --- a/app/zadanie03.js +++ b/app/zadanie03.js @@ -1 +1,25 @@ -//Twój kod \ No newline at end of file +//Twój kod + +const number_1 = process.argv[2]; +const number_2 = process.argv[3]; + +if (typeof number_1 === 'undefined' || typeof number_2 === 'undefined') { + console.log("Brak wymaganych co najmniej dwóch argumentów!"); + process.exit(1); +} + + +let sum = 0; + +process.argv.forEach((param, index) => { + if (index > 1) { + param = parseInt(param); + if (isNaN(param)) { + console.log("Wszystkie parametry muszą być liczbami!"); + process.exit(1); + } + sum += param; + } + }); + +console.log(sum); \ No newline at end of file diff --git a/app/zadanieDnia.js b/app/zadanieDnia.js index 8c20173..c66adb6 100644 --- a/app/zadanieDnia.js +++ b/app/zadanieDnia.js @@ -1 +1,18 @@ -//Twój kod \ No newline at end of file +//Twój kod + +process.argv.forEach((number, index) => { + if (index < 2) { + return; + } + sleepSort(number, index); +}); + + +function sleepSort(number, index) { + const parsedNumber = parseInt(number); + if (isNaN(parsedNumber)) { + console.log("Parametr " + index + " nie jest liczbą: " + number); + return; + } + setTimeout(() => { console.log(number); }, parsedNumber * 1000); +} \ No newline at end of file