Skip to content
Merged
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
28 changes: 14 additions & 14 deletions 1-js/03-code-quality/02-coding-style/1-style-errors/solution.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@

You could note the following:
Podrías notar lo siguiente:

```js no-beautify
function pow(x,n) // <- no space between arguments
{ // <- figure bracket on a separate line
let result=1; // <- no spaces before or after =
for(let i=0;i<n;i++) {result*=x;} // <- no spaces
// the contents of { ... } should be on a new line
function pow(x,n) // <- sin espacio entre argumentos
{ // <- llave en una línea separada
let result=1; // <- sin espacios antes o después de =
for(let i=0;i<n;i++) {result*=x;} // <- sin espacios
// el contenido de {...} debe estar en una nueva línea
return result;
}

let x=prompt("x?",''), n=prompt("n?",'') // <-- technically possible,
// but better make it 2 lines, also there's no spaces and missing ;
if (n<0) // <- no spaces inside (n < 0), and should be extra line above it
{ // <- figure bracket on a separate line
// below - long lines can be split into multiple lines for improved readability
let x=prompt("x?",''), n=prompt("n?",'') // <-- técnicamente posible,
// pero mejor que sea 2 líneas, también no hay espacios y falta ;
if (n<0) // <- sin espacios dentro (n < 0), y debe haber una línea extra por encima
{ // <- llave en una línea separada
// debajo - las líneas largas se pueden dividir en varias líneas para mejorar la legibilidad
alert(`Power ${n} is not supported, please enter an integer number greater than zero`);
}
else // <- could write it on a single line like "} else {"
else // <- podría escribirlo en una sola línea como "} else {"
{
alert(pow(x,n)) // no spaces and missing ;
alert(pow(x,n)) // sin espacios y falta ;
}
```

The fixed variant:
La variante fija:

```js
function pow(x, n) {
Expand Down
6 changes: 3 additions & 3 deletions 1-js/03-code-quality/02-coding-style/1-style-errors/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 4

---

# Bad style
# Estilo pobre

What's wrong with the code style below?
¿Qué hay de malo con el estilo de código a continuación?

```js no-beautify
function pow(x,n)
Expand All @@ -25,4 +25,4 @@ else
}
```

Fix it.
Arreglalo.
Loading