JS Example: see weighting in action