fixed JS Example to include more of surrounding needed code as a fuller example.