These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Apr 2016
Marc Schöni
@marcschoeni
Apr 16 2016 00:00
thats what i not understand :worried:
Stephen James
@sjames1958gm
Apr 16 2016 00:00
processArg (7) That is calling processArg with an argument of 7
@Mooli88 What does your code look like now
Marc Schöni
@marcschoeni
Apr 16 2016 00:02
function processArg(num) {
  return (num + 3) / 5;
}
i change num to 7?
Mooli
@Mooli88
Apr 16 2016 00:02
@sjames1958gm i restart the challenge :|
hjernefrys
@hjernefrys
Apr 16 2016 00:04
I need some help with the mutations algorithm challenge. All tests passes except the first one, and I can't figure out why it returns true. The code I have so far:
function mutation(arr) {

  var firstString = arr[0];
  var firstLowercase = firstString.toLowerCase();


  var secondString = arr[1];
  var secondLowerCase = secondString.toLowerCase();

  for(var i = 0; i < firstLowercase.length; i++){
    var contains = firstLowercase.indexOf(secondLowerCase[i]);

    if(contains === -1){
      return false;
    }else{
      return true;
    }

  }

  return arr;
}

mutation(["hello", "hey"]);
Mooli
@Mooli88
Apr 16 2016 00:05
@sjames1958gm
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  var arr = [];
  // Only change code below this line
  var arg2 = Object.keys(source);
  var tempArr = [];


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

     for(var key = 0; key < arg2.length; key++){

   // console.log('key', key, '+ i', i);

       if(!collection[i].hasOwnProperty(arg2[key])

          && collection[i][arg2[key]] !== source[arg2[key]]

          && Object.keys(collection[i]).length <= arg2.length){

            console.log(false);

         }//if

     }//for

    if(arr){
      arr.push(collection[i]);
    }
  }//for
  // Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Diego Mayer
@Chrono79
Apr 16 2016 00:06
@hjernefrys you are returning at the first loop
the h is in both words
so, true is returned
Stephen James
@sjames1958gm
Apr 16 2016 00:10
@Mooli88 In order to check for a bad value you need || not && . Before your second for put var good = true; inside your if good = false after your inside for if(good) { arr.push(collection[i]); }
@Mooli88 What the inner loop should be doing is looking for any key in source that is not in collection[i] OR the value for that key in collection is not equal to source value for that key
hjernefrys
@hjernefrys
Apr 16 2016 00:12
@Chrono79 ok, I see, but what are some good ways of changing it? I tried this, but without much luck. Is my logic still way off?

function mutation(arr) {

  var firstString = arr[0];
  var firstLowercase = firstString.toLowerCase();
  var statement = false;

  var secondString = arr[1];
  var secondLowerCase = secondString.toLowerCase();

  for(var i = 0; i < firstLowercase.length; i++){
    var contains = firstLowercase.indexOf(secondLowerCase[i]);

    if(contains === -1){
      statement =  false;
    }else{
      statement = true;
    }

  }

  return statement;
}

mutation(["hello", "hey"]);
Marc Schöni
@marcschoeni
Apr 16 2016 00:13
how can i assign processArg to processed? You should assign processArg to processed on the challange Assignment with a Returned Value
Stephen James
@sjames1958gm
Apr 16 2016 00:13
@marcschoeni processed = processArg(7)
Mooli
@Mooli88
Apr 16 2016 00:13
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];

  // Only change code below this line
  var arg2 = Object.keys(source);
  var tempArr = [];


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

     var good = true;
     for(var key = 0; key < arg2.length; key++){


       if(!collection[i].hasOwnProperty(arg2[key])

          || collection[i][arg2[key]] !== source[arg2[key]]

          || Object.keys(collection[i]).length <= arg2.length){

           good = false;

         }//if

     }//for

    if(good){
      arr.push(collection[i]);
    }
  }//for
  // Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Diego Mayer
@Chrono79
Apr 16 2016 00:14

@hjernefrys

 }else{
      statement = true;
    }

remove this
return false if your if condition is true and outside the for return true
inside the for loop if one of the values isn't there there is no need to keep looking at the rest

Stephen James
@sjames1958gm
Apr 16 2016 00:16
@Mooli88 Object.keys(collection[i]).length <= arg2.length should this be less than or equal ?
Marc Schöni
@marcschoeni
Apr 16 2016 00:16
This message was deleted
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processedArg(7);

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
Stephen James
@sjames1958gm
Apr 16 2016 00:17
@marcschoeni You were not supposed to change any existing code add code at the end.
@Mooli88 Either remove the third check, or make it <
Marc Schöni
@marcschoeni
Apr 16 2016 00:20
@sjames1958gm then its fail with Expected an assignement or function call and instead saw an expression
Moisés Man
@moigithub
Apr 16 2016 00:20
check the example above... @marcschoeni
first it have a variable.. with initial value of 0
Ross
@AnInsaneScientist
Apr 16 2016 00:20
I'm stuck on 'Generate Random Fractions with JavaScript'. I'm guessing there's some kind of control flow logic to make sure the function never returns a '0'. I feel like this should be easy but none of my attempts have worked DX
Moisés Man
@moigithub
Apr 16 2016 00:21
so u need to create a variable with initial value of 0 too... on ur case.. it should be named.. processedArg @marcschoeni
basiclly u need to copy the code above... with names changed...
Stephen James
@sjames1958gm
Apr 16 2016 00:21
@AnInsaneScientist What code did you add? And did it follow the instructions?
hjernefrys
@hjernefrys
Apr 16 2016 00:23
@Chrono79 thanks, but I still don't get it. It's 2 in the night here so I might just have a look at it tomorrow. Here is the current code, but I don't think I understood you correctly.
function mutation(arr) {

  var firstString = arr[0];
  var firstLowercase = firstString.toLowerCase();
  var statement = true;

  var secondString = arr[1];
  var secondLowerCase = secondString.toLowerCase();

  for(var i = 0; i < firstLowercase.length; i++){
    var contains = firstLowercase.indexOf(secondLowerCase[i]);

    if(contains === -1){
      statement =  false;
    }

  }

  return statement;
}

