fixed bug in JS example code