[object Object]

← back to Nationalrealestate

Fix watchlist.html crash: v.toFixed on string values

63d794eefd152213d4c29dce1c0170296d71efa8 · 2026-08-19 13:23:12 -0700 · Steve

The API returns score/pct/usd as strings, but the fmt formatters called
v.toFixed()/Math.round(v) directly — 'v.toFixed is not a function' broke the
page render. Coerce with +v and NaN-guard all three. Found via the RE-fleet
crash smoke.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 63d794eefd152213d4c29dce1c0170296d71efa8
Author: Steve <steve@designerwallcoverings.com>
Date:   Wed Aug 19 13:23:12 2026 -0700

    Fix watchlist.html crash: v.toFixed on string values
    
    The API returns score/pct/usd as strings, but the fmt formatters called
    v.toFixed()/Math.round(v) directly — 'v.toFixed is not a function' broke the
    page render. Coerce with +v and NaN-guard all three. Found via the RE-fleet
    crash smoke.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 public/watchlist.html | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/public/watchlist.html b/public/watchlist.html
index 8be9c95..8dc1372 100644
--- a/public/watchlist.html
+++ b/public/watchlist.html
@@ -84,9 +84,11 @@ let regions = [];
 let selected = null;
 
 const fmt = {
-  score: v => v==null?'—':v.toFixed(1),
-  usd: v => v==null?'—':'$'+Math.round(v).toLocaleString(),
-  pct: v => v==null?'—':(v*100).toFixed(1)+'%',
+  // coerce + NaN-guard: watchlist values arrive as strings from the API, so a bare
+  // v.toFixed() threw "v.toFixed is not a function" and broke the page render.
+  score: v => (v==null||isNaN(+v))?'—':(+v).toFixed(1),
+  usd: v => (v==null||isNaN(+v))?'—':'$'+Math.round(+v).toLocaleString(),
+  pct: v => (v==null||isNaN(+v))?'—':(+v*100).toFixed(1)+'%',
   num: v => v==null?'—':(+v).toLocaleString(),
 };
 

← 95e9e65 auto-data-snapshot: 2026-08-19T03:46:07 (1 data files) — dat  ·  back to Nationalrealestate  ·  chore: v0.20.1 (session close — watchlist toFixed crash fix; b4ad42f →