Writing a JavaScript Program to 'Measure' Text