mutation(["hello", "hey"]);
CamperBot
@camperbot
Apr 16 2016 00:23
hjernefrys sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 412 | @chrono79 | http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Apr 16 2016 00:23
@hjernefrys you should not keep looping after finding a mismatch
bkd705
@bkd705
Apr 16 2016 00:24
JavaScript arrays mainly objects confuse the piss out of me. What should I do to practice / learn more because fcc isn't really cutting it for me.
Ross
@AnInsaneScientist
Apr 16 2016 00:24
I just realized what I did wrong. Silly mistake. I thought you could use Math.random without '()' at the end.
Stephen James
@sjames1958gm
Apr 16 2016 00:25
@AnInsaneScientist :+1:
Diego Mayer
@Chrono79
Apr 16 2016 00:26
@hjernefrys
function mutation(arr) {

  var firstString = arr[0];
  var firstLowercase = firstString.toLowerCase();
  var statement = true;

  var secondString = arr[1];
  var secondLowerCase = secondString.toLowerCase();

  for(var i = 0; i < firstLowercase.length; i++){
    var contains = firstLowercase.indexOf(secondLowerCase[i]);

    if(contains === -1){ // this checks every individual letter on secondString is present on firstString, so if this is true, at least one is missing, no need to check the other
      statement =  false; // I would return false here
    }

  }

  return statement; // if all were present, statement is true here
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
Apr 16 2016 00:27
@hjernefrys The idea that @Chrono79 is saying is get out (return) at the first sign of trouble.
hjernefrys
@hjernefrys
Apr 16 2016 00:31
Am I just missing something, or is there something wrong with my code compared to the code of @Chrono79 ? It doesn't pass:

function mutation(arr) {

  var firstString = arr[0];
  var firstLowercase = firstString.toLowerCase();
  var statement = true;

  var secondString = arr[1];
  var secondLowerCase = secondString.toLowerCase();

  for(var i = 0; i < firstLowercase.length; i++){
    var contains = firstLowercase.indexOf(secondLowerCase[i]);

    if(contains === -1){
      statement = false;
    }


  }

  return statement;
}

mutation(["hello", "hey"]);
Diego Mayer
@Chrono79
Apr 16 2016 00:33
@hjernefrys
for(var i = 0; i < secondLowercase.length; i++){ 
    var contains = firstLowercase.indexOf(secondLowerCase[i]);
Stephen James
@sjames1958gm
Apr 16 2016 00:33
@hjernefrys Replace the statement = false with return false
hjernefrys
@hjernefrys
Apr 16 2016 00:36
thanks @Chrono79 and @sjames1958gm I changed it to: for(var i = 0; i < secondLowercase.length; i++) per the suggestion and it passed. My logic was a bit backwards
CamperBot
@camperbot
Apr 16 2016 00:36
hjernefrys sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: hjernefrys already gave chrono79 points
:star: 655 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Apr 16 2016 00:37
go to sleep now @hjernefrys a tired brain is not the best pilot when you're coding ;)
Stephen James
@sjames1958gm
Apr 16 2016 00:38
@Chrono79 :+1:
hjernefrys
@hjernefrys
Apr 16 2016 00:38
@Chrono79 haha, yes I think that might be a good idea :-P
Mauricio
@maudevelop
Apr 16 2016 00:42
function fearNotLetter(str) {
  var strlen = str.length;
      var minRange = str.charCodeAt(0);
  var maxRange = str.charCodeAt(strlen-1);
  var newStr=[];
  var result="";
    for (var i = minRange; i<=maxRange; i++){
      newStr.push(String.fromCharCode(i));
    }
    console.log(newStr.join());
  if (str == newStr.join() ){
    return undefined;
  }else{
    for (i=0; i<newStr.length; i++) {
      if (str.indexOf(newStr[i]) == -1){
        result += newStr[i];
      }
    }
    return result;
    }
}
fearNotLetter("bcd");
why is this not working? it's either being correct on the first 2 or on the last 2
but can't get it to work on both
Stephen James
@sjames1958gm
Apr 16 2016 00:43
@maudevelop Which challenge?
Diego Mayer
@Chrono79
Apr 16 2016 00:43
@maudevelop paste the case that doesn't pass
why return undefined?
Mauricio
@maudevelop
Apr 16 2016 00:45
The challenge tells you that, but woah, i just got it, it was only missing newStr.join('') instead of newStr.join()
@Chrono79

"Find the missing letter in the passed letter range and return it.

If all letters are present in the range, return undefined."

CamperBot
@camperbot
Apr 16 2016 00:45
find the missing letter in the passed letter range and return itif all letters are present in the range return undefined
nothing found
Mauricio
@maudevelop
Apr 16 2016 00:46
It's working now though, haha, im not sure if i made a mess on making the bonfire, is the code too messy/
?
Diego Mayer
@Chrono79
Apr 16 2016 00:46
@maudevelop you can solve it in only one for
Nate
@nateReiners
Apr 16 2016 00:49

Noob here... is it

(code here)

OR

(code here)
oh. I see.
Mauricio
@maudevelop
Apr 16 2016 00:50
@Chrono79 how would i do that?
Nate
@nateReiners
Apr 16 2016 00:50
In this code, I can't see the source array. What am I missing?
Array.prototype.map = function(projectionFunction) {
    var results = [];
    this.forEach(function(itemInArray) {

        // ------------ INSERT CODE HERE! ----------------------------
        // Apply the projectionFunction to each item in the array and add
        // each result to the results array.
        // Note: you can add items to an array with the push() method.
        // ------------ INSERT CODE HERE! ----------------------------

    });

    return results;
};
bkd705
@bkd705
Apr 16 2016 00:51
@nateReiners Ayeee it's you!!
Nate
@nateReiners
Apr 16 2016 00:51
yo man
Diego Mayer
@Chrono79
Apr 16 2016 00:51
@maudevelop do you want to discover how to do it yourself or do you prefer I send you my solution by PM?
Nate
@nateReiners
Apr 16 2016 00:51
are you the guy i was racing?
haha
@bkd705 -_-
Mauricio
@maudevelop
Apr 16 2016 00:52
@Chrono79, any hint on how to do it, just so i can think about it myself haha
bkd705
@bkd705
Apr 16 2016 00:52
Yes yes 😂 @nateReiners
Stephen James
@sjames1958gm
Apr 16 2016 00:52
@maudevelop
function fearNotLetter(str) {

  var expect = str.charCodeAt(0) + 1;
  for (var i = 1; i < str.length; i++) {
    if (str.charCodeAt(i) != expect) {
      return String.fromCharCode(expect);
    }
    expect++;
  }

  return undefined;
}
bkd705
@bkd705
Apr 16 2016 00:52
How far are you now? @nateReiners
Diego Mayer
@Chrono79
Apr 16 2016 00:52
@maudevelop ok, I'll try
inside the for advance the char you are checking in the string and compare it with should be expected
does it make sense to you?
Tim
@codemymind
Apr 16 2016 00:53
a bit confused on this challenge to convert celsius to F
Anyone mind, helping me out a bit please?
Stephen James
@sjames1958gm
Apr 16 2016 00:53
@maudevelop Start from the beginning of the string and stop when you find a missing char
Nate
@nateReiners
Apr 16 2016 00:53
@bkd705 Er. Not far. You're definitely ahead of me!! I've been working through some stuff on a different site in preparation for a code camp interview. Focusing on functional programming as much as I can since that's what will be tested in my technical interview.
I haven't done 1 challenge since I went to sleep and said my brain was mush @bkd705 lol #theshameisreal
bkd705
@bkd705
Apr 16 2016 00:54
Ahh true. I'm midway through the JavaScript challenges now like the palindrome and shtufffff @nateReiners
Nate
@nateReiners
Apr 16 2016 00:55
@bkd705 impressive!!! keep it up man
bkd705
@bkd705
Apr 16 2016 00:55
Aww true. Well at least I'm winning. ;). Is the code camp like a real life thing?
Stephen James
@sjames1958gm
Apr 16 2016 00:55
@codemymind The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
Tim
@codemymind
Apr 16 2016 00:56
@sjames1958gm I see that in the instructions, but not really sure how to write out the equation. Im a noob
Diego Mayer
@Chrono79
Apr 16 2016 00:56
@codemymind paste your code
Stephen James
@sjames1958gm
Apr 16 2016 00:56
@codemymind fahrenheit = Celsius times 9/5, plus 32.
Nate
@nateReiners
Apr 16 2016 00:56
@bkd705 yessir I have interviews scheduled for App Academy and Makersquare. App Academy usually does their interviews in Ruby, but I asked and they said Javascript would be just fine as long as I can write code that completes the challenges.
Mauricio
@maudevelop
Apr 16 2016 00:57
@sjames1958gm wouldn't that only return the first character not found in the string?
Nate
@nateReiners
Apr 16 2016 00:57
@bkd705 I'm the tortoise in this fable. ;)
Tim
@codemymind
Apr 16 2016 00:58

function convertToF(celsius) {
// Only change code below this line

fahrenheit = celsius * 9.5 + 32

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

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

not sure how to paste the screenshot - sorry
Stephen James
@sjames1958gm
Apr 16 2016 00:58
@maudevelop Which is what the instructions said - find "the" missing letter
Diego Mayer
@Chrono79
Apr 16 2016 00:58
@maudevelop depends on what you do then, but as @sjames1958gm said it says the letter, not the letters
Stephen James
@sjames1958gm
Apr 16 2016 00:58
@codemymind 9.5 is different that 9 / 5
bkd705
@bkd705
Apr 16 2016 00:58
@nateReiners ah well that's way more impressive than me winning this race. Congrats dude and good luck on the tests!!
Stephen James
@sjames1958gm
Apr 16 2016 00:59
This message was deleted
Tim
@codemymind
Apr 16 2016 00:59
@sjames1958gm haha it worked. well damn
@sjames1958gm Thank you
CamperBot
@camperbot
Apr 16 2016 00:59
codemymind sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 656 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 16 2016 00:59
:+1:
help format
CamperBot
@camperbot
Apr 16 2016 00:59

: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 the code.

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

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

Nate
@nateReiners
Apr 16 2016 01:00
@bkd705 Thanks man. Could be a gamechanger for me so I'm excited. I feel like I'll have a shot at getting in, but if I don't get in on my first try, I'll just put my head down and keep studying and try again.
CamperBot
@camperbot
Apr 16 2016 01:00
natereiners sends brownie points to @bkd705 :sparkles: :thumbsup: :sparkles:
:star: 259 | @bkd705 | http://www.freecodecamp.com/bkd705
Tim
@codemymind
Apr 16 2016 01:01

''' function convertToF(celsius) {
// Only change code below this line

fahrenheit = celsius * 9/5 + 32

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

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

CamperBot
@camperbot
Apr 16 2016 01:01
:bulb: to format code use backticks! ``` more info
Tim
@codemymind
Apr 16 2016 01:01
oops, sorry just a practice to figure this out :)

```function convertToF(celsius) {
// Only change code below this line

fahrenheit = celsius * 9/5 + 32

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

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

hmm, lol
Nate
@nateReiners
Apr 16 2016 01:03
make sure you put ``` at the end of your code too
I was using the snip tool for a while to paste pictures of my code in here lol
Tim
@codemymind
Apr 16 2016 01:03
oh, gotcha - ty - do i need to type js like js <code>
bkd705
@bkd705
Apr 16 2016 01:03
If you do the ticks and press enter it will automatically do it for you.
Tim
@codemymind
Apr 16 2016 01:03

```function convertToF(celsius) {
// Only change code below this line

fahrenheit = celsius * 9/5 + 32

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

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

Diego Mayer
@Chrono79
Apr 16 2016 01:04
@codemymind ``` should be the only thing in that line, use shift+enter to go to next line
Tim
@codemymind
Apr 16 2016 01:04
sorry im blowing up the feed -
Stephen James
@sjames1958gm
Apr 16 2016 01:04
@codemymind shift-return after the first three ticks
Nate
@nateReiners
Apr 16 2016 01:04
```for(i=0; i < Noob; i--) { }
hmm. that enter trick didn't seem to work
Diego Mayer
@Chrono79
Apr 16 2016 01:04
edit your posts
Stephen James
@sjames1958gm
Apr 16 2016 01:04
shift-return
Nate
@nateReiners
Apr 16 2016 01:04
@sjames1958gm thanks
CamperBot
@camperbot
Apr 16 2016 01:04
natereiners sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Mauricio
@maudevelop
Apr 16 2016 01:04
@Chrono79 and @sjames1958gm ohhhh right, haha I just made it that way and it's almost exactly like your code, thanks both!
CamperBot
@camperbot
Apr 16 2016 01:04
maudevelop sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 657 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 413 | @chrono79 | http://www.freecodecamp.com/chrono79
:star: 658 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Apr 16 2016 01:05
no problem
bkd705
@bkd705
Apr 16 2016 01:05
Do the ticks. Press enter. Then paste code.
Mauricio
@maudevelop
Apr 16 2016 01:06
Apparently I think very differently hahaa
bkd705
@bkd705
Apr 16 2016 01:06
It autocompletes
Mauricio
@maudevelop
Apr 16 2016 01:06
My solution was way more complex than it should have been
Tim
@codemymind
Apr 16 2016 01:06
ty for the advice guys, great group here. excited to learn and contribute when i can
Bob Evermore
@BeeQuickest
Apr 16 2016 01:06
Can anyone offer some suggestions to get me past this challenge? I've just about burned out on it...

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

// } else delete collection
} else collection[id][prop].push(value);
} else delete (collection[id][prop]);

return collection.id.prop.value;
}

Nate
@nateReiners
Apr 16 2016 01:07
Is it against the rules to post questions about non-FCC javascript challenges here?
Bob Evermore
@BeeQuickest
Apr 16 2016 01:07
Nate that's an interesting question that I don't know the answer to...
bkd705
@bkd705
Apr 16 2016 01:09
Is there really rules here? I think it's fine honestly. I've asked non fcc coding questions in the main chat.
We're all here to help each other so who really cares where it's from.
Nate
@nateReiners
Apr 16 2016 01:10
Right on. I think you're probably right. I just noticed the little "Activity" feed on the right and saw some people have been banned. I'd hate to show up on that feed! lol
Bob Evermore
@BeeQuickest
Apr 16 2016 01:11
Yeah, probably not where you want to end up.
Nate
@nateReiners
Apr 16 2016 01:11
I value this chatroom maybe more than any one individual resource on the web.
bkd705
@bkd705
Apr 16 2016 01:11
Lmfao probably mostly spammers. Bots and trolls.
Yeah I don't think I'd have made it through half the js challenges without these chats.
Bob Evermore
@BeeQuickest
Apr 16 2016 01:12
Speaking of making it through challenges, does anyone have suggestions about the code I posted 5 minutes ago?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:13
if ((prop) !== "tracks") {
collection[id][prop]=prop;
collection[id][prop][value]=value;
return collection[id][prop][value];

you should be looking to update just the value. consider collection[id][prop][value]=value as you telling the object that this is now a property inside collection that equals this value. which now means you can rule out collection[id][prop]=prop;

if ((prop) !== "tracks")

here you are using parenthesis around (prop) unnecessarily since nothing is happening inside those parenthesis

return collection[id][prop][value];

You only need this to be returned at the end of your function and not inside your if statements since you want it to cycle through them and then return whatever changes are proper inside your condition statements if/else

@BeeQuickest
bkd705
@bkd705
Apr 16 2016 01:14
Looks like he's got you covered aha.
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:15
// } else delete collection
} else collection[id][prop].push(value);
} else delete (collection[id][prop]);
look to add an if statement here that will add to the tracks array if the collection property contains and then run the delete as the final else statement @BeeQuickest
Bob Evermore
@BeeQuickest
Apr 16 2016 01:16
Thanks Jamie. I'm finding it hard to see the results of changes I make in the code because all I get are instant syntax warnings and a single statement about the last error encountered.
The last time I was learning to write code I was working on a terminal with a greenbar printer for output. And a much more BASIC language.
Matthew Fricker
@mattfricker
Apr 16 2016 01:17
This message was deleted
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:18
You want your function to declare the value for you. When you do var value = "" it's not needed because the function has an argument to take value in for you.
Your syntax errors are coming from your else format. Look into how if and else statements are formed, as well as nesting. @BeeQuickest that should help to fix those errors
if(something === true) {
   if(otherThing === false) {
  //do something inside nested if when if(something === true) && (otherThing === false) are both true
} else {
  // push up something 
   >>>> this runs if (otherThing === false) is not true
} else {
 //take out something
} >>>>  this runs if (something === true) is not true
notice how there's an if condition at the top that has two nested conditions inside of it if and else and then you have a final else statement for the parent condition if when something === true is not met @BeeQuickest
Tim
@codemymind
Apr 16 2016 01:23
how do you post the code like that? @Jlipschitz
Bob Evermore
@BeeQuickest
Apr 16 2016 01:24
I was wondering the same thing, Tim
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:24
help format
CamperBot
@camperbot
Apr 16 2016 01:24

: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 the code.

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

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

Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:24
@codemymind follow the format above using ticks to post code like that :D
Tim
@codemymind
Apr 16 2016 01:25
function convertToF(celsius) {
  // Only change code below this line

  var fahrenheit = (celsius * (9/5)) + 32;

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

// Change the inputs below to test your code
convertToF(30);
aha~!
@Jlipschitz thank you
CamperBot
@camperbot
Apr 16 2016 01:25
codemymind sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 117 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Tim
@codemymind
Apr 16 2016 01:28
man, this website / chat group is kinda invaluable - what a great setup
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:31
i've definitely had a lot help from others in this chat. it's great that people are willing to take out the time to help you out! @codemymind
Bob Evermore
@BeeQuickest
Apr 16 2016 01:32
Does the multi-line formatting work in Chrome browsers?
```
Nate
@nateReiners
Apr 16 2016 01:33
@bkd705 http://reactivex.io/learnrx/ thought I'd share this in case you're curious. This is the study material provided by Makersquare (and also Hack Reactor, though their interview slots are completely booked through JULY). The dude said if I make it through #16 I'd probably be good to go for the interview, in case you're wondering what it takes to get in. Apparently they value functional programming above all else.
Bob Evermore
@BeeQuickest
Apr 16 2016 01:33
js
function updateRecords(id, prop, value) {
  if ((value) !== "") {
    if (prop !== "tracks") {
        collection[id][prop]=prop;
        collection[id][prop][value]=value;


//    } else delete collection
    } else { collection[id][prop].push(value);
    } else delete (collection[id][prop]);
  }


    return collection[id][prop][value];
}
I guess so... lol
Marc Schöni
@marcschoeni
Apr 16 2016 01:34
why thats not go?
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
  return (num + 3) / 5;
}
function processedArg(num) {
  var  processed = processedArg(7);
}

// Only change code below this line
Diego Mayer
@Chrono79
Apr 16 2016 01:35

@marcschoeni don't define another function

function processedArg(num) {
  var  processed = processedArg(7);
}

replace that with this:

processed = processArg(7);
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:36

@BeeQuickest you want to return collection at the end of the function, not return collection[id][prop][value]; because you want the whole thing to come back after you've updated it, not just one property + value you passed in

collection[id][prop]=prop;

you're setting the property when you do collection[id][prop][value]=value so this can be taken out

} else { collection[id][prop].push(value);
    } else delete (collection[id][prop]);
  }

look at the nesting here. you have two else inside your parent if condition if ((value) !== "")

you're doing great man. you're really close!!!!!!! @BeeQuickest
Ozan Araz
@haraldur12
Apr 16 2016 01:42
I am such at basic js
can someone help me?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:43
plenty of people are willing to help. just ask away! @haraldur12
Marc Schöni
@marcschoeni
Apr 16 2016 01:44
Great thank @Chrono79
CamperBot
@camperbot
Apr 16 2016 01:44
marcschoeni sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 414 | @chrono79 | http://www.freecodecamp.com/chrono79
Ozan Araz
@haraldur12
Apr 16 2016 01:44
I am stuck at wordBlanks
can't I sum the variable inside result ?
" var1 + var2 "
WilliamDecker
@WilliamDecker
Apr 16 2016 01:45
I have a question in regards to accessing data in an array (related to the record collection)
Ozan Araz
@haraldur12
Apr 16 2016 01:45
for example?
Diego Mayer
@Chrono79
Apr 16 2016 01:45
@haraldur12 paste your code here
Ozan Araz
@haraldur12
Apr 16 2016 01:46

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

// Your code above this line
return result;
}

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

WilliamDecker
@WilliamDecker
Apr 16 2016 01:46
in earlier exercises it discussed using the dot operator and bracket notation
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:46
@haraldur12 attempt to do the exercise first and then we will be able to help out
Stephen James
@sjames1958gm
Apr 16 2016 01:46
@WilliamDecker For an array it is always []
WilliamDecker
@WilliamDecker
Apr 16 2016 01:46
is collection[id][prop] = value ; not the same as collection.id.prop = value;
?
Ozan Araz
@haraldur12
Apr 16 2016 01:47
I tried but I couldn't run it
Stephen James
@sjames1958gm
Apr 16 2016 01:47
@WilliamDecker If id and prop are variables, then no
Ozan Araz
@haraldur12
Apr 16 2016 01:47
I know how to solve it but can't apply it
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:47
that's fine . post the code that wouldn't run and we'll help guide you
Ken Haduch
@khaduch
Apr 16 2016 01:47
@haraldur12 - I don't know if you've posted all of your code, but you cannot concatenate the variables within quotation marks, as you have shown in a previous comment. (Not sure if your post was exactly as you were trying to do.) But in order to concatenate two variables, you cannot do this:"var1 + var2" but you must do this: var1 + var2 (note the lack of quotation marks in the second code example.)
WilliamDecker
@WilliamDecker
Apr 16 2016 01:48
so when accessing an array with a variable you always have to use bracket notation?
Stephen James
@sjames1958gm
Apr 16 2016 01:48
@WilliamDecker What you are showing is accessing an object (not an array) when accessing object properties with variables you must use brackets.
Ken Haduch
@khaduch
Apr 16 2016 01:49
@haraldur12 - and as they show in the examples on that exercise, if I recall correctly, you have to explicitly add spaces between words, using a syntax like this: var1 + ' ' + var2, etc.
Diego Mayer
@Chrono79
Apr 16 2016 01:49
@WilliamDecker [] is not only for arrays, you can use it to access object properties too
Ozan Araz
@haraldur12
Apr 16 2016 01:49
@khaduch Ken thanks for the tip!
CamperBot
@camperbot
Apr 16 2016 01:49
haraldur12 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 949 | @khaduch | http://www.freecodecamp.com/khaduch
Ozan Araz
@haraldur12
Apr 16 2016 01:49
I solved the problem
Bob Evermore
@BeeQuickest
Apr 16 2016 01:49
@JLipschitz The reason I put the <collection[id][prop]=prop; > is because I'm getting TypeError: Cannot set propety 'ABBA' of undefined. That error goes away when I set the value of prop but still not getting any green check marks...
Ozan Araz
@haraldur12
Apr 16 2016 01:49
it was because of the quotes
Ken Haduch
@khaduch
Apr 16 2016 01:49
@haraldur12 - great!
WilliamDecker
@WilliamDecker
Apr 16 2016 01:50
okay thanks @sjames1958gm
CamperBot
@camperbot
Apr 16 2016 01:50
williamdecker sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 659 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 16 2016 01:50
@BeeQuickest Post your code.
Bob Evermore
@BeeQuickest
Apr 16 2016 01:51
js
function updateRecords(id, prop, value) {
  if (value !== "") {
    if (prop !== "tracks") {
//        collection[id][prop]=prop;
        collection[id][prop][value]=value;



    } 
    else { 
// push value into array at end of existing data      
      collection[id][prop].push(value);

    } 
  } else {
//    } else delete collection property      
     delete (collection[id][prop]);
//  }
  }

//    return collection[id][prop][value];
  return collection;
}
Diego Mayer
@Chrono79
Apr 16 2016 01:53

@BeeQuickest

 collection[id][prop][value]=value;

should be

 collection[id][prop]=value;
Stephen James
@sjames1958gm
Apr 16 2016 01:53
@BeeQuickest collection[id][prop][value]=value; this is not correct.
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:53
collection[id][prop][value]=value; you want to change the property to = the value here which in turn changes the value inside that property
Bob Evermore
@BeeQuickest
Apr 16 2016 01:54
How do I send brownie points? You guys are the best!
Stephen James
@sjames1958gm
Apr 16 2016 01:54
@BeeQuickest Use their id with a thanks
CamperBot
@camperbot
Apr 16 2016 01:54
sjames1958gm sends brownie points to @beequickest :sparkles: :thumbsup: :sparkles:
:star: 227 | @beequickest | http://www.freecodecamp.com/beequickest
Bob Evermore
@BeeQuickest
Apr 16 2016 01:55
@sjames1958gm thanks!
CamperBot
@camperbot
Apr 16 2016 01:55
beequickest sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 660 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Bob Evermore
@BeeQuickest
Apr 16 2016 01:55
@jlipshitz Thanks!
CamperBot
@camperbot
Apr 16 2016 01:55
beequickest sends brownie points to @jlipshitz :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jlipshitz
Ozan Araz
@haraldur12
Apr 16 2016 01:55

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

result = myNoun + myAdjective + myVerb + myAdverb;
// Your code above this line
return result;
}

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

Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:57
@haraldur12 that's great! now look to do something about adding spaces in between your variables var1 + "space" + var2 so that's its not all joined together
Diego Mayer
@Chrono79
Apr 16 2016 01:57
@BeeQuickest you don't need to type the id, left click on their picture, mention copy and paste their id for you
Hal Trazo
@htdesign
Apr 16 2016 01:57
not sure if im at the right room or not. but which parallax plugin do you guys use?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:58
@BeeQuickest missing a c there in my name^_^
Diego Mayer
@Chrono79
Apr 16 2016 01:58
@haraldur12 don't forget to put words in between so the final sentence makes sense
help rooms
CamperBot
@camperbot
Apr 16 2016 01:58

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

See also: :earth_asia: Language Specific | :satellite: Technology | :crystal_ball: Miscellaneous

back to top

:pencil: read more about help rooms on the FCC Wiki

Diego Mayer
@Chrono79
Apr 16 2016 01:59
@htdesign isn't that a front end related question?
Bob Evermore
@BeeQuickest
Apr 16 2016 01:59
@Jlipschitz THANKS!!!
CamperBot
@camperbot
Apr 16 2016 01:59
beequickest sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 119 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Bob Evermore
@BeeQuickest
Apr 16 2016 01:59
@Chrono79 Thanks!!!
CamperBot
@camperbot
Apr 16 2016 01:59
beequickest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 415 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 16 2016 02:00
@BeeQuickest no problem, you can also mention more than one person at a time ;)
Ozan Araz
@haraldur12
Apr 16 2016 02:02
@Chrono79 which words?
Frank XC
@tenkdayz
Apr 16 2016 02:02

can someone explain this to me?

 var arr = [1,2,3];
  var temp = arr;
  delete arr[1];
  return temp; // temp: [1,,3];

why?

UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 02:03
@tenkdayz because index starts from 0
Ozan Araz
@haraldur12
Apr 16 2016 02:03
delete arr1gets the value of the second object
Frank XC
@tenkdayz
Apr 16 2016 02:03
@UtkarshShukla7 no look i delete it form arr .. not temp
so why is temp same as arr?
Ozan Araz
@haraldur12
Apr 16 2016 02:03
because you are assigning var temp to arr
Diego Mayer
@Chrono79
Apr 16 2016 02:04
@haraldur12
big dog ran quickly <- doesn't make sense to me (unless you are Tarzan ;)), you have to put some words in between to fix that
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 02:04
@tenkdayz becuase no new array is created only the reference is passed
Frank XC
@tenkdayz
Apr 16 2016 02:04
@haraldur12 isnt temp a copy of arr?
Ozan Araz
@haraldur12
Apr 16 2016 02:05
you are saying that the are equal so when you delete it from the arr the outcome of the var is 1 -2 since [1] the array starts with 0
Frank XC
@tenkdayz
Apr 16 2016 02:06
@haraldur12 I understand the index thing.. I just dont see why is temp affected if Im not doing anything to it.
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 02:06
I wouldn't say that it's because they are equal but rather you are referencing that array. any changes made to the original will reflect on the var you referenced it to
var temp = arr is just telling the compiler to point to arr when you use temp
Mauricio
@maudevelop
Apr 16 2016 02:07
So I just did the "Sorted Union" which is just uniting all values unique in many arrays, and I got it working with a little help with the Mozilla documentation, but have a question on how exactly this array reduce function is doing its work?
function uniteUnique(arr1, arr2, arr3) {
  //Flatten array
  var args = Array.from(arguments).reduce(function (a,b){
    return a.concat(b);
  });
the function (a,b) exactly, what is being passed on as A and what as B?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 02:08
@tenkdayz http://stackoverflow.com/questions/4220611/why-does-changing-one-array-alters-the-other check this link out for a better understanding
Frank XC
@tenkdayz
Apr 16 2016 02:09
@UtkarshShukla7 @haraldur12 @Jlipschitz thanks guys.
CamperBot
@camperbot
Apr 16 2016 02:09
tenkdayz sends brownie points to @utkarshshukla7 and @haraldur12 and @jlipschitz :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Apr 16 2016 02:09
@maudevelop a is the previous value and b is the current value of the array being processed. The initial "previous" value can be specified after the }
CamperBot
@camperbot
Apr 16 2016 02:09
:star: 120 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
:star: 312 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
:star: 176 | @haraldur12 | http://www.freecodecamp.com/haraldur12
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 02:09
@tenkdayz np
Mauricio
@maudevelop
Apr 16 2016 02:09
@sjames1958gm but what's the previous value?
Stephen James
@sjames1958gm
Apr 16 2016 02:10
@maudevelop I would write it this way to be explicit
var args = Array.from(arguments).reduce(function (prev, curr) {
  return prev.concat(curr);
}, []);
Mauricio
@maudevelop
Apr 16 2016 02:10
prev is just [0] and current is [1]?
and then so on and so on
Stephen James
@sjames1958gm
Apr 16 2016 02:11
The value returned from the inside function is the prev value on the next cycle, or the return value from reduce at the end of the loop
@maudevelop No
Mauricio
@maudevelop
Apr 16 2016 02:12
Hmm
Stephen James
@sjames1958gm
Apr 16 2016 02:12
This would sum the values in the array [1, 2, 3].reduce(function(prev, curr) { return prev + curr; }, 0); prev is 0, 1, 3 and curr 1, 2, 3 and 6 is returned
@sjames1958gm The previous value is sometimes called the accumulator as it is building up the final value.
Mauricio
@maudevelop
Apr 16 2016 02:15
okay so the current one is basically a counter running through all the array and the previous value is what the return function is doing to that value (the accumulator)
That's how im getting it right now, is that correct?
Stephen James
@sjames1958gm
Apr 16 2016 02:20
yes
If you have an array and you need a single value think reduce
Pat Lee
@pleedesigner
Apr 16 2016 02:24
This message was deleted
WilliamDecker
@WilliamDecker
Apr 16 2016 02:28
working on the Profile Lookup challenge
jesus it's hard for me to try to get through...I don't want to lookup the solution or try to google too much because I don't feel like I'm learning if I do that
but there is a greater than 0 chance my head may explode lol
Jarod Spiewak
@Memj
Apr 16 2016 02:32
part of Being a developer is knowing how to use Google.
@WilliamDecker I can help you with it if you'd like.
WilliamDecker
@WilliamDecker
Apr 16 2016 02:34
I have a hard time figuring out where my logic is failing with the feedback
Jarod Spiewak
@Memj
Apr 16 2016 02:35
Can you paste what you have?
WilliamDecker
@WilliamDecker
Apr 16 2016 02:35
yeah, I don't know if it's a mess, it's my brain failing, so it's still in progress :D
right now that's giving me the result of "No such property"
"Bob","number" passes with "No such contact"
and all the others fail
are the tests done top to bottom?
Stephen James
@sjames1958gm
Apr 16 2016 02:36
@WilliamDecker Can you explain what the inner for loop is for?
WilliamDecker
@WilliamDecker
Apr 16 2016 02:37
I think it's for going through the secondary arrays? the like's
I just realized there is the test item at the bottom for testing your function
Stephen James
@sjames1958gm
Apr 16 2016 02:38
@sjames1958gm "the given property (prop) is a property of that contact." There is nothing about going through any loops
Jarod Spiewak
@Memj
Apr 16 2016 02:39

That's the function call @WilliamDecker . You can use it to test but that's what actually allows your function to run.

Without a function call myFunction(); the function wont run.

WilliamDecker
@WilliamDecker
Apr 16 2016 02:40
I think I'm reading the question incorrectly, I think I can fix this
Stephen James
@sjames1958gm
Apr 16 2016 02:45
@WilliamDecker Reading these challenges sometime I can see why those where English is not their first language have so much trouble.
WilliamDecker
@WilliamDecker
Apr 16 2016 02:48
holy shit...I'm a native English speaker
:)
don't worry I didn't start with an ego, so you didn't bruise much :)
Stephen James
@sjames1958gm
Apr 16 2016 02:49
@WilliamDecker You already said you read it wrong
No insult was intended
WilliamDecker
@WilliamDecker
Apr 16 2016 02:49
none taken :)
Joe B
@jbreality
Apr 16 2016 02:52
I'm stuck on that profile look up too heh
I should've known it needed a for look considering I just went over it, was trying to do it only with if/else if commands
Stephen James
@sjames1958gm
Apr 16 2016 02:54
These two statements are confusing and lead to incorrect code:
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
If both are true, then return the "value" of that property.
Joe B
@jbreality
Apr 16 2016 02:55
yea, I think that was what was throwing me as well
Stephen James
@sjames1958gm
Apr 16 2016 02:56
The first inclination is to do if (firstname matches and property matches) return value else ...
Johnny K Juarez
@Reapnsow
Apr 16 2016 02:56
Hello, I'm currently stuck on the Local Scope and Functions lesson.
it's asking me to declare myVar inside of a function, then run the function
and afterwards to delete the second console.log
Son Dang
@viiiprock
Apr 16 2016 02:57
so do it
Frank XC
@tenkdayz
Apr 16 2016 02:57
just do it!
Joe B
@jbreality
Apr 16 2016 02:57
yep, I tried several different versions of that Stephen, and nothing was working, I'm going to clear my head and figure out a for statement
Johnny K Juarez
@Reapnsow
Apr 16 2016 02:57
Well After i do it, I get a red X next to "No global myVar variable", but when I add a global myVar
nothing changes
Stephen James
@sjames1958gm
Apr 16 2016 02:57
@jbreality You need a for statement to loop over the contacts, but not another one.
@Reapnsow You are supposed to run it and see there is an error in the little black window and then comment out the console.log outside the function run it again and it should pass
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:00
@sjames1958gm that doesn't work either.
Son Dang
@viiiprock
Apr 16 2016 03:00
put your code here
Stephen James
@sjames1958gm
Apr 16 2016 03:00
@jbreality What it really means is if (firstname matches) if (property exists) return value of property else no such property
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:00

function myLocalScope() {
'use strict';
var myVar = "hello";

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

Stephen James
@sjames1958gm
Apr 16 2016 03:01
@Reapnsow Did you remove or comment out the second console.log
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:01
@sjames1958gm both
Son Dang
@viiiprock
Apr 16 2016 03:02
what, you are just remove the console.log out side the function
just remove or comment it
and pass

function myLocalScope() {
'use strict';
var myVar = "hello";

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
//console.log(myVar);

// Now remove the console log line to pass the test

Johnny K Juarez
@Reapnsow
Apr 16 2016 03:03
@viiiprock I have done that, and it doesn't pass.......
Son Dang
@viiiprock
Apr 16 2016 03:04
function myFunction() {
'use strict';
var myVar;
console.log(myVar);
}
myFunction();
this is what I did lol
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:05
doing that gives me "console.log never called"
Diego Mayer
@Chrono79
Apr 16 2016 03:06
g'nite people
ALMY91
@ALMY91
Apr 16 2016 03:09
are values which can be manipulated called types?
Jarod Spiewak
@Memj
Apr 16 2016 03:09
They're called mutable
Types are String, Int, Boolean, Double, Float, etc.
Son Dang
@viiiprock
Apr 16 2016 03:11
@Reapnsow you could did right, but I don't know what bug is it, just reset & paste it again
function myLocalScope() {
'use strict';
var myVar = "hello";
console.log(myVar);
}
myLocalScope();
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:11
@sjames1958gm @viiiprock solved it, apparently, if you mess up you HAVE to refresh the page to reset the requirements to pass the test.
Dylan
@dhcodes
Apr 16 2016 03:11
night @Chrono79
ALMY91
@ALMY91
Apr 16 2016 03:11
Im reading the definitive guide @Memj
@Memj and it states that "The kinds of values that can be represented and manipulated in a programming language are known as types"
ALMY91
@ALMY91
Apr 16 2016 03:15
@Memj okay let me rephrase this , values in javascript are also known as types, of which they could be primitive or objects types. And they can be further divided into mutable and non mutable ones.
@Memj are we on the same page? cause the book is confusing me
Jarod Spiewak
@Memj
Apr 16 2016 03:21

yes, values are types.

var myArray = [0,1,2]; //Type: Array
var integer = 4; //Type: Int

These values can be manipulated in JS easily (code source MDN)

var foo = 42;    // foo is now a Number
var foo = "bar"; // foo is now a String
var foo = true;  // foo is now a Boolean
buonarfcc
@buonarfcc
Apr 16 2016 03:32

Please help with what I miss applying object & prop's name on these codes of mine: Thanks. ->//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName,lastName,number,likes, prop){
// Only change code below this line
for(var i=0; i < contacts.length; i++) {
var contact = contacts[i];
if (contact.firstName === firstName){return contact[prop];}
else if ( contact.firstName.prop === lastName) {return contacts[prop];}
else if ( contact.firstName.number === number){return contacts[prop];}
else if ( contact.firstName.likes === likes){return contacts[prop];}
else return "No such property";
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");

WilliamDecker
@WilliamDecker
Apr 16 2016 03:41
I did it
I powered through my stupid to get the results to the Profile Lookup
it's amazing how quickly I forgot the lessons of the immediate previous exercises
WilliamDecker
@WilliamDecker
Apr 16 2016 03:47
@buonarfcc contact I believe should be contacts
@buonarfcc also you need to use bracket notation for variables
Erin Heard
@ufi16
Apr 16 2016 03:49
i'm confused on the Return Early Patterns for Functions challenge. how do i set it up so that when a var is less than 0 the function will exit with undefined?
Jarod Spiewak
@Memj
Apr 16 2016 03:51
use return
Erin Heard
@ufi16
Apr 16 2016 03:51
i am and the test isn't running correctly
Jarod Spiewak
@Memj
Apr 16 2016 03:52
Paste your code pelase
please*
Erin Heard
@ufi16
Apr 16 2016 03:52

// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0, b < 0) {
return;
}

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);

Jarod Spiewak
@Memj
Apr 16 2016 03:52
you need to use or || not a comma
so a < 0, b < 0 should be a < 0 || b < 0
Erin Heard
@ufi16
Apr 16 2016 03:53
thank you @Memj
CamperBot
@camperbot
Apr 16 2016 03:53
ufi16 sends brownie points to @memj :sparkles: :thumbsup: :sparkles:
:star: 319 | @memj | http://www.freecodecamp.com/memj
Son Dang
@viiiprock
Apr 16 2016 03:55
for(var i=0; i < contacts.length; i++) {
var contact = contacts[i];
if (contact.firstName === firstName) {
sorry
V Arun Kumar
@arunvkumr
Apr 16 2016 03:57
wiki profile
CamperBot
@camperbot
Apr 16 2016 03:57

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

ewpratt
@ewpratt
Apr 16 2016 03:57
```having an issue with the queue problem.

```function nextInLine(arr, item) {
// Your code here
var removed;
testArr.push(item);
removed = testArr.shift(0);
return removed; // Change this line
}

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

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

``` but the results are: nextInLine([], 1) should return 1
nextInLine(pugjs/pug#2184, 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
V Arun Kumar
@arunvkumr
Apr 16 2016 03:58
@ewpratt remove 0 in shift
ewpratt
@ewpratt
Apr 16 2016 03:58
nope... same result
Son Dang
@viiiprock
Apr 16 2016 03:59
@buonarfcc I think it should be
for(var i=0; i < contacts.length; i++) {
var contact = contacts[i];
if (contact.firstName === firstName) {
if (contact[prop]) {
return contact[prop]
} else {
return "No such property";
}
}
return "No such contact";
V Arun Kumar
@arunvkumr
Apr 16 2016 03:59
@ewpratt use arr not testArr, testArr is global you have to use arr as the value.
ewpratt
@ewpratt
Apr 16 2016 03:59
the console log lines seem to be correct, but the checks aren't working out
ritzdacanay24
@ritzdacanay24
Apr 16 2016 04:00
Hello
ewpratt
@ewpratt
Apr 16 2016 04:01
thanks @arunkumrv
CamperBot
@camperbot
Apr 16 2016 04:01
ewpratt sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 461 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 16 2016 04:03

@buonarfcc

The function should check if firstName is an actual contact's firstName and the given proxperty (prop) is a property of that contact. The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

you're first if condition is correct, now you have to check if the property exists, for that you have to check with the contacts objects, not contacts[i].firstNameand to check if prop exists or not. you can use hasOwnProperty function.

buonarfcc
@buonarfcc
Apr 16 2016 04:05
Son Dang why not contacts instead of contact?
Erin Heard
@ufi16
Apr 16 2016 04:06
am i supposed to use a switch or if/else argument in the Counting Cards challenge?
Jarod Spiewak
@Memj
Apr 16 2016 04:06
if else is how I did it
V Arun Kumar
@arunvkumr
Apr 16 2016 04:08
@ufi16 you can solving it by any way you want, if it is not mentioned in the challenge.
Erin Heard
@ufi16
Apr 16 2016 04:12
i think i set up the switch right, but i don't think my return is right

var count = 0;

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

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

V Arun Kumar
@arunvkumr
Apr 16 2016 04:14
wiki count
CamperBot
@camperbot
Apr 16 2016 04:14

:point_right: challenge count backwards with a for loop [wiki]

Count Backwards With a For Loop

A for loop can also count backwards, so long as we can define the right conditions.

In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.

We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.

var ourArray = [];

for(var i = 10; i > 0; i -= 2) {

  ourArray.push(i);

}

ourArray will now contain [10,8,6,4,2]

:pencil: read more about challenge count backwards with a for loop on the FCC Wiki

Luis
@zdrifted
Apr 16 2016 04:14
I'm confused here. Any previous maps I should refer too that would help me understand this "Profile Lookup" challenge?
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
if ( contacts[firstName] === true && contacts[firstName[prop]] === true) {
  return contacts[firstName][prop];
} 
  if (contacts[firstName] === false) {
    return "No such contact";
  } 
  if (contacts[firstName][prop] === false) {
    return "No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
V Arun Kumar
@arunvkumr
Apr 16 2016 04:14
wiki count cards
CamperBot
@camperbot
Apr 16 2016 04:14
no wiki entry for: count cards
V Arun Kumar
@arunvkumr
Apr 16 2016 04:14
find cards
CamperBot
@camperbot
Apr 16 2016 04:14

find cards

:zero: checkpoint counting cards

V Arun Kumar
@arunvkumr
Apr 16 2016 04:14
wiki cards
CamperBot
@camperbot
Apr 16 2016 04:14

:point_right: checkpoint counting cards [wiki]

Checkpoint: Counting Cards

About Blackjack

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Value Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'

Instructions

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Example Output:

:pencil: read more about checkpoint counting cards on the FCC Wiki

Jarod Spiewak
@Memj
Apr 16 2016 04:15
@ufi16 switch statements need a default
buonarfcc
@buonarfcc
Apr 16 2016 04:15
txs for explanation @arunkumrv
CamperBot
@camperbot
Apr 16 2016 04:15
buonarfcc sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 462 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 16 2016 04:15
@Memj default is not mandatory.
Jarod Spiewak
@Memj
Apr 16 2016 04:17
no? Hm. Well, it's still good language practice to include it
Erin Heard
@ufi16
Apr 16 2016 04:17
thank you @camperbot
CamperBot
@camperbot
Apr 16 2016 04:17
ufi16 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1556 | @camperbot | http://www.freecodecamp.com/camperbot
Erin Heard
@ufi16
Apr 16 2016 04:18
thank you @arunkumrv
CamperBot
@camperbot
Apr 16 2016 04:18
ufi16 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 463 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Son Dang
@viiiprock
Apr 16 2016 04:21
@buonarfcc you declared var contact = contacts[i], so you could look up contact[prop] instead of contacts[i][prop]
V Arun Kumar
@arunvkumr
Apr 16 2016 04:21

@Rushh contacts is an array of objects.. to check with every entry you have to use a loop. This is what you need to do.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.If both are true, then return the "value" of that property.

Using the variable firstName check if the contacts exists or not and if he does return the property(for this you can check out hasOwnProperty function( or compare it with undefined).

If firstName does not correspond to any contacts then return "No such contact".

If contact doesn't exist return no such property.

If prop does not correspond to any valid properties then return "No such property".

After checking with all the entries if you didn't find the contact return no such property.

Ken Haduch
@khaduch
Apr 16 2016 04:23

@Rushh - hello there - I don't have more than a couple minutes, but you'll want to review (or recall) for loops, because the contacts structure is an array with objects, you need to have a loop to process through it to find matching names. You'll also want to review the Object.hasOwnProperty() method, which they link to in the exercise. Also how to access object properties using variables. Oh, and the Array.push() method.

Good luck!

Luis
@zdrifted
Apr 16 2016 04:25
thanks @khaduch @arunkumrv . I'll reread those
CamperBot
@camperbot
Apr 16 2016 04:25
rushh sends brownie points to @khaduch and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 950 | @khaduch | http://www.freecodecamp.com/khaduch
:star: 464 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 16 2016 04:25

@ufi16

Instructions
You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Inside each case you have to use the global count variable(either increment or decrement) using the table given and after that print count with either Bet or Hold using the condition given in the challenge.

ALMY91
@ALMY91
Apr 16 2016 04:29
values in javascript are also known as types, of which they could be primitive or objects types. And they can be further divided into mutable and non mutable ones.
am i correct?
V Arun Kumar
@arunvkumr
Apr 16 2016 04:30
@ALMY91 ya, i think that's right.
Luis
@zdrifted
Apr 16 2016 04:37
@arunkumrv Am I on the right track here?

function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if( contacts[i].hasOwnProperty(firstName) && contacts[i].hasOwnProperty(prop) ) {
    return contacts[i].hasOwnProperty(prop);
```
V Arun Kumar
@arunvkumr
Apr 16 2016 04:42
@Rushh Close..
hasOwnProperty function returns boolean values (i.e either true or false). So you have to return the property not true or false.. and the first if condition you have to compare with the firstName value of object to the firstname of the function. not the property firstName exists or not.
Luis
@zdrifted
Apr 16 2016 04:53
Would a for in loop help there?
ALMY91
@ALMY91
Apr 16 2016 04:55
has anyone tried jsjiddle.net?
jsfiddle.net
Luis
@zdrifted
Apr 16 2016 04:56
I use it sometimes
V Arun Kumar
@arunvkumr
Apr 16 2016 04:57
@Rushh your for is fine.. first if condition you need to compare it with the firstname of the function argument. like contacts[i].firstName === firstName, the problem with your if condition contacts[i].hasOwnProperty(firstName) is that it only checks if the firstName property exists in the contacts array. So for any value of firstName it will always return true.
then once the conditions are done.. return property of the contact.
ALMY91
@ALMY91
Apr 16 2016 04:58
im just wondering why isn the code working after i clicked run, this is my first time using it
@Rushh
blob
Luis
@zdrifted
Apr 16 2016 04:58
if( contacts[i][firstName] == firstName && contacts[i][prop] == prop ) {
    return contacts[i][prop];
V Arun Kumar
@arunvkumr
Apr 16 2016 05:00
@ALMY91 i think this value you will see in dev console. press F12.
@Rushh ya that's right.. but the second if condition your contact[i][prop] is value of the property and you are comparing with the property name.
@Rushh you can compare it with undefined to check if the value exists like contacts[i][prop] != undefined or using the hasOwnProperty function like you did in your previous code :point_up_2:
Nari Roh
@NariRoh
Apr 16 2016 05:04
help Using Objects for Lookups
CamperBot
@camperbot
Apr 16 2016 05:04

:point_right: challenge using objects for lookups [wiki]

Challenge: Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

:pencil: read more about challenge using objects for lookups on the FCC Wiki

V Arun Kumar
@arunvkumr
Apr 16 2016 05:05
@ALMY91 you are working only in js then try this site, https://repl.it/languages/javascript . it supports other languages as well
ALMY91
@ALMY91
Apr 16 2016 05:06
@arunkumrv whats a dev console? and other than a dev console what else are there?
Luis
@zdrifted
Apr 16 2016 05:07
Ok so I have this so far
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if( contacts[i][firstName] === firstName && contacts[i][prop] !== undefined ) {
    return contacts[i][prop];
  } 
  if( contacts[i].hasOwnProperty(firstName) === false) {
    return "No such contact";
  }
  if( contacts[i].hasOwnProperty(prop) === false ) {
    return "No such property";
  }
 }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
ALMY91
@ALMY91
Apr 16 2016 05:09
blob
Is anybody able to help me out in here?
Luis
@zdrifted
Apr 16 2016 05:10
Alright I'm going to take a break and stretch a bit. I'm brain locking right now
ALMY91
@ALMY91
Apr 16 2016 05:10
I tried running my file using chrome but it just prints out all the code i hv written
Luis
@zdrifted
Apr 16 2016 05:10
Thanks again though for the help Arun
V Arun Kumar
@arunvkumr
Apr 16 2016 05:11
@Rushh instead of using 3 if, you can try else-if clause it's efficient and remove the no such contact clause because you wouldn't need it now. and if you read the instruction for no such property it's says if the property doesn't exist then return no such property... so it will be almost same as the first if's condition, the only diff would be you will check it with undefined this time.
like contacts[i][prop] == undefined
henrywashere
@henrywashere
Apr 16 2016 05:13

anyone know what im suppose to do here:

Instructions
Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
Call the function.

functionWithArgs(1,2) should output 3
functionWithArgs(7,9) should output 16

ALMY91
@ALMY91
Apr 16 2016 05:13
blob
this is what happens when i try running it in internet explorer
it just prints out everything that i have written
kirbyedy
@kirbyedy
Apr 16 2016 05:14
@henrywashere you should create a function that is suppose to sum two numbers in the brackest
Rada
@Radascript
Apr 16 2016 05:14
do you guys know if there is a handy method to say "for each element in this array except this one"?
Like, if I'm iterating over an array or arrays, and when focusing on element #2, I want to compare things in it to those in element #0, #1, #3 and #4, but not itself
henrywashere
@henrywashere
Apr 16 2016 05:15
ok ill try it
V Arun Kumar
@arunvkumr
Apr 16 2016 05:15
@ALMY91 did you save the file correctly? you are runnin xampp so i think you have a local server right? and save the file in .html format looks like you saved it in chapter3.1.5
ALMY91
@ALMY91
Apr 16 2016 05:16
@arunkumrv i saved it in html format , that was my subject for the file
kirbyedy
@kirbyedy
Apr 16 2016 05:16
@henrywashere and you have to output the result to the console... with console.log
V Arun Kumar
@arunvkumr
Apr 16 2016 05:17
@ALMY91 is your xampp server running?
Frank XC
@tenkdayz
Apr 16 2016 05:17
@Radascript use something like if indoxof arr i !== j ?
henrywashere
@henrywashere
Apr 16 2016 05:18

this is what i wrote so far

function functionWithArgs(value1, value2) {
console.log(value1, value2);
}

ALMY91
@ALMY91
Apr 16 2016 05:18
@arunkumrv i forgot abt tt haha, just turned it on but it still ain working... when i open it in internet explorer it prints out everything tt i have written, wheras in chrome nth is printed out
V Arun Kumar
@arunvkumr
Apr 16 2016 05:18
@ALMY91 open dev console.. press F12 in chrome it will open the console there you will see the output..
kirbyedy
@kirbyedy
Apr 16 2016 05:19
@henrywashere what does the console.log output?
Rada
@Radascript
Apr 16 2016 05:19
@tenkdayz yeah I've been manually skipping it within a loop, was wondering if there is some better syntax along the lines of "eachElementExcepe" or whatever. ty though
Frank XC
@tenkdayz
Apr 16 2016 05:20
@Radascript are you working on symmetric difference?
ALMY91
@ALMY91
Apr 16 2016 05:20
blob
nth is appearing @arunkumrv
Rada
@Radascript
Apr 16 2016 05:20
@tenkdayz haha yes
Joe B
@jbreality
Apr 16 2016 05:20
So I was at like 95% of the code figured out for the profile lookup, but I looked up what i was misisng
Frank XC
@tenkdayz
Apr 16 2016 05:21
@Radascript I was just working on that also.. embrace the pain.
V Arun Kumar
@arunvkumr
Apr 16 2016 05:21
@ALMY91 type console.log("hello from dev console"); inside your script tag.
Joe B
@jbreality
Apr 16 2016 05:21
and I don't get why if (contacts[x][prop]) works and it's not if (prop == contact[x][prop])
V Arun Kumar
@arunvkumr
Apr 16 2016 05:21
@ALMY91 do you see anything now?
Rada
@Radascript
Apr 16 2016 05:22
@tenkdayz I skipped it yesterday because I wasn't sure how to start and solved Exact Change, took me so long. Now back to that one
Joe B
@jbreality
Apr 16 2016 05:22
contacts[x][prop] does not work
sorry
ALMY91
@ALMY91
Apr 16 2016 05:24
@arunkumrv wait where again?
Frank XC
@tenkdayz
Apr 16 2016 05:24
@Radascript I'll give it another shot in a bit..
ALMY91
@ALMY91
Apr 16 2016 05:24
blob
@arunkumrv do u mean here? or the console tab?
V Arun Kumar
@arunvkumr
Apr 16 2016 05:25
@ALMY91 inside your html file, inside<scritp> </script> tag
Rada
@Radascript
Apr 16 2016 05:25
@tenkdayz I also have skipped 4 internediate challenges - Missing Letters, Spinal Tap Case, Smallest Common Multiple and Steamroller. I'll be coming back to those in a bit
Frank XC
@tenkdayz
Apr 16 2016 05:25
@Radascript I just solved the last one I forgot the name.. that one is easier I think.
Rada
@Radascript
Apr 16 2016 05:26
@tenkdayz the phone numbers one?
Frank XC
@tenkdayz
Apr 16 2016 05:26
@Radascript pairwise. thats it
ALMY91
@ALMY91
Apr 16 2016 05:27
@arunkumrv nope nth
Frank XC
@tenkdayz
Apr 16 2016 05:27
missing letter was fun one.. I just like the feeling when you solve something on your own
Rada
@Radascript
Apr 16 2016 05:27
@tenkdayz ohh last one in that section, cool. I haven't looked at it yet
ALMY91
@ALMY91
Apr 16 2016 05:27
@arunkumrv ohyeah i do get smth if i press f12 tho
Rada
@Radascript
Apr 16 2016 05:28
@tenkdayz yes, especially when you've been banging your head against the wall for a few hours and then you get that green checkmark
ALMY91
@ALMY91
Apr 16 2016 05:28
blob
@arunkumrv
@arunkumrv is this what ur looking at?
Frank XC
@tenkdayz
Apr 16 2016 05:28
@Radascript and when you get the green checkmark and wonder why ha
V Arun Kumar
@arunvkumr
Apr 16 2016 05:29
@ALMY91 yea.. everything is working fine.. now you need to type valid code to get the output. :smile:
Frank XC
@tenkdayz
Apr 16 2016 05:29
@Radascript if youre doing the advance ones you'll find the intermediate easier you just have to look at the from a different point of view.
ALMY91
@ALMY91
Apr 16 2016 05:30
@arunkumrv actually why does it only work in f12 ? im not too sure why it does work when i save the file under js, but it only works if i save it in html format..
@arunkumrv and what does development console means?
Rada
@Radascript
Apr 16 2016 05:30
@tenkdayz yeah what happened with those four is I decided to start over but I was so fed up with that I just decided that I'm better off returning in a little bit
henrywashere
@henrywashere
Apr 16 2016 05:31

@kirbyedy didnt go through :(

function functionWithArgs(value1, value2) {
console.log(value1, value2);
}
functionWithArgs(1, 2);

ALMY91
@ALMY91
Apr 16 2016 05:31
@arunkumrv i mean it does not work when i save the file under js
Joe B
@jbreality
Apr 16 2016 05:32
would someone mind if I PM'ed thing, I have a question about a specific piece of the Profile Lookup challenge
*them
V Arun Kumar
@arunvkumr
Apr 16 2016 05:33
@ALMY91 F12 opens the developer console, this is like the magic wand for web developers :wink: . It shows the errors and it helps you to change the code of other sites to see how it works.. FCC has a challenge for dev console. you can check it out if you want to learn.
kirbyedy
@kirbyedy
Apr 16 2016 05:34
@henrywashere in the console log line in the brackets sum the values
ALMY91
@ALMY91
Apr 16 2016 05:35
@arunkumrv but why doesn it work the normally like how a html file does? for example im not getting the output im looking at just by saving the file under .js and running it directly.
kirbyedy
@kirbyedy
Apr 16 2016 05:35
now, you are just logging them
@henrywashere if you put an operator it should output the sum of those two values
V Arun Kumar
@arunvkumr
Apr 16 2016 05:35
@ALMY91 i think that's because everything in works under html, so js should be included in html to make it work either internally or externally.
Frank XC
@tenkdayz
Apr 16 2016 05:35
@Radascript symmetric diff. suggest using reduce are you using that?
ALMY91
@ALMY91
Apr 16 2016 05:36
@arunkumrv okay i see, but for css files if u include them internally, u cld just run it straight . u don hv to go into f12 to see the end results , if u get where i am coming from
@arunkumrv although it needs html to work as well
henrywashere
@henrywashere
Apr 16 2016 05:37
awesome i got it
thanks @kirbyedy
CamperBot
@camperbot
Apr 16 2016 05:37
henrywashere sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 872 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
ALMY91
@ALMY91
Apr 16 2016 05:39
@arunkumrv and not forgotting externally, u cld run it straight in the browser too so long u have included the link to the css file in the html file
@arunkumrv so im a tad confused w how javascript works. why is it so that we have to enter f12 to view the results?
V Arun Kumar
@arunvkumr
Apr 16 2016 05:42
@ALMY91 if you open either of the js or css file you will see the entire code of the file.. when they are included in html they all work under it.
js needs a console because it's a scripting language and when you F12 what you get is the Javascript console only works for JS. you need console to rectify errors and to find bugs.
ALMY91
@ALMY91
Apr 16 2016 05:42
Does anybody know the answer to this? Im stuck on page 35 of a 1000 page book haha and i cant move forward without having an answer to this...
Coy Sanders
@coymeetsworld
Apr 16 2016 05:43
yeah f12 is just the key to open up some tools for a browser like the console
ALMY91
@ALMY91
Apr 16 2016 05:45
@arunkumrv @coymeetsworld okay correct me if im wrong, so ur saying if i open a css file or js file directly in the browser, the entire code of css/js would appear in it. ONLY when a css file and js file is included in a html file will they then work. HOWEVER for js file we will need a console that is under F12 , and this console will ONLY work for javascript , we won b able to view css or html codes in it
Coy Sanders
@coymeetsworld
Apr 16 2016 05:46
f12 has a console, but it has other things too
ALMY91
@ALMY91
Apr 16 2016 05:46
@arunkumrv @coymeetsworld in layman terms what does a console mean?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:46
console is basically a text screen showing output of your code
its a good tool to use for debugging
for example if you put in your javascript code console.log("hello world");, it would print out hello world
V Arun Kumar
@arunvkumr
Apr 16 2016 05:47
@ALMY91 right click in chrome and go to inspect element you will get lots more toys to work on. :smile:
Coy Sanders
@coymeetsworld
Apr 16 2016 05:48
but a more practical use would be to display variables as you run your code, so you can see how your code runs
ALMY91
@ALMY91
Apr 16 2016 05:49
@arunkumrv @coymeetsworld okay hold on haha info overload..... let me try getting this work first... i tried console.log("hello world"); between my js tags and it works fine in the console
@arunkumrv @coymeetsworld now im trying to get this work but nth is appearing
Coy Sanders
@coymeetsworld
Apr 16 2016 05:49
get what to work @ALMY91 ?
ALMY91
@ALMY91
Apr 16 2016 05:50
blob
@coymeetsworld this..
Vivienne Sales
@Natto278
Apr 16 2016 05:51
Hi. I'm at the Counting Card challenge. I've re-written my code and now nothing works. I'm getting a SyntaxError: Unexpected identifier. What am I doing wrong?

var count = 0;

function cc(card) {
// Only change code below this line
var count =0;
if card >= 2 && <= 6 count ++;
return "5 Bet";

else if card  >= 7 && <= 9 count 0;

return "0 Hold";

else if card = 10 count --;

}

// Only change code above this line
}

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

ALMY91
@ALMY91
Apr 16 2016 05:51
@coymeetsworld did i do anything wrong
@arunkumrv hey thanks bud
CamperBot
@camperbot
Apr 16 2016 05:51
almy91 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 465 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Coy Sanders
@coymeetsworld
Apr 16 2016 05:51
what are you trying to accomplish @ALMY91 ? do you want that to be in the console?
@Natto278 you want to use a case/switch statement
because card may not be a number, you can't compare it with >= or <=
ALMY91
@ALMY91
Apr 16 2016 05:52
@coymeetsworld i would like my code to be running, and if its running the results shd have appeared in the console right?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:53
no @ALMY91, if you want it to show in the console, you have to put the value you want to display as an argument for console.log()
Rada
@Radascript
Apr 16 2016 05:53
@tenkdayz I wasn't, and I just thought I was done but it turns out if it's in all three arrays it counts again?! what the crappppppp
Coy Sanders
@coymeetsworld
Apr 16 2016 05:53
so if you wanted to print out elapsed, you would write console.log(elapsed);
ALMY91
@ALMY91
Apr 16 2016 05:53
@coymeetsworld but how will i know if my js code is working properly?
Paul Borawski
@iAmNawa
Apr 16 2016 05:53
@coymeetsworld wouldn’t that be an error?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:54
or if you want to be more descriptive, write something like console.log("Time elapsed: " + elapsed);
what would be an error @iAmNawa ?
Paul Borawski
@iAmNawa
Apr 16 2016 05:54
i mean if elapsed was undefined, sorry I didn’t read anythign before
Vivienne Sales
@Natto278
Apr 16 2016 05:54
@coymeetsworld Card may or may not be a number?!?! I used case and switch statements earlier and got the 1st three conditions right. But then I was told I need to use the global count variable.
ALMY91
@ALMY91
Apr 16 2016 05:54
@ALMY91 im actually calling out a date () constructor, so i wld like to know if the method is working out , and the only way to know if my js is working properly is if it prints out the results right on the console, no?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:54
no @iAmNawa, @ALMY91 is wondering why nothing is showing up on the console, but he has no console.log commands in it thats why
yeah @Natto278 you need to use the count variable
in the case switch statment
ALMY91
@ALMY91
Apr 16 2016 05:55
@coymeetsworld its actually grabbing data form my Date() constructor
Coy Sanders
@coymeetsworld
Apr 16 2016 05:55
add by 1 if card is 2,3,4,5,6
ALMY91
@ALMY91
Apr 16 2016 05:55
@coymeetsworld from*
Coy Sanders
@coymeetsworld
Apr 16 2016 05:55
do nothing if its 7,8,9
subtract one from count if its 10, 'J', 'Q', 'K', 'A'
thats all you should do in the case/switch statement
then after, look at the count value and depending on what it is, print either hold or bet with the count number included
Paul Borawski
@iAmNawa
Apr 16 2016 05:56
@coymeetsworld Sorry, I only saw what you had wrote after, I didn’t know there was actual code, my bad
Coy Sanders
@coymeetsworld
Apr 16 2016 05:56
right @ALMY91 but you're not printing anything to the console, you still need to do that part
np @iAmNawa lol
ALMY91
@ALMY91
Apr 16 2016 05:57
@coymeetsworld okay cos i actually went through all the javascript challenges and while i was doing it i didn have to include the console.log in it..
Frank XC
@tenkdayz
Apr 16 2016 05:57
@Radascript hah yea thats the hard part.
Coy Sanders
@coymeetsworld
Apr 16 2016 05:57
where are these challenges from @ALMY91 ? is this from free code camp?
ALMY91
@ALMY91
Apr 16 2016 05:57
@coymeetsworld so i was confused why do i have to add a console.log now when all i have to do is to call the function in the challenges
@coymeetsworld yes
@coymeetsworld it was from free code camp
Coy Sanders
@coymeetsworld
Apr 16 2016 05:58
well ok you dont need console.log in the challenges
but you should be writing it inside the screen it gives you on the specific challenge
then when you click run tests it will verify the values for you in the background and see if your code is right or not
got confused because you're using notepad++ for this
which is fine, just after you want to put that code in the challenge window and execute
ALMY91
@ALMY91
Apr 16 2016 05:59
@coymeetsworld so do u mean for the FCC challenges they have already included console.log as default? thats why i didn hv to write them for the challenges i did?
Coy Sanders
@coymeetsworld
Apr 16 2016 06:00
no they don't use console.log, that's just what you can use as a debugging tool
to see how your code is running
they probably do something else to verify your code works, i don't know what exactly but it doesn't really matter
what challenge are you on exactly @ALMY91?
ALMY91
@ALMY91
Apr 16 2016 06:00
@coymeetsworld ahhh i see okay...
@coymeetsworld im done with all the javascript challenges, moving on to the definitive guidebook.. im on page 35 haha and i have 1000pages more to go
@coymeetsworld thanks bud
CamperBot
@camperbot
Apr 16 2016 06:01
almy91 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 569 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 06:01
wait, so this isn't in free code camp? lol
thought you said it was
ALMY91
@ALMY91
Apr 16 2016 06:02
@coymeetsworld ive alr completed all the challenges in FCC, now im just trying to get some codes from the definitive guidebook to work in a normal setting like notepad++
@coymeetsworld but it isn working like how it used to when i was doing the FCC challenges thats why i got confused
Coy Sanders
@coymeetsworld
Apr 16 2016 06:03
ok maybe i misunderstood then
yeah FCC does validation for you, if you want to see your code work you need to utilize something like console.log
thats probably the best option
ALMY91
@ALMY91
Apr 16 2016 06:03
@coymeetsworld okay cool. i'd try working w that. thanks again bud
CamperBot
@camperbot
Apr 16 2016 06:03
almy91 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: almy91 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Apr 16 2016 06:04
sure np
Prateek Vasisht
@vaspv
Apr 16 2016 06:10
Hi - I have a loop problem. Doing Twitch TV and have an array but when I want to get array name in url, it comes undefined. Any ideas where I'm going wrong? CodePen is http://codepen.io/vaspv/pen/VaXLyG
Vivienne Sales
@Natto278
Apr 16 2016 06:15

@coymeetsworld I've got the 1st three items correct on the Counting Card challenge, but now I 'm having trouble with the 4th item. It keeps returning a "-1 Hold". What am I doing wrong? ar count = 0;

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

case 7:
case 8:
case 9:
  return "0 Hold";


case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count--;
  return "-5 Hold";
  break;

case 3:
count++;
case 7:
case 'Q':
  count--;
case 8:
case 'A':
  count--;
  return "-1 Hold";
  break;
ALMY91
@ALMY91
Apr 16 2016 06:19
blob
does anybody know why my lines ain breaking up into 3?
Frank XC
@tenkdayz
Apr 16 2016 06:21
@vaspv you have to use /channels not /streams to get the info on the offline people
Prateek Vasisht
@vaspv
Apr 16 2016 06:21
@Natto278 I think you need to put an if statement check for count because - When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.
This message was deleted
Vivienne Sales
@Natto278
Apr 16 2016 06:24
Thanks for helping get the 1st three items of Counting Cards correct @coymeetsworld
CamperBot
@camperbot
Apr 16 2016 06:24
natto278 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 570 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:24
@ALMY91 try console.log("one\nmore\nline");
Prateek Vasisht
@vaspv
Apr 16 2016 06:25
@tenkdayz ah ok will try that. but also do you know why when I try to get userlist[i] further dow n in the if function, then it comes undefined?
Rada
@Radascript
Apr 16 2016 06:25
@tenkdayz solved it!!!!
ALMY91
@ALMY91
Apr 16 2016 06:26
@UtkarshShukla7 hey it works but im just wondering , the book states that in ECMAScript 5 we can break a string literal across multiple lines by ending each line but the last w a backslash
@UtkarshShukla7 im not sure why it isn working in my case
Frank XC
@tenkdayz
Apr 16 2016 06:26
@vaspv Ill take a look.
@Radascript :+1:
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:26
@Natto278 try to return count+"xyz";
Nely
@nextasy2010
Apr 16 2016 06:27
hey guys
Im stuck on the stand in line challenge
my code is returning the correct answer but seems not to be recognised
Prateek Vasisht
@vaspv
Apr 16 2016 06:27
@tenkdayz thanks - and yes I will change the url and that gives me the name of the streamer so that will solve the problem but still keen to know why my loop cannot pick the the iterated data
CamperBot
@camperbot
Apr 16 2016 06:27
vaspv sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 399 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Coy Sanders
@coymeetsworld
Apr 16 2016 06:28
yw @Natto278
Nely
@nextasy2010
Apr 16 2016 06:28
blob
Coy Sanders
@coymeetsworld
Apr 16 2016 06:28
yeah also what everyone else is saying, you don't want to return anything in the case/switch statement
Frank XC
@tenkdayz
Apr 16 2016 06:29
@Radascript I'm still hacking at it. :d
Coy Sanders
@coymeetsworld
Apr 16 2016 06:29
you just want to modify the count variable, after the switch statement you need to check if its positive or negative
Frank XC
@tenkdayz
Apr 16 2016 06:29
@vaspv i know whats going on
Coy Sanders
@coymeetsworld
Apr 16 2016 06:29
@nextasy2010 use arr, not testArr
you want to use array that is passed into the function
also you don't need to create a variable addNum since you don't do anything with it
Rada
@Radascript
Apr 16 2016 06:30
@tenkdayz i didn't use reduce fwiw, and my code is 40 lines long after tidying it up
Vivienne Sales
@Natto278
Apr 16 2016 06:30
@UtkarshShukla7 What do you mean by count+"xyz"? I'm confused by the"xyz" part.
Coy Sanders
@coymeetsworld
Apr 16 2016 06:31
@Natto278 he just wrote xyz to mean either Bet or Hold
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:31
@Natto278 :smile: yes
Coy Sanders
@coymeetsworld
Apr 16 2016 06:31
you would write bet if the count is greater than 0, if count is 0 or less you put Hold
Frank XC
@tenkdayz
Apr 16 2016 06:31
@vaspv when you query the json object you have to sue the parameter variable in your case json to refer to the obj.. for example to get the name you have to use json.display_name
Nely
@nextasy2010
Apr 16 2016 06:31
i dont get it @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 06:31
your function has 2 parameters, arr and item right?
Nely
@nextasy2010
Apr 16 2016 06:32
yes
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32
you want to use both
Frank XC
@tenkdayz
Apr 16 2016 06:32
@Radascript did you have to reduce the arrays to their unique values?
Nely
@nextasy2010
Apr 16 2016 06:32
yes
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32
you're using item correctly by pushing it into an array, but you want to push it to arr, the array youre passing into the function
Prateek Vasisht
@vaspv
Apr 16 2016 06:32
@tenkdayz ah ok - so basically as soon as I get into the JSON then the iterations work for the initial feed but for all other data I have to use the values that json processes?
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32
not the global array testArr
Rada
@Radascript
Apr 16 2016 06:32
@tenkdayz no I didn't do that at all
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:32
@ALMY91 man I don't know about that technique.
btw where did you find it
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32
thats your only issue, just fix that and you'll be fine
Nely
@nextasy2010
Apr 16 2016 06:33
ok, let me try that
thanks @coymeetsworld
CamperBot
@camperbot
Apr 16 2016 06:33
nextasy2010 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 571 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 06:33
np
Rada
@Radascript
Apr 16 2016 06:33
@tenkdayz I really don't know how reduce can apply there, maybe I'll go google the solution and see if other people used it
Frank XC
@tenkdayz
Apr 16 2016 06:33
@vaspv yeah in the getJSON function you query the data using json or whatever your var is
ALMY91
@ALMY91
Apr 16 2016 06:33
@UtkarshShukla7 im working on the definitive guidebook
@Radascript i was going through the exercises yesterday too, and i still hv no idea what are they good for haha
Prateek Vasisht
@vaspv
Apr 16 2016 06:34
@tenkdayz great. thanks for the explanation. Now I'll use the other channels url as well to get other data. :)
CamperBot
@camperbot
Apr 16 2016 06:34
vaspv sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:warning: vaspv already gave tenkdayz points
Coy Sanders
@coymeetsworld
Apr 16 2016 06:34
are you on symmetric difference @Radascript ?
Vivienne Sales
@Natto278
Apr 16 2016 06:35
Okay!
Rada
@Radascript
Apr 16 2016 06:35
@ALMY91 yeah I'm generally not very comfortbale with reduce, but there I don't even really understand how it can apply. I think my code wasn't too messy without it
@coymeetsworld just solved it like 6 minutes ago. Frank is working on it.
Frank XC
@tenkdayz
Apr 16 2016 06:35
@Radascript I looked at one of the answers but didnt know what was going on.. I still have it on a note to study it.
Coy Sanders
@coymeetsworld
Apr 16 2016 06:35
oh ok, yeah I eventually figured out how to use reduce to solve it
it was tricky, I had to call it twice, once for each array, then combine the results together
not sure if that was the right way but that's how i solved it with using reduce
Frank XC
@tenkdayz
Apr 16 2016 06:36
@coymeetsworld Im guessing if you use reduce it wouldnt be a one step solution would it?
Vivienne Sales
@Natto278
Apr 16 2016 06:36
If you can't use the return statement to show the messsage "Bet" or "hold" how are you supposed to show the messages, @coymeetsworld?
ALMY91
@ALMY91
Apr 16 2016 06:36
@Radascript i decided to move on to the javascript definitive guidebook after completing the challenges ...in hopes tt it cld enlighten me better
Coy Sanders
@coymeetsworld
Apr 16 2016 06:36
it wasn't for me @tenkdayz no, but not 100% sure if you could do it with just one reduce call
i would say no
you use the return statement @Natto278 , just not within the case/switch statement
Frank XC
@tenkdayz
Apr 16 2016 06:38
@coymeetsworld I see.. thought so too.
ALMY91
@ALMY91
Apr 16 2016 06:38
@coymeetsworld @UtkarshShukla7 i forgotten if i'd thank you guys, anw here you go..
CamperBot
@camperbot
Apr 16 2016 06:38
almy91 sends brownie points to @coymeetsworld and @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: almy91 already gave coymeetsworld points
:star: 316 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
Coy Sanders
@coymeetsworld
Apr 16 2016 06:39
you break up the function into two steps: look at the card and modify the count where applicable
then after looking at the card, look at the count value and either print out Bet or Hold depending on the value of count
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:39
@ALMY91 np
Coy Sanders
@coymeetsworld
Apr 16 2016 06:40
yeah np @ALMY91
Eldar Tinjić
@EldarT90
Apr 16 2016 06:42
is this good start /approach to this problem ?
function sumPrimes(num) {
  var count = 0;
  var newArr = [];
for (var i = 0; i<=num; i++)
  {
    newArr.push(i);
}

  for (i=0;i<=num;i++) {

    for (j=0;j<newArr.length;j++)
      {
        if (newArr[j] % i === 0) 
          {
            count += j;
          }
      }

  }

  return count;

}



sumPrimes(10);
@coymeetsworld could you take a look at it mate
Coy Sanders
@coymeetsworld
Apr 16 2016 06:45
let me look
well one thing is you don't need to start i = 0 since you know 0 and 1 are not prime numbers
you might have an error there?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:47
well for 10, instead of 17 i get 135
so obviously too many numbvers are passing the statement
oh lol
Coy Sanders
@coymeetsworld
Apr 16 2016 06:48
yeah I know what I did, I'm trying to see why yours doesn't work
i think it would give more numbers than it should
like for example when you have i=6
Eldar Tinjić
@EldarT90
Apr 16 2016 06:48
now when i think about logc
my logic is not good in this problem
Coy Sanders
@coymeetsworld
Apr 16 2016 06:48
when j is 3 or 2 the mod is going to be 0
Eldar Tinjić
@EldarT90
Apr 16 2016 06:48
this is completely wrong logic
Coy Sanders
@coymeetsworld
Apr 16 2016 06:48
so you're going to be counting 6 twice into your count
which you don't want to do, you only want to count it once
so you need to add some additional logic within your 2nd for loop
Eldar Tinjić
@EldarT90
Apr 16 2016 06:49
yes
i dont think its fixable tbh
just need different approach perhas
Coy Sanders
@coymeetsworld
Apr 16 2016 06:50
no not necessarily
you're on the right path needs some tweaking
ALMY91
@ALMY91
Apr 16 2016 06:51
var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('S');
guys when i do this why doesn it give me
Eldar Tinjić
@EldarT90
Apr 16 2016 06:51
you dont want to split it by s
you want to split it by "nothing
which means by ("")
Coy Sanders
@coymeetsworld
Apr 16 2016 06:51
well, spaces
ALMY91
@ALMY91
Apr 16 2016 06:52
["S" ,"plit me into an array"];
Coy Sanders
@coymeetsworld
Apr 16 2016 06:53
split by space @ALMY91
ALMY91
@ALMY91
Apr 16 2016 06:53
yep i understood what the question was asking but i was just trying this out
Eldar Tinjić
@EldarT90
Apr 16 2016 06:53
command split
look at it
ALMY91
@ALMY91
Apr 16 2016 06:53
instead it gives me
Eldar Tinjić
@EldarT90
Apr 16 2016 06:53
@ALMY91 listen
ALMY91
@ALMY91
Apr 16 2016 06:53
```js
["" ,"plit me into an array"];
```
Eldar Tinjić
@EldarT90
Apr 16 2016 06:53
@ALMY91 your command takes certain value , in this case you put there "S" ; split("S") - that means splti when you see "S"
@ALMY91 you dont want to split when see "S", you want to split every letter, not jsut capital S
ALMY91
@ALMY91
Apr 16 2016 06:54
i understood that it was asking me to split by spaces, but what if i wanna split it by S?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:54
@ALMY91 you just did split it by S
@ALMY91 but they are not asking you to split it by S
@ALMY91 they want every letter to be an array
ALMY91
@ALMY91
Apr 16 2016 06:54
shouldn it give me
["S" ,"plit me into an array"];
Coy Sanders
@coymeetsworld
Apr 16 2016 06:55
nope
ALMY91
@ALMY91
Apr 16 2016 06:55
@EldarT90 yes i understood they are asking me to split by spaces and not by S, im just playing around w the code
Coy Sanders
@coymeetsworld
Apr 16 2016 06:55
the item you're splitting is removed from the array
ALMY91
@ALMY91
Apr 16 2016 06:55
@coymeetsworld ahh i see that makes sense now thanks
CamperBot
@camperbot
Apr 16 2016 06:55
almy91 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: almy91 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Apr 16 2016 06:55
ya
Clay Sheffler
@ClaySheffler
Apr 16 2016 06:56
where to learn how to update json ?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:56
@coymeetsworld i am just doing everything twice for every number and even that is not only mistake
Clay Sheffler
@ClaySheffler
Apr 16 2016 06:56
stackoverflow answers use loops, didnt get there yet..
Coy Sanders
@coymeetsworld
Apr 16 2016 06:56
doing everything twice?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:57
@coymeetsworld yes, but problem is that statement is so wrong; newArr[j] % i === 0
Coy Sanders
@coymeetsworld
Apr 16 2016 06:58
well that part is fine
Eldar Tinjić
@EldarT90
Apr 16 2016 06:58
@coymeetsworld it just means every number will be added
Coy Sanders
@coymeetsworld
Apr 16 2016 06:58
although you don't need an array for that, you can just use the value j
but what you need to do is once that statement is true, stop running the for loop further
or else like i said before, some numbers you're going to count it twice, like 6
when i is 6 and j is 2 and also when j is 3
Eldar Tinjić
@EldarT90
Apr 16 2016 06:59
@coymeetsworld but every number will pass it ; when it goes to i = 6 and j = 6; it will pass
and 6 is not primary number
prime*
Coy Sanders
@coymeetsworld
Apr 16 2016 06:59
right
but you're adding to count when it isn't prime :)
right?
Eldar Tinjić
@EldarT90
Apr 16 2016 07:00
well this way i am adding them regardless
if its not % 0
than it iwll add when i = 6 and j = 5
Coy Sanders
@coymeetsworld
Apr 16 2016 07:01
can't do that either
Eldar Tinjić
@EldarT90
Apr 16 2016 07:01
so its bad statement
Coy Sanders
@coymeetsworld
Apr 16 2016 07:01
sometimes it helps writing pseudocode to think about how to run the code
Eldar Tinjić
@EldarT90
Apr 16 2016 07:01
hmm let me try working on it for a while and i ll get back to you
and need to grab something to eat
Coy Sanders
@coymeetsworld
Apr 16 2016 07:02
sure thing
Eldar Tinjić
@EldarT90
Apr 16 2016 07:02
@coymeetsworld tnx anyway and cya soon
CamperBot
@camperbot
Apr 16 2016 07:02
eldart90 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 572 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 07:02
yeah see ya
Vivienne Sales
@Natto278
Apr 16 2016 07:14
Re: Counting Cards / I understand why my current code for items #1-#3, but not for items #4-#7. Am I on the right track if I close my switch statement and start a bunch of if / else if statements?
Clay Sheffler
@ClaySheffler
Apr 16 2016 07:16
How to fix this error? "TypeError: Cannot read property 'push' of undefined" function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
}
if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
}
if (value === "") {
collection[id].pop();
}
return collection;
}
ALMY91
@ALMY91
Apr 16 2016 07:21
just wondering why does it only work in chrome but not in IE?
blob
nth is appearing in my IE but when i open my console under chrome it works just fine
jw1540
@jw1540
Apr 16 2016 07:27
Hey, be super grateful if someone could offer some feedback on my completed local weather challenge? N.B. For some reason VueJS doesn't work in embedded codepens
http://codepen.io/jw1540/full/revLaz/
ALMY91
@ALMY91
Apr 16 2016 07:28
why does it seem exceptionally dead in this chatroom ...
usually its buzzling with convos back and fro every min
lol
and whats the diff between /\D+\/and /\d+/
/\D+/
helooooooooooooooo
:worried:
jw1540
@jw1540
Apr 16 2016 07:33
@ALMY91 d is for one digit
D is for one non-digit
  • is for one or more
/\D+\/ = 1 or more non-digit
/\d+/ = 1 or more digit
@ALMY91 I use this basically all the time haha https://www.debuggex.com/cheatsheet/regex/javascript
ALMY91
@ALMY91
Apr 16 2016 07:36
hokay hahahah @jw1540 thanks
CamperBot
@camperbot
Apr 16 2016 07:36
almy91 sends brownie points to @jw1540 :sparkles: :thumbsup: :sparkles:
:star: 155 | @jw1540 | http://www.freecodecamp.com/jw1540
Eldar Tinjić
@EldarT90
Apr 16 2016 07:50
@coymeetsworld i dont know how to write it
that it is the only number it should have % = 0
Matt Green
@mattxgreen
Apr 16 2016 07:51
@jw1540 Isn't one of the requirement to get the users location?
(reviewing your temp app)
Eldar Tinjić
@EldarT90
Apr 16 2016 07:52
function sumPrimes(num) {
  var count = 0;
  var newArr = [];
  var counter = 0;
for (var i = 0; i<=num; i++)
  {
    newArr.push(i);
}

  for (i=2;i<=num;i++) {


    for (j=2;j<newArr.length;j++)
      {
        if (newArr[j] % i === 0) 

          {
            counter += 1;

          }

        if (counter === 1) {
          count += j;
        } 
      }

  }

  return count;

}



sumPrimes(10);
this loooks bit more sensible
but still it is missing something
jw1540
@jw1540
Apr 16 2016 07:52
@mattxgreen thanks for taking a look. yeah, i just assumed it didn't have to be automatically detected (i.e. through navigation.geolocation)
CamperBot
@camperbot
Apr 16 2016 07:53
jw1540 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
Matt Green
@mattxgreen
Apr 16 2016 07:53
@jw1540 I would also do some form validation... If no city is entered, and you press submit it returns undefined
CamperBot
@camperbot
Apr 16 2016 07:53
:star: 453 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
jw1540
@jw1540
Apr 16 2016 07:53
@mattxgreen ooh, good shout actually
Matt Green
@mattxgreen
Apr 16 2016 07:54
@jw1540 If you don't want to use geolocation, nor geoip, you could consider the google places api for autocomplete
Vivienne Sales
@Natto278
Apr 16 2016 07:57
@sonjamoisset Thank you for helping me with the Counting Card challenge.
CamperBot
@camperbot
Apr 16 2016 07:57
natto278 sends brownie points to @sonjamoisset :sparkles: :thumbsup: :sparkles:
jw1540
@jw1540
Apr 16 2016 07:57
@mattxgreen yeah i found geoip was being wildly inaccurate; i didn't know about the google places api though, that's really cool I'll definitely look to implement that
CamperBot
@camperbot
Apr 16 2016 07:57
:warning: could not find receiver for sonjamoisset
Matt Green
@mattxgreen
Apr 16 2016 07:58
@EldarT90 Did you want help with that function?
Eldar Tinjić
@EldarT90
Apr 16 2016 08:03
@mattxgreen yes, but i like hints rather than direct help
Matt Green
@mattxgreen
Apr 16 2016 08:06
Xf
@Darcy-FzR
Apr 16 2016 08:07
This message was deleted
Eldar Tinjić
@EldarT90
Apr 16 2016 08:09
@mattxgreen hmm this looks like algorythm that i should be using
ofc if i can convert it to the right syntax
Matt Green
@mattxgreen
Apr 16 2016 08:09
@EldarT90 aye!
Eldar Tinjić
@EldarT90
Apr 16 2016 08:10
@mattxgreen tnx for your help, i have to go afk anyway so will bookmark this and hopefully i will ne able to convert it succesfully ^^ take care
CamperBot
@camperbot
Apr 16 2016 08:10
eldart90 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 454 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
ALMY91
@ALMY91
Apr 16 2016 08:11
hello guys
null is a language keyword that evaluates to a special value that is usually used to indicate the absence of a value. Using the typeof operator on null returns the string "no object"
is anyone able to do an illustration of how this works out?
ive yet to come across this in the FCC challenges and im not too sure what is typeof used for and how is it to be used
Justin
@daemedeor
Apr 16 2016 08:13
@ALMY91 your book is wrong
try in the console > typeof null
you'll find that it return object
@ALMY91 typeof is a nifty comparison to tell you what the typeof the supplied variable is
ALMY91
@ALMY91
Apr 16 2016 08:14
@daemedeor ohyeah its an object
Justin
@daemedeor
Apr 16 2016 08:14
in this case, for JS -> null is an object ... confusing but thats what the spec calls for
ALMY91
@ALMY91
Apr 16 2016 08:14
@daemedeor whats a ifty
nifty
Justin
@daemedeor
Apr 16 2016 08:15
@ALMY91 particularly good, skillful, or effective.
dictionary :D
so if you did var greeting = "heeey"; console.log(typeof greeting ); //"string"
ALMY91
@ALMY91
Apr 16 2016 08:16
@daemedeor wait a minute....
@daemedeor it states that values of javascript types can be categories into primative type and object types. Of which, primitive types are numbers, strings,booleans,null and undefined
Justin
@daemedeor
Apr 16 2016 08:17
bassssically
ALMY91
@ALMY91
Apr 16 2016 08:17
Object types are non-primitive, ect, functions
so how does null become an object in this case?
Justin
@daemedeor
Apr 16 2016 08:18
defined
ALMY91
@ALMY91
Apr 16 2016 08:18
weird.......they stated null falls under primitive type not object types?
so why was typeof for null printed as an object
Justin
@daemedeor
Apr 16 2016 08:19
because the spec definition
ALMY91
@ALMY91
Apr 16 2016 08:20
i dont understand can i u explain in layman terms
basically just... read the docs, its a bug
ALMY91
@ALMY91
Apr 16 2016 08:23
what do u mean its a bug haha
and why's the chatroom so quiet today...
Justin
@daemedeor
Apr 16 2016 08:24
@ALMY91 typeof null // object (bug in ECMAScript, should be null)
ALMY91
@ALMY91
Apr 16 2016 08:24
@daemedeor when they mentioned its a bug what does it mean
Justin
@daemedeor
Apr 16 2016 08:25
@ALMY91 a bug is something that is wrong, thats not intended, a pest
so if your code is buggy, something is wrong
Piyush Kaushik
@KaushikDev
Apr 16 2016 08:25
Hi, i need the following code to return true, but this some bi* is returning false

function truthCheck(collection, pre) {
// Is everyone being true?
var flag=0;

for(var i=0;i<collection.length;i++){
var obj=collection[i];

if(isNaN(obj[pre])===false && obj[pre]!==null && obj[pre]!=="" && obj[pre]!==undefined && obj[pre]!==0 && obj[pre]!==false || obj[pre]==="yes" ){

flag+=1;

}

}
if (flag===collection.length){

return true;

}

else return false;

}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");

Anyone???
Justin
@daemedeor
Apr 16 2016 08:27
@KaushikDev could you put it in a code block
help format
CamperBot
@camperbot
Apr 16 2016 08:27

: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 the code.

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

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

ALMY91
@ALMY91
Apr 16 2016 08:27
@daemedeor so what do i do if the result is appearing object instead of null. How do i fix this bug?
Justin
@daemedeor
Apr 16 2016 08:28
@ALMY91 you can't fix it... unless you work on the JS language yourself... which is unlikely, you'll have to find some way to deal with it
these kinda bugs in the language tend to be called.... quirks
ALMY91
@ALMY91
Apr 16 2016 08:32
@daemedeor so weird...
@daemedeor thanks anw
CamperBot
@camperbot
Apr 16 2016 08:32
almy91 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 402 | @daemedeor | http://www.freecodecamp.com/daemedeor
Piyush Kaushik
@KaushikDev
Apr 16 2016 08:56
@daemedeor sorry, i didn't get that :(
alpox
@alpox
Apr 16 2016 08:57
@ALMY91 Primitive types will not be showed as that with the typeof operator. The typeof operator shows its actual type so an integer, which also is a primitive type, will be shown as "Number". Since if a primitive type cannot just have no value for usual, the absence of any value in javascript is shown as 'undefined'. The indicator 'null' is an object because it shows the absence of an object. It means, that at this place, there should be an object, but there isnt. So its null. About the same way works 'NaN', which is typeof Number, but indicates that there is no number defined even if there should be a number.
I hope this clears things out a bit
@daemedeor Btw. thats not a bug in ECMAScript :-)
Marius
@rasmus1610
Apr 16 2016 09:03
function updateRecords(id, prop, value) {
  if (value !== "" && prop !== "tracks" && collection.hasOwnProperty(prop)) {
    collection[id][prop] = value;
  } else if (value !== "" && prop == "tracks" && collection.hasOwnProperty(prop)) {
    collection[id][prop].push(value);
  } else if (value === "") {
    delete collection[id][prop];
  }

  return collection;
}
can anyone help me with this function? cant see what's wrong
Aleksej
@tip14
Apr 16 2016 09:08
hello! can someone explain my, why this for (i=0; i<arr.length; i+2) is an infinite loop?
Marius
@rasmus1610
Apr 16 2016 09:09
@tip14 well how does your array look like?
Aleksej
@tip14
Apr 16 2016 09:10
@rasmus1610 ["a", "b", "c", "d","v", "g"]
Justin
@daemedeor
Apr 16 2016 09:10
@alpox accoding to MDN it is :D
Coryphaeus
@cvdeby
Apr 16 2016 09:10
@rasmus1610 try to change == to === on second condition
Justin
@daemedeor
Apr 16 2016 09:10
@tip14 cause you never reassign i
alpox
@alpox
Apr 16 2016 09:10
@daemedeor Hmm I don't think this is a bug :-)
Coryphaeus
@cvdeby
Apr 16 2016 09:11
@tip14 You're not assigned new i value - instead of i+2 use i+=2
Marius
@rasmus1610
Apr 16 2016 09:11
@cvdeby you mean where I test whether prop equals "tracks"?
didnt work
Aleksej
@tip14
Apr 16 2016 09:11
@daemedeor @cvdeby thank you!!!
CamperBot
@camperbot
Apr 16 2016 09:11
tip14 sends brownie points to @daemedeor and @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 340 | @cvdeby | http://www.freecodecamp.com/cvdeby
Justin
@daemedeor
Apr 16 2016 09:12
@alpox there are definitely WORSE bugs to have but in many languges null is null its crazy
CamperBot
@camperbot
Apr 16 2016 09:12
:star: 403 |