These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Jul 2016
Chris
@KhriztianG
Jul 13 2016 00:00
so i will need to create variables for each string?
Diego Mayer
@Chrono79
Jul 13 2016 00:00
@falconpunch12 instead of using total you could return in several places
@KhriztianG no, why create vars? myNoun is a parameter of your function already
falconpunch12
@falconpunch12
Jul 13 2016 00:01
@Chrono79 awesome, yah thats a simple cleanup. would you do everything else in a similar manner?
@Chrono79 also, thanks
CamperBot
@camperbot
Jul 13 2016 00:01
falconpunch12 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1490 | @chrono79 |http://www.freecodecamp.com/chrono79
Chris
@KhriztianG
Jul 13 2016 00:01
i have to create strings in-between each variable don't i?
Diego Mayer
@Chrono79
Jul 13 2016 00:01
yes, but they are string literals, not vars
like I wrote before:
@KhriztianG result = "somestring "+oneOfYourFunctionParams+" someOtherString "+ and so on
Chris
@KhriztianG
Jul 13 2016 00:03
then how do i create the strings?
Diego Mayer
@Chrono79
Jul 13 2016 00:03
@KhriztianG "hello, I'm a string" <- like this
Chris
@KhriztianG
Jul 13 2016 00:05
so i create a result and place strings in-between?
Diego Mayer
@Chrono79
Jul 13 2016 00:06
yes, look at the example 3 lines above, and leave spaces between words, I mean
"some string "+someVar is ok,
"some string"+someVar is not ok (this results in "some stringcat" for instance)
hakeemo
@hakeemo
Jul 13 2016 00:11
How can i embed code here?
Diego Mayer
@Chrono79
Jul 13 2016 00:12
help format
CamperBot
@camperbot
Jul 13 2016 00:12

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

hakeemo
@hakeemo
Jul 13 2016 00:14
This is my solution to the 4th code challenge "Wherefore art thou", in the intermediate algorithm scripting section. I would like to know if there is cleaner way of doing it.
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (let entry of collection){
    matches = 0;
    for (var key in source){
      if (entry.hasOwnProperty(key)) {
          if ( source[key]==entry[key]){
            matches+=1;
          }
      }

    }
    if (matches == Object.keys(source).length){
      arr = arr.concat(entry);
    }
  }

  // Only change code above this line
  return arr;
}
Daniel Mayle
@dmayle1
Jul 13 2016 00:15

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

stuck on this problem
Chris
@KhriztianG
Jul 13 2016 00:16
return = "The " + myAdjective + "ass " + myNoun + "for some reason " + myVerb + "then " + myAdverb + "faded from sight. ";
I have 3 errors
Moisés Man
@moigithub
Jul 13 2016 00:17
@KhriztianG spaces missing.. u only added space at 1 side...
Diego Mayer
@Chrono79
Jul 13 2016 00:18
@dmayle1 translate newline, backslash and carriage-return to escaped sequences
@KhriztianG Look at the output (left side of your screen, black background) and you'll see where to add the spaces
Chris
@KhriztianG
Jul 13 2016 00:24
I fixed it! How do I send brownie points @Chrono79
Diego Mayer
@Chrono79
Jul 13 2016 00:24
help brownie
CamperBot
@camperbot
Jul 13 2016 00:24

:point_right: brownie points [wiki]

Brownie Points

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are two ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.

:pencil: read more about brownie points on the FCC Wiki

Chris
@KhriztianG
Jul 13 2016 00:25
thanks @Chrono79
CamperBot
@camperbot
Jul 13 2016 00:25
khriztiang sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1491 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 13 2016 00:26
:+1:
Joel Rambert
@freedomiii
Jul 13 2016 00:28
I think I'm doing this completely wrong, could somebody help? It's the "Title Case a Sentence" challenge:

function titleCase(str) {
  var arrWords = str.split(' ');
  var arrString = [];
  for (var i = 0; i < arrWords.length; i++) {
    /* Word Analyzer */
    arrWords[i].toLowerCase();
    arrLetters = arrWords[i].split('');
    for (var x = 0; x < arrLetters.length; x++) {
    /* Converts first letter of each word into uppercase. */    
      if (x === 0) {
        arrLetters[x].toUpperCase();
      }
    }
    var arrWordString = arrLetters.join('');
    arrString.push(arrWordString);
  }
  var arrStringFinal = arrString.join(' ');
  return arrStringFinal;
}

titleCase("I'm a little tea pot");
Diego Mayer
@Chrono79
Jul 13 2016 00:30
@FreedomIII arrWords[i].toLowerCase(); this doesn't modify arrWords[i] value
The same applies here: arrLetters[x].toUpperCase();
Joel Rambert
@freedomiii
Jul 13 2016 00:31
How should I do it? Isn't it modifying the index "i" item on the arrWords array?
Sorry if I'm forgetting something haha
Norvin Burrus
@ndburrus
Jul 13 2016 00:32
@EdnaMode you're welcome! glad to hear the news :) you'll be fine :palm_tree:
i would replace your description with cogitative....
Diego Mayer
@Chrono79
Jul 13 2016 00:32
@FreedomIII arrWords[i] = arrWords[i].toLowerCase(); is a way of doing it
Norvin Burrus
@ndburrus
Jul 13 2016 00:32
@defeds you're very welcome :+1:
@Archangelpak nice work! :cake:
Joel Rambert
@freedomiii
Jul 13 2016 00:33
@Chrono79 Oh! Thanks! Now it works :) Is there any easier way of doing this challenge or mine is okay excepting that?
CamperBot
@camperbot
Jul 13 2016 00:33
freedomiii sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1492 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 13 2016 00:34
Yes, there are other ways of doing it, come back later and try to refactor your code (once you have more tools)
Joseph
@revisualize
Jul 13 2016 00:34
advanced regex????????
Joel Rambert
@freedomiii
Jul 13 2016 00:34
Thanks so much! ;)
Joseph
@revisualize
Jul 13 2016 00:35
@Chrono79 see my pm?
Diego Mayer
@Chrono79
Jul 13 2016 00:35
@revisualize yes, I asked you something there
Joseph
@revisualize
Jul 13 2016 00:37
it didn't show the reply
DC
@dctor
Jul 13 2016 00:48
hi all, it seems in below code...both if and else conditions are returned when i expected to see only one return. why is that?
function addTogether() {
  //console.log(arguments[0]);
  var x = 0;
  for (var i = 0; i < arguments.length; i++) {
    if (typeof(arguments[i]) === "number") {
      x++;
    }
    if (x === arguments.length) {
      var y = 0;
      for (j = 0; j < arguments.length; j++) {
        y = y + arguments[j];
      }
      console.log(y);
    } else {
      console.log("undefined");
    }
  }
}
addTogether(2, 1, 3);
Gary Siu
@GarySiu
Jul 13 2016 00:51
@dctor Are you sure that's the case? https://repl.it/CbZf
Montensia Banks
@Monty7
Jul 13 2016 00:51
Hello, I have no clue why my for loop only loops over the contacts array of objects once. This is for the 'Profile Lookup' challenge. Does any one know why:
function lookUpProfile(firstName, prop){
// Only change code below this line

    for(var j = 0; j < contacts.length; j++){
     // console.log(contacts[j]);
      if(contacts[j].firstName !== firstName){
        return "No such contact";     
      }
      else 
      if(contacts[j].firstName === firstName && contacts[j][prop]){
        return contacts[j][prop];
      }
      else 
      if(contacts[j].firstName === firstName && !contacts[j][prop]){
       return "No such property";
      }
    }
bitgrower
@bitgrower
Jul 13 2016 00:52
@Monty7 because there's no way to get to the bottom of the loop -- you have 3 return statements ... and as soon as your code hits any one of them, it's going to not just exit the loop but exit the function ...
DC
@dctor
Jul 13 2016 00:52
@GarySiu it console.log both undefined and 6 where i expected to see only 6 as all passed arguments are numbers
Gary Siu
@GarySiu
Jul 13 2016 00:54
@dctor If you move the console.log up a line to directly after you increment y: https://repl.it/CbZf/1
bitgrower
@bitgrower
Jul 13 2016 00:54
and ... @Monty7 -- the way your code is written, one or the other return statements will be executed the first time thru your loop
Montensia Banks
@Monty7
Jul 13 2016 00:55
@bitgrower Shouldn't it loop through all of the objects and check for the condition before returning?
Gary Siu
@GarySiu
Jul 13 2016 00:56
@dctor I think I see the point of confusion. Your else is Not on the first if block.
Montensia Banks
@Monty7
Jul 13 2016 00:57
@bitgrower If my if/else statements are return prematurely, where should I put my return for each condition?
DC
@dctor
Jul 13 2016 00:57
@GarySiu the else is for the 2nd if block...the 1st if block is finished after it checks the x value
bitgrower
@bitgrower
Jul 13 2016 00:57
you have to have a path in your for loop which doesn't hit a return statement, @Monty7
andybmx20
@andybmx20
Jul 13 2016 00:58

What i should do ......?
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

Norvin Burrus
@ndburrus
Jul 13 2016 00:59
@andybmx20 the goal is to change the string. how could we do it?
Joseph
@revisualize
Jul 13 2016 00:59
Strings are Immutable.
andybmx20
@andybmx20
Jul 13 2016 00:59
i should replace mystr[0] with mystr=hello world ?
Gary Siu
@GarySiu
Jul 13 2016 00:59
@dctor Right, so you have 2 undefined (first two iterations aren't the last element of arguments) and then you loop through all your arguments at once.
Joseph
@revisualize
Jul 13 2016 00:59
yes but correctly.
Norvin Burrus
@ndburrus
Jul 13 2016 00:59
@andybmx20 excellent, what else do we need for a string?
andybmx20
@andybmx20
Jul 13 2016 01:00
i made it
thanks
Norvin Burrus
@ndburrus
Jul 13 2016 01:00
@andybmx20 nice job :sparkles:
bitgrower
@bitgrower
Jul 13 2016 01:00
@Monty7 -- AND you have to understand that the first time your code doesn't find a match, it doesn't mean that no match is found in the entire population ... your loop must loop thru them all to determine that ... (which means you really can't say "no such contact" until you've searched thru all of them ...
Joseph
@revisualize
Jul 13 2016 01:00
Meh... My touchscreen isn't working.. BRB!
Gary Siu
@GarySiu
Jul 13 2016 01:00
@dctor I think the thing you're trying to do can be done with just 1 loop and a conditional
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:01
Hey can someone help wit the card counter?
Gary Siu
@GarySiu
Jul 13 2016 01:02
@LordYamanouchi What do you have so far?
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:02

var count = 0;

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

return "Change Me";
// Only change code above this line
}

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

I want to put an if ( count > 0) { return count + " Bet";}
Montensia Banks
@Monty7
Jul 13 2016 01:03
@bitgrower I'm still stuck. Thanks for replying thou.
CamperBot
@camperbot
Jul 13 2016 01:03
monty7 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1137 | @bitgrower |http://www.freecodecamp.com/bitgrower
Anton Kaminsky
@nakamin
Jul 13 2016 01:03
@LordYamanouchi use === instead of ==
Norvin Burrus
@ndburrus
Jul 13 2016 01:03
@LordYamanouchi adjust the count in the if statement, handle the result outside of the if statement...
Joseph
@revisualize
Jul 13 2016 01:03
Meh.. Not really need for this less but, whatev.
Anton Kaminsky
@nakamin
Jul 13 2016 01:03
@LordYamanouchi also you need to change the string that you return it says "Change Me"
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:04
@ndburrus So no return in the if statement?
Joseph
@revisualize
Jul 13 2016 01:04
@LordYamanouchi You have returns inside of the if statement.
Anton Kaminsky
@nakamin
Jul 13 2016 01:04
@LordYamanouchi also no need to += 0
Joseph
@revisualize
Jul 13 2016 01:04
@LordYamanouchi your thought is correct.
Are we really here to heavily critique code?
Norvin Burrus
@ndburrus
Jul 13 2016 01:05
@LordYamanouchi remember that the if statement is processing info for 5 cards... so we don't have the final count value until all cards are evaluated, right?
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:05
It's weird because I don't fully know how the return's work
Yeah I get that
DC
@dctor
Jul 13 2016 01:06
@GarySiu can you elaborate how can it be done in one if? the 1st if is based on a value after loop is completed, then starts the 2nd if.
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:06
@ndburrus Why does the return work thrice then?
Joseph
@revisualize
Jul 13 2016 01:06
@LordYamanouchi The returns should be after the Switch.
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:07
@revisualize I understand. Thanks !
CamperBot
@camperbot
Jul 13 2016 01:07
lordyamanouchi sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1416 | @revisualize |http://www.freecodecamp.com/revisualize
Gary Siu
@GarySiu
Jul 13 2016 01:07
@dctor You have 2 variables. 1 for iterating through arguments, 1 holding your result. Each iteration, you test to see if the element is a number and change the result accordingly. 1 loop, 1 condition.
Norvin Burrus
@ndburrus
Jul 13 2016 01:08
@LordYamanouchi why are we returning the count for each if/else?
bitgrower
@bitgrower
Jul 13 2016 01:09
@Monty7 sorry -- you can put your code into this cool app here http://pythontutor.com/javascript.html -- and step thru it, and see how it executes based on various input ... maybe that will help ?
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:09
@ndburrus It was a mistake. It's just that it worked for the three 'ifs'. I suspected it was wrong.
Z.G.Hao
@akidox
Jul 13 2016 01:09
Someone please help me with my codes,I don’t know why it isn’t work.The challenge of Seek and Destroy.
function destroyer(arr){
  var argus = Array.prototype.slice.call(arguments);
  for (i = 1; i < argus.length; i ++) {
    arr.filter(destroy);
  }
  function destroy(val) {
    return val !== argus[i];
  }
  return arr;
}
Anton Kaminsky
@nakamin
Jul 13 2016 01:10
@akidox you are not calling the destroy function
Norvin Burrus
@ndburrus
Jul 13 2016 01:10
@LordYamanouchi the purpose of the if/else is to evaluate/adjust the running/total count.
after we have that, we can present (using the final count value) the desired (requirement) output.
make sense?
Anton Kaminsky
@nakamin
Jul 13 2016 01:11
@akidox need to put (val)
After it
Z.G.Hao
@akidox
Jul 13 2016 01:11
like arr.filter(destroy(val));?
@nakamin
Anton Kaminsky
@nakamin
Jul 13 2016 01:11
@akidox arr.filter(destroy);
Yeah
Filter takes a callback function
Z.G.Hao
@akidox
Jul 13 2016 01:12
thanks,let me try it
Anton Kaminsky
@nakamin
Jul 13 2016 01:12
@akidox I didn't check the logic though so this might not be a fix
Z.G.Hao
@akidox
Jul 13 2016 01:13
@nakamin I got thisReferenceError: val is not defined
DC
@dctor
Jul 13 2016 01:13
@GarySiu hmmm ok i'll give it a try...but how come it returns 2 undefined? since all parameters are numbers undefined shouldn't be returned
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:13
@ndburrus Makes perfect sense. Returns don't have to be there.
Norvin Burrus
@ndburrus
Jul 13 2016 01:13
@LordYamanouchi can we update the code?
Anton Kaminsky
@nakamin
Jul 13 2016 01:14
@akidox you are filtering arr need to filter Argus
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:14

function cc(card) {
// Only change code below this line
if ( card == 2 || card == 3 || card == 4 || card == 5 || card == 6){
count += 1;
}
if ( card == 7 || card == 8 || card == 9){
count += 0;
}
if ( card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A'){ count -= 1;
}
switch(card){
case (count > 0):
count += " Bet";
break;
case (count === 0):
count += " Hold or Bet";
break;
case (count < 0):
count += " Hold";
break;
}
return count;

// Only change code above this line
}

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

Gary Siu
@GarySiu
Jul 13 2016 01:14
@dctor The 'undefined' is from your else. That else is actually part of a conditional testing to see if that iteration is the last element in arguments. It is not testing to see if it's a number.
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:14
@ndburrus But it's still not working
Anton Kaminsky
@nakamin
Jul 13 2016 01:15
@akidox do you get what I'm saying?
Norvin Burrus
@ndburrus
Jul 13 2016 01:15
@LordYamanouchi you're right. here: ReferenceError: count is not defined see what's happening? we're handling a variable, that does not exist.
we need to adhere to:
var count = 0;

function cc(card) {
  // Only change code below this line
Anton Kaminsky
@nakamin
Jul 13 2016 01:16
@akidox never mind sorry
Z.G.Hao
@akidox
Jul 13 2016 01:16
@nakamin So you don’t know?
Anton Kaminsky
@nakamin
Jul 13 2016 01:16
@akidox pit the destroy function inside the filter
@akidox I'm not sure this is valid syntax
Z.G.Hao
@akidox
Jul 13 2016 01:17
won’t work,also not suggested
Anton Kaminsky
@nakamin
Jul 13 2016 01:17
@akidox I forget the requirements
Gary Siu
@GarySiu
Jul 13 2016 01:18
@dctor Maybe this will make things clearer: https://repl.it/CbZf/2
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:18
@ndburrus But isn't var count a global variable? Or can it only work if I make it a local variable ?
Z.G.Hao
@akidox
Jul 13 2016 01:18
@nakamin what do you mean?
Anton Kaminsky
@nakamin
Jul 13 2016 01:19
@akidox ok I read the instructions you're doing it wrong
Norvin Burrus
@ndburrus
Jul 13 2016 01:20
@LordYamanouchi it is a global variable, which is accessible locally (within the function) - see previous comment (code from lesson) :point_up: July 12, 2016 9:15 PM
notice: // Only change code below this line
Z.G.Hao
@akidox
Jul 13 2016 01:20
how?
Anton Kaminsky
@nakamin
Jul 13 2016 01:20
@akidox you only want the first from the args
DC
@dctor
Jul 13 2016 01:20
@GarySiu your example makes sense i understand it, but in my code all parameters are numbers and should not return undefined.....the else is to return undefined if x is not arguments.length...which means not all parameters are numbers therefore return undefined
Anton Kaminsky
@nakamin
Jul 13 2016 01:21
And compare with the rest
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:21
@ndburrus Then why is the switch failing? I put the return at the bottom of everything.
Z.G.Hao
@akidox
Jul 13 2016 01:22
But if I return arr,it just gets arguments[0]
Gary Siu
@GarySiu
Jul 13 2016 01:22
@dctor Try your code with 1 non-number
Z.G.Hao
@akidox
Jul 13 2016 01:22
So I guess I can filter arr
Norvin Burrus
@ndburrus
Jul 13 2016 01:23
@LordYamanouchi ok, first - decide which decision structure you'd like to use. originally, there was an if/else, now we have an if/else and switch decision structures. think about what we need, and how the structure can support getting it. hint: one decision structure can support the requirement/s - we don't need both. brb
Gary Siu
@GarySiu
Jul 13 2016 01:24
@dctor Then you get 3 undefined. You get an undefined whenever you are not at the end of arguments AND if all the arguments are not numbers.
DC
@dctor
Jul 13 2016 01:24
@GarySiu it returned undefined 3 times.
Z.G.Hao
@akidox
Jul 13 2016 01:24
did I write the callback functon right? @nakamin
Gary Siu
@GarySiu
Jul 13 2016 01:24
@dctor But with 3 numbers you get 2 undefined and then the 3rd iteration it satisfies both those conditions.
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:26
@ndburrus I can return the if statements for the " Bet" / "Hold" Outputs? When count <, >, === 0 ?
Vikrant Singh
@VikrantSingh13
Jul 13 2016 01:26
This is the website I am trying to copy. http://headsupguys.org/
Scroll down their homepage, and you will see four boxes with some hover animation. What's the best way to achieve that effect? This is what I got so far: https://codepen.io/vikrantsingh13/full/wWPvBb/
罗雪梅
@MayLuo
Jul 13 2016 01:26
This message was deleted
DC
@dctor
Jul 13 2016 01:27
@GarySiu the intention is if any of the input is not number then return undefined. I planned to do this with a counter x which add to the length of the argument if it's less than it then return one undefined. if x===length then do the next loop which is to add all inputs
罗雪梅
@MayLuo
Jul 13 2016 01:28
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>

    <script type="text/javascript" src="jquery/jquery-2.1.4.min.js"></script>
    <script>
    $(document).ready(function(){
        var backgrounds = ["http://ww4.sinaimg.cn/mw690/006wpDPjjw1f5remc1c43j30b406o3yl.jpg",
            "http://ww1.sinaimg.cn/mw690/006wpDPjjw1f5r4m8xjmgj30hs0azjs9.jpg",
            "http://ww3.sinaimg.cn/mw690/006wpDPjjw1f5r3o0itpcj30go0afabh.jpg"]

        var index =parseInt(Math.random()*(backgrounds.length-1));
        var currentImage=backgrounds[index];
        $("button").on('click',function(){
            $("body").css("background","url('+currentImage+')");
        });
    });


    </script>
</head>
<body>
    <button type="button">click to change background-image</button>
</body>
</html>
Help~~Please tell me why it fail to load resource?
Jessica
@kaistelle
Jul 13 2016 01:28

what am i doing wrong? :/

``` // Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== ""){
collection[id][prop] = value;

} else if (prop === "tracks" && value !== "") {
collection[id].tracks.push(value);

} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
```

LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:28
@ndburrus If I can only use the if statements for increment or decrementing count then there should only be one return.
Gary Siu
@GarySiu
Jul 13 2016 01:28
@dctor Then isn't what you're trying to do exactly the same as my code except mine logs "not a number" instead of "undefined"?
@dctor I don't really understand why you're introducing another variable that's also tied to a length
Archangelpak
@Archangelpak
Jul 13 2016 01:31
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];
guys can anyone help me to understand an array method
myData should be equal to 8.
Blake Johnston
@johnstonbl01
Jul 13 2016 01:32
@kaistelle Make sure to check to see if the tracks property exists. If it doesn’t exist, then you’ll need to create it as an empty array before pushing values to it.
Tiffany Lam
@tymeart
Jul 13 2016 01:32
@kaistelle The second to last else if block might be the issue.
Gary Siu
@GarySiu
Jul 13 2016 01:33
@Archangelpak myArray[outerIndex][innerIndex]
@Archangelpak myArray[0] would return [1,2,3]
Ronique Ricketts
@RoniqueRicketts
Jul 13 2016 01:34
hello guys i have a question
function translatePigLatin(str) {
   switch (str[0]){
    case "a":
    case "e":
    case "i":
    case "o":
    case "u":
     var str = str.split('');
    var string = str.shift();
    str.push(string + "way");
    return str.join(''); 
      break;
  default:
    var str = str.split('');
    var stringCut = [];
    var string = str.shift();
    str.push(string + "ay");
    return str.join('');
 }
}

translatePigLatin("consonant");
Why couldn't this block of code work?
Gary Siu
@GarySiu
Jul 13 2016 01:34
@Archangelpak myArray[0][2] would return 3
@Archangelpak It'd be the same as var temp = [1,2,3]; temp[2];
DC
@dctor
Jul 13 2016 01:35
@GarySiu because var i is for a loop to run up to length to calculate a counter x....if x === length, then var j is to add all inputs to the length value, else if the counter is less than x then return undefined
Archangelpak
@Archangelpak
Jul 13 2016 01:35
@GarySiu I dont get it
Gary Siu
@GarySiu
Jul 13 2016 01:36
@Archangelpak Just start with the first index. Try myArray[0] then myArray[1] etc. and see what you get
@dctor I don't understand why you think you need x. Do you have a link to the bonfire/challenge?
John Alcher
@alchermd
Jul 13 2016 01:38

hey fellas. I'm having a hard time understanding RegExp. Is it possible to

var str = "I am a string with an array [1,2,3,4] inside";
str.replace( // delete everything between [ and ] );

How do I do that?

Ara Yaghsizian
@MurphyPicard
Jul 13 2016 01:40
In the Manipulating complex objects section of JavaScript, I just typed in and copied/pasted a new album below and I was correct. Is this all I was supposed to learn this lesson?
DC
@dctor
Jul 13 2016 01:40
@GarySiu you mean the url to this algo challenge?
Gary Siu
@GarySiu
Jul 13 2016 01:40
@alchermd [ and ] have a special meaning in regex so you need to escape them with a \ to match them. So you're looking to match [ and any number of characters and then a ]
Archangelpak
@Archangelpak
Jul 13 2016 01:40
@GarySiu thank you
CamperBot
@camperbot
Jul 13 2016 01:40
archangelpak sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 121 | @garysiu |http://www.freecodecamp.com/garysiu
Ara Yaghsizian
@MurphyPicard
Jul 13 2016 01:40

{
"artist": "MJ",
"title": "Thriller",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true

}

Archangelpak
@Archangelpak
Jul 13 2016 01:40
@GarySiu but I still dont get it how array works
Gary Siu
@GarySiu
Jul 13 2016 01:41
@dctor Yes please
@Archangelpak All arrays or just nested arrays (arrays inside arrays)?
John Alcher
@alchermd
Jul 13 2016 01:41
@GarySiu would you be kind enough to show me what that expression looks like? I'm thinking str.replace(/[]/) would match both [ and ] but not anything in between them
DC
@dctor
Jul 13 2016 01:41
@GarySiu pm to you
Tiffany Lam
@tymeart
Jul 13 2016 01:42

Help! I can't figure out what I'm doing wrong.

function multiplyAll(arr) {
var product = 1;
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(product * arr[i][j]);
}
}
return product;
}

CamperBot
@camperbot
Jul 13 2016 01:42
no wiki entry for: i cant figure out what im doing wrongfunction multiplyallarr var product 1 for var i0 i arrlength i for var j0 j arrilength j consolelogproduct arrij return product
Gary Siu
@GarySiu
Jul 13 2016 01:46
@alchermd https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp Checkout Quantifiers and Special Character sections
@dctor The question is asking a very different thing to what you're trying to do. You should read up on the topics it links you to.
DC
@dctor
Jul 13 2016 01:51
@GarySiu i know this will not solve this challenge but trying to understand why it returns undefined not as i had expected
Norvin Burrus
@ndburrus
Jul 13 2016 01:52
@LordYamanouchi have you decided on only one decision structure?
Gary Siu
@GarySiu
Jul 13 2016 01:53
@dctor I don't think I can explain any further because I don't understand what you're not understanding. Maybe try asking someone else. Good luck!
DC
@dctor
Jul 13 2016 01:54
@GarySiu thank you for your help
CamperBot
@camperbot
Jul 13 2016 01:54
dctor sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 122 | @garysiu |http://www.freecodecamp.com/garysiu
Joseph
@revisualize
Jul 13 2016 01:54
@tymeart Remove the console.log and it works.
@tymeart Well, you have to change the to a =
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:55
@ndburrus Yes I want to use if statements.
Norvin Burrus
@ndburrus
Jul 13 2016 01:56
@LordYamanouchi can you post updated code?
Joseph
@revisualize
Jul 13 2016 01:56
@tymeart Your assigning procduct = 1 then doing nothing to reassign product. Then you just return product. So, you're returning 1.
LordYamanouchi
@LordYamanouchi
Jul 13 2016 01:57
@ndburrus If I don't use return then my other if statements are ignored. If I use return then there is null.

@ndburrus function cc(card) {
// Only change code below this line

if ( card == 2 || card == 3 || card == 4 || card == 5 || card == 6 ){
count += 1;

}
if ( card == 7 || card == 8 || card == 9){
count += 0;

}
if ( card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A' ){
count -= 1;
}
if( count > 0){
count += " Bet";
}
if( count === 0){
count += " Hold or Bet";
}
if( count < 0){
count1 += " Hold";
}

// Only change code above this line
}

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

Tiffany Lam
@tymeart
Jul 13 2016 01:57
@revisualize am I supposed to increment product as well?
Norvin Burrus
@ndburrus
Jul 13 2016 01:59
@LordYamanouchi
you may enjoy these: :sparkles:
Tiffany Lam
@tymeart
Jul 13 2016 01:59
@revisualize I'm not supposed to change the return product part
LordYamanouchi
@LordYamanouchi
Jul 13 2016 02:00
@ndburrus Okay. Thanks.
CamperBot
@camperbot
Jul 13 2016 02:00
lordyamanouchi sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 961 | @ndburrus |http://www.freecodecamp.com/ndburrus
Tiffany Lam
@tymeart
Jul 13 2016 02:05
@revisualize Nevermind, I got it! I had to use *= to add the products together.
John Wypick
@johnwypick
Jul 13 2016 02:05
Seems like this is a difficult problem.
var myStr= \" FirstLine \n \SecondLine\ \r ThirdLine\" ; // Change this line I keep getting errors for mystr shuld have encoded text with the proper escape sequence...... The second error message is myStr should have tow correctly escaped backslash characters \
Jessica
@kaistelle
Jul 13 2016 02:07

@johnstonbl01 still stuck on the problem. the second else if statement is wrong, wasn't sure how to create a new array :(

function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== ""){
collection[id][prop] = value;

} else if (prop === "tracks" && collection.hasOwnProperty("tracks")) {
collection[id][prop] = new Array[];

} else if (prop === "tracks" && value !== "") {
collection[id].tracks.push(value);

} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

