These are chat archives for FreeCodeCamp/Help

12th
Nov 2017
Kyle Holm
@thekholm80
Nov 12 2017 01:07 UTC
@daddycardona if you ask 5 devs what the best text editor is, you'll get 5 different answers. At the end of the day just use what works best for you
for me, it's Atom
lion18
@lion18
Nov 12 2017 04:23 UTC

Hi
Can anyone tell me what's wrong in this code https://codepen.io/lion18/pen/yzrKQw

that when I click on the temperature, it gets converted from Celsius to Farenheit once but doesn't respond after that.
Basically, it's just does it one time, doesn't get looped.
_

Darren
@DarrenfJ
Nov 12 2017 08:29 UTC
evening fCC
quiet night :D
@daddycardona sorry brutha i just missed yah.. hope the algo's are still rawkin' :D
Ene Catalin
@EneCatalin
Nov 12 2017 09:08 UTC
@thekholm80 that's like, so wrong, they will all say something from jetbrains
@daddycardona google jetbrains and pick one
heroiczero
@heroiczero
Nov 12 2017 10:29 UTC

@lion18 Well it seems you got it working, but you may want to look into an icon. it should be under your icon in your API. From this response example:

{ "coord":{ "lon":159, "lat":35 }, "weather":[ { "id":500, "main":"Rain", "description":"light rain", "icon":"https://cdn.glitch.com/6e8889e5-7a72-48f0-a061-863548450de5%2F10n.png?1499366021399" } ], "base":"stations", "main":{ "temp":22.59, "pressure":1027.45, "humidity":100, "temp_min":22.59, "temp_max":22.59, "sea_level":1027.47, "grnd_level":1027.45 }, "wind":{ "speed":8.12, "deg":246.503 }, "rain":{ "3h":0.45 }, "clouds":{ "all":92 }, "dt":1499521932, "sys":{ "message":0.0034, "sunrise":1499451436, "sunset":1499503246 }, "id":0, "name":"", "cod":200 }

or you could use a custom background and use a switch or something.

primuscovenant
@primuscovenant
Nov 12 2017 11:04 UTC
@heroiczero thx
CamperBot
@camperbot
Nov 12 2017 11:04 UTC
primuscovenant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2053 | @heroiczero |http://www.freecodecamp.com/heroiczero
Marc
@MWBauer
Nov 12 2017 13:24 UTC
Morning everyone!
Stephen James
@sjames1958gm
Nov 12 2017 14:11 UTC
@MWBauer hello
Long Nguyen
@longnt80
Nov 12 2017 14:12 UTC
good evening
about to go to sleep
Ken Haduch
@khaduch
Nov 12 2017 14:29 UTC
@longnt80 - hey there - how's the new job going?
@MWBauer - good morning...
Long Nguyen
@longnt80
Nov 12 2017 14:56 UTC
@khaduch I'll start next week
@khaduch but I had a short visit last Friday with them and had lunch with the team
the culture is pretty cool, no corporate attitude, seems just like a group of friends that do something together
Uriel Guzmán
@Burinson
Nov 12 2017 19:18 UTC
function checkCashRegister(price, cash, cid) {
  var currency = {
   "PENNY": 0.01, 
   "NICKEL": 0.05,
   "DIME": 0.10, 
   "QUARTER": 0.25, 
   "ONE": 1.00, 
   "FIVE": 5.00, 
   "TEN": 10.00, 
   "TWENTY": 20.00, 
   "ONE HUNDRED": 100.00
  };
  var currArr = [];
  for (var c in currency) {
    currArr.push(currency[c]);
    // Push all the currency values.
  }

  var cidArr = [];
 for (var i in cid) {
   for (var x in cid[i]);
  cidArr.push(cid[i][x]);
   // Push all the cash in drawer values.

 }

  var result = [];
  var howMany = currArr.concat(cidArr);
  for (var z = 9; z < howMany.length; z++) {
    result.push(howMany[z] / howMany[z-9]);
    // Push how many of each currency the cash in drawer has.   
  }

   var difference = cash - price; // Change.

  var keys = Object.keys(currency); // Names of currency
var backwards = keys.reverse(); // Greater to smaller

  var value;
for (var y = 0; y < backwards.length; y++) {

  var valuesReversed = currency[backwards[y]];

   if (difference % valuesReversed !== difference) { 
     // Return the greatest divisible number of the change.
       value = valuesReversed; 
     break;
    } 
}

  var name;

  for (var v in currency) {
    if (currency[v] === value) {
      name = v;
      // Name of the currency to give back.
    }
  }

  var have = "";
  for (var h in cid) {
    if (cid[h][0] === name) {
      have = cid[h][1];
      // How much money of that currency type is in the drawer.
    }    
  }
 var change;
  var give;
  var newDiff;
  if (difference > have) {
    // If there is more change than currency of that type in the register...
    newDiff = difference - have;
    // Difference between change and how much we have.
    change = difference - newDiff;
    // Return the maximum amount of money for that currency type.   
  }  

  return [[name, change]];

} 

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]]);
How can I repeat this function until there no more change left?
heroiczero
@heroiczero
Nov 12 2017 19:28 UTC
@Burinson you usually use for ... in for properties in a object. cid is a array.
alpox
@alpox
Nov 12 2017 19:43 UTC
@heroiczero thats no problem, its used on arrays as well for convenience
heroiczero
@heroiczero
Nov 12 2017 19:46 UTC

