We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7853aff + 1db3ed0 commit efc7829Copy full SHA for efc7829
examples/ballmer-peak/example.js
@@ -10,6 +10,10 @@ function computeBallmerPeak(x) {
10
) / 1.6;
11
}
12
13
+function percentage(x) {
14
+ return isNaN(x) ? 'N/A' : (100 - Math.round(x * 100)) + '%';
15
+}
16
+
17
var BallmerPeakCalculator = React.createClass({
18
getInitialState: function() {
19
return {bac: 0};
@@ -18,12 +22,7 @@ var BallmerPeakCalculator = React.createClass({
22
this.setState({bac: event.target.value});
23
},
20
24
render: function() {
21
- var pct = computeBallmerPeak(this.state.bac);
- if (isNaN(pct)) {
- pct = 'N/A';
- } else {
25
- pct = (100 - Math.round(pct * 100)) + '%';
26
- }
+ var pct = percentage(computeBallmerPeak(this.state.bac));
27
return (
28
<div>
29
<img src="./ballmer_peak.png" />
0 commit comments