typos + clean-up wording
This commit is contained in:
parent
1bd8f97e4b
commit
1e28ff8978
1 changed files with 4 additions and 4 deletions
|
@ -4,22 +4,22 @@ You could note the following:
|
||||||
```js no-beautify
|
```js no-beautify
|
||||||
function pow(x,n) // <- no space between arguments
|
function pow(x,n) // <- no space between arguments
|
||||||
{ // <- figure bracket on a separate line
|
{ // <- figure bracket on a separate line
|
||||||
let result=1; // <- no spaces to the both sides of =
|
let result=1; // <- no spaces before or after =
|
||||||
for(let i=0;i<n;i++) {result*=x;} // <- no spaces
|
for(let i=0;i<n;i++) {result*=x;} // <- no spaces
|
||||||
// the contents of { ... } should be on a new line
|
// the contents of { ... } should be on a new line
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
let x=prompt("x?",''), n=prompt("n?",'') // <-- technically possible,
|
let x=prompt("x?",''), n=prompt("n?",'') // <-- technically possible,
|
||||||
// but better make it 2 lines, also there's no spaces and ;
|
// 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
|
if (n<0) // <- no spaces inside (n < 0), and should be extra line above it
|
||||||
{ // <- figure bracket on a separate line
|
{ // <- figure bracket on a separate line
|
||||||
// below - a long line, may be worth to split into 2 lines
|
// below - long lines can be split into multiple lines for improved readability
|
||||||
alert(`Power ${n} is not supported, please enter an integer number greater than zero`);
|
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 // <- could write it on a single line like "} else {"
|
||||||
{
|
{
|
||||||
alert(pow(x,n)) // no spaces and ;
|
alert(pow(x,n)) // no spaces and missing ;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue