These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Jan 2017
alican karalar
@alicankaralar
Jan 26 2017 00:00
i already passed this one but i want a better way to do it so you are being immensely helpful thank you @DanCouper
CamperBot
@camperbot
Jan 26 2017 00:00
alicankaralar sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: alicankaralar already gave dancouper points
CoryCMyers
@CoryCMyers
Jan 26 2017 00:01
@DanCouper @JLuboff Thanks for the help so far
CamperBot
@camperbot
Jan 26 2017 00:01
corycmyers sends brownie points to @dancouper and @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 707 | @jluboff |http://www.freecodecamp.com/jluboff
:cookie: 459 | @dancouper |http://www.freecodecamp.com/dancouper
CoryCMyers
@CoryCMyers
Jan 26 2017 00:01
Now i am trying to figure out where my error is, the things I normally miss are all present

function rot13(str) { // LBH QVQ VG!
   var arr = [];
  for (var i = 0; i < str.length; i++); 
     if ( str[i].charCodeAt() >= 65 && <= 78 ) {
       arr.push(value + 13);
     } else {
       arr.push(value);
   } 

  return arr.toLocaleString().fromCharCode() ;

}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Moisés Man
@moigithub
Jan 26 2017 00:02
@CoryCMyers what 65 and 78 means ?
CoryCMyers
@CoryCMyers
Jan 26 2017 00:02
@moigithub Unicode value
Dan Couper
@DanCouper
Jan 26 2017 00:03
Right, first thing is, the range of character codes A-M is 65 to 77
If you add 13 to 78
you get [
as 78 is N
so you want to change the 78 down one
CoryCMyers
@CoryCMyers
Jan 26 2017 00:04
@DanCouper got that.
Dan Couper
@DanCouper
Jan 26 2017 00:05
So now you can add another else if in now which covers 78 to 90
CoryCMyers
@CoryCMyers
Jan 26 2017 00:05
I thought I wanted to just get 78 through 90 for the value, and convert it back with .fromCharCode?
Jason Luboff
@JLuboff
Jan 26 2017 00:05
str[i].charCodeAt() >= 65 && <= 78 we need this instead don't we? -- str[i].charCodeAt() >= 65 && str[i].charCodeAt() <= 77?
CoryCMyers
@CoryCMyers
Jan 26 2017 00:06
@DanCouper Or does the cypher go both ways? Or just best to repeat it for practice?
@JLuboff That resolved the error I was getting!
Dan Couper
@DanCouper
Jan 26 2017 00:07
@CoryCMyers for 78 through 90, you want a different sum - they are the characters N to Z, and with those, it wraps around
CoryCMyers
@CoryCMyers
Jan 26 2017 00:08
@dan so go back and read more on the values or can I just take the values I have in the first one, and reverse them to subtract?
@DanCouper
Greg Duncan
@GregatGit
Jan 26 2017 00:08
@CoryCMyers >= 65 or > 64
alican karalar
@alicankaralar
Jan 26 2017 00:08

function destroyer(arr) {
  // Remove all the values

  var args = Array.from(arguments);

  args = args.slice(1);

  var result = arr.filter(function(val) {return args.indexOf(val)==-1; 

  });

  return result;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
c0d0er
@c0d0er
Jan 26 2017 00:08
@toianw thanks
CamperBot
@camperbot
Jan 26 2017 00:08
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 492 | @toianw |http://www.freecodecamp.com/toianw
alican karalar
@alicankaralar
Jan 26 2017 00:09
this works @DanCouper
thank you :)
Dan Couper
@DanCouper
Jan 26 2017 00:09
@alicankaralar np :)
@CoryCMyers so for N, you want A. O you want B. For Z you want M. 78 goes to 65, 79 goes to 66, 90 goes to 77.
else if ( str[i].charCodeAt() >= 79 && <= 90 ) {
  arr.push(…
Jason Luboff
@JLuboff
Jan 26 2017 00:13
@DanCouper is that a valid && statement?
CoryCMyers
@CoryCMyers
Jan 26 2017 00:13
@JLuboff It was not, you covered what I was wondering on
I forgot you need to put the parameter you are checking in there on each side of the &&
Dan Couper
@DanCouper
Jan 26 2017 00:14
AH no it is not! copy pasting here - you need
else if ( str[i].charCodeAt() >= 79 && str[i].charCodeAt() <= 90 ) {
  arr.push(…
ALSO
it needs to be .charCodeAt(0)
Jason Luboff
@JLuboff
Jan 26 2017 00:14
Haha...I just don't want to try correcting @DanCouper and end up looking a fool :laughing:
CoryCMyers
@CoryCMyers
Jan 26 2017 00:14
So here is what I have, and the last problem I am having is I am being told str[i] is undefined.
function rot13(str) { // LBH QVQ VG!
     var arr = [];
  for (var i = 0; i < str.length; i++); 
     if ( str[i].charCodeAt() >= 65 && str[i].charCodeAt() <= 77 ) {
       arr.push(value + 13 );
     } else if ( str[i].charCodeAt() >= 78 && str[i].charCodeAt() <= 90 ) {
       return arr.push(value - 13 );
     } else {
       arr.push(value);
   } 

  return arr.toLocaleString().fromCharCode() ;


}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Jason Luboff
@JLuboff
Jan 26 2017 00:15
@CoryCMyers Its becuase after your look declaration you have ;
I also like to use brackets to keep track of things, but I don't think its required (someone correct me if I'm wrong)
Dan Couper
@DanCouper
Jan 26 2017 00:16
Ok, first charCodeAt is saying ‘give me the character code at this index' - you need to put the index value in the brackets. As you’re just looking at a single character each time, that index value is always 0 - str[i].charCodeAt(0)
Second, value is not defined
what I would do, to save on typing
for (var i = 0; i < str.length; i++);
  // just get the char code for each every time the loop runs,
  // and call it `value`
  var value =  str[i].charCodeAt(0);

  // now you can just use `value` instead of typing it out each time:
  if (value  >= 65 && value <= 77 ) {
    arr.push(value + 13 );
  } else if (value >= 78 && value <= 90 ) {
    // this is wrong: just need to not return, you just want to push
    return arr.push(value - 13 );
  } else {
    arr.push(value);
  }
Third, there’s that return which shouldn’t be there
Dan Couper
@DanCouper
Jan 26 2017 00:21
push modifies the array, you want to keep modifying not exit the function
Alejandro Tejada
@wannabecoding
Jan 26 2017 00:21
Hi guys. Going through the first YDKJS book and found something that isn't registering.
~~~
Can't do code blocks on mobile...
Dan Couper
@DanCouper
Jan 26 2017 00:23
Ah, yeah, it’s not good, I normally type it into notes then copy paste from there
Alejandro Tejada
@wannabecoding
Jan 26 2017 00:23
Bah
Image neither?
CoryCMyers
@CoryCMyers
Jan 26 2017 00:23
That is right. If you use something more than twice either write a function for it or make it a variable right?
Dan Couper
@DanCouper
Jan 26 2017 00:24
:) normally, generally it saves a bit of typing which is always nice
makes it more difficult to make mistakes, which is also nice
CoryCMyers
@CoryCMyers
Jan 26 2017 00:25
So really I should jsut lay out all the things I might need in Variables from the get go, almost like I was putting together a stylesheet?
Dan Couper
@DanCouper
Jan 26 2017 00:25
That's a good analogy i think.
Good example, if you ever look at any code for games, that’s really common - there’s normally a huge list of stuff declared right at the top, and the programmer then just uses those throughout the code.
Other thing is to use as few variables as possible
is a tricky balance
not for any crazy reason, it is just very hard to name things well, and the less things you have to name the better

naming things well is the hardest thing in programming (not a joke, it is very, very hard)

the two hardest things in programming are naming things, cache invalidation, and off-by-one errors

Stanislav Alieksieienko
@Stas1988
Jan 26 2017 00:28
Need help! What is wrong?

var count = 0;

function cc(card) {
// Only change code below this line
if (card >=2 && card <=6) {
count ++;
return count + " " + "Bet";
} else if (card >= 7 && card <= 9) {
return count + " " + "Hold";
} else if (card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A') {
count --;
return count + " " + "Hold";
}

return "Change me";

// Only change code above this line
}

// Add/rem

Dan Djaker
@dandjaker
Jan 26 2017 00:31

function repeatStringNumTimes(str, num) {
// repeat after me
var newStr = "";
str=str.repeat(num);
if (str.length > 0){
return str;
}
else {
return ("");
}
}

repeatStringNumTimes("abc", -2);

okay another question why is my code not returning an empty string for the negative numbers its telling me RangeError: Invalid count value. its working for everything else

Dan Couper
@DanCouper
Jan 26 2017 00:33
put the str.repeat inside the if(str.length > 0)
CoryCMyers
@CoryCMyers
Jan 26 2017 00:34
@DanCouper Okay, I am getting the str[i] is undefined error again, but I am not seeing anything in the code that would be throwing that. What would you recommend checking? I would rather find it than be told what the problem is.
jamesjd54
@jamesjd54
Jan 26 2017 00:34
for profile lookup (https://www.freecodecamp.com/challenges/profile-lookup), do I need to use a while loop?
Dan Couper
@DanCouper
Jan 26 2017 00:34
@dandjaker at the minute, it is trying to do str.repeat bfore checking the length, and str.repeat is designed to error on negative numbers
jamesjd54
@jamesjd54
Jan 26 2017 00:34
im completely lost on this one...
Lance
@LalaDarbz
Jan 26 2017 00:35

instruction: Change the code to use the -- operator on myVar.
var myVar = 11;

// Only change code below this line
myVar = myVar - 1;

Currently stuck on this task!

Jason Luboff
@JLuboff
Jan 26 2017 00:35
@Stas1988 Break it into two parts. A switch statement to handle when you should add or subtract from count and then an if/else that tests count to determine if you should bet or hold
Dan Djaker
@dandjaker
Jan 26 2017 00:35

function repeatStringNumTimes(str, num) {
// repeat after me
var newStr = "";
str=str.repeat(num);
if (str.length > 0){
str = str.repeat(num);
return str;
}
else {
return ("");
}
}

repeatStringNumTimes("abc", -2);

okay so i put it inside the if statement
Coy Sanders
@coymeetsworld
Jan 26 2017 00:35
@LalaDarbz -- operator is used to replace = myVar - 1; its shorthand
Dan Djaker
@dandjaker
Jan 26 2017 00:35
but it still isnt working for the negative number
Coy Sanders
@coymeetsworld
Jan 26 2017 00:36
its like myVar++ is really myVar = myVar + 1
just shorter so its better way to write
Jason Luboff
@JLuboff
Jan 26 2017 00:36
@dandjaker Becuase you still have str = str.repeat(num) before your if statement
Walid Ashri
@walidashri
Jan 26 2017 00:36
@dandjaker u need to check num not the str.length
GuilioM
@GuilioM
Jan 26 2017 00:36
\
Dan Djaker
@dandjaker
Jan 26 2017 00:36
oh yea lol i forgot to delete that
Lance
@LalaDarbz
Jan 26 2017 00:37
@coymeetsworld Thanks!
CamperBot
@camperbot
Jan 26 2017 00:37
laladarbz sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1947 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Dan Djaker
@dandjaker
Jan 26 2017 00:37
oh yes it worked thank you guys
Coy Sanders
@coymeetsworld
Jan 26 2017 00:37
yw @LalaDarbz
Dan Couper
@DanCouper
Jan 26 2017 00:39
@CoryCMyers just checking atm, I’ll just be asec
jamesjd54
@jamesjd54
Jan 26 2017 00:39

for profile lookup(https://www.freecodecamp.com/challenges/profile-lookup) is this anywhere close to what I need?

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0;i<contacts.length;i++){
while (contacts[i].hasOwnProperty(firstName)===true){
return contacts[i][prop];
}
}
// Only change code above this line
}

CoryCMyers
@CoryCMyers
Jan 26 2017 00:40
@DanCouper Do you want the updated Code?
GuilioM
@GuilioM
Jan 26 2017 00:40
function translatePigLatin(str) {
  var vowels = ["a", "e", "i", "o", "u"],
      way = false,
      clust = 0;

  while (!way) {
    for (var vowel in vowels){
      if (str[clust] === vowel) {
        way = true;
        break;
      }
      clust++;
    }
  }

  if (way) {
    str = str.push("way");
  }
  else {
    str = str.slice(clust) + str.slice(0, clust) + "ay";
  }
  return str;
}

getting "potential infinite loop" at for(var vowel in vowels)

anybody knows why?

Dan Couper
@DanCouper
Jan 26 2017 00:42
@CoryCMyers yes, just to check, but I think I know what it is
CoryCMyers
@CoryCMyers
Jan 26 2017 00:42
function rot13(str) { // LBH QVQ VG!
    var arr = [];
     for (var i = 0; i < str.length; i++)
       var value = str[i].charCodeAt(0);
         if ( str[i].charCodeAt(0) >= 65 && str[i].charCodeAt(0) <= 77 ) {
           arr.push(str[i].charCodeAt(0) + 13 );
       } else if ( str[i].charCodeAt(0) >= 78 && str[i].charCodeAt(0) <= 90 ) {
           arr.push(str.charCodeAt(0) - 13 );
       } else {
           arr.push(str[i].charCodeAt());
   } 

  return arr.toLocaleString() ;


}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Dan Couper
@DanCouper
Jan 26 2017 00:42
need curly brackets for the for loop
you can’t miss them off
because it’s multiple lines
CoryCMyers
@CoryCMyers
Jan 26 2017 00:43
Oh I feel silly
Dan Couper
@DanCouper
Jan 26 2017 00:43
np, easy to miss, I was stumped, couldn’t figure out why for a while
Jason Luboff
@JLuboff
Jan 26 2017 00:44
@DanCouper I had mentioned the missing brackets earlier...but wondering...you can write if/else statements without them...are you not able to write loops without them?
Dan Couper
@DanCouper
Jan 26 2017 00:45
Yes, sometimes, but it’s a little bit flakey
I think
I’ve never tried tbh, I know you can do it with for…of loops
Jason Luboff
@JLuboff
Jan 26 2017 00:46
I'll just stick with using them...helps me stay organized lol
CoryCMyers
@CoryCMyers
Jan 26 2017 00:47
What I really want to learn is how to use ternary operators. I like how smooth and minimalist they look.
Dan Couper
@DanCouper
Jan 26 2017 00:50
heh
> const coords = []
> for (const y of [0,1,2]) for (const x of [0,1,2]) coords.push([x,y]);
[[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]
Walid Ashri
@walidashri
Jan 26 2017 00:51
@CoryCMyers
if (x){
return 'yes'
}else{
return 'no'
}
// this can be 
(x)?'yes':'no'
Dan Couper
@DanCouper
Jan 26 2017 00:51
:point_up:
CoryCMyers
@CoryCMyers
Jan 26 2017 00:51
Can I roll them directly into another ternary?
Dan Couper
@DanCouper
Jan 26 2017 00:53

Yeeeeesssss, but it starts to get very complicated fast. Try to keep them for small stuff with only two options, they’re really good for that. They’re expressions as well, so you can do

return (x)?'yes':’no

or they can be a variable

var x = (ifTrue) ? 1 : 2;
Walid Ashri
@walidashri
Jan 26 2017 00:55
if (x==1){
return 'yes'
}else if (x==0){
return 'z'
} else{
return 'no'
}
// this can be 
(x)?'yes':(x==0)?'z':'no'
Gabriela Bazan
@GabrielaLBazan
Jan 26 2017 00:55
Can someone reassure me that they too had difficulty with algorithms? I am feeling very discouraged at this part.
Perhaps that's the point?
Jason Luboff
@JLuboff
Jan 26 2017 00:56
@GabrielaLBazan I had a horrible time with them. You'll eventually get them, and then later go back to them and go "Damn...this is easy"
CoryCMyers
@CoryCMyers
Jan 26 2017 00:57

Also I am encountering something interesting it I have

return arr.toLocaleString()

It returns the unicode values I have. However

car uniCode =  arr.toLocaleString()

I get nothing as a return, and if I try to break it down further through

var translate = uniCode.fromCharCode()

I get told that

uniCode.fromLocaleString()

is not defined

Gabriela Bazan
@GabrielaLBazan
Jan 26 2017 00:57
Thanks @JLuboff it seems like an insurmountable feat
CamperBot
@camperbot
Jan 26 2017 00:57
gabrielalbazan sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 708 | @jluboff |http://www.freecodecamp.com/jluboff
Dan Couper
@DanCouper
Jan 26 2017 00:57
Also @CoryCMyers , I’m going to need to get some sleep, but one last thing is that I think you’ll have one last problem - toLocaleString() is not going to convert that array of character codes. You want to either: convert to string in each of the if …elses - like arr.push(String.fromCharCode(value + 13));, and join the array at the end or
Ah, hah, you’ve just hit that issue
anyhoo, or
CoryCMyers
@CoryCMyers
Jan 26 2017 00:57
@GabrielaLBazan It is not just you, I have been banging my head against them for days
Gabriela Bazan
@GabrielaLBazan
Jan 26 2017 00:58
I think it's more the structure of these things that's throwing me off. But hopefully we'll get through it @CoryCMyers GOOD LUCK!! (We'll need it I think)
CoryCMyers
@CoryCMyers
Jan 26 2017 00:59
@DanCouper So what does adding the bracket before the string etc do?
@GabrielaLBazan I normally end up clicking the help link then reading over what that method does for a bit. Then reading through more methods randomly until something sparks an idea.
Gabriela Bazan
@GabrielaLBazan
Jan 26 2017 01:01
Ok, thanks @CoryCMyers I guess it's just gonna go a little slower than some of the other stuff has gone.
CamperBot
@camperbot
Jan 26 2017 01:01
gabrielalbazan sends brownie points to @corycmyers :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @corycmyers |http://www.freecodecamp.com/corycmyers
CoryCMyers
@CoryCMyers
Jan 26 2017 01:02
@GabrielaLBazan This is what I have been doing, when I get frustrated I pause and pull up the map, then look at the estimated time to finish the algorithm block. Everything else has been <= 10 hours unless it was a project. Basic algorithms is 50
Gabriela Bazan
@GabrielaLBazan
Jan 26 2017 01:03
HAHAHA... that helps too @CoryCMyers and thanks for the laugh!
CamperBot
@camperbot
Jan 26 2017 01:03
gabrielalbazan sends brownie points to @corycmyers :sparkles: :thumbsup: :sparkles:
:warning: gabrielalbazan already gave corycmyers points
Dan Couper
@DanCouper
Jan 26 2017 01:03
@CoryCMyers String.fromCharCode() can take a sequence of characters (not an array). You get around it not taking an array by using the method apply that can be used on any function - apply takes two arguments, the first is a context, which is useful with objects, but you don't have to care about here (use null or undefined), the second is the arguments you’d normally give to the function, but in the form of an array: String.fromCharCode.apply(null, [72, 69, 76, 76, 79]) - this is the same as String.fromCharCode(72, 69, 76, 76, 79), and gives you the string straightaway (in this case HELLO)
What do you mean before the string?
btw
CoryCMyers
@CoryCMyers
Jan 26 2017 01:05
I was confused a bit by arr.push(String.fromCharCode(value + 13)) is string not a method that takes a period before?
so the extra set of not-curly brackets threw me
@DanCouper Nevermind, I am being an idiot and should probably take a break to let my brain bounce back
David Amanze
@GodKingShogun
Jan 26 2017 01:16
can someone help me with the random generator. i am suppose to use generate random quotes by clicking a button. i found an api that does, copied it, then nested it in my $(document).ready function but when i click it i do not get a quote
<script>
$(document).ready(function(){
 $(".btn-block").on('click', function() {
   $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
  $(".well").append(a[0].content + "<p>— " + a[0].title + "</p>")
});
});
});
</script>
Master Builder
@McGowanC
Jan 26 2017 01:18
@GodKingShogun did you just copy and paste it?
David Amanze
@GodKingShogun
Jan 26 2017 01:18
@mcgowanc yes
is that bad
Master Builder
@McGowanC
Jan 26 2017 01:18
yes, you should be writing the code from scratch. Or at least copying the text by typing it out instead of just pasting it
what errors does your javascript console show?
David Amanze
@GodKingShogun
Jan 26 2017 01:19
@mcgowanc this is the only part i copied
 $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
  $(".well").append(a[0].content + "<p>— " + a[0].title + "</p>")
});
to get the random quotes
Master Builder
@McGowanC
Jan 26 2017 01:19
do you have a .well class?
Dan Couper
@DanCouper
Jan 26 2017 01:20
@CoryCMyers :) If it’s what I think is confusing you (sorry if it’s not) it confuses everyone at first - You have a few methods under each object namespace that that are static - they’re just functions, but JS needs to put them somewhere, so they get shoved under the most relevant name. Like all the Mathfunctions - Math.max(0,1). If, in the documentation, it’s called Something.prototype.someMethod(), you use it like mySomething.someMethod(). If it’s instead Something.someMethod() (NOTE no prototype), you use it like it’s written, it’s just a function - Something.someMethod(myVal). Good example is String.prototype.charCodeAt() - with that you do like 'hello'.charCodeAt(1). But String.fromCharCode() is just like that, a function so you use it String.fromCharCode(1). Generally static methods create whatever thing they are called according to the parameters(normally creating from something else) String.fromCharCode() creates a string from a number, Array.from() creates an array from something that’s like an array (like arguments), Object.assign takes two or more objects and merges them.
David Amanze
@GodKingShogun
Jan 26 2017 01:20
@mcgowanc yes that's where the quote is going to be written
@mcgowanc once i click the button
CoryCMyers
@CoryCMyers
Jan 26 2017 01:21
@DanCouper Thank you, I have been racking my brain on that cypher for the last 4 hours so when I did not understand that string in your example meant str in my code I thought it might be needed :smile:
CamperBot
@camperbot
Jan 26 2017 01:21
corycmyers sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 460 | @dancouper |http://www.freecodecamp.com/dancouper
Master Builder
@McGowanC
Jan 26 2017 01:21
yeah I just wanted to make sure you had the .well class already in your html before hand
David Amanze
@GodKingShogun
Jan 26 2017 01:21
@mcgowanc i am using codepen and no error is being displayed
Master Builder
@McGowanC
Jan 26 2017 01:21
link the codepen please
David Amanze
@GodKingShogun
Jan 26 2017 01:22
@mcgowanc ok give me one sec
@mcgowanc still there
Johnny
@JohnnyBizzel
Jan 26 2017 01:25
Who's is this? ^^
The jQuery is in the wrong place
Master Builder
@McGowanC
Jan 26 2017 01:26
yeah I mean first off, your JS is in the CSS section of your CodePen,
you also don't have jQuery added to your CodePen project
if you can't read the documentation and write the code yourself, you might be a bit ahead of yourself doing this project
don't copy and paste if you want to learn
David Amanze
@GodKingShogun
Jan 26 2017 01:29
@mcgowanc ok but the example in the lessons have the javascript portion in css i believe like so
<script>
  $(document).ready(function() {

    $("#getMessage").on("click", function() {
      $.getJSON("/json/cats.json", function(json) {

        var html = "";
        // Only change code below this line.
        json.forEach(function(val) {
  var keys = Object.keys(val);
  html += "<div class = 'cat'>";
  keys.forEach(function(key) {
    html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
  });
  html += "</div><br>";
});


        // Only change code above this line.

        $(".message").html(html);

      });
    });
  });
