Calculator reload

Calculator reload
0

#1

hi guys this Calculator challenge https://codepen.io/webster123/full/VyNPjN/
please checkout and give your suggestion:eyeglasses:
please try to reload the to check what happen:fireworks:


#2

Very fancy! Way prettier than mine. Your code is much more logical/clean than mine, too. How long (roughly) did it take you to make it?


#3

Thank you , it’s take 8-9 hour but if I remove the 2 hrs because I mass with the CSS then 6-7 hrs☺️


#4

You have some issues.

#1) I should not be able to enter consecutive operators or decimal points such as 2…6++++3****4. It gives me an error (which makes sense), but it should not even allow me to make such an entry.

#2) If I enter 1 / 3 = the result is 0.3333333333333333 If I then enter * 3, I should get 1, but instead it shows error.

#3) Did you intend for your Close button to be positioned in a specific location relative to the calculator? When I view it on a desktop pc, I see the following.

When I view it on a smaller screen, things are not centered as I would expect them to be (see below):


#5

Thank you for mentioning issues in my calculator.I resolve last 2 issues that you mention and i am trying resolve remaining issue.


#7

I reviewed your calculator again. Now, if I type 1 /3 and hit = I get error instead 0.33333333333


#8

FYI - You could get rid of a lot of repetitive code by replacing:

  $(".bt1").click(function() {
    $(".textcal").val($(".textcal").val() + "1");
  });
  $(".bt2").click(function() {
    $(".textcal").val($(".textcal").val() + "2");
  });
  $(".bt3").click(function() {
    $(".textcal").val($(".textcal").val() + "3");
  });
  $(".bto3").click(function() {
    $(".textcal").val($(".textcal").val() + "+");
  });
  $(".bt4").click(function() {
    $(".textcal").val($(".textcal").val() + "4");
  });
  $(".bt5").click(function() {
    $(".textcal").val($(".textcal").val() + "5");
  });
  $(".bt6").click(function() {
    $(".textcal").val($(".textcal").val() + "6");
  });
  $(".bt7").click(function() {
    $(".textcal").val($(".textcal").val() + "7");
  });
  $(".bt8").click(function() {
    $(".textcal").val($(".textcal").val() + "8");
  });
  $(".bt9").click(function() {
    $(".textcal").val($(".textcal").val() + "9");
  });
  $(".bt0").click(function() {
    $(".textcal").val($(".textcal").val() + "0");
  });
  $(".bt00").click(function() {
    $(".textcal").val($(".textcal").val() + "00");
  });
  $(".btd").click(function() {
    $(".textcal").val($(".textcal").val() + ".");
  });
  $(".bto1").click(function() {
    $(".textcal").val($(".textcal").val() + "%");
  });
  $(".bto2").click(function() {
    $(".textcal").val($(".textcal").val() + "/");
  });
  $(".bto4").click(function() {
    $(".textcal").val($(".textcal").val() + "-");
  });
  $(".bto5").click(function() {
    $(".textcal").val($(".textcal").val() + "*");
  });

with the following which will select all the elements with class=‘btn’ which do not have a class=‘bto6’ (the equal sign button).

  $('.btn').not('.bto6').click(function() {
    $(".textcal").val($(".textcal").val() + $(this).text()); 
  });

#9

Thank you for giving a suggestion .I have improved the code and you can see again .


#10

Your calculator still allows me to enter consecutive operators and decimal points. You need to think about how you could prevent the user from entering such cases.