Front End Development Libraries Projects - Build a JavaScript Calculator

Tell us what’s happening:
Describe your issue in detail here.
I am stuck on the last test

## 15. My calculator should have several decimal places of precision when it comes to rounding (note that there is no exact standard, but you should be able to handle calculations like “2 / 7” with reasonable precision to at least 4 decimal places)

i have tried toFixed() and toPrecision() method but it doesnot seem to work

Your code so far
thank you for your reply
is it due to repeating decimal(285714)
link to codepen

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Front End Development Libraries Projects - Build a JavaScript Calculator

Link to the challenge:

I’m not sure how we can help you without seeing your code. Keep in mind that it says, “… to at least 4 decimal places”. You can have more precision than that, you just can’t have less, for example, you can’t round everything off to the nearest whole number.

I don’t understand why this isn’t working. When I look at the test code:

      it(`My calculator should have several decimal places of
      precision when it comes to rounding (note that there is no exact
      standard, but you should be able to handle calculations like "2 / 7" with
      reasonable precision to at least 4 decimal places)`, async function () {
        clickButtonsByIdWithDelay([_2, _div, _7, _eq], CLICK_DELAY);
        await timeout(DELAY);
        assert.isOk(
          /0?\.2857\d*/.test(getInputValue(document.getElementById('display'))),
          'The expression "2 / 7" should produce an output number with at ' +
            'least 4 decimal places of precision '
        );
      });

It looks like what you have should pass. When I log out what you are displaying there, it seems like it should pass.

Wait, it is trying to get the element with the id of “display”. When I inspect your DOM, I see this:

So, there might be a disconnect with how you’ve labeled your DOM elements and what the test is expecting.

thanks for all your help i was able to find the problem
the display was not showing the correct answer

the problem was the function i defined that does not allow multiple zero’s at the beggining

because of it when division that results in 0 at the start becomes empty string
and it shows error
thanks for your support