</script>
Sam Houlahan
@Sam-Houlahan
Jan 26 2017 01:31
Hi Team, after some help on the "Counting Cards" challenge. I just want to know if i am on the right track.
Master Builder
@McGowanC
Jan 26 2017 01:31
@GodKingShogun all that code is wrapped in an HTML <script> tag, so that would actually go in the html section
Sam Houlahan
@Sam-Houlahan
Jan 26 2017 01:32
Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'
You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
var count = card++;
break;
}

return card;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
This is what i have currently. So i am wanting to know if I'm on the right track or if i should rethink how i am approaching this challenge.

Stephen James
@sjames1958gm
Jan 26 2017 01:33
@keewhy The switch is a correct start - but you are supposed to increment count not set it to card++
@keewhy Don't use var inside the function for count - you want to modify the global
Walid Ashri
@walidashri
Jan 26 2017 01:34
@keewhy the idea is right but this is wrong var count = card++;
count already defined, and u need to increase it by one only
David Amanze
@GodKingShogun
Jan 26 2017 01:35
@mcgowanc so would i just copy everything i have written down in my css section to my js section like so
<script>
$(document).ready(function(){
 $(".btn-block").on("click", function() {
   $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
  $(".well").append(a[0].content + "<p>— " + a[0].title + "</p>")
});
});
});
</script>
Stephen James
@sjames1958gm
Jan 26 2017 01:35
@GodKingShogun without the <script> tags
Stanislav Alieksieienko
@Stas1988
Jan 26 2017 01:36
@keewhy almost. You should return count and then do if statement to set "Bet" and "hold"
David Amanze
@GodKingShogun
Jan 26 2017 01:37
@sjames1958gm okay why is it that the example from the lesson can have the api in the css section but for my api on random quotes generator i have to have it in my js section
Stephen James
@sjames1958gm
Jan 26 2017 01:37
@GodKingShogun I don't recall that lesson - but the js goes in the js section.
Esera
@drakho
Jan 26 2017 01:38

Hi Campers Ive run into a prob and need your pear of eyes..​
hears the code.. It returns no such name, even When the name is there.. PS:sorry for the way it appears ..
//Setup

var contacts = [

{

    "firstName": "Akira",

    "lastName": "Laine",

    "number": "0543236543",

    "likes": ["Pizza", "Coding", "Brownie Points"]

},

{

    "firstName": "Harry",

    "lastName": "Potter",

    "number": "0994372684",

    "likes": ["Hogwarts", "Magic", "Hagrid"]

},

{

    "firstName": "Sherlock",

    "lastName": "Holmes",

    "number": "0487345643",

    "likes": ["Intriguing Cases", "Violin"]

},

{

    "firstName": "Kristian",

    "lastName": "Vos",

    "number": "unknown",

    "likes": ["Javascript", "Gaming", "Foxes"]

}

];

function lookUpProfile(firstName/, prop/){

// Only change code below this line

for(i = 0; i < contacts.length; i++)

{

  if(contacts[i].firstName === firstName)

    {

      return firstName;

    }

  else

    {

      return "No such contact";

    }

}

// Only change code above this line

}

// Change these values to test your function

lookUpProfile("Harry"/, "address"/);

David Amanze
@GodKingShogun
Jan 26 2017 01:39
@sjames1958gm ok thanks
CamperBot
@camperbot
Jan 26 2017 01:39
godkingshogun sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5549 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
zhekau
@zhekau
Jan 26 2017 01:39
Hi everyone! Anyone cares to help me with the Friendly Date Ranges challenge? I can't pass one of the tests
Joseph
@revisualize
Jan 26 2017 01:40
@drakho Let me get you some code.
Stephen James
@sjames1958gm
Jan 26 2017 01:40
@drakho Don't post the contacts array - just takes up space.
You are supposed to return the property prop not firstName.
Also you cant return no such contact until all the contacts are checked
@drakho FInally you need to test if the property is defined
Joseph
@revisualize
Jan 26 2017 01:42
Actually, I don't want to post that yet.
You're not far enough along.
Meh.
for ( ..... ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }
That loop... Won't loop.
Aaron Bell
@awb715
Jan 26 2017 01:44
why did all my solutions go away?
Joseph
@revisualize
Jan 26 2017 01:44
about @awb715
CamperBot
@camperbot
Jan 26 2017 01:44
:cookie: 304 | @awb715 |http://www.freecodecamp.com/awb715
Aaron Bell
@awb715
Jan 26 2017 01:44
@revisualize ?
Joseph
@revisualize
Jan 26 2017 01:44
Nope.
I see them.
Esera
@drakho
Jan 26 2017 01:45
@sjames1958gm I understand I have to get the property but I coudnt get past getting the names checked.. So return "No such property" should be outside the for loop.. Thank you..
CamperBot
@camperbot
Jan 26 2017 01:45
drakho sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5550 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Jan 26 2017 01:46
@drakho It can be inside of the loop.
Aaron Bell
@awb715
Jan 26 2017 01:49
@revisualize what are yous aying
Joseph
@revisualize
Jan 26 2017 01:50
Words. In English. Psuedo-sentences.
Aaron Bell
@awb715
Jan 26 2017 01:50
you see what
keihlmm
@keihlmm
Jan 26 2017 01:50
can anyone help me with building a string in the format of word blanks
Aaron Bell
@awb715
Jan 26 2017 01:50
remember me?
Joseph
@revisualize
Jan 26 2017 01:50
@awb715 What do you mean what am I saying? I see your solutions.
Look at your profile.
Your solutions are there.
jonathan callaghan
@SLASHEh
Jan 26 2017 01:51
hey guys, trying to reverse an array but im getting the message that reverse() isn't a function
Aaron Bell
@awb715
Jan 26 2017 01:51
how
i cant see mine
Joseph
@revisualize
Jan 26 2017 01:51
What are you doing
about @awb715
CamperBot
@camperbot
Jan 26 2017 01:51
:cookie: 304 | @awb715 |http://www.freecodecamp.com/awb715
Joseph
@revisualize
Jan 26 2017 01:51
------^^^^^^^^^^^^^^^^^^^^^^^^^
There
jonathan callaghan
@SLASHEh
Jan 26 2017 01:51
i use str.split(""); to split the string into an array, that works
Joseph
@revisualize
Jan 26 2017 01:51
Your solutions.
jonathan callaghan
@SLASHEh
Jan 26 2017 01:51
then try str.reverse(); to reverse the array
Aaron Bell
@awb715
Jan 26 2017 01:52
phew
not gone
@revisualize thanks
CamperBot
@camperbot
Jan 26 2017 01:52
awb715 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3113 | @revisualize |http://www.freecodecamp.com/revisualize
Aaron Bell
@awb715
Jan 26 2017 01:52
i cleared my cookies and thought they were
remember me? @revisualize
jonathan callaghan
@SLASHEh
Jan 26 2017 01:52

function reverseString(str) {
str.split("");
str.reverse();
str.join("");

}

reverseString("hello");

Joseph
@revisualize
Jan 26 2017 01:53
@SLASHEh You're not returning anything.
keihlmm
@keihlmm
Jan 26 2017 01:53
how do you start string in word blanks?
Aaron Bell
@awb715
Jan 26 2017 01:53
@revisualize dont ignore me
jonathan callaghan
@SLASHEh
Jan 26 2017 01:54
it doesnt like the 2nd method
no not yet, but when i return the 1st line it works
Joseph
@revisualize
Jan 26 2017 01:54
@keihlmm Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
@awb715 Did we talk yesterday?
Aaron Bell
@awb715
Jan 26 2017 01:54
@revisualize dissapointed you dont remember
jonathan callaghan
@SLASHEh
Jan 26 2017 01:54
type error: str.reverse() is not a function
Aaron Bell
@awb715
Jan 26 2017 01:54
im moving to cap hill feb 9
Joseph
@revisualize
Jan 26 2017 01:55
Don't be.
@SLASHEh You're not assigning the split to anything.
keihlmm
@keihlmm
Jan 26 2017 01:55
@revisualize thanks
CamperBot
@camperbot
Jan 26 2017 01:55
:star2: 3114 | @revisualize |http://www.freecodecamp.com/revisualize
keihlmm sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Esera
@drakho
Jan 26 2017 01:55

@revisualize It seems to only work if I have it outside like this. Could you show me how you would get it inside? function lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++)
{
if(contacts[i].firstName === firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else
{
return "No such property";
}
}

}
     return "No such contact";

// Only change code above this line
}

jonathan callaghan
@SLASHEh
Jan 26 2017 01:56
thanks @revisualize
CamperBot
@camperbot
Jan 26 2017 01:56
slasheh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3115 | @revisualize |http://www.freecodecamp.com/revisualize
horatio velveteen
@horatio-velveteen
Jan 26 2017 01:56
im having a problem with this escape sequence with the special characters section in js is anyone able to help at the mement
jonathan callaghan
@SLASHEh
Jan 26 2017 01:56

function reverseString(str) {
newString=str.split("");
newString.reverse();
return newString.join("");

}

that worked
João Mhurilo Godoi da Silva
@ebak123
Jan 26 2017 01:58

Good Night guys, i'm stuck at lesson DNA Pairing. So, why my case 'A' are running twice, and so, pushing twice the values?

function pairElement(str) {
var arrSplit=[],arr1=[],arr2=[],arr3=[],arr4=[],res=[];
arrSplit=str.split('');
function caso(a){
switch(a) {
case 'A':
arr1.push("A","T");
res.push(arr1);
break;
case 'T':
arr2.push("T","A");
res.push(arr2);
break;
case 'C':
arr3.push("C","G");
res.push(arr3);
break;
case 'G':
arr4.push("G","C");
res.push(arr4);
break;
}
}
for (var i=0;i<arrSplit.length;i++){
caso(arrSplit[i]);
}
return res;
}
pairElement("ATCGA");

Joseph
@revisualize
Jan 26 2017 02:03
@SLASHEh You can chain some methods together.
@SLASHEh Those methods do allow for chaining.
Aaron Bell
@awb715
Jan 26 2017 02:04
see you in seattle @revisualize pce
byeee
Joseph
@revisualize
Jan 26 2017 02:04
:v:
Johnny
@JohnnyBizzel
Jan 26 2017 02:04
@ebak123 Not sure why you have an inner function?
And can you format your code?
'''
function pairElement(str) {
var arrSplit=[],arr1=[],arr2=[],arr3=[],arr4=[],res=[];
arrSplit=str.split('');
function caso(a){
switch(a) {
case 'A':
arr1.push("A","T");
res.push(arr1);
break;
case 'T':
arr2.push("T","A");
res.push(arr2);
break;
case 'C':
arr3.push("C","G");
res.push(arr3);
break;
case 'G':
arr4.push("G","C");
res.push(arr4);
break;
}
}
for (var i=0;i<arrSplit.length;i++){
caso(arrSplit[i]);
}
return res;
}
pairElement("ATCGA");
CamperBot
@camperbot
Jan 26 2017 02:05
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Jan 26 2017 02:06
@yemicarter Returning no contact too early.
João Mhurilo Godoi da Silva
@ebak123
Jan 26 2017 02:07

'''
function pairElement(str) {
var arrSplit=[],arr1=[],arr2=[],arr3=[],arr4=[],res=[];

for (var i=0;i<str.length;i++){
switch(str[i]) {

case 'A':
    arr1.push("A","T");
    res.push(arr1);
    break;

case 'T':
    arr2.push("T","A");
    res.push(arr2);
    break;

case 'C':
    arr3.push("C","G");
    res.push(arr3);
    break;

case 'G':
    arr4.push("G","C");
    res.push(arr4);
    break;  
}

}

return res;
}

pairElement("ATCGA");

'''

CamperBot
@camperbot
Jan 26 2017 02:07
:bulb: to format code use backticks! ``` more info
João Mhurilo Godoi da Silva
@ebak123
Jan 26 2017 02:07

'''js
function pairElement(str) {
var arrSplit=[],arr1=[],arr2=[],arr3=[],arr4=[],res=[];

for (var i=0;i<str.length;i++){
switch(str[i]) {

case 'A':
    arr1.push("A","T");
    res.push(arr1);
    break;

case 'T':
    arr2.push("T","A");
    res.push(arr2);
    break;

case 'C':
    arr3.push("C","G");
    res.push(arr3);
    break;

case 'G':
    arr4.push("G","C");
    res.push(arr4);
    break;  
}

}

return res;
}

pairElement("ATCGA");

'''

CamperBot
@camperbot
Jan 26 2017 02:07
:bulb: to format code use backticks! ``` more info
Margaret
@Margaret2
Jan 26 2017 02:08
@ebak123 ```, not '''
CamperBot
@camperbot
Jan 26 2017 02:08
:bulb: to format code use backticks! ``` more info
Margaret
@Margaret2
Jan 26 2017 02:08
the ''' just triggers the message
Rocaservices
@Rocaservices
Jan 26 2017 02:08

"Assign the value 7 to variable a.

Assign the contents of a to variable b." how do i do this

CamperBot
@camperbot
Jan 26 2017 02:08
:bulb: to format code use backticks! ``` more info
Margaret
@Margaret2
Jan 26 2017 02:08
@Rocaservices use = to:
  • set a equal to 7
  • set b equal to a
Rocaservices
@Rocaservices
Jan 26 2017 02:08
i just started so thats why its so close to be begining
thanks
Johnny
@JohnnyBizzel
Jan 26 2017 02:10

@ebak123 Instead of doing this:

    arr1.push("A","T");
    res.push(arr1);

You can do this

    var arr1 = ["A","T"];
    res.push(arr1);
Rocaservices
@Rocaservices
Jan 26 2017 02:10
@Margaret2 i keep getting this tho "a should be assigned to b with =
"
Margaret
@Margaret2
Jan 26 2017 02:11
@Rocaservices that means you didn't do the second thing i just said
yemicarter
@yemicarter
Jan 26 2017 02:11
@revisualize i still don't get what i am to do. is the other part the (contacts[i].hasOwnProperty(prop)) correct?
Rocaservices
@Rocaservices
Jan 26 2017 02:12
@Margaret2 i have this a = 7;
b = 7;
Guille
@guillegn
Jan 26 2017 02:12

In the game of golf each hole has a par meaning the average number of strokes a golfer is expected to make in order to sink the ball in a hole to complete the play. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"
par and strokes will always be numeric and positive.

function golfScore(par, strokes) {
// Only change code below this line
if () {
return "Hole-in-one";
}

else {
return "Change Me";
}

// Only change code above this line
}

// Change these values to te

Rocaservices
@Rocaservices
Jan 26 2017 02:12
but what else do i do
Johnny
@JohnnyBizzel
Jan 26 2017 02:13
@ebak123 Because there are 2 As you will increase the size of arr1 on the 2nd A
Margaret
@Margaret2
Jan 26 2017 02:13
@Rocaservices do NOT set b equal to 7, set b equal to a
Johnny
@JohnnyBizzel
Jan 26 2017 02:13
@guillegn So how did you do it?
Guille
@guillegn
Jan 26 2017 02:14
I understand very well the if and else conditionals, but in this "game" i cant figure it out how to represent the two arguments
yemicarter
@yemicarter
Jan 26 2017 02:14
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i].prop;
     }
      if (firstName != contacts[i].firstName) {
       return "No such contact";
     }
     if (!contacts[i].hasOwnProperty(prop)) {
       return "No such Property";
     }



   }


// Only change code above this line
}

// Change these values to test your function
//lookUpProfile("Akira", "likes");
lookUpProfile("Akira", "likes");
Johnny
@JohnnyBizzel
Jan 26 2017 02:14
@guillegn par is the average score, and strokes is the score
Margaret
@Margaret2
Jan 26 2017 02:14
@guillegn in each of your if statements, you have to check the value of strokes. So if (strokes == 1) and so on
Guille
@guillegn
Jan 26 2017 02:14
@JohnnyBizzel i cant
Stephen James
@sjames1958gm
Jan 26 2017 02:15
@yemicarter How can you return no such contact until all the contacts have been checked
grantknaver
@grantknaver
Jan 26 2017 02:15
function checkCashRegister(price, cash, cid) {
  // Here is your change, ma'am.
  var moneyTypes = [
    {name:"PENNY", val: 0.01},
    {name: "NICKEL", val: 0.05},
    {name: "DIME", val: 0.10},
    {name: "QUARTER", val: 0.25},
    {name:"ONE", val: 1.00},
    {name: "FIVE", val: 5.00},
    {name:"TEN", val: 10.00},
    {name:"TWENTY", val: 20.00},
    {name: "ONE HUNDRED", val: 100.00}
];
  var answer = [];
  var howManyDenominations = [];
  for(var i = 0; i < cid.length; i++){
    answer.push(cid[i][1]);
    howManyDenominations.push(Math.round(cid[i][1] / moneyTypes[i].val));
  }
  var cashInDrawer = answer.reduce(function(a,b){return a + b;});
  var changeDo = cash - price;
  //var sortedChange = changeDo.sort(function(a,b){return b[1] < a[1];});
var testFunction= function(){
  for(var a = 0; a < moneyTypes.length; a++){
   if(howManyDenominations[a] !== 0){
     for(var b = 1; b < howManyDenominations[a]; b++){
       var test = changeDo - (b * moneyTypes[a].val);
     }//for statement 
    }//if statement
  }//for statement
};
   testFunction(); //actually returns cashCheck
yemicarter
@yemicarter
Jan 26 2017 02:15
Folks, i have been on this since yersterday, someone pls clue me in
Johnny
@JohnnyBizzel
Jan 26 2017 02:15
@guillegn par is the average score, and strokes is the score
grantknaver
@grantknaver
Jan 26 2017 02:15
does anyone follow code
J. Kelley
@jothetraveler
Jan 26 2017 02:16

Evening all!!! I'm not entirely sure what I'm missing. The instructions were to Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

  ```

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha": "Adams",

"bravo": "Boston",

"charlie": "Chicago",

"delta": "Denver",

"echo": "Easy",

"foxtrot": "Frank"
};

// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");
```

Johnny
@JohnnyBizzel
Jan 26 2017 02:16
@yemicarter Use http://pythontutor.com/javascript.html#mode=edit and you should see the issue

does anyone follow code

I copy and paste code? Does that count?

@jothetraveler use val somehow
Guille
@guillegn
Jan 26 2017 02:18
@Margaret2 so in the first example i should put: if (stroke == 1) {
Margaret
@Margaret2
Jan 26 2017 02:18
@jothetraveler so in your code the result is still "" because you never change it. You have to use bracket notation or dot notation to get the value out of lookup
@guillegn strokes with s
Guille
@guillegn
Jan 26 2017 02:18
{ return "hole-in-one";
yemicarter
@yemicarter
Jan 26 2017 02:18
@sjames1958gm is that the only part of the code that is faulty?
J. Kelley
@jothetraveler
Jan 26 2017 02:19
@JohnnyBizzel I figured that much....drawing a blank...... @Margaret2 Thank you! just had an "aha!" moment.
CamperBot
@camperbot
Jan 26 2017 02:19
jothetraveler sends brownie points to @johnnybizzel and @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1189 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:star2: 1388 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Jan 26 2017 02:19
@guillegn return value has to match exactly what they want, pay attention to uppercase letters and symbols
but you're on the right track :+1:
Guille
@guillegn
Jan 26 2017 02:20
yes yes i know, but what about that lookup?
Johnny
@JohnnyBizzel
Jan 26 2017 02:20
Bed time for me. @Margaret2 you take over ;)
Margaret
@Margaret2
Jan 26 2017 02:20
@JohnnyBizzel good night :sparkles:
Emmanuel Fletcher
@Fletcher14
Jan 26 2017 02:20
does someone know how to solve lesson 86 counting cards because i have no clue
Johnny
@JohnnyBizzel
Jan 26 2017 02:20
:zap: :zzz:
Guille
@guillegn
Jan 26 2017 02:20
i doesnt help me much, but thank you @JohnnyBizzel
CamperBot
@camperbot
Jan 26 2017 02:20
guillegn sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1190 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Jan 26 2017 02:21
@guillegn You should be fine now...
Guille
@guillegn
Jan 26 2017 02:21
@Margaret2 it seems that you're talking about like a variable
Margaret
@Margaret2
Jan 26 2017 02:22

yes yes i know, but what about that lookup?

wait, what?

Em Eloy
@emilze
Jan 26 2017 02:22
How did you guys solved the Quoting Strings with Single Quotes challenge?
Remove all the backslashes () and
Only remove the backslashes \ used to escape quotes doesn't make sense.
Thanks
Margaret
@Margaret2
Jan 26 2017 02:23
@guillegn you just need a series of if/else if and return statements, like you're doing. I was talking about the lookup with someone else
Guille
@guillegn
Jan 26 2017 02:23
i'm going nuts. Now I checked and realize it was for another perso====
person
Okk I would trie, thanks! @Margaret2
CamperBot
@camperbot
Jan 26 2017 02:24
guillegn sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1389 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Jan 26 2017 02:24
@emilze maybe they meant only remove the slashes used to escape quotes :D because yeah, all of the backslashes are used to escape quotes anyway :D
Guille
@guillegn
Jan 26 2017 02:25
try
Margaret
@Margaret2
Jan 26 2017 02:25
but there are a few forward slashes
Guille
@guillegn
Jan 26 2017 02:25
f&ck
Joseph
@revisualize
Jan 26 2017 02:27
Okay. I should work on another challenge.
Walid Ashri
@walidashri
Jan 26 2017 02:27
@emilze remove \ and replace " with '
oliviathomas
@oliviathomas
Jan 26 2017 02:30

if (card==2 || card==3 || card==4 || card==5 || card==6) {
count+= 1;
}
else if (card==7 || card==8 || card==9) {
count+= 0;
}
else {
count-= 1;
}

if (count>0) { 
  return count + "Bet";
}

else {
return count + "Hold";
}
how is this wrong?

yemicarter
@yemicarter
Jan 26 2017 02:30
@JohnnyBizzel still not getting it. The place seems advanced for me
Margaret
@Margaret2
Jan 26 2017 02:31
@oliviathomas what about J, Q, K, A?
oh wait, that's in your else statement...
Anh Nguyen
@tiremon112
Jan 26 2017 02:31
lol
Margaret
@Margaret2
Jan 26 2017 02:31
@tiremon112 :P
Ken Haduch
@khaduch
Jan 26 2017 02:31
@oliviathomas - look at the results that they want you to return - carefully note the string value is " Bet", for example, with a space.
Anh Nguyen
@tiremon112
Jan 26 2017 02:32
sick code
Em Eloy
@emilze
Jan 26 2017 02:32
@Margaret2 and @walidashri , I replaced " for ' and removed all \. :worried:
Anh Nguyen
@tiremon112
Jan 26 2017 02:32
why not just use switch lmao
Margaret
@Margaret2
Jan 26 2017 02:32
yeah, it's the space, my bad :D
@emilze can you show your whole code?
Anh Nguyen
@tiremon112
Jan 26 2017 02:32
switch card case 1 case 2 case 3 case 4 :sparkles:
Walid Ashri
@walidashri
Jan 26 2017 02:33
@emilze not all keep the 1st and last
Anh Nguyen
@tiremon112
Jan 26 2017 02:33
@Margaret2 he heard manish giri he about to leave this place forever
:scream:
Rocaservices
@Rocaservices
Jan 26 2017 02:33
a should be defined and have a value of 6
b should be defined and have a value of 15
Ken Haduch
@khaduch
Jan 26 2017 02:33
@oliviathomas - so you would return count + " Bet", not count + "Bet"
Rocaservices
@Rocaservices
Jan 26 2017 02:33
how do i do this
i have "a = a = 6;
b = b = 15;"
Margaret
@Margaret2
Jan 26 2017 02:34
@walidashri there won't be any \ in the finished string, maybe they changed it since you did it
Ken Haduch
@khaduch
Jan 26 2017 02:34
@Rocaservices a and b must be variables? How do you define a variable, a variable...
a variable
yemicarter
@yemicarter
Jan 26 2017 02:34
@Margaret2 pls could you point me in the right direction.
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i].prop;
     }


   }

}

// Change these values to test your function
//lookUpProfile("Akira", "likes");
lookUpProfile("Akira", "likes");
Margaret
@Margaret2
Jan 26 2017 02:35
@tiremon112 what!? Are you serious!
Anh Nguyen
@tiremon112
Jan 26 2017 02:35
yea he said it this afternoon
let say it about 9 hour ago
Rocaservices
@Rocaservices
Jan 26 2017 02:35
@khaduch what do you mean im still new to this type of coding im good at .net not this
Anh Nguyen
@tiremon112
Jan 26 2017 02:35
@yemicarter you on the right track
Em Eloy
@emilze
Jan 26 2017 02:36
@Margaret2 @walidashri var myStr = '<a href= "https://www.example.com" target= "_blank">Link</a>';
I didn't create a new line. Jus modified de code.
Ken Haduch
@khaduch
Jan 26 2017 02:36

@yemicarter - were we looking at this this morning ? I think that things that we mentioned this morning are still incorrect.

Note that the prop is a variable, and if you want to use a property to access an object, you have to use one of either dot or bracket notation - there were lessons about that. Do you know the answer to the question of which one you need to use?

oliviathomas
@oliviathomas
Jan 26 2017 02:37
@khaduch isn't that the same thing?
Margaret
@Margaret2
Jan 26 2017 02:37
@emilze you need to remove the spaces after the = symbols
Ken Haduch
@khaduch
Jan 26 2017 02:37
@Rocaservices var a would be how you declare a variable - the lessons should cover that basic information.
Margaret
@Margaret2
Jan 26 2017 02:37
@tiremon112 yeah, i went back and found it, i don't think he was being serious :D
oliviathomas
@oliviathomas
Jan 26 2017 02:38
nevermind I got it thank you
Guille
@guillegn
Jan 26 2017 02:38
So it was all about that "!" sign in the return statement.. Next time i would pay more attention like you told me @Margaret2
Margaret
@Margaret2
Jan 26 2017 02:38
@tiremon112 in other news, i just sold a coffee mug :coffee: :D
Ken Haduch
@khaduch
Jan 26 2017 02:38
@oliviathomas - no, they are different... It would be good to review those lessons since it is super critical to know that going forward.
Rocaservices
@Rocaservices
Jan 26 2017 02:38
yea but all if says for me to do is to make sure var a is 6 and var b is defined as 15
@khaduch
Margaret
@Margaret2
Jan 26 2017 02:39
@guillegn :joy: :+1:
Ken Haduch
@khaduch
Jan 26 2017 02:39
@oliviathomas - so when you have a property name stored in a variable, how do you access the object to get the property? If you get this right, you'll have some of the tests passing with that modification in the current code.
Anh Nguyen
@tiremon112
Jan 26 2017 02:39
lol
Ken Haduch
@khaduch
Jan 26 2017 02:39
@Rocaservices - should simply be var a = 6; for the a variable.
Em Eloy
@emilze
Jan 26 2017 02:40
@Margaret2 I just did it but still not working.
yemicarter
@yemicarter
Jan 26 2017 02:40
@khaduch gone back to previous lesson. bracket
Eric
@eric-ds
Jan 26 2017 02:40

I think i'm making a logical error, anyone care to take a look?

`function convertToRoman(num) {

num = num.toString().split("");

var ones;
var fives;
var tens;
var temp;

for (var i = 0; i < num.length; i++){

switch(num[i]){
  case 1:
    temp = "o";
    break;
  case 2:
    temp = "oo";
    break;
  case 3:
    temp = "ooo";
    break;
  case 4:
    temp = "of";
    break;
  case 5:
    temp = "f";
    break;
  case 6:
    temp = "fo";
    break;
  case 7:
    temp = "foo";
    break;
  case 8:
    temp = "fooo";
    break;
  case 9:
    temp = "ot";
    break;
  default:
    temp = "";
}

temp = temp.split("");

switch(num.length - i){
  case 1:
    ones = "I";
    fives = "V";
    tens = "X";
    break;
  case 2:
    ones = "X";
    fives = "L";
    tens = "C";
    break;
  case 3:
    ones = "C";
    fives = "D";
    tens = "M";
    break;
  default:
    ones = "M";
    fives = "";
    tens = "";
}

for(var j = 0; j < temp.length; j++){
  switch(temp[j]){
    case "o":
      temp.splice(j, 1, ones);
      break;
    case "f":
      temp.splice(j, 1, fives);
      break;
    case "t":
      temp.splice(j, 1, tens);
      break;
    default:
  }
}

temp = temp.join("");

num.splice(i, 1, temp);

}

num = num.join("");

return num;
}

convertToRoman(36);`

Rocaservices
@Rocaservices
Jan 26 2017 02:40
@khaduch thanks i shouldve known that im actually dumb
CamperBot
@camperbot
Jan 26 2017 02:40
rocaservices sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Margaret
@Margaret2
Jan 26 2017 02:40
@emilze oh, also take the s out of the url, should be http://
CamperBot
@camperbot
Jan 26 2017 02:40
:star2: 2358 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jan 26 2017 02:41
@yemicarter - great! So if you have the property (which you discovered using .hasOwnProperty(prop), then how would you use bracket notation to return the property value?
Rocaservices
@Rocaservices
Jan 26 2017 02:42
@khaduch no that wasnt it i did it for var a and it didnt do anything
Ken Haduch
@khaduch
Jan 26 2017 02:42
@Rocaservices - sometimes the terminology is confusing. Oh, okay - is this the lesson " Storing Values with the Assignment Operator"? Or which one is it?
Walid Ashri
@walidashri
Jan 26 2017 02:43
@emilze sorry for last msg now it's the spaces after the = :(
Rocaservices
@Rocaservices
Jan 26 2017 02:43
one sec let me check i think
yemicarter
@yemicarter
Jan 26 2017 02:43
@khaduch GOD BLESS YOU!!!
Rocaservices
@Rocaservices
Jan 26 2017 02:43
@khaduch this Understanding Uninitialized Variables
Walid Ashri
@walidashri
Jan 26 2017 02:45
@emilze this works var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Ken Haduch
@khaduch
Jan 26 2017 02:45
@Rocaservices - oh, this is a little more complicated than that, then. The thing that I told you was true, var a = is the way to start that. The thing that you have to do, then, is take into consideration the code down below. For example, for variable a, they are adding 1 to it. So if you want the final answer to be 6, but they are adding 1, what do you have to store in var a = ??? to make that work (fill in the question marks.)
Em Eloy
@emilze
Jan 26 2017 02:46
@Margaret2 and @walidashri It worked! Thank you! :smile:
CamperBot
@camperbot
Jan 26 2017 02:46
emilze sends brownie points to @margaret2 and @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 860 | @walidashri |http://www.freecodecamp.com/walidashri
:star2: 1390 | @margaret2 |http://www.freecodecamp.com/margaret2
Anh Nguyen
@tiremon112
Jan 26 2017 02:46

Rocaservices
@Rocaservices
Jan 26 2017 02:47
@khaduch ok thanks
CamperBot
@camperbot
Jan 26 2017 02:47
rocaservices sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: rocaservices already gave khaduch points
Harout Payaslyan
@hpaya
Jan 26 2017 02:47

function reverseString(str) {

  return str;
}

reverseString("hello");
Can someone give me a hint where to start please, i need to reverse the resulted string
Walid Ashri
@walidashri
Jan 26 2017 02:47
@emilze oh thank GOD :clap:
CamperBot
@camperbot
Jan 26 2017 02:47
walidashri sends brownie points to @emilze :sparkles: :thumbsup: :sparkles:
:cookie: 143 | @emilze |http://www.freecodecamp.com/emilze
Margaret
@Margaret2
Jan 26 2017 02:47
@tiremon112 ~ BLACK HOLE ~
Harout Payaslyan
@hpaya
Jan 26 2017 02:49
anyone please
Ken Haduch
@khaduch
Jan 26 2017 02:50
@hpaya - which lesson is this?
Harout Payaslyan
@hpaya
Jan 26 2017 02:50
@khaduch Reverse a String, under Basic Algorithm Scipting
Rocaservices
@Rocaservices
Jan 26 2017 02:50
@khaduch i dont know if this is right would this be it? var a;
var b;
var c;
var a = 1+5;
var b = 5+10;
c = "I am a";
Walid Ashri
@walidashri
Jan 26 2017 02:51
@hpaya turn the string to array of letters and revers that array
Harout Payaslyan
@hpaya
Jan 26 2017 02:51
using the .reverse()?
Walid Ashri
@walidashri
Jan 26 2017 02:51
yes
Harout Payaslyan
@hpaya
Jan 26 2017 02:51
great
thanks @walidashri
CamperBot
@camperbot
Jan 26 2017 02:51
hpaya sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 861 | @walidashri |http://www.freecodecamp.com/walidashri
Rocaservices
@Rocaservices
Jan 26 2017 02:51
@khaduch nvm got it
Ken Haduch
@khaduch
Jan 26 2017 02:51
@Rocaservices - not quite. the code below does this calculation: a = a + 1; and you want the final result to be 6. You are initializing the variables, so you want var a = 5; and that is all you want in the top part of your code for a.
(Had a typo in the original post)
Anh Nguyen
@tiremon112
Jan 26 2017 02:52
that wrong lul
@Margaret2
void say(string  s);
void ayC();
int main(void)
{
ayC();
}
void ayC()
{
say("I love C" );
}
void say(string  s)
{
printf("%s", s);
}
:coffee:
Margaret
@Margaret2
Jan 26 2017 02:54
Java :dizzy_face: :dizzy:
Is anyone here?
Anh Nguyen
@tiremon112
Jan 26 2017 02:56
@Margaret2 My brain going blow up lul. I learned C from havard lecture, learn java from book, learn C# from derek banas, learn javascript from fcc :scream:
Ken Haduch
@khaduch
Jan 26 2017 02:56
@Anmar0293 - what happens if you have a value in val that is 3 - what should it return?
Margaret
@Margaret2
Jan 26 2017 02:56
@tiremon112 omg idk how you're doing it
Anmar0293
@Anmar0293
Jan 26 2017 02:56
@khaduch it should return less than 5?
Anh Nguyen
@tiremon112
Jan 26 2017 02:56
i opened 3 window and start translate them
i mean 4
lol
Ken Haduch
@khaduch
Jan 26 2017 02:57
@Anmar0293 - that's correct. So what will your code return, and why?
Margaret
@Margaret2
Jan 26 2017 02:57
@tiremon112 why not add Ruby into the mix? one more can't hurt :yum: :gem:
Harout Payaslyan
@hpaya
Jan 26 2017 02:57

@khaduch

```


function reverseString(str) {

  var array = [];
  array = str.split();
  return str;
}

reverseString("hello");
do i seem to be on the right track?
thank
Joseph
@revisualize
Jan 26 2017 02:58
la la la
function addTogether() {
  var x = arguments[0] || 0;
  console.log(x);
  console.log(arguments[1]);
  var y = arguments[1] || 0;
  console.log(y);
  return function(y) {
    return x + y;
  };
}
hmmm.
Margaret
@Margaret2
Jan 26 2017 02:58
@hpaya yeah, but why not just do var array = str.split('');
Ken Haduch
@khaduch
Jan 26 2017 02:58
@hpaya - take a look at the documentation for string.split() - you need to put an argument there.
Anmar0293
@Anmar0293
Jan 26 2017 02:58
@khaduch but it is already written in the code! which is
else if (val < 5) {
return "Less than 5";
could you please put the code so I can see my issue?
Ken Haduch
@khaduch
Jan 26 2017 02:58
@Anmar0293 - yes, but is it also less than 10? And which condition is tested first... basically, ordering of the tests is what I'm after here...
@Anmar0293 - it will respond to the first test condition that tests true
Anmar0293
@Anmar0293
Jan 26 2017 03:00
I solved it. I got it right. But I didn't know it has to be in order. I thought the loop should go no matter what number you insert. I honestly didn't get the point! @khaduch
JacekWrycz-Rekowski
@JacekWrycz-Rekowski
Jan 26 2017 03:00
how to paste a code to chat?
Anmar0293
@Anmar0293
Jan 26 2017 03:01
@JacekWrycz-Rekowski copy the URL link from the browser and paste it here
Ken Haduch
@khaduch
Jan 26 2017 03:01
@Anmar0293 - the examples that they show clearly show the importance of ordering - you should re-read those to make sure you understand how they try to explain things.
@JacekWrycz-Rekowski - if your code is short, you can find the info in the following post from camperbot '''
CamperBot
@camperbot
Jan 26 2017 03:01
:bulb: to format code use backticks! ``` more info
Anmar0293
@Anmar0293
Jan 26 2017 03:02
@khaduch thanks!
CamperBot
@camperbot
Jan 26 2017 03:02
anmar0293 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2359 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jan 26 2017 03:02
@JacekWrycz-Rekowski - if your code is long, you should use a Gist (the info is in the navbar at the top of the chat room) and if it is URL, just post it here.
JacekWrycz-Rekowski
@JacekWrycz-Rekowski
Jan 26 2017 03:02
Basicly i have problem, for(x = 2 ; x < 6; x++) how could it make infinite loop?
Ken Haduch
@khaduch
Jan 26 2017 03:03
@JacekWrycz-Rekowski - it depends what is in the body of the for loop, perhaps. Is this your entire code?
@Anmar0293 - you're welcome.
JacekWrycz-Rekowski
@JacekWrycz-Rekowski
Jan 26 2017 03:03
yes
Joseph
@revisualize
Jan 26 2017 03:04
This is a tough one.
Ken Haduch
@khaduch
Jan 26 2017 03:04
@JacekWrycz-Rekowski - maybe because you have no body of code for the for loop, it is fooling the loop detector? I have not seen this before. Is this a freecodecamp challenge?
@revisualize the addTogether() function problem?
JacekWrycz-Rekowski
@JacekWrycz-Rekowski
Jan 26 2017 03:06
I'm at smallest common multiple, i have added some body and now it looks like :
for(x = 2 ; x < 6; x++){
console.log(x);
}
Joseph
@revisualize
Jan 26 2017 03:06
function addTogether() {
  var x = arguments[0] || 0;
  if (typeof x !== "number") return undefined;
  console.log(x);
  console.log(arguments[1]);
  if (arguments[1] !== undefined) {
    var y = arguments[1];
    if (typeof y !== "number") return undefined;
  }
  return function(y) {
    if (typeof y !== "number") return undefined;
    return x + y;
  };
}
I solved 4/5
addTogether(2, 3); should return 5.
hmmm.
yemicarter
@yemicarter
Jan 26 2017 03:07
unction lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
     }      
   }
   if (firstName != contacts.firstName) {
            return "No such contact";
        }
  if (contacts.hasOwnProperty(prop) !== true) {
     return "No such property";
  }
}
Ken Haduch
@khaduch
Jan 26 2017 03:07
@revisualize - you are missing the simple case...
@yemicarter - alright! You must have a couple tests passing...
yemicarter
@yemicarter
Jan 26 2017 03:08
what is wrong with my last "if statement"?
Joseph
@revisualize
Jan 26 2017 03:08
WAT?
yemicarter
@yemicarter
Jan 26 2017 03:08
@khaduch yeah, remains the last one
Kurt
@recnepstruk
Jan 26 2017 03:09
I need help creating a function that checks for quarternary numbers.
Ethan Rayner Hasan
@TEHEPICDUCK
Jan 26 2017 03:09
some one plz help me
Kurt
@recnepstruk
Jan 26 2017 03:10
@TEHEPICDUCK state your question first.
Ken Haduch
@khaduch
Jan 26 2017 03:10
@yemicarter - there are a couple problems... Remember that contacts is an array, so you are using contacts[i] everywhere that you want to access contacts... except that you aren't...
Joseph
@revisualize
Jan 26 2017 03:10
@khaduch I don't know what you're talking about.
Ethan Rayner Hasan
@TEHEPICDUCK
Jan 26 2017 03:10

var myVar = 87;

// Only change code below this line
myVar ++ myVar = 1;

Ken Haduch
@khaduch
Jan 26 2017 03:11
@revisualize - addTogether(2, 3); should return 5. You aren't handling that case where you simply add them together.
Ethan Rayner Hasan
@TEHEPICDUCK
Jan 26 2017 03:11
dont tell me this is ez im 11
Joseph
@revisualize
Jan 26 2017 03:12
@khaduch Can't I just pass y to the the function?
Ken Haduch
@khaduch
Jan 26 2017 03:13
@revisualize - how does the function get called in that case? How does it get called in the cases like addTogether(2)(3)
It is a great little problem! Very JavaScript-y
Joseph
@revisualize
Jan 26 2017 03:14
x is arguments[0]; ... 2 and ... I really don't know how (3) gets passed to the other function .. I just know it does.
Ken Haduch
@khaduch
Jan 26 2017 03:15

@revisualize - you can create a function like this:

var myFunc = function(a) { return a+1;}

How do you call that function?

Joseph
@revisualize
Jan 26 2017 03:16
myFunc(41);
Returns 42
Ken Haduch
@khaduch
Jan 26 2017 03:16
Okay, so you are returning a function when you have addTogether(2), and then the (3) is invoking that function. For the problem at hand.
Joseph
@revisualize
Jan 26 2017 03:17
I know I can do this:
function addTogether() {
  var x = arguments[0];
  if (typeof x !== "number") return undefined;
  if (arguments[1] !== undefined) {
    var y = arguments[1];
    if (typeof y !== "number") {
      return undefined;
    } else {
      return x+y;
    }
  }
  return function(y) {
    if (typeof y !== "number") return undefined;
    return x + y;
  };
}
addTogether(2,3);
That doesn't seem right though.
Eric
@eric-ds
Jan 26 2017 03:17
@TEHEPICDUCK what does it say on the left about incrementing 'i'?
Ken Haduch
@khaduch
Jan 26 2017 03:18
@revisualize - it is right! At that point, you have two arguments that are both known to be numbers, so you can just add and return.
Joseph
@revisualize
Jan 26 2017 03:18
Doesn't seem very well written.
Moisés Man
@moigithub
Jan 26 2017 03:19
was gonna say something about that || 0 but u removed it ! @revisualize
Ken Haduch
@khaduch
Jan 26 2017 03:19
I did mine a little differently.
Joseph
@revisualize
Jan 26 2017 03:20
@moigithub Yeah.
Okay.. What do you folks think of my solution for that challenge?
Okay?
I mean.. It works.
But, maybe there is a learning opportunity.
Ken Haduch
@khaduch
Jan 26 2017 03:23
@revisualize - I could post my solution - not saying that it is the ultimate, but you could see what I did?
yemicarter
@yemicarter
Jan 26 2017 03:23
@khaduch not gotten it yet
Noah Overcash
@smileytechguy
Jan 26 2017 03:24
@revisualize what is yours again? i will analyze for you
Joseph
@revisualize
Jan 26 2017 03:24
@smileytechguy I literally just posted it.
Like scroll up a few lines.
Noah Overcash
@smileytechguy
Jan 26 2017 03:24
sorry
just joined chat
Joseph
@revisualize
Jan 26 2017 03:24
S`all good.
Anmar0293
@Anmar0293
Jan 26 2017 03:25
I got it thank all
thanks* all
Noah Overcash
@smileytechguy
Jan 26 2017 03:25
yours is actually much more elegant than mine
so i have no comments
Joseph
@revisualize
Jan 26 2017 03:26
hmmm.
I just wrote that up.
Damn. I only spent about 45min on it.
Just think a year and a half ago.. I couldn't even write semi-complex programming.
Ken Haduch
@khaduch
Jan 26 2017 03:28

@yemicarter :point_up: January 25, 2017 10:08 PM - there are two things wrong at this point

  • (this was mentioned many times) You are returning "No such contact" at a point in your loop where you have not examined all of the contacts. There is really no test that you can do within the loop to determine that you have "No such contact".
  • your block where you are returning "No such property" has two problems - one is that you are not using contacts[i] But the other one is that at that point in your loop, you do not know if you have matched the firstName for the contact anyway.

I don't know how much to give for an answer at this point - see if you understand those two points?

Joseph
@revisualize
Jan 26 2017 03:28
I guess I could use Ternary Operator
Ken Haduch
@khaduch
Jan 26 2017 03:29
@revisualize - I'll bet you could even use .reduce()? :)
Joseph
@revisualize
Jan 26 2017 03:31
function addTogether() {
  var x = arguments[0];
  if (typeof x !== "number") return undefined;
  if (arguments[1] !== undefined) {
    var y = arguments[1];
    return (typeof y !== "number") ? undefined : x + y;
  }
  return function(y) {
    return (typeof y !== "number") ? undefined : x + y;
  };
}
Can you use ternary operator in variable assignment?
Ken Haduch
@khaduch
Jan 26 2017 03:34
@revisualize - I think that you can. This new one looks pretty clean. I was hoping for .reduce(), though.. :)
surferpilgrim
@surferpilgrim
Jan 26 2017 03:36
can you help
var myStr="I am a"\"double quoted\"string inside"\double quotes".;
Joseph
@revisualize
Jan 26 2017 03:36
@khaduch I'm actually, trying to finish FCC. I need to stop being a lazy var f = "foxtrot uniform charlie kilo" and get my var s = "stuffs"; addTogether().
Ken Haduch
@khaduch
Jan 26 2017 03:37
@revisualize - I'm in the same boat. I spend more time in the chat rooms than I do on my own coding...
Ogundele Olumide
@Lumexralph
Jan 26 2017 03:37
@surferpilgrim "\" should be \"
@revisualize @khaduch hello :wave:
Ken Haduch
@khaduch
Jan 26 2017 03:38
I've been trying to change course a little and do some of my own learning / completion of exercises.
Joseph
@revisualize
Jan 26 2017 03:38
@khaduch My plan has been to look at migrating my career out of IT Ops (Network Systems Administration) into more of a dev focused role.
Kevin Patel
@kevpatel7
Jan 26 2017 03:38
Hello! For "Profile lookup" am I using .hasOwnProperty to do the checks?
Ken Haduch
@khaduch
Jan 26 2017 03:38
@Lumexralph - hey there...
Jamil Akhtar
@frontender007
Jan 26 2017 03:39
Hello World!
CamperBot
@camperbot
Jan 26 2017 03:39

welcome to FreeCodeCamp @frontender007!

Joseph
@revisualize
Jan 26 2017 03:39
@kevpatel7 Depends on which check.
Ogundele Olumide
@Lumexralph
Jan 26 2017 03:39
@kevpatel7 you're on the way I think
Jamil Akhtar
@frontender007
Jan 26 2017 03:39
my smallestCommons(23,18) not working
every other test is passing
Ken Haduch
@khaduch
Jan 26 2017 03:40
@frontender007 - hello and welcome to freecodecamp!
Ogundele Olumide
@Lumexralph
Jan 26 2017 03:40
@khaduch how're you?
Ken Haduch
@khaduch
Jan 26 2017 03:41
@Lumexralph - I'm okay - tired and ready to stop this for the night... how about you? Just getting started on your coding time?
Ogundele Olumide
@Lumexralph
Jan 26 2017 03:42
@khaduch i just woke up, trying to do some study before work
@khaduch been taking time with ES6 and React, want to use it for my advanced projects
Matheus Vicente
@chamatt
Jan 26 2017 03:44

Hey guys, i just did the Seek and Destroy algorithm, but i'm having trouble undestanding how a part of it works


function destroyer(arr) {
  var args = Array.from(arguments);
  for(var i = 1;i<args.length;i++){
    arr = arr.filter(function(arr){
      return arr !== args[i];
    });
  }
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

How does the callback function gets the variables from the higher level function without me passing arguments to it?

Jamil Akhtar
@frontender007
Jan 26 2017 03:44
@khaduch hi, thanks
CamperBot
@camperbot
Jan 26 2017 03:44
frontender007 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2360 | @khaduch |http://www.freecodecamp.com/khaduch
Ogundele Olumide
@Lumexralph
Jan 26 2017 03:46
@chamatt you mean how it goes through the arr Array?
Matheus Vicente
@chamatt
Jan 26 2017 03:46

I attemped to pass it like this:

arr = arr.filter(function(arr, args, i){
      return arr !== args[i];
    });

but it didn't work, but if i remove the "args" and the "i", then it works.

Kevin Patel
@kevpatel7
Jan 26 2017 03:46
I'm confused on how to check the following: " The function should check if firstName is an actual contact's firstName"?
Matheus Vicente
@chamatt
Jan 26 2017 03:48
I mean how the "args" and the "i" value gets read by the callback function of "filter" without me passing those arguments?
Are does variables in the same scope as the callback and this means it can access it?
Ogundele Olumide
@Lumexralph
Jan 26 2017 03:49
@chamatt the format of callback function for functions like that is function(element, index, array) ...if you change the other you'll get unusual behaviour . this (function(arr, args, i didn't work because you expected the function to think what you wrote whereas this is what the function is doing arr is the element args is the index of the current element and i is the array you changed their names but order stays the same
@kevpatel7 if(contacts[i].firstName === firstName) i assume you have a loop to go through the contacts array
Cindy Xiong
@cindyx123
Jan 26 2017 03:54
how do you exit a function with undefined?
Margaret
@Margaret2
Jan 26 2017 03:55
@cindyx123 return undefined;
return exits the function, undefined is a keyword in javascript
Matheus Vicente
@chamatt
Jan 26 2017 04:01
@Lumexralph Thank you, my question was more about scope of the variables and if it could be acessed by a child function, i messed a little with jsfiddle and found out what i was looking for.
johanna
@joehesse
Jan 26 2017 04:05

stuck whit the counting cards challenge function cc(card) {
// Only change code below this line
switch(card){

case 2:
case 3:
case 4:
case 5:
case 6:
  count++;
  break;

case 10:
case "J":
case "Q":
case "K":
case "A":
  count--;
  break;

}
if (count > 0) {
return Count +" Bet";
}
else {
return count +" Hold";
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Daisy
@dav7788
Jan 26 2017 04:09

Hello everyone, I am stuck on the part that's titled stand in line. I have three of the four check marks, but I can't seem to get them all. This is what I wrote. Can some one please tell me what I did wrong?

function nextInLine(arr, item) {
// Your code here
testArr.push(item);

return testArr.shift(); // Change this line
}

Never mind I figured it out lol
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:13
@chamatt @chamatt okay
@dav7788 testArr.push push into arr not testArr
Alexander
@DurableMicron
Jan 26 2017 04:15
hey guys
for drop it
whats wrong with my code/
Vishnu Vikash Medisetty
@vishnuvikash
Jan 26 2017 04:15

hello everyone , I am stuck here // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)=="true")
return myObj[checkProp];
else
return "Not Found";
}

// Test your code by modifying these values
checkObj("pet");
I tried but i am not able to figure it out, it always prints Not Found

Ogundele Olumide
@Lumexralph
Jan 26 2017 04:15
@joehesse typo Count should be count here return Count +" Bet";
Alexander
@DurableMicron
Jan 26 2017 04:15
i like cant see

function dropElements(arr, func) {
// Drop them elements.
for(var i in arr){
if(func(arr[i])){

  return arr;
}else{
arr.shift();
}

}
return [];
}

oh that markups horrible sorry :C
Cindy Xiong
@cindyx123
Jan 26 2017 04:16
// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a<=0||b<=0);

  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(-2,2);
@Margaret2 I'm trying to exist with this code so i can't return with that code
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:20
@vishnuvikash this returns a boolean already (myObj.hasOwnProperty(checkProp)=="true" and it should be boolean true not a string true, your else statement is without { }
@DurableMicron are you using for...in loop for an array?
Joseph
@revisualize
Jan 26 2017 04:22
Didn't someone say that there was a trick or a shortcut to uppercase a letter in a string?
Nolanmacg
@Nolanmacg
Jan 26 2017 04:22
http://codepen.io/whiteElf_420/pen/GrMRZK How do I center my column
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:25
@cindyx123 just return undefined in the { } of your if statement
@revisualize here? I might have missed that
Kenn Hadnot
@khadnot
Jan 26 2017 04:26
Hey guys I'm having a problem with finding the remainder in javascript. I've already set the the var remainder to 2. The part I'm having trouble with is setting the remainder equal to the remainder of 11 divided by 3
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:27
@khadnot you know what % does, right?
Cindy Xiong
@cindyx123
Jan 26 2017 04:27
@Lumexralph thanks
CamperBot
@camperbot
Jan 26 2017 04:27
cindyx123 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 860 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:27
@cindyx123 :+1:
Kenn Hadnot
@khadnot
Jan 26 2017 04:27
@Lumexralph it divides right?
when I put 11 % 3; nothing happens
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:29
@khadnot it returns the remainder after dividing 2 values, when you divide 11 by 3 what is the remainder ? 3 goes in 11 3 times, right? and it remains 2 ..... % returns that remaining 2
Joseph
@revisualize
Jan 26 2017 04:29
@khadnot Three questions:
What is the returned value of num ... var num = 4 + 3;
What is the returned value of num ... var num = 10 / 5;
What is the returned value of num ... var num = 5 * 3;
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:29
@khadnot you need to store the value returned
Joseph
@revisualize
Jan 26 2017 04:30
@khadnot Also, hello from Interbay. :D
Kenn Hadnot
@khadnot
Jan 26 2017 04:30
how do I store the value returned?
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:30
@khadnot in a variable
Joseph
@revisualize
Jan 26 2017 04:30
@khadnot Can you answer my three questions?
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:31
@khadnot you already have your variable remainder
Kenn Hadnot
@khadnot
Jan 26 2017 04:31
oh i got it!!
i just had to type in remainder = 11 % 3
THANKS @Lumexralph
CamperBot
@camperbot
Jan 26 2017 04:31
khadnot sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 861 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:32
@khadnot yes, but do you understand what you did?
Kenn Hadnot
@khadnot
Jan 26 2017 04:32
yes I set the variable remainder to equal 2
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:32
@khadnot if you don't @revisualize help will be handy
@khadnot where did the 2 come from?
Vishnu Vikash Medisetty
@vishnuvikash
Jan 26 2017 04:33
@Lumexralph thanks it was boolean true.
CamperBot
@camperbot
Jan 26 2017 04:33
vishnuvikash sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 862 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 26 2017 04:33
@vishnuvikash :+1:
Joseph
@revisualize
Jan 26 2017 04:48
BOOM!
I just solved another challenge!
Binary Agents
Two Intermed Algo Challenges today.. Arguments Optional and Binary Agents.
h1tag
@h1tag
Jan 26 2017 05:03

Hey, I'm on the Wiki Viewer project, after typing in the search text box and clicking the button to search, I get these 2 errors:

Ken Haduch
@khaduch
Jan 26 2017 05:04
@revisualize - congratulations! Good to make progress on these, isn't it?
Joseph
@revisualize
Jan 26 2017 05:04
Yeah.
@khaduch Would you be willing to review my solution?
Ken Haduch
@khaduch
Jan 26 2017 05:05
@revisualize - I'd take a look... I just did one for "Arguments Optional" using a .reduce()... a little contrived, but it works. :)
The commented solution is how I did it the first time.
raney150
@raney150
Jan 26 2017 05:06
OK, I am having issues on number 206. the instructions say "Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".. In my code I have "function checkObj(checkProp) {
// Your Code Here
if (checkObj.hasOwnProperty(checkProp)){
return myObj.checkProp;
}else{
return 'Not Found';
}
}" Any ieas on what I am doing wrong?
Ogundele Olumide
@Lumexralph
Jan 26 2017 05:08
@raney150 watch this myObj.checkProp checkProp is a parameter/variable dot method won't work
Joseph
@revisualize
Jan 26 2017 05:08
@Chrono79 thanks for the PM.
Ogundele Olumide
@Lumexralph
Jan 26 2017 05:08
@raney150 is the name of your object checkObj ? here checkObj.hasOwnProperty(checkProp)
Joseph
@revisualize
Jan 26 2017 05:09
cbot
CamperBot
@camperbot
Jan 26 2017 05:09
you called?
revisualize sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3245 | @chrono79 |http://www.freecodecamp.com/chrono79
Ken Haduch
@khaduch
Jan 26 2017 05:09
@revisualize - looks nice. Did you think about using the parseInt() function? Makes it nice and compact. On the other hand, I wrote a binary to decimal converter today that used a .reduce() (can you tell that I'm hung up on the .reduce() method? I'm trying to get the hang of how to use that.)
raney150
@raney150
Jan 26 2017 05:10
@Lumexralph wait, I think I see what I did wrong. let me retry real quick
Ogundele Olumide
@Lumexralph
Jan 26 2017 05:11
@raney150 :smile:
Ken Haduch
@khaduch
Jan 26 2017 05:12
@revisualize - but I like your bin2dec function... nice!
khaduch @khaduch - getting out of here for the night... happy coding everyone!
raney150
@raney150
Jan 26 2017 05:12
@Lumexralph I think you highlighted one problem I had, but it didn't quite fix it. let me post all of the code.

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)){
return myObj.checkProp;
}else{
return 'Not Found';
}
}

// Test your code by modifying these values
checkObj("gift");

Ogundele Olumide
@Lumexralph
Jan 26 2017 05:13
@raney150 myObj.checkProp; checkProp is a parameter how do you use a variable to access an object?
raney150
@raney150
Jan 26 2017 05:15
@Lumexralph That clue helped. Thanks
CamperBot
@camperbot
Jan 26 2017 05:15
raney150 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 863 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 26 2017 05:15
@raney150 :smile:
Joseph
@revisualize
Jan 26 2017 05:20
@khaduch I freaking 1 linered Binary Agents
Ken Haduch
@khaduch
Jan 26 2017 05:22
@revisualize :+1: way to go!
Ademola Adegbuyi
@ooade
Jan 26 2017 05:37
Hola
Jacky Lui
@Recelis
Jan 26 2017 05:43
hey, could someone tell me why this doesn't work? var myStr = "FirstLine\n \SecondLine\ \rThirdLine"; // Change this line //escape clause problem
Satyam Saurabh
@satyam2401
Jan 26 2017 05:44
@Recelis no need of space
@Recelis and for backslash use \\
zuber
@jkdjf
Jan 26 2017 05:45
hi gyes
Dany
@Danylrs
Jan 26 2017 05:45
hey does anyone know how to stop an infinite loop
Joseph
@revisualize
Jan 26 2017 05:45
@Danylrs Buy a new computer.
Dany
@Danylrs
Jan 26 2017 05:45
seriously
zuber
@jkdjf
Jan 26 2017 05:45
anyone know how to assigned a = b
hi dany can u help me
Dany
@Danylrs
Jan 26 2017 05:46
@revisualize really? omg
zuber
@jkdjf
Jan 26 2017 05:46
yes
Jacky Lui
@Recelis
Jan 26 2017 05:46
thanks @satyam2401 !
CamperBot
@camperbot
Jan 26 2017 05:46
recelis sends brownie points to @satyam2401 :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @satyam2401 |http://www.freecodecamp.com/satyam2401
Ademola Adegbuyi
@ooade
Jan 26 2017 05:46
@jkdjf No cos you're already assigning b to a :smile:
Dany
@Danylrs
Jan 26 2017 05:46
i did this by mistake and now my browser froze
I cant even shut the computer off or restart it
zuber
@jkdjf
Jan 26 2017 05:46
cat u
can't you
Joseph
@revisualize
Jan 26 2017 05:47
@Danylrs I'm kidding. You don't need to buy a new computer.
@Danylrs It really depends on your browser and/or OS.
Dany
@Danylrs
Jan 26 2017 05:47
jesus i almost crapped myself lol
i have a mac
Ogundele Olumide
@Lumexralph
Jan 26 2017 05:47
@ooade brotherly
zuber
@jkdjf
Jan 26 2017 05:47
joseph help me
Ogundele Olumide
@Lumexralph
Jan 26 2017 05:48
@ooade good morning
zuber
@jkdjf
Jan 26 2017 05:48
i m just getting stuck in assigned
Ademola Adegbuyi
@ooade
Jan 26 2017 05:48
@Danylrs Windows, Ctrl + Alt + Delete. Linux(Chrome), Shift + Esc to open the browser's task manager then kill the tab :smile:
@jkdjf I just showed u how to assign b to a
@jkdjf var a = b; b is assigned to a
@Lumexralph :raised_hands: Boss, good morning
Dany
@Danylrs
Jan 26 2017 05:52
@ooade Thank You! I almost lost it over here lol, thought I actually needed a new computer.
CamperBot
@camperbot
Jan 26 2017 05:52
danylrs sends brownie points to @ooade :sparkles: :thumbsup: :sparkles:
:cookie: 838 | @ooade |http://www.freecodecamp.com/ooade
Joseph
@revisualize
Jan 26 2017 05:53
@jkdjf Sorry I was talking network security with someone. What do you need?
Ademola Adegbuyi
@ooade
Jan 26 2017 05:53
@Danylrs :smile: @revisualize is a sarcastic fellow, get used to it :laughing:
Joseph
@revisualize
Jan 26 2017 05:53
This:
How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
?
Dany
@Danylrs
Jan 26 2017 05:54
not going to lie I was worried however now im cracking up. Only shows me how much more I have to learn thanks allot @ooade
CamperBot
@camperbot
Jan 26 2017 05:54
danylrs sends brownie points to @ooade :sparkles: :thumbsup: :sparkles:
:warning: danylrs already gave ooade points
Joseph
@revisualize
Jan 26 2017 05:54
@Danylrs OMG.. I was seriously joking. If your computer ever has really bad issues you can / should be able to fix it with a reboot.
Well, I take that back.
Our file server at work got ransomware.
That was a really bad issue that ... you can't really reboot from.
Dany
@Danylrs
Jan 26 2017 05:55
nah its cool dude its actually funny now
Joseph
@revisualize
Jan 26 2017 05:56
It's like telling people to use ALT+F4 to pull up the help menu.
Dany
@Danylrs
Jan 26 2017 06:00
thanks allot for the help guys see you tomorrow, same bat time, same bat channel. ;)
Ricardo González
@Rickgonnz
Jan 26 2017 06:02
hi can help me with the challenge Logical Order in If Else Statements
Nikolay Neykov
@shkurata
Jan 26 2017 06:03
@Rickgonnz, give me some code
Ricardo González
@Rickgonnz
Jan 26 2017 06:03
I'm just missing this point
orderMyLogic(4) should return "Less than 5"
Nikolay Neykov
@shkurata
Jan 26 2017 06:05
@Rickgonnz, you should make two nested if statements
first checks if input is lower than 10
and the inner checks if greater than 5
and output the coorect message
Markus Kiili
@Masd925
Jan 26 2017 06:06
@revisualize Did you use map and parseInt with radix 2?
Joseph
@revisualize
Jan 26 2017 06:06
@Masd925 I did.
Markus Kiili
@Masd925
Jan 26 2017 06:07
@revisualize NIce. Next do Exact change on 1 line ;)
Joseph
@revisualize
Jan 26 2017 06:07
@Masd925 LOL!
I heard that challenge is hard.
Markus Kiili
@Masd925
Jan 26 2017 06:11
@revisualize One-liners are nice when they are readable and elegant. Like this one:
function checkCashRegister(price, cash, cid) {    
  return  (changeLeft = cash-price) && (change = cid.reverse().reduce(function(prev,curr){
    return (amount = (Math.min(changeLeft,curr[1])+(LAMBDA=0.0000001))/
           (note = {"ONE HUNDRED":100,"TWENTY":20,"TEN":10,"FIVE":5,"ONE":1,"QUARTER":0.25,
                    "DIME":0.10,"NICKEL":0.05,"PENNY":0.01}[curr[0]])>>0) ? 
             prev.push([curr[0],amount*note]) && (curr[1] -= amount*note)+1 && (changeLeft -= amount*note)+1 && prev
             :
             prev;
  },[])) &&
  changeLeft>LAMBDA ? 
    "Insufficient Funds" 
    :          
    cid.every(function(elem){return elem[1]<LAMBDA;}) ? "Closed" : change;
}
Ricardo González
@Rickgonnz
Jan 26 2017 06:12
@shkurata i'm stuck on this
Joseph
@revisualize
Jan 26 2017 06:12
GEZUH!
Sourav Borah
@Souravborah
Jan 26 2017 06:14
can anyone helpme with this lesson "
Make Object Properties Private". i logged into freecodecamp after some months and i nearly forgot everything. pk,ease help
Markus Kiili
@Masd925
Jan 26 2017 06:14
@Souravborah Post the code you have done so far.
Sourav Borah
@Souravborah
Jan 26 2017 06:15
can u just explain me this once? i'll try doing it myself once
@Masd925
Nikolay Neykov
@shkurata
Jan 26 2017 06:15
@Rickgonnz, want to see my code?
Sourav Borah
@Souravborah
Jan 26 2017 06:16
???
Shusil Banjade
@shusil123
Jan 26 2017 06:17
@Masd925 , That is the most elegant solution I've seen to Exact Change problem. :+1:
Markus Kiili
@Masd925
Jan 26 2017 06:17
@Souravborah When you make a new object with a constructor function var obj = new constr(); the engine makes a new plain object and puts it as value of this and runs the constructor code. So those properties defined by this.prop=... become properties of the new object. Variables inside constuctor defined by var something; are private variables that can be accessed only by the methods. That way objects can have some private data that can be accessed by methods but not in any other way, after the object is created.
@shusil123 You mean the ugliest.
Shusil Banjade
@shusil123
Jan 26 2017 06:18
@Masd925 , :smile: A Big YES.
Markus Kiili
@Masd925
Jan 26 2017 06:19
@shusil123 That was just to warn @revisualize not to stuff everything on one line.
Nikolay Neykov
@shkurata
Jan 26 2017 06:19
@Rickgonnz, you have 3 cases
Ricardo González
@Rickgonnz
Jan 26 2017 06:19
@shkurata ok!
Joseph
@revisualize
Jan 26 2017 06:25
@Masd925 Yeah yeah. There's a point when one line just becomes too much.
yemicarter
@yemicarter
Jan 26 2017 06:26
still not getting this
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
     } 

   } 
  if (contacts.hasOwnProperty(prop) !== true) {
    return "No such property";
  }
   if (firstName != contacts[i].firstName) {
            return "No such contact";
   }
}
Joseph
@revisualize
Jan 26 2017 06:27
@yemicarter You're returning things way too early.
ag8023
@ag8023
Jan 26 2017 06:27
hello! i have a quesry for JS
Joseph
@revisualize
Jan 26 2017 06:27

@yemicarter This:

  if (contacts.hasOwnProperty(prop) !== true) {
    return "No such property";
  }

Should be inside of your for loop.

ag8023
@ag8023
Jan 26 2017 06:27
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp))
return myObj.checkProp;
return "Not Found";
Sourav Borah
@Souravborah
Jan 26 2017 06:27

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear = 1;

this.accelerate = function(change){
gear += 1;
};

this.decelerate = function(){
gear -= 1;
};

this.getGear = function(){
return gear;
};

this.setGear = function(){
return gear;
};
};

var myCar = new Car();

var myBike = new Bike();

can anyone help me with this?
Joseph
@revisualize
Jan 26 2017 06:28
@ag8023 Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
ag8023
@ag8023
Jan 26 2017 06:28
im not sure what is wrong with the code
ahh ok!
Joseph
@revisualize
Jan 26 2017 06:28
Okay.
Sourav Borah
@Souravborah
Jan 26 2017 06:29
@Masd925 cn u check my code ?
Joseph
@revisualize
Jan 26 2017 06:29
1028pm here in Seattle.
I'm off to get those :zzz: s
Actually.
ag8023
@ag8023
Jan 26 2017 06:29
Thanks Joseph!
Joseph
@revisualize
Jan 26 2017 06:29
@Masd925 Would you be willing to look over my solution for Arguments Optional?
Markus Kiili
@Masd925
Jan 26 2017 06:29
@revisualize Sure.
Markus Kiili
@Masd925
Jan 26 2017 06:30
@Souravborah Check what methods you were supposed to make and what they do.
Sourav Borah
@Souravborah
Jan 26 2017 06:31
okay let me check
yemicarter
@yemicarter
Jan 26 2017 06:31
@revisualize i put it in the for loop, still not passing
Joseph
@revisualize
Jan 26 2017 06:31
@yemicarter Show me.
@yemicarter Have you tried using www.pythontutor.com/javascript.html ?
yemicarter
@yemicarter
Jan 26 2017 06:32
@revisualize
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
     } 
    if (contacts.hasOwnProperty(prop) !== true) {
    return "No such property";
  } 
   } 

   if (firstName != contacts[i].firstName) {
            return "No such contact";
   }
}
@revisualize yeah, cldn't understand all those arrows and stuff
Joseph
@revisualize
Jan 26 2017 06:33
@yemicarter What's the difference between your two references for .hasOwnProperty()?
Nitesh Kumar
@Nitesh8833
Jan 26 2017 06:33
hi everyone any one can help to solve the issue of Javascript ie var myVar=87;
Joseph
@revisualize
Jan 26 2017 06:33

@Nitesh8833

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Xyrus Pangyarihan
@xyruspangyarihan
Jan 26 2017 06:34
@Nitesh8833 whats the error with your code?
Nitesh Kumar
@Nitesh8833
Jan 26 2017 06:34
Joseph
@revisualize
Jan 26 2017 06:34
I'm @revisualize .. But, you're welcome.
yemicarter
@yemicarter
Jan 26 2017 06:34
@revisualize ???
Nitesh Kumar
@Nitesh8833
Jan 26 2017 06:35
My Error myVar = myVar should be changed
Joseph
@revisualize
Jan 26 2017 06:35
@Nitesh8833 It should.
Markus Kiili
@Masd925
Jan 26 2017 06:35
@revisualize Fine solution. I think the logic is not very easy to read there. I like this kind of checking more for readability:
  if (arguments.length===2 && typeof(arguments[0])==='number' && typeof(arguments[1])==='number') return ...
  if (arguments.length===1 && typeof(arguments[0])==='number') return ...
And let the engine return undefined on other cases.
Joseph
@revisualize
Jan 26 2017 06:36
@Masd925 I see. Thanks.
CamperBot
@camperbot
Jan 26 2017 06:36
revisualize sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3230 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jan 26 2017 06:36
Some repetition, but much clearer imo.
Ricardo González
@Rickgonnz
Jan 26 2017 06:37
please i need an orientation with the challenge Logical Order in If Else Statements
in this point orderMyLogic(4) should return "Less than 5"
Joseph
@revisualize
Jan 26 2017 06:38
@yemicarter Look at what you're doing
if (contacts.hasOwnProperty(prop) !== true) {
but, on the line above...
contacts[i].hasOwnProperty(prop))
...
Alright.. I really do need to go to bed.
Good Night.
Good luck.
yemicarter
@yemicarter
Jan 26 2017 06:40
@revisualize i have changed it, though no such property is passing, no such contact is not
Joseph
@revisualize
Jan 26 2017 06:40
@yemicarter Because you don't need all that if stuff around the return statement.
in fact. Outside of the for loop.. i is pretty useless.
(for that challenge.)
:zzz: ... :sailboat: ... :zzz: ... :sailboat: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :dolphin: :whale2: :sunrise: ... :zzz:
:v:
revisualize @revisualize really does leave.
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 06:45

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

]; var myMusic =[

{
"artist":"Huzaifa",
"title": "Homework",

}

];

is there anything wrong ?
Satyam Saurabh
@satyam2401
Jan 26 2017 06:46
@yemicarter contacts[i].hasOwnProperty(prop) will check if the property is there in object or not. You don't need !== true assignment to it. And return "no such contact" will come after for loop ends.
@huzaifa83 use a coma and not ; between two objects
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 06:47
ok
i tried using comma
i am getting an error

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

], var = myMusic1 =[

{
"artist":"Huzaifa",
"title": "Homework",

}

];

I am getting an error for the second object
Satyam Saurabh
@satyam2401
Jan 26 2017 06:51
@huzaifa83 remove = between var and myMusic
yemicarter
@yemicarter
Jan 26 2017 06:54
Guyys i have gotten it @satyam2401 @revisualize
yemicarter
@yemicarter
Jan 26 2017 06:54
@satyam2401 @revisualize thanks guys
CamperBot
@camperbot
Jan 26 2017 06:54
yemicarter sends brownie points to @satyam2401 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @satyam2401 |http://www.freecodecamp.com/satyam2401
:star2: 3121 | @revisualize |http://www.freecodecamp.com/revisualize
redoz94
@redoz94
Jan 26 2017 06:55
hi there can i use .push for this? (https://www.freecodecamp.com/challenges/stand-in-line)
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 06:56

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

], myMusic[1] =[

{
"artist":"Huzaifa",
"title": "Homework",

}

];

I am getting an unexpected token error
after the first object
Dipen Bagia
@dbagia
Jan 26 2017 06:57
@huzaifa83 remove "]," before myMusic[1].
Ammy3165
@Ammy3165
Jan 26 2017 06:57
hi, everybody I hate reading whole stuff on MDN. what should I do to come over?
Satyam Saurabh
@satyam2401
Jan 26 2017 06:57
you have not declared myMusic with var . @huzaifa83
yemicarter
@yemicarter
Jan 26 2017 06:57
@satyam2401 @revisualize been meditating on this to find the thinking behind the error
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
     } 
    if (contacts[i].hasOwnProperty(prop) !== true) {
    return "No such property";
      } 

   } 
  if (firstName != contacts.firstName) {
            return "No such contact";
     }
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 06:59
now I am getting error of var
Markus Kiili
@Masd925
Jan 26 2017 06:59
@yemicarter Last return is the problem. Simplest structure would be two nested if's for the firstname and property existence checks.
Satyam Saurabh
@satyam2401
Jan 26 2017 07:00
@yemicarter close the function with }
Then it should run @yemicarter
Dipen Bagia
@dbagia
Jan 26 2017 07:01
@huzaifa83 ignore my previous comment. Your first var myMusic is variable declaration and initialization. You need to delete the "," after that. You could instead use ";"
Satyam Saurabh
@satyam2401
Jan 26 2017 07:02
@huzaifa83 show your code after you have edited it
ag8023
@ag8023
Jan 26 2017 07:03
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName && contacts[i].hasOwnProperty(prop))
return contacts[i][prop];
else if(!contacts[i].firstName)
return "No such contact";
else if (!contacts[i].hasOwnProperty(prop))
return "No such property";
}
im a bit confused here
oh forgot firstName ==
Markus Kiili
@Masd925
Jan 26 2017 07:04
@yemicarter contacts is an array. It has no firstName property contacts.firstName
sanjeev
@sanjeev26
Jan 26 2017 07:04
I need to create a private method with gear and two public methods called get
Brittni Willett
@Willow606
Jan 26 2017 07:05
Hey can someone help me with https://www.freecodecamp.com/challenges/binary-agents ? This is what I have so far:
function binaryAgent(str) {
  //split string into an array
  str = str.split(' ');
  for(i = 0; i < str.length; i++){
    //turn array values into unicode values
    str[i] = parseInt(str[i], 2);
    //turn unicode values into new strings
    str[i] = String.fromCharCode(str[i]);
  }
  str = str.toString();
  //return string
  return str;
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
sanjeev
@sanjeev26
Jan 26 2017 07:05
getGear n setGear to get and set that value
ag8023
@ag8023
Jan 26 2017 07:06
hello i need help with this please
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
if(firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop))
return contacts[i][prop];
else if(firstName != contacts[i].firstName)
return "No such contact";
else if (!contacts[i].hasOwnProperty(prop))
return "No such property";
}
// Only change code above this line
}
sanjeev
@sanjeev26
Jan 26 2017 07:08

got stuck, anybody this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear = 0;

this.getGear = function(get){
gear = get;
};
this.setGear = function(){
return get;
};
};

var myCar = new Car();

var myBike = new Bike();

Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 07:09

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

]; myMusic[1] =[

{
"artist":"Huzaifa",
"title": "Homework",
"release_year": 1983,
"formats": [
"CD",
"DVD"
],
"silver":true

}

];

Satyam Saurabh
@satyam2401
Jan 26 2017 07:09
@ag8023 !== is right and this != is not , also why is there ! before contacts[i].hasOwnProperty(prop)
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 07:10
the object is added
but the properties to the second are coming fine
are not fine
ag8023
@ag8023
Jan 26 2017 07:11
@satyam2401 thats just to check for the boolean. if false, the ! turns it to true
@satyam2401 I will try the !==
thanks!
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 07:11
please help
yemicarter
@yemicarter
Jan 26 2017 07:12
@Masd925 but it passed exactly like this
unction lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i= 0; i < contacts.length; i++ ){
     if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
     } 
    if (contacts[i].hasOwnProperty(prop)) {

      } 
     else {
       return "No such property";
     }

   } 
  if (firstName != contacts.firstName) {
            return "No such contact";
     }

}
Satyam Saurabh
@satyam2401
Jan 26 2017 07:12
; myMusic[1] =[ replace it with , myMusic = [ @huzaifa83
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 07:12
But they want the name as myMusic[1]
Markus Kiili
@Masd925
Jan 26 2017 07:13
@yemicarter The last if is redundant. You can just return without the if.
Satyam Saurabh
@satyam2401
Jan 26 2017 07:16
@huzaifa83 give the link of the challenge
Markus Kiili
@Masd925
Jan 26 2017 07:16
@yemicarter Because of the repeating conditions and the empty if block, the logic is hard to follow. You could refactor the code into something like this:
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i<contacts.length; i++) {
    if (contacts[i].firstName===firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
Satyam Saurabh
@satyam2401
Jan 26 2017 07:18
@huzaifa83 this is correct.
What is the problem you are getting?
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 07:19

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

]; myMusic[1] =[

{
"artist":"Huzaifa",
"title": "Homework",
"release_year": 1983,
"formats": [
"CD",
"DVD"
],
"silver":true

}

];

this is my current code
when i run the results it just displays the code in the results
thats it
What to do ?
Markus Kiili
@Masd925
Jan 26 2017 07:21
@huzaifa83 You need to assign an object there, not an array.
Satyam Saurabh
@satyam2401
Jan 26 2017 07:21
@huzaifa83 you have to add another record. You are making an array
yemicarter
@yemicarter
Jan 26 2017 07:21
is there a way here to archirve comments in case i want to read them again??
Satyam Saurabh
@satyam2401
Jan 26 2017 07:22
var myMusic = [
{
},
{
}
];
@huzaifa83
Andy
@AndyRSV
Jan 26 2017 07:25
blob
Hi everyone! Looking for help in this exercice! A dont understand what I'm doing wrong!
blob
ag8023
@ag8023
Jan 26 2017 07:25
hello i am still not getting results even after refactoring the code
please help!
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++)
{
if(contacts[i].firstName === firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
return "No such property";
}
return "No such contact";
}
// Only change code above this line
}
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:26
@ag8023 return no such contact when your loop is done
Jor
@joreyesl
Jan 26 2017 07:26
@AndyRSV ThirdLine need to cap the line
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:26
@Masd925 hallo
Satyam Saurabh
@satyam2401
Jan 26 2017 07:27

function lookUpProfile(firstName, prop){
// Only change code below this line
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i= 0; i < contacts.length; i++ ){
if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
if (contacts[i].hasOwnProperty(prop) !== true) {
return "No such property";
}

}
if (firstName !== contacts.firstName) {
return "No such contact";
}
}
@yemicarter @Masd925 This is also correct, which @yemicarter stated before. Though it is not the optimal solution, but it is correct.

ag8023
@ag8023
Jan 26 2017 07:27
@Lumexralph im passing the tests for no such property and no such contact
what i am not passing the test for is for values that exist
Markus Kiili
@Masd925
Jan 26 2017 07:28
@satyam2401 Last condition is totally wrong and also redundant.
@Lumexralph Hi.
Satyam Saurabh
@satyam2401
Jan 26 2017 07:29
@Masd925 True, no need of last if statement.
Andy
@AndyRSV
Jan 26 2017 07:30
@joreyesl oh damn thanks a lot! I
CamperBot
@camperbot
Jan 26 2017 07:30
andyrsv sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 379 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ponlawat
@Ponlawat15
Jan 26 2017 07:30

var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4 || card == 5 || card == 6)
return "5 Bet";
if (card == 7 || card == 8 || card == 9)
return "0 Hold";
if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A")
return "-5 Hold";
if (card == 3 || card == 7 || card == "Q" || card == 8 || card == "A")
return "-1 Hold";
if (card == 2 || card == "J" || card == 9 || card == 2 || card == 7)
return "1 Bet";
if (card == 2 || card == 2 || card == 10)
return "1 Bet";
if (card == 3 || card == 2 || card == "A" || card == 10 || card == "K")
return "-1 Hold"; {

}  

return "Change Me";

Satyam Saurabh
@satyam2401
Jan 26 2017 07:30
But even if it is there, it will only increase the run time @Masd925
Markus Kiili
@Masd925
Jan 26 2017 07:31
@satyam2401 It makes it bad code. That is the problem.
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:31
@ag8023 I've told you what you're missing, remove the return no such contact from the loop and return it out of the loop, try that
Ponlawat
@Ponlawat15
Jan 26 2017 07:31
Trying to do the card counting problem. it seems like I am doing something wrong. Could someone assist?
var count = 0;

function cc(card) {
  // Only change code below this line
  if (card == 2 || card == 3 || card == 4 || card == 5 || card == 6) 
  return "5 Bet";
   if (card == 7 || card == 8 || card == 9) 
    return "0 Hold";
  if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A")
    return "-5 Hold";
  if (card == 3 || card == 7 || card == "Q" || card == 8 || card == "A") 
    return "-1 Hold";
  if (card == 2 || card == "J" || card == 9 || card == 2 || card == 7)
    return "1 Bet";
  if (card == 2 || card == 2 || card == 10)
    return "1 Bet";
  if (card == 3 || card == 2 || card == "A" || card == 10 || card == "K")
    return "-1 Hold"; {

    }  
  return "Change Me”;
}
cc(2); cc('J'); cc(7); cc('K'); cc('A');
Satyam Saurabh
@satyam2401
Jan 26 2017 07:31
@Masd925 I agree.
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:31
@Masd925 How're you? and How's today panning out?
Chigoziem Nwaiwu
@mindsworth
Jan 26 2017 07:31
@Ponlawat15 .. will this work?
Pramod Potdar
@ppmakeitcount
Jan 26 2017 07:32
Hey anyone here has stored image files with multer on server?
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:32
@Ponlawat15 you're to increment or decrement count in your condition statements
Ponlawat
@Ponlawat15
Jan 26 2017 07:32
@mindsworth No,.
Markus Kiili
@Masd925
Jan 26 2017 07:32
@Lumexralph Some flu this week. Otherwise fine.
Chigoziem Nwaiwu
@mindsworth
Jan 26 2017 07:33
am stock here ... any idea? @Ponlawat15
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:33
@Masd925 sorry man
ag8023
@ag8023
Jan 26 2017 07:33
@Lumexralph that worked! Thanks!
CamperBot
@camperbot
Jan 26 2017 07:33
ag8023 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 864 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ponlawat
@Ponlawat15
Jan 26 2017 07:33
@Lumexralph I see
@mindsworth I am guessing we are on the same boat.
Chigoziem Nwaiwu
@mindsworth
Jan 26 2017 07:34
@Ponlawat15 ... it worked LOL
Ponlawat
@Ponlawat15
Jan 26 2017 07:35
@mindsworth really? how?
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:35
@Ponlawat15 yeah, when you're done with the condition statement then you'll check if count is greater or less than 0 to return count + string
Ponlawat
@Ponlawat15
Jan 26 2017 07:37
@Lumexralph Thank you
CamperBot
@camperbot
Jan 26 2017 07:37
ponlawat15 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 865 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 26 2017 07:37
@Ponlawat15 you're welcome
yemicarter
@yemicarter
Jan 26 2017 07:39
is there any way to save a comment here??
c0d0er
@c0d0er
Jan 26 2017 07:41
now i can use button click to change board with redux, but cannot find the way to use setInterval (currently the setInterval is inside componentDidMount), any idea to fix? http://codepen.io/c0d0er/pen/apLNPV
Huzaifa Gadiwala
@huzaifa83
Jan 26 2017 07:41

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

{
"artist": "Bruce Wayne",
"title": "The Batman",
"release_year":1983,
"formats":[
"CD",
"DVD"
]
}

];

finally got it
thanks
Chigoziem Nwaiwu
@mindsworth
Jan 26 2017 07:46
Markus Kiili
@Masd925
Jan 26 2017 07:55
@mindsworth Value of card should only change count. After that you should determine the return value from count, not card.
Archit Chandra
@architchandra
Jan 26 2017 07:57

var falsy = [false, null, 0, '', undefined, NaN];

function checkFalse(value)  {

  if(falsy.indexOf(value) == -1)  {

    return true;
  }

  else

    return false;
}

function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  arr = arr.filter(checkFalse);

  return arr;
}

bouncer([false, null, 0, NaN, undefined, ""]);
It seems that the IndexOf method does not check for null properly. Any suggestions on how I should approach this problem?
Markus Kiili
@Masd925
Jan 26 2017 07:58
@architchandra The problem is NaN (shown as null on FCC console). NaN is not equal to any value, so indexOf fails.
Archit Chandra
@architchandra
Jan 26 2017 07:59
Oh okay.
Jor
@joreyesl
Jan 26 2017 08:01
@architchandra if a value is falsy, then if([insert value here]) will evaluate as false.
Archit Chandra
@architchandra
Jan 26 2017 08:03
@joreyesl Even if the value is NaN?
Jor
@joreyesl
Jan 26 2017 08:04
@architchandra yes, NaN is falsy
Markus Kiili
@Masd925
Jan 26 2017 08:08
@architchandra Another way to put it is that if(val){...} tests for truthiness.
So no need to list all the falsies.
Archit Chandra
@architchandra
Jan 26 2017 08:09
@Masd925 Okay, I'll try that.
Based on what @joreyesl said, I tried the following, but it's giving a typerror: cannot read property isNan of null

var falsy = [false, null, 0, '', undefined];

function checkFalse(value)  {

  if(value.isNaN)  {

    return false;
  }

  else if(value)  {

    return false;
  }

  else return true;

}

function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  arr = arr.filter(checkFalse);


}

bouncer([false, null, 0, undefined, "", NaN]);
Markus Kiili
@Masd925
Jan 26 2017 08:12
@architchandra You could do if(value){return true;}. There are even more simple ways too.
Jor
@joreyesl
Jan 26 2017 08:13
@architchandra Since you are checking if a value is truthy or falsy, you can just do
if(value) {return true;} else { return false;}
John Njenga
@smartkiddo
Jan 26 2017 08:13
Archit Chandra
@architchandra
Jan 26 2017 08:14
@Masd925 @joreyesl - It worked. Thank you very much. Had been racking my brains on this one for a while. Overcomplicated it. :)
CamperBot
@camperbot
Jan 26 2017 08:14
architchandra sends brownie points to @masd925 and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3231 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jan 26 2017 08:14
@architchandra If you know that filter has automatic coercion to type Boolean (it keeps those array elements that return a truthy value from the callback), you can solve it with just function checkFalse(value) {return value;}
grantknaver
@grantknaver
Jan 26 2017 08:18
help where do I go from here
CamperBot
@camperbot
Jan 26 2017 08:18
no wiki entry for: where do i go from here
grantknaver
@grantknaver
Jan 26 2017 08:18

function checkCashRegister(price, cash, cid) {

 // Here is your change, ma'am.
  var moneyTypes = [

{name: "ONE HUNDRED", val: 100.00},
{name:"TWENTY", val: 20.00},
{name:"TEN", val: 10.00},
{name: "FIVE", val: 5.00},
{name:"ONE", val: 1.00},
{name: "QUARTER", val: 0.25},
{name: "DIME", val: 0.10}, 
{name: "NICKEL", val: 0.05},
{name:"PENNY", val: 0.01}

];
  var answer = [];
  var inverseCid = cid.sort(function(a,b){
    return a < b;  
  });
  var howManyDenominations = [];
  for(var i = 0; i < cid.length; i++){
    answer.push(cid[i][1]);
    //howManyDenominations.push(Math.round(inverseCid[i][1] / moneyTypes[i].val));
  }
  var cashInDrawer = answer.reduce(function(a,b){return a + b;});
  cashInDrawer = cashInDrawer.toFixed(2);
  var changeDo = cash - price;
  changeDo = changeDo.toFixed(2);

  var changeReturn = [];
    if(cashInDrawer < changeDo){
      return "Insufficient Funds";
    }else if(cashInDrawer === changeDo){
      return "Closed";
    }else{
      for(var a = 0; a < inverseCid.length; a++){
        for(var b = 0; b <moneyTypes.length; b++){
          if(inverseCid[a][0] === moneyTypes[b]){
             if(){

             }  
          }
        }    
      }
    }
  alert(inverseCid[0][0]); 

  //var changeReturnReduced = changeReturn.reduced(function(a,b){return a + b;});
  //var sortedChange = changeDo.sort(function(a,b){return b[1] < a[1];});




}



checkCashRegister(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]]);
here is the lesson
Archit Chandra
@architchandra
Jan 26 2017 08:20
@Masd925 Shit, you're right. I was also trying to see if I could directly pass the array into the array.filter() function directly but that seems undoable. So need to create a new function just to pass the value into filter.
@Masd925 Do you think there is a simple way to write this without creating a separate function ?
grantknaver
@grantknaver
Jan 26 2017 08:21
Ok if someone can help cause me stuck completely no idea
Markus Kiili
@Masd925
Jan 26 2017 08:22
@architchandra You always pass a function into filter, but one way is function bouncer(arr) {return arr.filter(Boolean);}
Ugur Ozcelik
@ugurozcelik
Jan 26 2017 08:23

function palindrome(str) {
if (str.split("") === str.reverse.split(""));
// Good luck!
return true;
}
else ;{
return false;
}

palindrome("eye");
what did i do wrong here?

playingwithinfinity
@playingwithinfinity
Jan 26 2017 08:28
What is wrong with my code for Check for Palindromes? It passes on some test cases but fails on others?

function palindrome(str) {
  str = str.toLowerCase();
  var re = /\W/gi;
  var a = str.replace(re,'');
  a = a.split('');
  a = a.join('');

return a === str;
}
palindrome("race car");
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:30
hi any regex enthusiasts out here?
i would appreciate your help
Coy Sanders
@coymeetsworld
Jan 26 2017 08:32
@playingwithinfinity whitespaces shouldn't be kept
Archit Chandra
@architchandra
Jan 26 2017 08:32
@Masd925 That was super amazing. Thanks! Now trying to understand boolean vs Boolean
CamperBot
@camperbot
Jan 26 2017 08:32
architchandra sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: architchandra already gave masd925 points
Coy Sanders
@coymeetsworld
Jan 26 2017 08:33
\W is filtering out anything thats not a word, digit, or whitespace
playingwithinfinity
@playingwithinfinity
Jan 26 2017 08:33
@coymeetsworld So what should I do?
CamperBot
@camperbot
Jan 26 2017 08:34
no wiki entry for: please httpswwwfreecodecampcomchallengesgenerate-random-whole-numbers-within-a-rangesolution0a2f2f20example0afunction20ourrandomrangeourmin2c20ourmax207b0a0a2020return20mathfloormathrandom2020ourmax20-20ourmin202b201202b20ourmin3b0a7d0a0aourrandomrange12c2093b0a0a2f2f20only20change20code20below20this20line0a0afunction20randomrangemymin2c20mymax207b0a0a2020return20mathfloormathrandom3e3dmymax-mymin2b12bmymin3b202f2f20change20this20line0a0a7d0a0a2f2f20change20these20values20to20test20your20function0avar20myrandom203d20randomrange52c20153b0aam i doing this right it wont pass examplefunction ourrandomrangeourmin ourmax return mathfloormathrandom ourmax - ourmin 1 ourminourrandomrange1 9 only change code below this linefunction randomrangemymin mymax return mathfloormathrandommymax-mymin1mymin change this line change these values to test your functionvar myrandom randomrange5 15
Coy Sanders
@coymeetsworld
Jan 26 2017 08:34
need something more specific than that regex @playingwithinfinity
playingwithinfinity
@playingwithinfinity
Jan 26 2017 08:34
@coymeetsworld What do you mean? I have to change the Regex?
Markus Kiili
@Masd925
Jan 26 2017 08:34
@architchandra Beware that the Boolean object (created by new Boolean() ) is the one you don't really use ever. You use boolean values true/false of type Boolean and Boolean function Boolean().
Coy Sanders
@coymeetsworld
Jan 26 2017 08:34
that would be the best option yeah @playingwithinfinity
or a less than ideal solution is write another regex that removes spaces along with that, but better to just use replace just once
playingwithinfinity
@playingwithinfinity
Jan 26 2017 08:35
@coymeetsworld Ok
Coy Sanders
@coymeetsworld
Jan 26 2017 08:35
http://regexr.com/ good place to test out and it has a cheatsheet
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:36
i have string f="a1,b11,c12"
and if i find index of b1 it shows 3
thats a problem
Coy Sanders
@coymeetsworld
Jan 26 2017 08:37
why is that a problem @sheetalgiri? Thats the right answer
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:38
for my use case b1 should not be a part of f
Coy Sanders
@coymeetsworld
Jan 26 2017 08:38
@sheetalgiri can you explain specifically what you're trying to do? I'm not following. Also is this JavaScript?
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:38
i tried with /b1,?/
Jor
@joreyesl
Jan 26 2017 08:38
you mean, you want to match, b11 but not b1?
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:39
yes
Antoine Guillien
@Sladix
Jan 26 2017 08:39
Hello everyone !
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:39
i also tried with /b1,*/
Coy Sanders
@coymeetsworld
Jan 26 2017 08:39
think you would need to use a lookahead or something like that
negative lookahead?
Antoine Guillien
@Sladix
Jan 26 2017 08:40
I was wondering, how would you efficiently go from a ['key:value','key:value'] array to a {key:value,key:value} object ?
CamperBot
@camperbot
Jan 26 2017 08:40
no wiki entry for: please httpswwwfreecodecampcomchallengesgenerate-random-whole-numbers-within-a-rangesolution0a2f2f20example0afunction20ourrandomrangeourmin2c20ourmax207b0a0a2020return20mathfloormathrandom2020ourmax20-20ourmin202b201202b20ourmin3b0a7d0a0aourrandomrange12c2093b0a0a2f2f20only20change20code20below20this20line0a0afunction20randomrangemymin2c20mymax207b0a0a2020return20mathfloormathrandom3e3dmymax-mymin2b12bmymin3b202f2f20change20this20line0a0a7d0a0a2f2f20change20these20values20to20test20your20function0avar20myrandom203d20randomrange52c20153b0aam i doing this right it wont pass examplefunction ourrandomrangeourmin ourmax return mathfloormathrandom ourmax - ourmin 1 ourminourrandomrange1 9 only change code below this linefunction randomrangemymin mymax return mathfloormathrandommymax-mymin1mymin change this line change these values to test your functionvar myrandom randomrange5 15
Coy Sanders
@coymeetsworld
Jan 26 2017 08:40
but in negative lookahead you need to say specifically what you don't want after b1
guessing that would be a comma, idk
Nitesh Kumar
@Nitesh8833
Jan 26 2017 08:40
help me pls in this
CamperBot
@camperbot
Jan 26 2017 08:40
no wiki entry for: me pls in this
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:40
why aren't my ways working?
logically they seem correct
Jor
@joreyesl
Jan 26 2017 08:41
@sheetalgiri what have you tried?
Nitesh Kumar
@Nitesh8833
Jan 26 2017 08:41
var myStr ='FirstLine"\n"\SecondLine\"\r"ThirdLine';
myStr should have encoded text with the proper escape sequences and no spacing
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:41
/b1,?/ and /b1,*/
Coy Sanders
@coymeetsworld
Jan 26 2017 08:42
just b1, should work
Joseph Uchenna
@afrikhero
Jan 26 2017 08:42
please I want to know to sum data in array e.g var fun = [2, 4, 5, 6] sum fun to total 17
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:42
but sometimes b11 can be at the end of the string
Coy Sanders
@coymeetsworld
Jan 26 2017 08:42
* or ? is going to match more characters in your regex
so? you don't care about b11 right?
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:43
well there is either one comma or no comma following b11
redoz94
@redoz94
Jan 26 2017 08:44
guys plz i need help
playingwithinfinity
@playingwithinfinity
Jan 26 2017 08:44
How do I check if a character is in lowercase or not?
Antoine Guillien
@Sladix
Jan 26 2017 08:44
@afrikhero Hey, you can use var sum = fun.reduce(function(pv, cv) { return pv + cv; }, 0);
Timurtek
@Timurtek
Jan 26 2017 08:44
str === str.toLowerCase()
Dan Couper
@DanCouper
Jan 26 2017 08:44
@afrikhero you can set a var total = 0 then loop over the array adding each number in turn to total (then return the final total at the end). Or you can use reduce to do the same thing.
playingwithinfinity
@playingwithinfinity
Jan 26 2017 08:44
@Timurtek Thanks!
CamperBot
@camperbot
Jan 26 2017 08:44
playingwithinfinity sends brownie points to @timurtek :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @timurtek |http://www.freecodecamp.com/timurtek
redoz94
@redoz94
Jan 26 2017 08:44
// Example
function ourRandomRange(ourMin, ourMax) {
return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}
ourRandomRange(1, 9);
// Only change code below this line.
function randomRange(myMin, myMax) {
return Math.floor(Math.random()>=(myMax-myMin+1))+myMin; // Change this line
}
// Change these values to test your function
var myRandom = randomRange(5, 15);
I cant get it to generate a number which is equal to myMax
Archit Chandra
@architchandra
Jan 26 2017 08:45
@Masd925 Yes, was just reading about that only. Learnt a pretty interesting thing today.
Antoine Guillien
@Sladix
Jan 26 2017 08:45
Does anyone have a clue for my question ? Beside from declaring a new object
Coy Sanders
@coymeetsworld
Jan 26 2017 08:45
@sheetalgiri but b11, isn't going to be matched with /b1,
so, i guess i don't understand why thats an issue
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:47
but b1 will match with b11
two things can happen
Coy Sanders
@coymeetsworld
Jan 26 2017 08:48
@sheetalgiri, yes, but /b1, will not, it will pattern match the comma
Sheetal Giri
@sheetalgiri
Jan 26 2017 08:48
b1 is followed by comma
or b1 is at the end of the string
Jor
@joreyesl
Jan 26 2017 08:48
@sheetalgiri you can try using an or then
Dan Couper
@DanCouper
Jan 26 2017 08:48
@Timurtek if you’re exhausting the memory, it’s probably because you’re modifying the array you’re working on as you loop over it (that will generally do it). You probably want to play around with getting the values you want, and putting them into another array; use one array for reference, looping over it, and another to put the value into.
Coy Sanders
@coymeetsworld
Jan 26 2017 08:49
or an or operator |
match either b1, or b1$
Antoine Guillien
@Sladix
Jan 26 2017 08:49
@afrikhero I don't have the time right now worry dude