Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Radu Matees
@RaduMatees
hello there!
can someone take a look on my code ?:) I need some help, I am stuck at one of the advanced algorithms

function checkCashRegister(price, cash, cid) {
var change = cash - price;
var drawer = [];
var values = [
["ONE HUNDRED", 100.00],
["TWENTY", 20.00],
["TEN", 10.00],
["FIVE", 5.00],
["ONE", 1.00],
["QUARTER", 0.25],
["DIME", 0.10],
["NICKEL", 0.05],
["PENNY", 0.01]
];
var result = [];
for (i=cid.length-1; i>=0; i--){
drawer.push(cid[i]);
}
for (i=0; i<drawer.length; i++){ var temp = [drawer[i][0], 0]; while (change >= values[i][1] && drawer[i][1] - values[i][1] >= 0){
drawer[i][1] -= values[i][1];
change -= values[i][1];
temp[1] += values[i][1];
}
if (temp[1] > 0){
result.push(temp);
}
}
return result;
}

checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);

got to learn how to paste this
anyway, if you run the code in repl.it or other site, you will notice that the result, the change, is sometimes a bit off... not always, sometimes, at certain values.... don't seem to find any logic in them
especially if it has pennys in the change
Kevin K. Lee
@kevinkiklee
probably because of floating point numbers
computers are very very very bad at decimals.
try converting penny to 1. dollar to 100. and twenty to 2000 and such.
for example, open up devtools, or go into node repl
type this in: 0.1 * 0.2
Radu Matees
@RaduMatees

function checkCashRegister(price, cash, cid) {
  var change = cash - price;
  var drawer = [];
  var values = [
    ["ONE HUNDRED", 100.00],
    ["TWENTY", 20.00],
    ["TEN", 10.00],
    ["FIVE", 5.00],
    ["ONE", 1.00],
    ["QUARTER", 0.25],
    ["DIME", 0.10],
    ["NICKEL", 0.05],
    ["PENNY", 0.01]
  ];
  var result = [];
  for (i=cid.length-1; i>=0; i--){
    drawer.push(cid[i]);
  }
  for (i=0; i<drawer.length; i++){
    var temp = [drawer[i][0], 0];
    while (change >= values[i][1] && drawer[i][1] - values[i][1] >= 0){
      drawer[i][1] -= values[i][1];
      change -= values[i][1];
      temp[1] += values[i][1];
    }
    if (temp[1] > 0){
      result.push(temp);
    }
  }
  return result;
}


checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Kevin K. Lee
@kevinkiklee
see what you get for the asnwer
Radu Matees
@RaduMatees
ta-da!
Kevin K. Lee
@kevinkiklee
what was the problem?
Radu Matees
@RaduMatees
@kevinkiklee no, I just figured out how to correctly paste the code
good idea with decimals, I am looking into it right now
@kevinkiklee yes, it seems that 0.1 * 0.2 turn out really weird... didn't know that
I am reviewing my code
Kevin K. Lee
@kevinkiklee
Radu Matees
@RaduMatees
@kevinkiklee thank you very much, it's working now. I multiplied all by 100 for the duration of the algorithm, and returned the result/100 at the end
CamperBot
@camperbot
radumatees sends brownie points to @kevinkiklee :sparkles: :thumbsup: :sparkles:
api offline
Radu Matees
@RaduMatees
I am going to look more into the floating numbers problem now
Isaiah Trembley
@IsaiahCT
hey guys
don't be afraid to like the code lmao
Kaz Baig
@kbaig
@IsaiahCT Ahhh I finally get what you were going for hah
Kevin K. Lee
@kevinkiklee
yea, avoid floating numbers at all cost. when it comes to money, just use a value of 1 (a penny) as the base unit.
Ivan Ngundela
@ingundela
hello everyone, please advice me on this, should I always have my projects located at the local web server folder installed in my Mac? e.g I'm currently using MAMP on my Mac but I don't always use it unless I need to test for example a php code etc...
Isaiah Trembley
@IsaiahCT
man
nobody has seen the fridge.... HOW?
It's codevemeber what that balls
Aes
@CyberFistor
Hello Guys, i'm really struggling to make the image round i've tried everything i could and made several searches on internet but the image doesnt get completly round, if you could at least give me an hint you would be my savior ! https://codepen.io/cyberfistor/pen/QOLGKY
ADIL KARMOUZI
@mradil16
what parts of javascript do I need to know to build a website like this one : https://music.airfrance.com/en
Kaz Baig
@kbaig
@CyberFistor the usual way is border-radius: 50%;
you've got a round image on the left in the What Is Sorband section
micah4232
@micah4232
@kbaig That is correct @CyberFistor
delete all the other border properties you are trying to use they are making it look obscure like that

@CyberFistor delete all these: "-webkit-border-top-left-radius: 2000px;
-webkit-border-top-right-radius: 2000px;
-webkit-border-bottom-right-radius: 3000px;
-webkit-border-bottom-left-radius: 4000px;

-moz-border-radius-topleft: 2000px;
-moz-border-radius-topright: 2000px;
-moz-border-radius-bottomright: 3000px;
-moz-border-radius-bottomleft: 4000px;

border-top-left-radius: 2000px;
border-top-right-radius: 2000px;
border-bottom-right-radius: 3000px;
border-bottom-left-radius: 4000px;"

then add this: border-radius: 50%; and viola you got a circle image
hello community i have question...is it possible to make slider out of google drive folder?
micah4232
@micah4232
@CyberFistor like this: #gui{
text-align:right;
max-width:300px;
border-radius: 50%;
}
Aes
@CyberFistor
thx @kbaig
And thanks @micah4232 too :D
CamperBot
@camperbot
cyberfistor sends brownie points to @micah4232 :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @micah4232 |http://www.freecodecamp.com/micah4232
micah4232
@micah4232
yw enjoi the coding wish i had time to again...lol @CyberFistor
Aes
@CyberFistor
I've already tried 50% but the problem was that i couldn't put the text + photo on the right but i'm close to solve it
haha thanks :D !
ArthurM111
@FocusAndItCanBeDone
var worked,rate,amount;
worked = prompt("How many hours have you worked?");
rate = prompt("How much do you get paid per hour?");
var int_worked=parseInt(worked);
var int_rate=parseInt(rate);
amount=worked*rate
document.write=(amount);
can anyone help with this?