Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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: 7 additions & 0 deletions 01/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
const randomNumber = Math.round(Math.random() * 20);
console.log(randomNumber);

for (let i = 5; i < randomNumber; i++) {
console.log(i);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ta część ma się pojawić tylko wtedy, kiedy warunek poniżej jest nieprawidłowy.
Dlatego powinna pojawić się ona w else tj.

if(...) {
     ...
} else {
   for(...)
}

if (randomNumber < 5) {
console.log('Wylosowana liczba jest zbyt mała, aby użyć pętli');
}
9 changes: 8 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
const x = 5;
let result = 0;
let result = 0;

for (let i = 0; i < x; i++) {
if(x < result) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Czy faktycznie ten raunek jest tutaj potrzebny? Sam w sobie for m warunek, który zatrzymuje pętle.

x = x + result
}
console.log(result);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Wyświetlenie wyniku powinno być poza pętlą.

}