|
1 | 1 |
|
2 | | -You could note the following: |
| 2 | +Podrías notar lo siguiente: |
3 | 3 |
|
4 | 4 | ```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 |
| 5 | +function pow(x,n) // <- sin espacio entre argumentos |
| 6 | +{ // <- llave en una línea separada |
| 7 | + let result=1; // <- sin espacios antes o después de = |
| 8 | + for(let i=0;i<n;i++) {result*=x;} // <- sin espacios |
| 9 | + // el contenido de {...} debe estar en una nueva línea |
10 | 10 | return result; |
11 | 11 | } |
12 | 12 |
|
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 |
| 13 | +let x=prompt("x?",''), n=prompt("n?",'') // <-- técnicamente posible, |
| 14 | +// pero mejor que sea 2 líneas, también no hay espacios y falta ; |
| 15 | +if (n<0) // <- sin espacios dentro (n < 0), y debe haber una línea extra por encima |
| 16 | +{ // <- llave en una línea separada |
| 17 | + // debajo - las líneas largas se pueden dividir en varias líneas para mejorar la legibilidad |
18 | 18 | alert(`Power ${n} is not supported, please enter an integer number greater than zero`); |
19 | 19 | } |
20 | | -else // <- could write it on a single line like "} else {" |
| 20 | +else // <- podría escribirlo en una sola línea como "} else {" |
21 | 21 | { |
22 | | - alert(pow(x,n)) // no spaces and missing ; |
| 22 | + alert(pow(x,n)) // sin espacios y falta ; |
23 | 23 | } |
24 | 24 | ``` |
25 | 25 |
|
26 | | -The fixed variant: |
| 26 | +La variante fija: |
27 | 27 |
|
28 | 28 | ```js |
29 | 29 | function pow(x, n) { |
|
0 commit comments