Build a JavaScript Calculator \n character issue

Build a JavaScript Calculator \n character issue
0

#1

Tell us what’s happening:
I’ve finished my JS calculator and everything is working as intended, however I’m failing more than half the test on a technicality. For some reason, my button and display elements have a \n character at the end of them, but I’m not sure which part of my code is adding those new lines in. So, I’m getting errors like "expected '=\n' to equal '='" for my #equals button, and the same for my #display, #decimal, etc. How can I avoid this \n being added in?

Your browser information:

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

Link to the challenge:


#2

It passes the tests for me.

I actually don’t really know the assignment but i do have a question, how is it supposed to handle chaining? If i do 4 + 5 * 2 should it not do (4 + 5) * 2 and not 4 + (5 * 2).


#3

There are at least two methods in which a calculator can calculate a sequence of operands and operators. Take a look at the challenge which explains the two methods.


#4

Weird, I get only 6/16 test passed and all the failed tests are due to the \n being added.

As for the chaining, the challenge itself actually mentions that there are two ways to implement calculator logic, called immediate execution logic and formula logic. The example given uses the same logic as my implementation, which is formula logic.


#5

What browser are you using? Can you show a screenshot after you click Run Tests?


#6

Chrome Version 70.0.3538.16 (Official Build) beta (64-bit)

Sure, not sure how much of the page you need.


#7

Interesting. When I run the tests, I get the same result as the OP. I will have to think about how that is possible.


#8

I tried a few things, nothing changes, it still passes.

  1. I ran Chrome in incognito mode and it still passes, so it’s not an extension issue.
  2. Cleared the browser, closed and reopened, same thing.
  3. Ran Chrome sandboxed using sandboxie, same thing.

Don’t think i have seen this happen before, with other tests.


#9

I just tried it in Microsoft Edge and all the tests are passing, miraculously. This is a really weird issue. If anyone manages to figure out what’s going on here, please let me know.

Edit: Working fine in the latest version of Firefox as well.


#10

I installed Chrome Canary (nightly build), and it still passes the test.

Then i ran it in Vivaldi (Chrome/69.0.3497.93) and it fails the test (6/16).