28 lines
369 B
Markdown
28 lines
369 B
Markdown
importance: 4
|
|
|
|
---
|
|
|
|
# Bad style
|
|
|
|
What's wrong with the code style below?
|
|
|
|
```js no-beautify
|
|
function pow(x,n)
|
|
{
|
|
let result=1;
|
|
for(let i=0;i<n;i++) {result*=x;}
|
|
return result;
|
|
}
|
|
|
|
let x=prompt("x?",''), n=prompt("n?",'')
|
|
if (n<=0)
|
|
{
|
|
alert(`Power ${n} is not supported, please enter an integer number greater than zero`);
|
|
}
|
|
else
|
|
{
|
|
alert(pow(x,n))
|
|
}
|
|
```
|
|
|
|
Fix it.
|