Norvin Burrus
@ndburrus
Jul 13 2016 02:07
@johnwypick where is the backslash escape code?
why do we have a \ here: \" FirstLine?
John Wypick
@johnwypick
Jul 13 2016 02:08
not familiar with that, doesn't mention it.
says just to use escape sequences

Here is the text with the escape sequences written out.

"FirstLine newline backslash Second Linebackslash carriage-return ThirdLine"

Willyan
@hashtagCode
Jul 13 2016 02:10
@kaistelle collection.hasOwnProperty change to collection.id.hasOwnProperty
tracks are nested in ID
Norvin Burrus
@ndburrus
Jul 13 2016 02:11
@johnwypick
ok, we need to take the given string, here:
"FirstLine newline backslash SecondLine backslash carriage-return ThirdLine" (ignore the spacing) and replace the appropriate text (bold words) with the escape coding (use the Code/Output chart)...
carefully match each character, per the requirement/s... :)
John Wypick
@johnwypick
Jul 13 2016 02:12
var myStr= \"FirstLine\n\SecondLine\rThirdLine\";
Tiffany Lam
@tymeart
Jul 13 2016 02:12
@kaistelle You can create a new array by setting the variable to an empty array.
John Wypick
@johnwypick
Jul 13 2016 02:13
doesn't work: var myStr= \"FirstLine\n\SecondLine\rThirdLine\";
Norvin Burrus
@ndburrus
Jul 13 2016 02:15
@johnwypick see previous comment/s: :smile:
Chad Hurley
@ChadDean82
Jul 13 2016 02:19
Hi Everyone My Name is Chad & I have a problem, but besides drinking I don't seem to understand this. Some help Please!!!
function nextInLine(arr, item) {
 var nextInLine = (); // Your code here

  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stri
LordYamanouchi
@LordYamanouchi
Jul 13 2016 02:20
@ndburrus I did it !! Thanks!!
CamperBot
@camperbot
Jul 13 2016 02:20
lordyamanouchi sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: lordyamanouchi already gave ndburrus points
Chad Hurley
@ChadDean82
Jul 13 2016 02:21
inclosed text to fallow was or is v

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

sorry its been a super long day
John Wypick
@johnwypick
Jul 13 2016 02:23
This is right, but still getting error messages. var myStr= \"FirstLine\n\SecondLine\rThirdLine\";
Tiffany Lam
@tymeart
Jul 13 2016 02:23
@ChadDean82 Do you remember how to add items to the end of an array?
Chad Hurley
@ChadDean82
Jul 13 2016 02:24
the .push?
@tymeart sorry more direct the .push?
Tiffany Lam
@tymeart
Jul 13 2016 02:26
@ChadDean82 Yeah! So you're going to use that to add the number to the end of the array. And then you have to remove the first time from the same array.
*first number
Tony Kelly
@TonyKelly12
Jul 13 2016 02:28

Can somebody help me figure out how to target the (val) to use to return the results ?

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

// Only change code below this line
var lookup = {

 alpha: 
  result = "Adams",

 bravo: 
  result = "Boston",
charlie: 
  result = "Chicago",

  delta:
  result = "Denver",

echo: 
  result = "Easy",

 foxtrot: 
  result = "Frank"

};

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

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

Blake Johnston
@johnstonbl01
Jul 13 2016 02:28
@kaistelle You get it figured out?
Chad Hurley
@ChadDean82
Jul 13 2016 02:29
@tymeart thank You
CamperBot
@camperbot
Jul 13 2016 02:29
chaddean82 sends brownie points to @tymeart :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @tymeart |http://www.freecodecamp.com/tymeart
Diego
@disofu234
Jul 13 2016 02:33
This message was deleted
can anyone tell me why this returns an error?
"cannot return property 'push' of undefined
nvm lol i figured it out
i forgot to put return acc at the end of reduce
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:41
yo!
can someone help me out??
Diego
@disofu234
Jul 13 2016 02:42
whats up?
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:43
hey man im stuck on this javascript
Understanding Uninitialized Variables this one
on map
Tony Kelly
@TonyKelly12
Jul 13 2016 02:44
@disofu234 lol can i be next in line
Diego
@disofu234
Jul 13 2016 02:44
yeah for sure
@mukulsahi52 is that an algorithm or a lesson?
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:44
lesson
basic javascript
im getting error for c man
Diego
@disofu234
Jul 13 2016 02:45
how did you declare c?
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:46
"I am a String!"
Diego
@disofu234
Jul 13 2016 02:46
it's supposed to be var c = "I am a";
Jessicazhou1994
@Jessicazhou1994
Jul 13 2016 02:47
how to deal with this?

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result=myAdjective;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Diego
@disofu234
Jul 13 2016 02:47
so that later on when c = c + " String!";
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:47
@disofu234 i did bro
it didnt work

var a=5;
var b=10;
var c="i am a";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

look
Diego
@disofu234
Jul 13 2016 02:48
make the i uppercase
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:49
ohh snap
it worked
@disofu234 thank you!
CamperBot
@camperbot
Jul 13 2016 02:49
mukulsahi52 sends brownie points to @disofu234 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @disofu234 |http://www.freecodecamp.com/disofu234
Diego
@disofu234
Jul 13 2016 02:50
@mukulsahi52 haha no problem!
Mukul Sahi
@mukulsahi52
Jul 13 2016 02:50
that was dumb man haha
Diego
@disofu234
Jul 13 2016 02:50
nah don't worry i make mistakes like that all the time
Jose Mendoza
@jmendozav
Jul 13 2016 02:51
haha
Tony Kelly
@TonyKelly12
Jul 13 2016 02:52

@disofu234 can you help me understand how to target the (val) in this code i know what to do just dont know correct syntax

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

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

"bravo": 
  result = "Boston",

"charlie": 
  result = "Chicago",

"delta": 
  result = "Denver",

"echo": 
  result = "Easy",

"foxtrot":
result = "Frank"
};

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

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

Mukul Sahi
@mukulsahi52
Jul 13 2016 02:54
@disofu234 Fo sho!
Diego
@disofu234
Jul 13 2016 02:56
@The1Tonedef what challenge is this?
Tony Kelly
@TonyKelly12
Jul 13 2016 02:56
Using Objects for Lookups
Jessica
@kaistelle
Jul 13 2016 02:57

@johnstonbl01
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== ""){
collection[id][prop] = value;

} else if (prop === "tracks" && collection.id.hasOwnProperty("tracks")) {
new Array.push(id);

} else if (prop === "tracks" && value !== "") {
collection[id].tracks.push(value);

} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

Stephen James
@sjames1958gm
Jul 13 2016 02:58
@The1Tonedef Firstly the format of your object is incorrect - you don't need the result = part. Then you can use lookup and val to assign to result before the return.
Recall this project on how to use a variable (val in this case) to access a property in the lookup object:
https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
Diego
@disofu234
Jul 13 2016 03:00
@The1Tonedef your look up object should look like this,
  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank"
  };
Tony Kelly
@TonyKelly12
Jul 13 2016 03:01
Oh ok
Diego
@disofu234
Jul 13 2016 03:01
and then result = lookup[val];
Tony Kelly
@TonyKelly12
Jul 13 2016 03:03
@disofu234 Thats the part i was trying to figure out how to code. started changing everything else
thats @disofu234 & @sjames1958gm
Thanks @disofu234 & @sjames1958gm
CamperBot
@camperbot
Jul 13 2016 03:04
:cookie: 296 | @disofu234 |http://www.freecodecamp.com/disofu234
:star2: 1817 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
the1tonedef sends brownie points to @disofu234 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
Tony Kelly
@TonyKelly12
Jul 13 2016 03:07
I tried var lookup[val] = { .... first
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:09
Hi all, never really used this chat, but I'm having a very difficult time with the Record Collection problem and could use some help
Michael Karpinski
@karpimpski
Jul 13 2016 03:09
wiki record collection
CamperBot
@camperbot
Jul 13 2016 03:09

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

Michael Karpinski
@karpimpski
Jul 13 2016 03:10
are you having problem accessing the JSON elements?
@nickbart90
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:11
Well no, what's giving me a really tough time was I tried to simply the problem
@karpimpski
Michael Karpinski
@karpimpski
Jul 13 2016 03:11
what exactly are you having trouble with?
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:11
@karpimpski and when I'd boil it down to look similar to a previous problem, I'd get an error that the 'collection is not defined'
Let me see if I can add a photo in here
Stephen James
@sjames1958gm
Jul 13 2016 03:12
@nickbart90 See the following for posting code
help format
CamperBot
@camperbot
Jul 13 2016 03:12

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Stephen James
@sjames1958gm
Jul 13 2016 03:12
:point_up:
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:13

@karpimpski ```
function testOutput(val) {

var result = "";

var collection = {
"2548": "aa"
};

result = collection[val];

return result;
}
testOutput("2548");
```

function testOutput(val) {

  var result = "";

  var collection = {
      "2548": "aa"
  };

  result = collection[val];

  return result;
}
testOutput("2548");
Sorry, obvi new here, thanks for the guidance in advance!
When running this, I receive a "ReferenceError: collection is not defined", but this format was simplified to look like a similar problem to help me troubleshoot, and the output made no sense to me
Michael Karpinski
@karpimpski
Jul 13 2016 03:18
@nickbart90 why did you make a testOutput function?
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:19
@karpimpski because none of the tests I was running on the actual conditions were working on this problem, it made no sense to me, so I figured I'd go simpler to help myself start from the bottom up
Michael Karpinski
@karpimpski
Jul 13 2016 03:20
but as for accessing an object, that function would return "aa"
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:20
And I'm ok with that
Does the error output make sense in that case then?
Kate
@kalex666
Jul 13 2016 03:20
can someone help me get this started:

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var cToF= 9/5 + 32;

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

// Change the inputs below to test your code
convertToF(30);

Stephen James
@sjames1958gm
Jul 13 2016 03:21
@kalex666 Use the celsius variable (parameter) and the formula to set the fahrenheit variable
Michael Karpinski
@karpimpski
Jul 13 2016 03:21
@nickbart90 I'm not sure why it would return that error, it may be because you have 2 collection variables in your code?
David Di Feo
@ddifeo
Jul 13 2016 03:21
@nickbart90 Collection doesnt exist because its only in the scope of that function
Michael Karpinski
@karpimpski
Jul 13 2016 03:22
anyway, that's not important to the problem. how would we edit something in an object? that's the first requirement
or add something I mean
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:23
@karpimpski do you mean like a format similar to inserting a property?
Stephen James
@sjames1958gm
Jul 13 2016 03:23
@nickbart90 I would reset the challenge and start with the updateRecords function, to be sure that you have the correct collections object.
Michael Karpinski
@karpimpski
Jul 13 2016 03:24
@nickbart90 yeah. given id and prop, how would you insert the prop with the correct value into that id?
David Di Feo
@ddifeo
Jul 13 2016 03:25
@kalex666 you almost got it. you forgot to multiply Celsius by 9/5, then set Fahrenheit to that result
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:27
@karpimpski would I be inserting both the prop and the value into that id?
@karpimpski like as a key-value pair?
Michael Karpinski
@karpimpski
Jul 13 2016 03:27
@nickbart90 it is a key-value pair, yeah
you would be inserting the prop, with a value of value, into that id for the first requirement
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:29
@karpimpski yeah I think that's where I'm getting most confused: the format of how you would insert that. Let me shoot for an example of condition 1
Brian
@BrianCodes33
Jul 13 2016 03:30
can someone help me make an api call for random quote machine?
Michael Karpinski
@karpimpski
Jul 13 2016 03:30
@nickbart90 collection[id][prop] = value;
Brian
@BrianCodes33
Jul 13 2016 03:30
am i on the right track here ?
var request = new XMLHttpRequest();

request.open('GET', 'http://api.forismatic.com/api/1.0/', true);

request.onload(function() {
  if (request.status >= 200 && request.status < 400) {
    var data = JSON.parse;
  }
})
Michael Karpinski
@karpimpski
Jul 13 2016 03:30
that would handle basic insertions or overwriting of a value in the collection
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:32
@karpimpski
@karpimpski
function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== "") {
    collection.id.prop = value;
  }

  return collection;
}
Michael Karpinski
@karpimpski
Jul 13 2016 03:33
@nickbart90 read the instructions on accessing properties in an object with variables
I generally avoid dot notation for this reason, it's just simpler to use bracket because it always works
using dot notation doesn't work with variables, only strings I think
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:34
@karpimpski for variables? ok, I have that noted, that's a solid tip
Jessica
@kaistelle
Jul 13 2016 03:34

still having trouble how to create a new array in the second if else statement:

function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== ""){
collection[id][prop] = value;

} else if (prop === "tracks" && collection.id.hasOwnProperty("tracks")) {
new Array(id);

} else if (prop === "tracks" && value !== "") {
collection[id].tracks.push(value);

} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

Michael Karpinski
@karpimpski
Jul 13 2016 03:34
@nickbart90 yeah, I personally used bracket notation even for strings for a while until I got comfortable with JS
Nicholas Bartolone
@nickbart90
Jul 13 2016 03:36
@karpimpski cool, thanks for the help! I think I can now get going
CamperBot
@camperbot
Jul 13 2016 03:36
nickbart90 sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @karpimpski |http://www.freecodecamp.com/karpimpski
Michael Karpinski
@karpimpski
Jul 13 2016 03:37
@nickbart90 let me know if you need more help, the tracks portion is kind of difficult
Jack
@jh0l
Jul 13 2016 03:37
why does M turn into @ omg

function rot13(str) { // LBH QVQ VG!
  str = str.toUpperCase().split("").map(function (value) {
    var doodad = (value.charCodeAt(0)-51)%26+64;
    return value.charCodeAt(0) > 64 && value.charCodeAt(0) < 91 ? String.fromCharCode(doodad) : value; 
  });
  return str.join("");
}

// Change the inputs below to test
rot13("abcdefghijklm !?.");
David Di Feo
@ddifeo
Jul 13 2016 03:39
@kaistelle you would create an empty array like this:
Michael Karpinski
@karpimpski
Jul 13 2016 03:39
@Jhollond I think you've overthinking the whole thing. I'm not even sure what math that is
David Di Feo
@ddifeo
Jul 13 2016 03:39
collection[id][prop] = [];
Jack
@jh0l
Jul 13 2016 03:39
@karpimpski it's mod
David Di Feo
@ddifeo
Jul 13 2016 03:40
@kaistelle and then use push() to add elements in it
Jack
@jh0l
Jul 13 2016 03:40
@karpimpski for caesar cipher
Michael Karpinski
@karpimpski
Jul 13 2016 03:40
@Jhollond I know what a modulus is, but I'm not sure why you would use it in this case. it's much simpler to just shift the charCode by 13
if it goes out of range of the alphabet just continue with the difference
Jack
@jh0l
Jul 13 2016 03:41
@karpimpski that's what % does?
Michael Karpinski
@karpimpski
Jul 13 2016 03:41
@Jhollond the modulus returns the remainder of dividing
Jack
@jh0l
Jul 13 2016 03:42
@karpimpski it works
just not for the letter M
try it
Michael Karpinski
@karpimpski
Jul 13 2016 03:42
3%2 = 1 because 3/2 returns a remainder of 1. and it doesn't work, not for all cases like you said. I'm offering you a simpler solution, since I'm not exactly sure how this one works (or doesn't work)
gdntian
@gdntian
Jul 13 2016 03:43
help Manipulating Complex Objects
CamperBot
@camperbot
Jul 13 2016 03:43
no wiki entry for: manipulating complex objects
gdntian
@gdntian
Jul 13 2016 03:44
help data structure
CamperBot
@camperbot
Jul 13 2016 03:44
no wiki entry for: complex objects
Jack
@jh0l
Jul 13 2016 03:44
@karpimpski how is shifting the charctercode by 13 different to using %
gdntian
@gdntian
Jul 13 2016 03:44
help data structure
CamperBot
@camperbot
Jul 13 2016 03:44

:point_right: data structure arrays [wiki]

Data Structure Arrays

Internally, array is a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

array consists of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.

:pencil: read more about data structure arrays on the FCC Wiki

Tiffany Lam
@tymeart
Jul 13 2016 03:45

It seems like the "No such contact" and "No such property" blocks are working, but not the first if statement.

```
function lookUpProfile(firstName, prop){
for (var i=0; i<contacts.length; i++) {
if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) === true) {
return contacts[i][prop];
} else if (firstName !== contacts[i].firstName) {
return "No such contact";
} else if (contacts[i].hasOwnProperty(prop) === false) {
return "No such property";
}
}
}

That last bracket was a typo
Michael Karpinski
@karpimpski
Jul 13 2016 03:45
@Jhollond just find the charcode and subtract by 13. using a modulus brings in division and more math functions when all you need is subtraction. then you'll just need an if statement to check if subtracting by 13 brings you to an invalid charcode and fix it if that happens
it may take more code, but it's much simpler to understand, read, and edit that kind of code. writing code isn't all about one-liners, it's about make the most editable and readable code possible. using subtraction versus a modulus(multiple operations) may be less code, but it's more complicated and harder to troubleshoot than simple subtraction
Jack
@jh0l
Jul 13 2016 03:47
if I'm doing all that I might as well keep this and check if the value is M and change it to Z if it is
hmm okay
@karpimpski thanks lol
CamperBot
@camperbot
Jul 13 2016 03:48
jhollond sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @karpimpski |http://www.freecodecamp.com/karpimpski
Michael Karpinski
@karpimpski
Jul 13 2016 03:49
@Jhollond yeah, I'm sure you could. that would fix this specific problem. however, that solution isn't a good one. I don't mean to sound mean, but your code should work for all values. you shouldn't make specific cases in your code, that ruins the point of programming. it's all about automation, and doing work for specific cases goes against those principles and makes bad code
programming is lazy, making specific solutions for even 1 of your "problem" cases is less lazy than a programmer should be :)
Jack
@jh0l
Jul 13 2016 03:50
@karpimpski but why doesn't it work for 77
If we knew that then this wouldn't be an issue
Galen Crofut
@Owl-Exterminator
Jul 13 2016 03:50
Hello! I have a bit of a problem. I'm doing the "Random Quote Generator" challenge, and am trying to implement the tweet button. I included a comment in the JavaScript section where the problem is. I'd greatly appreciate it if someone can point out what's my error!
http://codepen.io/GCrofut/pen/PzJkKm?editors=1010
Michael Karpinski
@karpimpski
Jul 13 2016 03:51
@Jhollond that's what I keep trying to say. I'll try to figure out why it won't work for 77, but it would be much simpler if you tried my solution. it's just less math and less complication. like I said though I'll check it out for you quick
Jack
@jh0l
Jul 13 2016 03:52
@karpimpski mod is not even that much maths tho, it's simple
David Di Feo
@ddifeo
Jul 13 2016 03:52
@tymeart you have to use bracket notation for variables
Michael Karpinski
@karpimpski
Jul 13 2016 03:52
@Jhollond it's simple, yeah. but it's much more complicated than what the problem calls for
David Di Feo
@ddifeo
Jul 13 2016 03:53
firstName == contacts[i][firstName]
Michael Karpinski
@karpimpski
Jul 13 2016 03:53
@Jhollond the charcode for m is 109, not 77
Jack
@jh0l
Jul 13 2016 03:54
yes it is?
Michael Karpinski
@karpimpski
Jul 13 2016 03:54
not for ASCII or whatever this documentation says, but when I consolelog the charcode it says 109
Tiffany Lam
@tymeart
Jul 13 2016 03:54
@realxtensive I used bracket notation on prop but firstName is also the name of the property, so I used dot notation for that.
Jack
@jh0l
Jul 13 2016 03:54
blob
Michael Karpinski
@karpimpski
Jul 13 2016 03:55
@Jhollond that says 109, and i told you i'm not referring to a chart, i'm referring to the value that's returned when you check it in your code
Jack
@jh0l
Jul 13 2016 03:56
@karpimpski okay dood
:+1:
Michael Karpinski
@karpimpski
Jul 13 2016 03:57
@Jhollond not sure why you said 77 but gave me a photo that says 109. i'm still looking at your code, but in this time you could've written a subtraction function so much easier
Jack
@jh0l
Jul 13 2016 03:58
on the right it's 77 if u zero index lol
okay
I know why I've been confused
Michael Karpinski
@karpimpski
Jul 13 2016 03:59
78, and I guess JS does it the first way. anyway, i'm checking it out and it returns 70 for m
with your math i mean
Jack
@jh0l
Jul 13 2016 04:00
it's been using the decimal code when I thought it was using the straight number code
Michael Karpinski
@karpimpski
Jul 13 2016 04:00
can you give me that link you got the photo from?
Seth
@rifen
Jul 13 2016 04:01
I am totally lost on 173 Javascript
Stand in Line it's called
Michael Karpinski
@karpimpski
Jul 13 2016 04:03
@Jhollond I was testing this wrong, I didn't notice you upcased your whole function (also a problem with this. I think the problem specifically says any case)
let me see what i can do now
and yeah, it's exactly what i thought. it just goes one below, A. you'll have to do what i said anyway, in regards to the if statement.
Jack
@jh0l
Jul 13 2016 04:05
@rifen show us ur code
@karpimpski okay dood lol
Seth
@rifen
Jul 13 2016 04:05
I don't have code lol but heres the start
Michael Karpinski
@karpimpski
Jul 13 2016 04:05
you'll have to say something like "if it's below 65, subtract the difference below the index and 65 below Z's index"
@Jhollond
Seth
@rifen
Jul 13 2016 04:06

'function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
'

sorry I forgot the code tag o.o
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Michael Karpinski
@karpimpski
Jul 13 2016 04:06
help format
CamperBot
@camperbot
Jul 13 2016 04:06

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Michael Karpinski
@karpimpski
Jul 13 2016 04:06
@rifen
Seth
@rifen
Jul 13 2016 04:07
function nextInLine(arr, item) {
  // Your code here


  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I just don't understand what it's telling me 2 do.
Michael Karpinski
@karpimpski
Jul 13 2016 04:09
@rifen do you know the method to add to the end of an array?
Seth
@rifen
Jul 13 2016 04:09
I don't remember. I took a day break before this problem @karpimpski
that adds to the end of an array
this takes the first element from an array
Seth
@rifen
Jul 13 2016 04:11
ahh right. I am remembering now. Thanks I should be able to figure it out now :D
Thanks @karpimpski
CamperBot
@camperbot
Jul 13 2016 04:11
rifen sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @karpimpski |http://www.freecodecamp.com/karpimpski
Michael Karpinski
@karpimpski
Jul 13 2016 04:12

also, a hint for the last instruction:

[1,2,3].shift()

would return 1

Jack
@jh0l
Jul 13 2016 04:12
@karpimpski if (ROT13 === 64) {ROT13 = 90;}
this works
Michael Karpinski
@karpimpski
Jul 13 2016 04:12
@Jhollond yep! however, I would do something more mathematical. let me just write something real quick
Jack
@jh0l
Jul 13 2016 04:13
help caesar
CamperBot
@camperbot
Jul 13 2016 04:13

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is shifted by 13 places. e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

Relevant Links

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Jack
@jh0l
Jul 13 2016 04:13
oh hey look at that
Michael Karpinski
@karpimpski
Jul 13 2016 04:13
if (ROT13 < 65) {newROT13 = 91 - (65 - ROT13);}
if (ROT13 < 65) {newROT13 = 91 - (65 - ROT13);}
Brian
@BrianCodes33
Jul 13 2016 04:14
someone please help me make an api call for random quote generator?
getting errors with this code...
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://forismatic.com/en", false);
// Add your code below!
xhr.send();
console.log(xhr.status);
console.log(xhr.statusText);
Dany Din
@danydin
Jul 13 2016 04:14
whats the name of splice,push,pop and so on in arrays? methods or?
@BrianCodes33 where did you learned how to write in this way the api call?
Michael Karpinski
@karpimpski
Jul 13 2016 04:16
@danydin yep, those are examples of methods
Dany Din
@danydin
Jul 13 2016 04:17
@karpimpski ah ok thanks cuz in objects methods is something totally different :worried:
CamperBot
@camperbot
Jul 13 2016 04:17
danydin sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @karpimpski |http://www.freecodecamp.com/karpimpski
Dany Din
@danydin
Jul 13 2016 04:19
This message was deleted
jbeaumont1010
@jbeaumont1010
Jul 13 2016 04:22
Super demoralized by "Profile Lookup"
Tiffany Lam
@tymeart
Jul 13 2016 04:22
@jbeaumont1010 I'm having trouble with that one too
Jack
@jh0l
Jul 13 2016 04:23
I think I looked up the wiki solution before I should have for that one haha
don't do that tho
it will spoil your morale
Taro
@TaroWong
Jul 13 2016 04:26
help record collection
CamperBot
@camperbot
Jul 13 2016 04:26

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

Taro
@TaroWong
Jul 13 2016 04:26
Hi everyone :)
ronaldrdguez
@ronaldrdguez
Jul 13 2016 04:29
@Owl-Exterminator Hi, your twitter button is followed by a <script> tag which loads async code that operates on the tweet widget. document.getElementById() is not returning the <a> element but null since the async code hasn’t loaded yet. Instead of using the button that way, try instead something like <a target=“_blank" href="https://twitter.com/intent/tweet?text=“your quote text”>Tweet</a> which doesn’t have that problem and is simpler.
Kurt Louise
@kurtlouise
Jul 13 2016 04:39
studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
someone can help me
Chris Cuevo
@ccuevo
Jul 13 2016 04:41
hi everyone, i need help with the seek and destroy challenge. im' not sure what they're asking for. this is my code so far:
function destroyer(arr) {
  // Remove all the values
  for (var i = 0; i < arr.length; i++) {
    return arr.filter(arguments[i] = i+1);
  }
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Michael Karpinski
@karpimpski
Jul 13 2016 04:42
wiki seek and destroy
CamperBot
@camperbot
Jul 13 2016 04:42

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Relevant Links

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Michael Karpinski
@karpimpski
Jul 13 2016 04:44
@ccuevo first, I would add 2 arguments to your function
Kurt Louise
@kurtlouise
Jul 13 2016 04:45
studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
Galen Crofut
@Owl-Exterminator
Jul 13 2016 04:46
@ronaldrdguez That works!! Thanks for your help, I was stuck for three days figuring that out!
CamperBot
@camperbot
Jul 13 2016 04:46
owl-exterminator sends brownie points to @ronaldrdguez :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @ronaldrdguez |http://www.freecodecamp.com/ronaldrdguez
gdntian
@gdntian
Jul 13 2016 04:51
help Record Collection
CamperBot
@camperbot
Jul 13 2016 04:51

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

Kurt Louise
@kurtlouise
Jul 13 2016 04:52
Modify the existing declarations and assignments so their names use camelCase.
Do not create any new variables.
Seung Won Lee
@leesw98
Jul 13 2016 04:52
myStr should have encoded text with the proper escape sequences and no spacing.
"var myStr = "FirstlLine\n\SecondLine\\rThirdLine"; // Change this line"
EDIT: typo..
What am I doing wrong
Kurt Louise
@kurtlouise
Jul 13 2016 04:52
can someone help me
Seung Won Lee
@leesw98
Jul 13 2016 04:53
Kurt Whats wrong?
Kurt Louise
@kurtlouise
Jul 13 2016 04:53
@leesw98 studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
Seung Won Lee
@leesw98
Jul 13 2016 04:55
What did you put as your solution?
@kurtlouise Do you want me to just give you the solution?
Subramanya Chakravarthy
@chakrihacker
Jul 13 2016 04:58
help repeat a string
CamperBot
@camperbot
Jul 13 2016 04:58

:point_right: algorithm repeat a string repeat a string [wiki]

Algorithm Repeat a String

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

The program is very simple, we have to take a variable and return that variable being repeated certain amount of times. No need to add space or anything, just keep repeating it into one single string.

Relevant Links

:pencil: read more about algorithm repeat a string repeat a string on the FCC Wiki

NPeyralans
@NPeyralans
Jul 13 2016 04:59
@ndburrus Thanks!
CamperBot
@camperbot
Jul 13 2016 04:59
npeyralans sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 962 | @ndburrus |http://www.freecodecamp.com/ndburrus
96street
@96street
Jul 13 2016 04:59
can someone tell me why this doesn't work
function myReplace(str, before, after) {

  var upper = '/[A-Z]/';
  if(before.charAt(0) == upper) {
    after.charAt(0) = after.charAt(0).toUpperCase();
  }
  else {
    after.charAt(0) = after.charAt(0).toLowerCase();
  }

  return str.replace(before, after);

}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting");
if the first letter of 'before' is uppercase i want to change 'after' to uppercase
Chris Katzmann
@cwkatzmann
Jul 13 2016 05:00
I wrote such a weird piece of code that passes all the tests and I dont even know why

// passes tests but is no good
function truncateString(str, num) {
// Clear out that junk in your trunk
if(num >= str.length){
return str;}
if(str.charAt(num) !== " " && num > 8){
return truncateString(str, num-1);}
return str.slice(0, num) + "...";
}

truncateString("Absolutely Longer", 2);

that line where it says "if(str.charAt(num) !== " " && num > 8)"
the code will pass all tests if i put any number for the second part of the condition 2 through 8
but nothing higher
Nick Irvine
@irvin3
Jul 13 2016 05:07
hey I have a question about my Sum All Prime code.. I thought any prime number greater than 3 divided by 6 has a remainder of 5 or 1? My code should add all those numbers together but fails to solve the test case of 977
function primes(num){


var total = 5;

for(var i = 0; i < num; i++){
  if(i%6 === 5 || i%6 === 1 ){
    total = total + i;
  }
}

console.log(total);
}

primes(977);
Michael Karpinski
@karpimpski
Jul 13 2016 05:08
@irvin3 sorry, but primes don't really operate like that. not all primes follow that rule, I'm not sure if most primes follow that rule
make a loop that goes up to num and for each value in that loop, have something that loops up to that number to see if it's divisible. if it's not divisible by any of those numbers, add it to your total
Nick Irvine
@irvin3
Jul 13 2016 05:11
okay that makes sense, I really thought that was a rule I have read before, but i understand how your way will work also
thanks @karpimpski
CamperBot
@camperbot
Jul 13 2016 05:11
irvin3 sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 374 | @karpimpski |http://www.freecodecamp.com/karpimpski
Michael Karpinski
@karpimpski
Jul 13 2016 05:12
@irvin3 no problem. the best way to go about it (for me) is to make a boolean variable for prime. if you find a number that can be divided into your number, make prime false
initialize it at true
tonysim024
@tonysim024
Jul 13 2016 05:13

hey guys, need help. The instructions were:
Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine

this was wmy code:
var myStr = "FirstLine\n\SecondLine\rThirdLine";
what did i do wrong... T_T??
Michael Karpinski
@karpimpski
Jul 13 2016 05:14
help format
CamperBot
@camperbot
Jul 13 2016 05:14

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Michael Karpinski
@karpimpski
Jul 13 2016 05:14
@tonysim024
Shusil Banjade
@shusil123
Jul 13 2016 05:14

@96street , because you are comparing the character at 0 to the regular expression. You don't need that upper variable. You can just do,

 if(before.charAt(0)==before.charAt(0).toUpperCase()) {
    after = after.charAt(0).toUpperCase()+after.substr(1);
  }
  else {
    after = after.charAt(0).toLowerCase()+after.substr(1);
  }

Or if you wanna use regex, you have to use some other regex methods like .match() / .test , I guess

This message was deleted
You have to concatenate the string (first character + remaining others).
Seth
@rifen
Jul 13 2016 05:15

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


  return arr[0]; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
having trouble with nextInLine([], 1) should return 1
@karpimpski
Michael Karpinski
@karpimpski
Jul 13 2016 05:18
@rifen put push first

what's the name of this challenge again? let me check it out quick. but, here's my hint again:

[1,2,3].shift()

returns 1, not the array

in this case, with an empty array, you may need to use an if statemt though @rifen
statement*
Seth
@rifen
Jul 13 2016 05:19
that's what I was thinking
Michael Karpinski
@karpimpski
Jul 13 2016 05:20
@rifen first of all, you'll PROBABLY want to do something like this:
function nextInLine(arr, item) {
  // Your code here

  testArr.push(item);


  return  testArr.shift(); // Change this line
}
though I'm not positive
however, you may need to add a ternary or if else statement to check for empty arrays
nope, no need for the if statement because you'll always add something to the array. the solution I gave works, you just need to add item to the array and then return the value of the first value in that array
Seth
@rifen
Jul 13 2016 05:25
Then this doesn't work: nextInLine([5,6,7,8,9], 1) should return 5
Michael Karpinski
@karpimpski
Jul 13 2016 05:25
@rifen replace testArr with arr
Seth
@rifen
Jul 13 2016 05:26
lol now the first and last objective's do not work
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:26
what does this error mean?
This message was deleted
TypeError: Assignment to read-only properties is not allowed in strict mode
Michael Karpinski
@karpimpski
Jul 13 2016 05:27
@rifen can you paste your code?
@amanmehta-maniac there's something in there that you can't write to based on FreeCodeCamp's rules
probably a certain variable in a FCC challenge? not too sure
Seth
@rifen
Jul 13 2016 05:28

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

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

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@karpimpski
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:28
I am trying to titleCase a string
I split it
changed each to lowercase
Michael Karpinski
@karpimpski
Jul 13 2016 05:29
when you push item to testArr, you're not pushing it to arr
you need to push to arr and shift from arr, testArr shouldn't be used in your function
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:29
but whenever I try to access first char of each term, it shows me ^that erroe
Michael Karpinski
@karpimpski
Jul 13 2016 05:30
@amanmehta-maniac can you copy your code?
Mustafijur rahman
@Dinar717
Jul 13 2016 05:30
This message was deleted
Michael Karpinski
@karpimpski
Jul 13 2016 05:30
@rifen testArr is passed to that function as a parameter. you never use the variable that's used for the parameter, always use the parameter itself
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:30

function titleCase(str) {
var x=str.split(' ');
var y=["sms","aman"];
console.log(x);
y[0]=x[0].toLowerCase();
for(var i=0;i<x.length;i++)
{
y[i]=x[i].toLowerCase();
y[i][0]=x[i][0].toUpperCase();
// console.log(x[i].length);
// for(var j=0;j<x[i].length;j++)
//
// y[i][j]=x[i][j].toLowerCase();

    //
}

// y[0][0]=y[0][0].toUpperCase();
return str;
}

titleCase("I'm a little tea pot");

Seth
@rifen
Jul 13 2016 05:31
@karpimpski Thanks, alright. I will remember that for future references!
CamperBot
@camperbot
Jul 13 2016 05:31
rifen sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @karpimpski |http://www.freecodecamp.com/karpimpski
Ahmad K
@bartlett705
Jul 13 2016 05:31
@amanmehta-maniac you can't change strings by index like that
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:31
so what do i do?
Michael Karpinski
@karpimpski
Jul 13 2016 05:31
@rifen yeah, no problem! just to be more clear, if I wasn't. say there's a function called myFunction(arr) and you say myFunction([1,2,3]) you would never edit [1,2,3] within that function. ALWAYS edit arr
@amanmehta-maniac can you fix your code format?
help format
CamperBot
@camperbot
Jul 13 2016 05:32

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Ahmad K
@bartlett705
Jul 13 2016 05:32
compose a new string with slices
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:32
@karpimpski fix my code format? what do u mean
Ahmad K
@bartlett705
Jul 13 2016 05:32
@amanmehta-maniac y=x[0].toLowerCase() + y.slice(1);
Michael Karpinski
@karpimpski
Jul 13 2016 05:33
@amanmehta-maniac paste your code within three ticks like this`
Ahmad K
@bartlett705
Jul 13 2016 05:33
@amanmehta-maniac that'll give you the first character of x, plus the rest of y
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:33
slice, what does this do?
Michael Karpinski
@karpimpski
Jul 13 2016 05:33
so it looks like actual code
Ahmad K
@bartlett705
Jul 13 2016 05:33
look up the documentation for it
it gives you part of a string, in this case everything but the first character
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:35
u mean slice(x) will give me all chars after xth char? @bartlett705
Ahmad K
@bartlett705
Jul 13 2016 05:35
yep
string.slice(x), that is
Hey guys, I'm banging my head on this one. Here's my code:
```
hehe, oops
Aman Mehta
@amanmehta-maniac
Jul 13 2016 05:36
ok, let me get back at u.
Ahmad K
@bartlett705
Jul 13 2016 05:37
var Person = function(firstAndLast) {
  var self = this;
  self.names = firstAndLast.split(' ');
  return {
  getFirstName: function() {
      return self.names[0];
    },
...(more of this)...

var jim = new Person('jim dangle');
why isn't jim instanceof Person true?
Subramanya Chakravarthy
@chakrihacker
Jul 13 2016 05:40
help truncate
CamperBot
@camperbot
Jul 13 2016 05:40

:point_right: algorithm truncate a string [wiki]

Algorithm Truncate a String

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

Relevant Links

:pencil: read more about algorithm truncate a string on the FCC Wiki

Markus Kiili
@Masd925
Jul 13 2016 05:41
@bartlett705 Because you return a plain object from the constructor.
MetaSean
@metasean
Jul 13 2016 05:43
help remainder
CamperBot
@camperbot
Jul 13 2016 05:43

:point_right: challenge finding a remainder in javascript [wiki]

Challenge Finding a Remainder in Javascript

The remainder operator % gives the remainder of the division of two numbers.

:pencil: read more about challenge finding a remainder in javascript on the FCC Wiki

Markus Kiili
@Masd925
Jul 13 2016 05:43
@bartlett705 Usually, constructors don't have a return value.
Ahmad K
@bartlett705
Jul 13 2016 05:44
yeah...that was the only way i could figure out to add 'methods' such that Object.keys(jim).length is equal to the number of methods
Markus Kiili
@Masd925
Jul 13 2016 05:45
@bartlett705 Just add them normally this.methodName=function (..){...
No need for self or return value here.
Ahmad K
@bartlett705
Jul 13 2016 05:47
@Masd925 ok, I tried that outside of the 'class' definition, i.e. Person.prototype.methodName=Function(...) {...} but they didn't get counted in Object.keys. Thanks for the tip.
CamperBot
@camperbot
Jul 13 2016 05:47
bartlett705 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2089 | @masd925 |http://www.freecodecamp.com/masd925
Norvin Burrus
@ndburrus
Jul 13 2016 05:47
@NPeyralans you're welcome! :smile: enjoy :palm_tree:
Markus Kiili
@Masd925
Jul 13 2016 05:48
@bartlett705 No need to use prototype either. Just basic constructor and some private property declared with var. You are thinking too complex.
Dany Din
@danydin
Jul 13 2016 05:48
@bartlett705 @bartlett705 what task name is it
Ahmad K
@bartlett705
Jul 13 2016 05:50
@Masd925 Yeah, same problem as when I tried using prototypes
Dany Din
@danydin
Jul 13 2016 05:50
@Masd925 when you use prototype and constructor in arrays for what reasons?
Ahmad K
@bartlett705
Jul 13 2016 05:50
@Masd925 Got it, thanks a bunch!
CamperBot
@camperbot
Jul 13 2016 05:50
bartlett705 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: bartlett705 already gave masd925 points
Dany Din
@danydin
Jul 13 2016 05:51
@bartlett705 what name was that task
Jowi Nyangweso
@holy-jowi
Jul 13 2016 05:51
need some quick help with " Selecting from many options with Switch Statements"
can anyone lend a hand?
Markus Kiili
@Masd925
Jul 13 2016 05:51
@danydin Arrays?
Ahmad K
@bartlett705
Jul 13 2016 05:51
@danydin 'Make a Person'
Dany Din
@danydin
Jul 13 2016 05:51
ya in ararys @Masd925
Markus Kiili
@Masd925
Jul 13 2016 05:52
@danydin You mean something like Array.prototype.slice.call...
MetaSean
@metasean
Jul 13 2016 05:52
@ndburrus Thanks!
CamperBot
@camperbot
Jul 13 2016 05:52
metasean sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 963 | @ndburrus |http://www.freecodecamp.com/ndburrus
Dany Din
@danydin
Jul 13 2016 05:52
for what reasons you shall use those propeties constructor and prototype
Norvin Burrus
@ndburrus
Jul 13 2016 05:52
@metasean you're welcome! :palm_tree:
MetaSean
@metasean
Jul 13 2016 05:52
@ndburrus - I also found http://javascript.about.com/od/problemsolving/a/modulobug.htm - I'm glad I went back through this one, because I thought it was modulus :blush:
Markus Kiili
@Masd925
Jul 13 2016 05:54
@danydin The .constructor property is rarely used. Constructor functions prototype property points to an object that is the prototype of the objects created with new and the constructor. Methods are usually put to the prototype instead of the constructor.
Norvin Burrus
@ndburrus
Jul 13 2016 05:54

@metasean did you mean modulo? lol, it can get confusing...

...I thought it was modulus :)

Dany Din
@danydin
Jul 13 2016 05:54
@Masd925 ya ok then what is the prototype used for
MetaSean
@metasean
Jul 13 2016 05:55
@ndburrus - Indeed! (It doesn't help that bedtime was about 2 hours ago, but I'd rather be codin' than sleepin')
Jowi Nyangweso
@holy-jowi
Jul 13 2016 05:55

``` switch ( val ){
case 1:
console.log ("alpha");
break;
case 2:
return "beta";
case 3:
return "gamma";
case 4:
return "delta";

}```

Markus Kiili
@Masd925
Jul 13 2016 05:55
@danydin For example Array is the constructor of arrays and Array.prototype is the object that holds all the array methods and is the prototype of all arrays. That way arrays can use the array methods.
Norvin Burrus
@ndburrus
Jul 13 2016 05:56
@metasean you're a champion! i too should be asleep, but there were a couple more things I wanted to do... :panda_face:
Jowi Nyangweso
@holy-jowi
Jul 13 2016 05:56
the first case statement doesnt have the value of "alpha" but the ones where i used return dont use the break what word am i needing to use instead?
Norvin Burrus
@ndburrus
Jul 13 2016 05:56
@holy-jowi lesson name?
Markus Kiili
@Masd925
Jul 13 2016 05:57
@danydin If array methods were in the Array constructor, then all arrays would have their own copy of the method. When the method is in the prototype object, there is only one method that all the arrays use along the prototype chain.
Joseph
@revisualize
Jul 13 2016 05:57
@holy-jowi You don't console.log. you need to assign the answer value that you're returning.
Jowi Nyangweso
@holy-jowi
Jul 13 2016 05:57
@ndburrus "Selecting from many options with Switch Statements"
Dany Din
@danydin
Jul 13 2016 05:58
@Masd925 so it basically makes it avilable in the lexical global scope or?
Jowi Nyangweso
@holy-jowi
Jul 13 2016 05:58
thanks @revisualize
CamperBot
@camperbot
Jul 13 2016 05:58
holy-jowi sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1417 | @revisualize |http://www.freecodecamp.com/revisualize
Norvin Burrus
@ndburrus
Jul 13 2016 05:59
@holy-jowi ok, take a look at the lesson sample code. we want to do something if the case condition/s are true/met. what do we want to do (ie what should our statements look like)?
Markus Kiili
@Masd925
Jul 13 2016 06:05
@danydin I think an execution context has a reference to an outer (lexical) environment, and an object (in memory) can have a reference to a prototype object. Not sure if those two have anything to do with each other.
Jowi Nyangweso
@holy-jowi
Jul 13 2016 06:06
thanks @ndburrus i ended up figuring it out i appreciate it
CamperBot
@camperbot
Jul 13 2016 06:06
holy-jowi sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 964 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 13 2016 06:07
@holy-jowi excellent! nice job :palm_tree:
Michael Karpinski
@karpimpski
Jul 13 2016 06:15
http://codepen.io/karpimpski/pen/akVGYX
hey guys, it would be great if you could check out my Connect 4 game and give me feedback! the only thing I need to do is add win conditions, so some help on that would be great! I may add AI in the future
Vinh Huynh
@vinh512
Jul 13 2016 06:18
I'm on the javascript golf Q. Can someone explain the equation for 'hole in one'?
Rohan Mohammad
@reolander
Jul 13 2016 06:18
Hey guys is there any simple solution to Roman Numeral apart from this?
i
function convertToRoman(num) {

  var array = [];

  while(num > 0) {


    if(num >= 1000) {

      var M = Math.floor(num / 1000);
      for(var i =0; i < M; i++)
         array.push('M');
      num = num % 1000;


    } else if(num >= 500) {

       if(num >= 900 && num < 1000) {
          array.push("CM");
        num = num % 900;

       }

      else {
          var D = Math.floor(num / 500);
          for(var i =0; i < D; i++)
              array.push('D');
          num = num % 500;
      }

    } else if(num >= 100) {

        if (num >= 400 && num < 500){
           array.push("CD");
        num = num % 100;
        }

        else {
            var C =Math.floor(num / 100);
            for(var i =0; i < C; i++)
              array.push('C');
            num = num % 100;
        }    
    } else if(num >= 50) {

      if (num >= 90 && num < 100){
           array.push("XC");
        num = num % 90;
        }

      else{

       var L = Math.floor(num / 50);
       for(var i =0; i < L; i++)
         array.push('L');
       num = num % 50;
      }

    } else if(num >= 10) {

        if(num >=40 && num < 50){
          array.push("XL");
          num = num % 40;
        }

        else {
           var X = Math.floor(num / 10);
           for(var i =0; i < X; i++)
              array.push('X');
           num = num % 10;

        } 
    } else if(num >=5) {

        if(num == 9){
          array.push("IX");
          num = 0;
        }

        else {
           var V = Math.floor(num / 5);
           for(var i =0; i < V; i++)
              array.push('V');
           num = num % 5;
        }
    } else if(num > 0) {

      if(num == 4) {
        array.push('IV');
        num = 0;
      }

      else {

        for(var i =0; i < num; i++)
              array.push('I');
        num = 0;

      }

    }

  }

  var string  = array.join('');

 return string;
}

convertToRoman(97);
Michael Karpinski
@karpimpski
Jul 13 2016 06:18
@rohan222 I'll show you mine if I can find it. I think it's much simpler than that
Markus Kiili
@Masd925
Jul 13 2016 06:18
@rohan222 Better place for working code is https://gitter.im/FreeCodeCamp/CodeReview
Rohan Mohammad
@reolander
Jul 13 2016 06:19
@karpimpski yeah sure can you send me your code :)
Michael Karpinski
@karpimpski
Jul 13 2016 06:19
@rohan222
function convertToRoman(num) {
  var originalNumber = num;
  var roman = "";
  var numerals = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
  var numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
  for (var i = 0; i < numbers.length; i++) {
    while (num >= numbers[i]) {
      roman += numerals[i];
      num -= numbers[i];
    }
    insertNum(originalNumber, roman)
  }
}
Rohan Mohammad
@reolander
Jul 13 2016 06:20
@Masd925 Thanks for the info
CamperBot
@camperbot
Jul 13 2016 06:20
rohan222 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2091 | @masd925 |http://www.freecodecamp.com/masd925
Michael Karpinski
@karpimpski
Jul 13 2016 06:20
yeah, that's much simpler
function convertToRoman(num) {
  var originalNumber = num;
  var roman = "";
  var numerals = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
  var numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
  for (var i = 0; i < numbers.length; i++) {
    while (num >= numbers[i]) {
      roman += numerals[i];
      num -= numbers[i];
    }
    insertNum(originalNumber, roman)
  }
}
better format
Rohan Mohammad
@reolander
Jul 13 2016 06:20
@karpimpski nicee!!
Michael Karpinski
@karpimpski
Jul 13 2016 06:20
yeah, so basically what I did was I made an array of corresponding values for English numbers and Roman numerals and looped through
just removed values from the original number as I added Roman numerals to my final string
Markus Kiili
@Masd925
Jul 13 2016 06:21
@karpimpski What is insertNum ?
Michael Karpinski
@karpimpski
Jul 13 2016 06:22
@Masd925 sorry, I made my own project based on this challenge. insertNum just adds to my string
function insertNum(num, roman) {
  $("#romanResult").html(num + " = " + roman);
}
it's for the HTML portion of my page
Markus Kiili
@Masd925
Jul 13 2016 06:23
@karpimpski I did it similarly with reduce:
function convertToRoman(num) {
  var NUM = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
  var ROM = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
  return NUM.reduce(function(prev,curr,index){
    while(num>=curr) {
      num-=curr;
      prev+=ROM[index];
    }
    return prev;
  }, '');
}
Michael Karpinski
@karpimpski
Jul 13 2016 06:24
@Masd925 when I did this I wasn't familiar with .reduce. I like your solution!
Markus Kiili
@Masd925
Jul 13 2016 06:25
@karpimpski Essentially the same solution.
Rohan Mohammad
@reolander
Jul 13 2016 06:25
@Masd925 @karpimpski Is there any other website where I can learn Ajax Tech? I could not understand it in FCC.
Michael Karpinski
@karpimpski
Jul 13 2016 06:26
yeah, yours just requires a little less code
@rohan222 FCC's Ajax is absolutely terrible
go to Udacity, they have a good AJAX course
Rohan Mohammad
@reolander
Jul 13 2016 06:29
@karpimpski thanks :)
CamperBot
@camperbot
Jul 13 2016 06:29
rohan222 sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @karpimpski |http://www.freecodecamp.com/karpimpski
Rohan Mohammad
@reolander
Jul 13 2016 06:30
@karpimpski had a look at your Connect 4 game. It is really nice. But can you reduce the time for the Red and Yellow dots to appear once we click the empty holes? Just a bit faster would be nice.
@karpimpski Also can you please share how long it took for you to accomplish a task like that? How many hours spread over how many days? TIA
Michael Karpinski
@karpimpski
Jul 13 2016 06:31
@rohan222 thanks! yeah, that's an easy fix. that game took me about an hour and a half
CamperBot
@camperbot
Jul 13 2016 06:31
karpimpski sends brownie points to @rohan222 :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @rohan222 |http://www.freecodecamp.com/rohan222
Michael Karpinski
@karpimpski
Jul 13 2016 06:32
I still need to do work on it, but a basic 2-player game like that took me an hour and a half. the design is bad, there is no win condition, and no AI. it's not very impressive by any means
Rohan Mohammad
@reolander
Jul 13 2016 06:33
@karpimpski Also i think you should de-link the restart button with the click of mouse on the board. Everytime I click the board even the restart button fades and 'un-fades'
Just 1: 30 hours?! Wow. I'm new to Coding and a simple tribute page took me 2:30 hours ha-ha
Michael Karpinski
@karpimpski
Jul 13 2016 06:34
@rohan222 yeah, I just thought it would be cool to have the restart button change color depending on who is up next
and I've been programming for a few months, I've had more practice. don't worry, you'll be able to do stuff like that in no-time, it's really not very hard
Rohan Mohammad
@reolander
Jul 13 2016 06:36
@karpimpski I hope so :) Thanks for your encouragement
CamperBot
@camperbot
Jul 13 2016 06:36
rohan222 sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:warning: rohan222 already gave karpimpski points
Rohan Mohammad
@reolander
Jul 13 2016 06:36
Okay back to coding! Bye, it was nice talking to you.
Michael Karpinski
@karpimpski
Jul 13 2016 06:37
@rohan222 of course! definitely check out that Udacity course on Ajax
Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:37
Help me :( IN this: https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20%0A%20%20switch(id)%3A%0A%20%20%20%20case%202548%3A%0A%20%20%20%20%20%20collection%5Bid%5D.artist%20%3D%20value%3B%20%2F%2F%20Adding%20new%20property%20on%20Album%20ID%0A%20%20%20%20%20%20collection%5B5439%5D.tracks%20%3D%20%5Bvalue%5D%3B%20%2F%2F%20Adding%20new%20property%20on%20Album%20ID%0A%20%20%20%20%20%20break%3B%0A%20%20%20%20case%202468%3A%0A%20%20%20%20case%201245%3A%0A%20%20%20%20case%205439%3A%0A%20%20%20%20%20%20%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
CamperBot
@camperbot
Jul 13 2016 06:37
no wiki entry for: me in this httpswwwfreecodecampcomchallengesrecord-collectionsolution0a2f2f20setup0avar20collection203d207b0a20202020222548223a207b0a20202020202022album223a2022slippery20when20wet222c0a20202020202022artist223a2022bon20jovi222c0a20202020202022tracks223a205b200a202020202020202022let20it20rock222c200a202020202020202022you20give20love20a20bad20name22200a2020202020205d0a202020207d2c0a20202020222468223a207b0a20202020202022album223a20221999222c0a20202020202022artist223a2022prince222c0a20202020202022tracks223a205b200a2020202020202020221999222c200a202020202020202022little20red20corvette22200a2020202020205d0a202020207d2c0a20202020221245223a207b0a20202020202022artist223a2022robert20palmer222c0a20202020202022tracks223a205b205d0a202020207d2c0a20202020225439223a207b0a20202020202022album223a2022abba20gold220a202020207d0a7d3b0a2f2f20keep20a20copy20of20the20collection20for20tests0avar20collectioncopy203d20jsonparsejsonstringifycollection3b0a0a2f2f20only20change20code20below20this20line0afunction20updaterecordsid2c20prop2c20value207b0a20200a2020switchid3a0a20202020case2025483a0a202020202020collection5bid5dartist203d20value3b202f2f20adding20new20property20on20album20id0a202020202020collection5b54395dtracks203d205bvalue5d3b202f2f20adding20new20property20on20album20id0a202020202020break3b0a20202020case2024683a0a20202020case2012453a0a20202020case2054393a0a2020202020200a2020return20collection3b0a7d0a0a2f2f20alter20values20below20to20test20your20code0aupdaterecords54392c2022artist222c2022abba223b0a0a
Markus Kiili
@Masd925
Jul 13 2016 06:38
@SopanTripathi Copy/paste code here instead of a link. Use code formatting:
Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:38
How to update records when there is no value ??
Markus Kiili
@Masd925
Jul 13 2016 06:38
explain format
CamperBot
@camperbot
Jul 13 2016 06:38

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Markus Kiili
@Masd925
Jul 13 2016 06:38
@SopanTripathi You mean tracks property?
willfree108
@willfree108
Jul 13 2016 06:38
@Masd925 Oh that's really cool with reduce, can i ask the purpose of '' at the end ?
Taro
@TaroWong
Jul 13 2016 06:38
explain record collection
CamperBot
@camperbot
Jul 13 2016 06:38

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

Markus Kiili
@Masd925
Jul 13 2016 06:38
@willfree108 The initial running value.
Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:39

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

  switch(id):
    case 2548:
      collection[id].artist = value; // Adding new property on Album ID
      collection[5439].tracks = [value]; // Adding new property on Album ID
      break;
    case 2468:
    case 1245:
    case 5439:

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Problem is on "3rd task" ...
After updateRecords(2548, "artist", ""), artist should not be set
Markus Kiili
@Masd925
Jul 13 2016 06:40
@SopanTripathi Don't hardcode id values. You need to test parameters value and prop, because they hold the passed arguments. Then only in if blocks, you access collection.
willfree108
@willfree108
Jul 13 2016 06:41
@Masd925 not sure i fully understand, u mean it's start with '' and the reduce will add an value for each element ?
Markus Kiili
@Masd925
Jul 13 2016 06:42
@willfree108 There is a running value that reduce updates on each iteration (array element). If you don't provide an initial running value, reduce takes the first array element instead.
willfree108
@willfree108
Jul 13 2016 06:42
@Masd925 oh i got it now ty a lot
CamperBot
@camperbot
Jul 13 2016 06:42
willfree108 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2092 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 13 2016 06:43
@willfree108 The reduce callback function tells reduce how to get the next running value (return value) from the previous running value and the element being iterated (callback parameters).
Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:43
@Masd925 ok.. i will try and let you know...
willfree108
@willfree108
Jul 13 2016 06:45
@Masd925 great explanation ty again !
CamperBot
@camperbot
Jul 13 2016 06:45
willfree108 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: willfree108 already gave masd925 points
Brian
@BrianCodes33
Jul 13 2016 06:46
anyone know why i'm not linking my scripts properly?
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
      <script src="jquery-1.12.4.min.js"></script>
      <script type="text/javascript" src="main.js"></script>
kirbyedy
@kirbyedy
Jul 13 2016 06:47
@BrianCodes33 first one is pulled from the internet link, while the other two are most probably on your local machine
but is the path correct ?
Brian
@BrianCodes33
Jul 13 2016 06:48
i dont know thats why im asking @kirbyedy
kirbyedy
@kirbyedy
Jul 13 2016 06:48
btw, you should load jquery first, and then bootstrap
well if you ask me, the second link is wrong for sure :)
Dmitrij Schmidt
@dmitrij-schmidt
Jul 13 2016 06:49
@BrianCodes33 if you want, you can link jquery from CDN - links are here https://code.jquery.com/
Brian
@BrianCodes33
Jul 13 2016 06:50
can someone help me get this right? :(
Dmitrij Schmidt
@dmitrij-schmidt
Jul 13 2016 06:50
first of all, it's better and cleaner store your scripts in /js folder, not in root folder
Michael Karpinski
@karpimpski
Jul 13 2016 06:50
@BrianCodes33 what does your file architecture look like?
Brian
@BrianCodes33
Jul 13 2016 06:51
just index.html main.js and style.css . trying to just get the functionality working
Michael Karpinski
@karpimpski
Jul 13 2016 06:51
@BrianCodes33 then your jquery src won't work
make a CDN link similar to your bootstrap one, put the jquery above bootstrap, and try that
Brian
@BrianCodes33
Jul 13 2016 06:52
can you show me the right way to link scripts in jquery and bootstrap once and for all? This shouldn't be rocket science.
Dmitrij Schmidt
@dmitrij-schmidt
Jul 13 2016 06:52
@BrianCodes33 - <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> should do the trick for you. and just as @kirbyedy said - load jquery before bootstrap
Michael Karpinski
@karpimpski
Jul 13 2016 06:53
@dmitrij-schmidt wouldn't maxcdn load faster? not really important for this example, but for future reference
Dmitrij Schmidt
@dmitrij-schmidt
Jul 13 2016 06:53
@karpimpski - well, on their page it says that they are "Powered by MaxCDN" :)
Michael Karpinski
@karpimpski
Jul 13 2016 06:54
oh, the maxcdn link is the one you gave, it uses maxcdn
yeah I just looked on the page you provided and noticed :P
Brian
@BrianCodes33
Jul 13 2016 06:55
will you guys help me make an api call for random quote machine?
not getting any errors anyomre on the scripts
Dmitrij Schmidt
@dmitrij-schmidt
Jul 13 2016 06:55
@karpimpski there's also https://developers.google.com/speed/libraries/#jquery . don't know which one is faster/more popular
Michael Karpinski
@karpimpski
Jul 13 2016 06:55
I'll do my best. I don't use the same setup as you, though
@dmitrij-schmidt I automatically believe that Google's is faster, but I just like Google and haven't really looked into it :P I'm trying to stray away from jQuery though
Brian
@BrianCodes33
Jul 13 2016 06:56
function newQuote() {
  var url = "http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?";
  $.getJSON(url, function(data) {
    $(".main-quote").text(data.quoteText);
    $(".blockquote").text(data.quoteAuthor);
  });
}
right track?
Michael Karpinski
@karpimpski
Jul 13 2016 06:57
try doing something like alert(data.quoteText)
see if you get what you should
Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:58
find js
Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:58
find js
wiki topic
CamperBot
@camperbot
Jul 13 2016 06:58

:point_right: gitter camperbot topic [wiki]

Gitter CamperBot topic Command

This is an example. You should replace topic with the thing you want to find info on. For example:

wiki css    # find a wiki page on css
find js     # find all pages related to css

:pencil: read more about gitter camperbot topic on the FCC Wiki

Vivek Tripathi
@SopanTripathi
Jul 13 2016 06:59
wiki js
CamperBot
@camperbot
Jul 13 2016 06:59

:point_right: challenge accessing nested arrays in json [wiki]

Challenge Accessing Nested Arrays in JSON

As we have seen in earlier examples, JSON objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.

Here is an example of how to access a nested array:

```javascript
var ourPets = {
"cats": [
"Meowzer",
"Fluffy",
"Kit-Cat"
],
"dogs": [
"Spot",
"Bowser",
"Frankie"
]
};
ourPets.cats1; // "Fluffy"
:pencil: read more about challenge accessing nested arrays in json on the FCC Wiki

Brian
@BrianCodes33
Jul 13 2016 06:59
@karpimpski doesn't give me anything in console.
Michael Karpinski
@karpimpski
Jul 13 2016 06:59
alert displays a pop-up. then that's not the correct way to call, let me find mine and show you the format I used for JSON
Brian
@BrianCodes33
Jul 13 2016 07:00
it worked!
Konstantin
@kostanakis
Jul 13 2016 07:00
'''js
CamperBot
@camperbot
Jul 13 2016 07:00
:bulb: to format code use backticks! ``` more info
Brian
@BrianCodes33
Jul 13 2016 07:00
thanks @karpimpski
CamperBot
@camperbot
Jul 13 2016 07:00
briancodes33 sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @karpimpski |http://www.freecodecamp.com/karpimpski
Vivek Tripathi
@SopanTripathi
Jul 13 2016 07:00
about @saadanerdetbare
CamperBot
@camperbot
Jul 13 2016 07:00
:cookie: 454 | @saadanerdetbare |http://www.freecodecamp.com/saadanerdetbare
Michael Karpinski
@karpimpski
Jul 13 2016 07:00
@BrianCodes33 yeah no problem
Brian
@BrianCodes33
Jul 13 2016 07:01
@karpimpski i'm gonna need more help on the functionality
Michael Karpinski
@karpimpski
Jul 13 2016 07:02
@BrianCodes33 what do you need?
Brian
@BrianCodes33
Jul 13 2016 07:03
the blockquote isn't working for the author of the quote and would like to toggle to click more quotes. let me try and hack away
Konstantin
@kostanakis
Jul 13 2016 07:03
$('.header-bg').mouseover(function(e) {
  $(this).mousemove(function(e){
    while(this.style.left >= -40 && this.style.left <= 0) {
      if(e.posX > this.width()/2) {
        this.style.left= this.style.left + 0.5 + "%";
      } 
    }
  });
});
Compiler complains that width isn't a function. So...
Vivek Tripathi
@SopanTripathi
Jul 13 2016 07:04
wiki vedio
CamperBot
@camperbot
Jul 13 2016 07:04
no wiki entry for: vedio
Vivek Tripathi
@SopanTripathi
Jul 13 2016 07:04
wiki video
CamperBot
@camperbot
Jul 13 2016 07:04

:point_right: gitter embed video [wiki]

Embed YouTube Videos on Gitter

You can add inline video to the wiki with just a google link. Inside the chatwiki this will show up as an embedded video.

https://www.youtube.com/watch?v=BMUiFMZr7vk

:pencil: read more about gitter embed video on the FCC Wiki

Michael Karpinski
@karpimpski
Jul 13 2016 07:05
@BrianCodes33 I won't be awake much longer, and when I'm this tired I'm not sure how much help I can be. I'll do my best though
Vivek Tripathi
@SopanTripathi
Jul 13 2016 07:05
rollem
CamperBot
@camperbot
Jul 13 2016 07:05
Subramanya Chakravarthy
@chakrihacker
Jul 13 2016 07:05
help chunky
CamperBot
@camperbot
Jul 13 2016 07:05

:point_right: algorithm chunky monkey [wiki]

Algorithm Chunky Monkey

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Relevant Links

:pencil: read more about algorithm chunky monkey on the FCC Wiki

Brian
@BrianCodes33
Jul 13 2016 07:05
@karpimpski no problem i'll talk to you more hopefully
Michael Karpinski
@karpimpski
Jul 13 2016 07:10
@BrianCodes33 yeah I'll be more than happy to help whenever I can
Brian
@BrianCodes33
Jul 13 2016 07:18
i just want to get my clcik handler to get new quote rather than reload the page
Michael Karpinski
@karpimpski
Jul 13 2016 07:21
@BrianCodes33 for that I actually kinda cheated and made my own array to loop through my own list of quotes
maybe you could take a similar route and have an array containing the next few quotes?
also, idk if the format matters, but for my Twitch project I used this kind of format and it loaded without reloading the page:
function ajax(user) {
  $.ajax({
    url: 'https://api.twitch.tv/kraken/streams/' + user,
    jsonp: "callback",
    dataType: "jsonp",
    success: function(json) {
      var name = user;
      var offline = false;
      if (json.stream == null) {
        offline = true;
      }
      channel(user, offline, name)
    },
  });
}
Brian
@BrianCodes33
Jul 13 2016 07:23
hmm
why do i need all that logic
if i just want to get a new quote every time i press new button
i mean yea eveentually i'd like to handle users
Michael Karpinski
@karpimpski
Jul 13 2016 07:24
@BrianCodes33 I don't mean the logic, I mean that kind of foramt
Brian
@BrianCodes33
Jul 13 2016 07:24
oh ok
Michael Karpinski
@karpimpski
Jul 13 2016 07:24
let me just translate it to something like you did
Brian
@BrianCodes33
Jul 13 2016 07:25
$( ".glyphicon-chevron-right" ).click(function() {
  var url = "http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?";
  $.getJSON(url, function(data) {
    $(".main-quote").text(data.quoteText);
    $(".blockquote").text(data.quoteAuthor);
}();
Michael Karpinski
@karpimpski
Jul 13 2016 07:26
@BrianCodes33
function newQuote() {
  $.ajax({
    url: "http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?",
    jsonp: "callback",
    dataType: "jsonp",
    success: function(data) {
      $(".main-quote").text(data.quoteText);
      $(".blockquote").text(data.quoteAuthor);
    },
  });
}
that should work the same, and it may not reload the page
Magnus Holm
@mghlm
Jul 13 2016 07:26
Hi guys. I’m currently doing the card counting function, but I get an error when trying to use “under 0” statement like this:
if (count <= 0) {
  return count + " " + "Hold";
} else {
  return count + " " + "Bet";
}
if the number is 0 or -1, -2 or under, I want to return “Hold”. But I get an error
Michael Karpinski
@karpimpski
Jul 13 2016 07:26
@m4gnusholm I'm not sure about the problem, but count < 0 is not under 0
it's less than or equal to 0. maybe try just count < 0 ?
Konstantin
@kostanakis
Jul 13 2016 07:27
Guys, is there any way to retrieve smth like $('element').css(left) in percentage?
Magnus Holm
@mghlm
Jul 13 2016 07:27
@karpimpski It says “illegan return statement"
Michael Karpinski
@karpimpski
Jul 13 2016 07:27
@kostanakis do you mean the margin-left percentage? if that's what you mean, I don't think so
Magnus Holm
@mghlm
Jul 13 2016 07:27
illegal*
Michael Karpinski
@karpimpski
Jul 13 2016 07:28
@m4gnusholm try count.toString + " " + "Hold"
if (count <= 0) {
  return count.toString() + " " + "Hold";
} else {
  return count.toString() + " " + "Bet";
}
Magnus Holm
@mghlm
Jul 13 2016 07:29
@karpimpski oh, nah I’m not supposed to return the count as a string
@karpimpski I’m pretty sure that’s not what I’m supposed to do
Michael Karpinski
@karpimpski
Jul 13 2016 07:29
@m4gnusholm the only way you can return count in the same statement as a string is by converting it to a string
Markus Kiili
@Masd925
Jul 13 2016 07:30
@m4gnusholm count+" "+... makes a string.
Konstantin
@kostanakis
Jul 13 2016 07:30
@karpimpski nope. absolute position left.
Michael Karpinski
@karpimpski
Jul 13 2016 07:30
@kostanakis same answer, as far as I know you can't. but I'm really not great with jQuery so I can't tell you for sure
Magnus Holm
@mghlm
Jul 13 2016 07:30
@karpimpski ok, but it works fine if the number is not negative.. so I don’t understand
Michael Karpinski
@karpimpski
Jul 13 2016 07:31
@m4gnusholm maybe try absolute value?
what's the challenge?
Markus Kiili
@Masd925
Jul 13 2016 07:31
@m4gnusholm Your code seems ok. Post the whole function please.
Magnus Holm
@mghlm
Jul 13 2016 07:32
@karpimpski it’s the card counting challenge - I have to write a function that either increment or decrement the total count of cards depending on their value.
@Masd925 ok

var count = 0;

function cc(card) {

  if((card >=2) && (card <= 6)) {
    count = count+1;
  } else if ((card === 10) || (card === "J") || (card === "Q") || (card === "K") || (card === "A")) {
    count = count-1;
  }   
}

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

cc('2'); cc('3'); cc(7); cc('K'); cc('5');
Michael Karpinski
@karpimpski
Jul 13 2016 07:32
sorry I couldn't be more help, I'm gonna hop off for the night. good night everybody!
Magnus Holm
@mghlm
Jul 13 2016 07:32
@karpimpski no worries, thanks and good night
CamperBot
@camperbot
Jul 13 2016 07:32
m4gnusholm sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @karpimpski |http://www.freecodecamp.com/karpimpski
Markus Kiili
@Masd925
Jul 13 2016 07:33
@m4gnusholm Problem with braces. Returns are outside the function.
Magnus Holm
@mghlm
Jul 13 2016 07:34
@Masd925 but can I have two if statements inside one function?
I tried to have the return as “else if” but that didn’t work
Markus Kiili
@Masd925
Jul 13 2016 07:34
@m4gnusholm Yes you can, but at the moment returns are not inside the function.
Magnus Holm
@mghlm
Jul 13 2016 07:35
@Masd925 ah, now it works! apparently I can have two :)
@Masd925 Wow, I’ve been working on this function for 50 minutes now, it feels soooo good when it works, lol
@Masd925 thank you!
CamperBot
@camperbot
Jul 13 2016 07:35
m4gnusholm sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2093 | @masd925 |http://www.freecodecamp.com/masd925
McCall Alexander
@mccallofthewild
Jul 13 2016 07:37
@m4gnusholm Just copy & paste it into your browse console & it'll tell you what's wrong most of the time.
Magnus Holm
@mghlm
Jul 13 2016 07:37
@mccallofthewild sure, that’s a good idea actually.
@mccallofthewild thanks
CamperBot
@camperbot
Jul 13 2016 07:37
m4gnusholm sends brownie points to @mccallofthewild :sparkles: :thumbsup: :sparkles:
:cookie: 66 | @mccallofthewild |http://www.freecodecamp.com/mccallofthewild
McCall Alexander
@mccallofthewild
Jul 13 2016 07:40
@m4gnusholm You bet. 👊
Norvin Burrus
@ndburrus
Jul 13 2016 07:55
@m4gnusholm you may also enjoy this: :sparkles:
Magnus Holm
@mghlm
Jul 13 2016 07:56
@ndburrus nice, thank you
CamperBot
@camperbot
Jul 13 2016 07:56
m4gnusholm sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 967 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 13 2016 07:57
@m4gnusholm you're welcome! enjoy :palm_tree:
place your code there, run... easy...
AnshulDawar
@anshuldawar
Jul 13 2016 08:17

hey guys i can't find the bug in Counting Cards if(card == 2 || 3 || 4 || 5 || 6)
{
count++;
}
else if(card == 7 || 8 ||9)
{
count += 0;
}

else if( card == 'J' || 'Q' || 'K' || 'A' )
{
count--;
}

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

Krishna Sai Gullapalli
@Krish2704
Jul 13 2016 08:20
@anshuldawar you can't directly give card== 2||3||4 you should give all of them seperately like card==2||card==3||card==4
AnshulDawar
@anshuldawar
Jul 13 2016 08:24
thanks @Krish2704
CamperBot
@camperbot
Jul 13 2016 08:24
anshuldawar sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 663 | @krish2704 |http://www.freecodecamp.com/krish2704
Nikos Daskalakis
@nikoym
Jul 13 2016 08:27
Hi,
In the tesitng Objects for Properties chalenge I can't return the property's value.

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

function checkObj(checkProp) {
// Your Code Here
var result = "";
if(myObj.hasOwnProperty(checkProp)){
result = myObj.checkProp;
return result;
}
return "Not Found";
}

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

Where is my mistake?
Magnus Holm
@mghlm
Jul 13 2016 08:30
Why doesn’t this return “pony” ?
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {  
  if(myObj.hasOwnProperty("checkProp") === true) {
    return myObj.checkProp;
  } else {
    return "Not Found";
  }
}

checkObj("gift");
Nikos Daskalakis
@nikoym
Jul 13 2016 08:31
I don't know..
It seems corect
willfree108
@willfree108