@Burinson if you want just the values for each amount. i would

for(let i =0;i<cid.length;i++){
    cidArr.push(cid[i][1]);
}
cidArr.reverse();

this will give you the values of each amount and reverse it since you are reversing currency. You should systematically subtract from the cash in drawer or cid, so it would be changeGiven-cid starting from the largest and if it not enough, you cannot give the change. Or, something like that

@alpox reason i said usually :)
Uriel Guzmán
@Burinson
Nov 12 2017 19:49 UTC
I wanted to do something like that, but my function doesn't modify the cid argument
Ravi Kishore Thella
@ravikishorethella
Nov 12 2017 19:49 UTC
@longnt80 all the best buddy
Uriel Guzmán
@Burinson
Nov 12 2017 19:50 UTC
I want some kind of loop or something that keeps updating difference until the remainder === 0
heroiczero
@heroiczero
Nov 12 2017 19:52 UTC
@Burinson yeah, you are on the right track. how would you do that? The cashier gives change from highest to lowest. So you "subtract" from the cash in drawer.
Uriel Guzmán
@Burinson
Nov 12 2017 19:52 UTC
First, the change is 96.74, then it should subtract the change given (in this case, 60) and difference would be updated to 36.74 because allthough 36.74 can give me another twenty dollar bill... there are no more twenty dollar bills
I don't know :(
heroiczero
@heroiczero
Nov 12 2017 19:54 UTC
@Burinson do you have 10 dollar bills?
Uriel Guzmán
@Burinson
Nov 12 2017 19:54 UTC
Yes
I want it to move on to the 10 dollar bills after the first iteration of my imaginary loop
Because the twenty dollar ones would now be empty
heroiczero
@heroiczero
Nov 12 2017 19:59 UTC
Wouldn't you use two loops to go through your dollar bills?
Uriel Guzmán
@Burinson
Nov 12 2017 20:02 UTC
Not that I planned to do so
heroiczero
@heroiczero
Nov 12 2017 20:07 UTC
@Burinson well you should try implementing your imaginary loop. Should be subtracting from difference and it should be adding in the amount that you are trying to return. The amount is the change that you have to return. Well, I got to run. Got some tasks that i have to do. Good luck :+1:
Darren
@DarrenfJ
Nov 12 2017 21:10 UTC
afternoon fCC
@longnt80 oh yah i think i did but if i forgot congrats on the new job brutha!
Ken Haduch
@khaduch
Nov 12 2017 21:47 UTC
@DarrenfJ - howdy Darren - how are things?
Uriel Guzmán
@Burinson
Nov 12 2017 22:29 UTC
@heroiczero Alright, thanks. I made consecutive if statements, subtracting from difference each time it passed a condition
CamperBot
@camperbot
Nov 12 2017 22:29 UTC
burinson sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2055 | @heroiczero |http://www.freecodecamp.com/heroiczero
Long Nguyen
@longnt80
Nov 12 2017 22:47 UTC
@ravikishorethella thanks
CamperBot
@camperbot
Nov 12 2017 22:47 UTC
longnt80 sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:star2: 1056 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Long Nguyen
@longnt80
Nov 12 2017 22:48 UTC
@DarrenfJ yes you did, thanks again :+1:
CamperBot
@camperbot
Nov 12 2017 22:48 UTC
:star2: 2269 | @darrenfj |http://www.freecodecamp.com/darrenfj
longnt80 sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles: