A newbie here! Wondering why the following conversion fails!
var num= prompt("Enter num");
Any of those should work better for you.
The issue is that the
Number objects overrides the
toString method of
Object objects to accept an optional radix as an argument to provide the functionality you are looking for. The
String object does not override
toString method, so any arguments passed in are ignored.
For more detailed information about these objects, see the docs at Mozilla:
or W3 schools: