Browser doesnt observe classic pemdas

What is your hint or solution suggestion?

The browser doesn’t observe classic PEMDAS. It’s running PE(MD)(AS). Which means 4878 has a solution NOT in the tests… (4-8+7)*8.

If addition has no priority over subtraction 4-8 = -4, -4 + 7 = 3, 3 * 8 = 24. Unless you expect students to additionally implement a subroutine to evaluate strings via classic PEMDAS, you need to update the tests.

Challenge: 24 game

Link to the challenge:

Do you actually have some code that demonstrates that a function that returns such a string fails. That would help.

All valid solution codes should use PEMDAS, that is the default evaluation for nearly every programming language. Allthough the test page does not list all 10 valid result strings, it does check for them.

Didn’t see it fail, and in the end it didn’t. I just saw it coming back in a console.log() before running the test suite, but seeing the list to the left that said it must match one of two expressions.

"solve24("4878") should return (7-8/8)*4 or 4*(7-8/8)" doesn’t leave room for more possibilities. It could be worded better.

Sure, it probably could use better wording, though I wouldn’t list all 10 possibilities. That would be messy. Do you have a better wording in mind?