0

we have string input number input="6145390195186705543" if we want to convert to number ;java Script auto rounded this input;

(6145390195186705543)

(6145390195186705000)

2

1 Answer 1

0

This should work for what you are trying to achieve

const myFunction = (num) => {

const length = num.length;

const result = `(${num.slice(0,16).padEnd(length, "0")})`;
return result;
};

const input="6145390195186705543";
const output = myFunction(input); 
console.log(output)

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

2 Comments

this answer is have rounded the string input
@mahdiyarjafari oh I see, check the edited snippet; I have done the correction

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.