Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:32
    User @bjorno43 unbanned @linkin-park
  • 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
  • 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
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
@kurzninja how about voice recognition
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
How about blinks from webcam
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
}
// Add record here
];

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

Can anyone help me?
I don't understand this prob
when I add code, it keep saying ] is expected.
Franco Zapata
@Francozt01
@misonam03 u just have to add a new album , whatever u want following the structure of the array myMusic

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

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

Salman Shahid
@salman-shahid
@misonam03 I think instructions are to add a new album. The array structure is [ {}, {}]
Franco Zapata
@Francozt01
wrong....
send what i copied
lol
pikachu
@misonam03
@Francozt01 tried to add new album,
it says they expect ]
not strings
Franco Zapata
@Francozt01
@misonam03 give me the link to the exercise
Salman Shahid
@salman-shahid
@misonam03 Here's an explanation of the myMusic structure. [ {albumEntry1}, {albumEntry2} ]