Skip to content

Commit

Permalink
replaced string parsing with fixed float
Browse files Browse the repository at this point in the history
  • Loading branch information
roaldchristesen committed Oct 9, 2023
1 parent 526e2a8 commit 5986f9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Controller, Component } from '@sndcds/mvc'
export default class App extends Controller {
constructor(model, view) {
super(model, view)

this.onDistrictChanged = this.onDistrictChanged.bind(this) // TODO: Description!
}

Expand Down Expand Up @@ -201,9 +200,10 @@ export default class App extends Controller {

static floatToString(value, decimals) {
// TODO: Check! Is there a better/faster method?
// TODO: Rename and move to controller
if (decimals === undefined) {
decimals = 2
}
return value.toLocaleString('en-US', { style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: decimals })
return parseFloat(value.toFixed(decimals))
}
}
Loading

0 comments on commit 5986f9d

Please sign in to comment.