Skip to content

Commit 3769466

Browse files
authored
Merge pull request #97 from otmon76/1.3.2
Coding Style
2 parents 0b64f0a + 220acc7 commit 3769466

File tree

4 files changed

+171
-171
lines changed

4 files changed

+171
-171
lines changed
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11

2-
You could note the following:
2+
Měli byste si všimnout následujícího:
33

44
```js no-beautify
5-
function pow(x,n) // <- no space between arguments
6-
{ // <- figure bracket on a separate line
7-
let result=1; // <- no spaces before or after =
8-
for(let i=0;i<n;i++) {result*=x;} // <- no spaces
9-
// the contents of { ... } should be on a new line
10-
return result;
5+
function mocnina(x,n) // <- chybí mezera mezi argumenty
6+
{ // <- levá složená závorka na zvláštním řádku
7+
let výsledek=1; // <- chybějí mezery před a za =
8+
for(let i=0;i<n;i++) {výsledek*=x;} // <- chybějí mezery
9+
// obsah { ... } by měl být na novém řádku
10+
return výsledek;
1111
}
1212

13-
let x=prompt("x?",''), n=prompt("n?",'') // <-- technically possible,
14-
// but better make it 2 lines, also there's no spaces and missing ;
15-
if (n<=0) // <- no spaces inside (n <= 0), and should be extra line above it
16-
{ // <- figure bracket on a separate line
17-
// below - long lines can be split into multiple lines for improved readability
18-
alert(`Power ${n} is not supported, please enter an integer number greater than zero`);
13+
let x=prompt("x?",''), n=prompt("n?",'') // <-- technicky je to možné,
14+
// ale lepší je to rozdělit na 2 řádky, navíc tam chybějí mezery a ;
15+
if (n<=0) // <- chybějí mezery uvnitř (n <= 0) a nad ním by měl být prázdný řádek
16+
{ // <- levá složená závorka na zvláštním řádku
17+
// níže - dlouhé řádky by měly být rozděleny na více řádků pro lepší čitelnost
18+
alert(`${n}-tá mocnina není podporována, zadejte prosím celé číslo větší než nula`);
1919
}
20-
else // <- could write it on a single line like "} else {"
20+
else // <- toto může být na jediném řádku: "} else {"
2121
{
22-
alert(pow(x,n)) // no spaces and missing ;
22+
alert(mocnina(x,n)) // chybějí mezery a ;
2323
}
2424
```
2525

26-
The fixed variant:
26+
Opravená varianta:
2727

2828
```js
29-
function pow(x, n) {
30-
let result = 1;
29+
function mocnina(x, n) {
30+
let výsledek = 1;
3131

3232
for (let i = 0; i < n; i++) {
33-
result *= x;
33+
výsledek *= x;
3434
}
3535

36-
return result;
36+
return výsledek;
3737
}
3838

3939
let x = prompt("x?", "");
4040
let n = prompt("n?", "");
4141

4242
if (n <= 0) {
43-
alert(`Power ${n} is not supported,
44-
please enter an integer number greater than zero`);
43+
alert(`${n}-tá mocnina není podporována,
44+
zadejte prosím celé číslo větší než nula`);
4545
} else {
46-
alert( pow(x, n) );
46+
alert( mocnina(x, n) );
4747
}
4848
```

1-js/03-code-quality/02-coding-style/1-style-errors/task.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ importance: 4
22

33
---
44

5-
# Bad style
5+
# Špatný styl
66

7-
What's wrong with the code style below?
7+
Co je špatného na stylu níže uvedeného kódu?
88

99
```js no-beautify
10-
function pow(x,n)
10+
function mocnina(x,n)
1111
{
12-
let result=1;
13-
for(let i=0;i<n;i++) {result*=x;}
14-
return result;
12+
let výsledek=1;
13+
for(let i=0;i<n;i++) {výsledek*=x;}
14+
return výsledek;
1515
}
1616

1717
let x=prompt("x?",''), n=prompt("n?",'')
1818
if (n<=0)
1919
{
20-
alert(`Power ${n} is not supported, please enter an integer number greater than zero`);
20+
alert(`${n}-tá mocnina není podporována, zadejte prosím celé číslo větší než nula`);
2121
}
2222
else
2323
{
24-
alert(pow(x,n))
24+
alert(mocnina(x,n))
2525
}
2626
```
2727

28-
Fix it.
28+
Opravte ho.

0 commit comments

Comments
 (0)