Created
July 5, 2016 04:31
-
-
Save edinsoncs/9c7ba59bf08e7197521e3f1da73f2169 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Document</title> | |
| </head> | |
| <body> | |
| <script> | |
| var question = prompt("0 Parseint - 1 toFixed - 2 Parse Float") | |
| var miNumber = convertNumber("50", question); | |
| verify(miNumber); | |
| function verify(scan) { | |
| if (typeof scan) { | |
| console.log(typeof scan + " " + scan); | |
| } | |
| } | |
| /** | |
| * convertNumber function return string to number | |
| */ | |
| function convertNumber(number, question) { | |
| if (question == 0) { | |
| //Convert Number One Form | |
| return parseInt(number); | |
| } else if (question == 1) { | |
| return number.toFixed(0); | |
| } else { | |
| return parseFloat(number); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment