Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- /**
- * This is one way to do constants in JS
- * Constants are usually UPPERCASE but I put a fail-safe in to accept UPPER, lower and MixED cASe
- * Also did a parseFloat on the return, which may not strictly be necessary - MMXIV Donkeysoft
- */
- function constants(type) {
- _c = [];
- _c["ft"] = 0.3048;
- _c["pi"] = 3.1415;
- return parseFloat( _c[ type.toLowerCase() ] )
- }
- console.log( "There are exactly " + constants("FT") + "metres to the foot" );
- console.log( "The value of PI is exactly " + constants("PI") );
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement