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

rozwiązania #2

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
7 changes: 6 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
//Twój kod
//Twój kod
console.log('Łukasz Dadlez');

setTimeout(() => {
console.log('wita się z Node.js');
}, 5000);
22 changes: 21 additions & 1 deletion app/zadanie02.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
//Twój kod
//Twój kod
// nie ma informacji o danych wejściowych
const textArray = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Eleganckie rozwiązanie!

4: 'Node.js',
1: 'się',
0: 'Witam',
6: 'i korzystam',
5: 'w konsoli',
7: 'z funkcji czasu',
2: 'z',
3: 'programem'
}

for (let i = 0, len = Object.keys(textArray).length; i < len; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Mała podpowiedź: .forEach lub for..in wyglądają znacznie przejrzyściej.

setTimeout(() => {
process.stdout.write(textArray[i] + ' ');
if (i === (len - 1)) {
process.stdout.write('\033[1D\033[K.\n'); //usuń ostatnią spację i wpisz kropkę
}
}, i*300);
}
4 changes: 3 additions & 1 deletion app/zadanie03.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//Twój kod
//Twój kod
const [ num1, num2 ] = process.argv.slice(2,4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Fajne wykorzystanie destrukturyzacji tablicy :)

console.log(`${num1} + ${num2} = ${parseInt(num1) + parseInt(num2)}`);
11 changes: 10 additions & 1 deletion app/zadanieDnia.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
//Twój kod
//Twój kod
const argvArray = process.argv.slice(2);

argvArray.forEach(num => {
let value = new Number(num);

setTimeout(() => {
console.log(num)
}, parseInt(value * 500)); //żeby mniej czekać na rozwiązanie ;)
});