by

## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jun 19 20:09
@krisb1220 banned @Gastony
• May 14 22:39
• May 14 22:38
@bjorno43 banned @real-action
• Feb 01 00:27
@bjorno43 banned @Ndoua
• Jan 07 03:10
@bjorno43 banned @doctor-sam
• Aug 17 2019 09:32
• Jun 20 2019 21:19
@bjorno43 banned @shenerd140
• Apr 25 2019 17:13
@mstellaluna banned @cmal
• Jan 08 2019 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
Alex Evans
@alex-evans
Can someone help me out with the "Exact Change" challenge? I'm confused by how it is pointing me towards using Global Objects. I'm sure there is a reason as I'm writing the answer without them currently and it is ugly but I'm not grasping how the Global Objects will help simplify it. Any pointers?
For example I currently have the following:
function drawer(price, cash, cid) {
var change = cash - price;
var total = cid[0][1] + cid[1][1] + cid[2][1] + cid[3][1] + cid[4][1] + cid[5][1] + cid[6][1] + cid[7][1] + cid[8][1];

if(total < change) {
return "Insufficient Funds";

} else if(total == change) {
return "Closed";

} else {
return ...;    // will determine exact change at this point and things get very very messy
}
}

drawer(19.50, 20.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]]);
JackeL
@jackel27
So, I finished the calculator challenge.. spent around 4 hours on it.. but could use a few fixes on layout adjustment....
Brett Guillory
@kurzninja
currently working on the Calculator myself
Sam Reeves
@smreeves
Also just finished the calc challenge. Starting to feel pretty comfortable with jQuery now...
Salman Shahid
@salman-shahid
The calculator is annoying.. a lot of error checking
JackeL
@jackel27
@mynameissal what type of error checking?
Brett Guillory
@kurzninja
I'm just starting to work on the value entry logic
trying to figure out how I want to do this
Salman Shahid
@salman-shahid
@kurzninja I made 2 plans then I decided to #yolo
Brett Guillory
@kurzninja
lol
Salman Shahid
@salman-shahid
@jackel27 Mostly math logic
JackeL
@jackel27
@mynameissal check out eval
Salman Shahid
@salman-shahid
and things like character limit checks, checks to see if there are no operators back to back..
JackeL
@jackel27
hmm
Salman Shahid
@salman-shahid
I am using eval but I have to make sure I don't have things like 1++1
JackeL
@jackel27
good point. I did not do that, I figured taking the string into an expression and returning it back would be fine... even if it was 6**6
Salman Shahid
@salman-shahid
Really.. hmm
Brett Guillory
@kurzninja
I'm thinking about implementing some kind of event subscription to determine what button is being pressed, and passing the value of that button to an assignment controller
so if it's a number, it possibly goes into or replaces the current operand
if it's an operator, it goes into my currOp function
var currOp = function() {

if (arguments[0]) {
this.value = arguments[0];
return;
} else {
return this.value;
}
};
Salman Shahid
@salman-shahid
@jackel27
console.log(eval("1--1"));
SyntaxError: invalid decrement operand 1--1
@kurzninja I see, also depends on how you want your calculator works.
JackeL
@jackel27
@mynameissal good point.. I will have to work on that myself
Salman Shahid
@salman-shahid
E.g. do you want to display the whole line of calculations and evaluate when user presses = or evalulate after an operation..
Brett Guillory
@kurzninja
that's what I was wondering too
it looks like in the example, it doesn't evaluate until you hit =
but different calculators work differently
Salman Shahid
@salman-shahid
I think the second option is easier but each have their own difficulties.
Yeah, I am going with first option
JackeL
@jackel27

heres mine.. need to work on a few things though.. best viewed in browser...

http://codepen.io/Jackel27/pen/obQoRN

Brett Guillory
@kurzninja
if you want a real challenge, try implementing the user being able to type in the numbers on their keyboard as well as clicking on the page ;)
JackeL
@jackel27
Salman Shahid
@salman-shahid
@jackel27 Looks good this is the errors I pick up: multiple decimal places and the one I mentioned earlier.
Brett Guillory
@kurzninja
hahaha
JackeL
@jackel27
@mynameissal yeah, I noticed that also. I will have to do a check on last char in string
Salman Shahid
@salman-shahid
Brett Guillory
@kurzninja
set up a variable that checks to see if the current operation has had a decimal input, and ignore any after that
JackeL
@jackel27
@kurzninja can't do that. cause user could type 24.4 * 43.92
@kurzninja well, in my code anyways. I could get away with blocking consecutive decimals... but what if user has 24.4.4.4 lol
Brett Guillory
@kurzninja
well once an operator is selected, it's a new operand being entered
so that shouldn't be a problem
Salman Shahid
@salman-shahid
The way I combated that was set a current variable. So I check if there is a dot in the current variable. If none set dot. When a user clicks an operator the current variable is reset.
Brett Guillory
@kurzninja
Hmmm
JackeL
@jackel27
hmm. I'll have to improve my calculator to be more FP
Salman Shahid
@salman-shahid
Current variable is seperate from finalevaluation string
Brett Guillory
@kurzninja
I think I might do this with a simple array
pikachu
@misonam03
Add a new album to the myMusic JSON object. Add artist and title strings, release_year number, and a formats array of strings.

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}