EDITABLE CODE:
LiveDemo: JavaScript String Object : Properties
Note: Always use Math object instead of regular JavaScript Code.