1

I have string "000" and I want to convert it to a number 000.

parseInt and Number parse it to 0.

I try this:

const number      = '0000';
const parseNumber = parseInt(number, 10);

console.log(parseNumber); // the output is 0 :/

thanks :)

1
  • Your string is 0000, not 000. Commented Aug 15 at 15:44

1 Answer 1

4

Actually, there is no way to do this because 000 is equivalent to 0! If you want to do some arithmetic operations then simply use 0. If you want to just output 000, then use it as a string.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I will use it as string thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.