Hi,
I am trying to build the calculator, but I have issues with user stories 11 (and 12).
If I allow multiple decimal points (which is of course not acceptable), I can pass user story 12 (operations on decimal numbers).
If I disable the button decimal after the first press:
if(event.target.innerHTML === '.')
document.getElementById("decimal").disabled = true;
and of course I re-eanble it when I press an operation or the equal sign, I still am not able to pass user story 11, and in addition I can pass user story 12 anymore!
But the calculator does its job: I can’t add more than one decimal per number, and I can perform calculations on decimal numbers…
Could anyone please help?
Here is my pen for reference:
https://codepen.io/simone-saimon-rossi/pen/LYbQWyr
Thank you
Kind regards
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
.
Challenge: Build a JavaScript Calculator
Link to the challenge:
miku86
March 3, 2021, 10:32am
2
Hey Simone,
great work so far!
You can have a look at the tests and how they work:
import { assert } from 'chai';
import { clickButtonsById, getInputValue } from '../utils/element-utils';
import { frontEndLibrariesStack } from '../utils/shared-test-strings';
export default function createCalculatorTests() {
const _1 = 'one';
const _2 = 'two';
const _3 = 'three';
const _4 = 'four';
const _5 = 'five';
const _6 = 'six';
const _7 = 'seven';
const _8 = 'eight';
const _9 = 'nine';
const _0 = 'zero';
const _x = 'multiply';
const _plus = 'add';
const _min = 'subtract';
const _div = 'divide';
const _AC = 'clear';
This file has been truncated. show original
Because debugging is a very valuable skill to learn, try to understand the tests on your own and let us know if you need some help.
This is speculation, but I’m thinking he test may not like that you are disabling the button because what it ends up seeing is a non function decimal button
Solved!
I didn’t re-enable the button “decimal” when I press “Clear”… This solved both user stories!
Thank you both!
system
Closed
September 1, 2021, 11:07pm
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.