These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Mar 2016
James Bond
@Dman89
Mar 26 2016 00:05
I need help writing script to access this object using getJSON
```
$(document).ready(function(b){ 

          $("#contentDisplay").empty();
  $.getJSON("http://en.wikipedia.org/w/api.php?action=query&format=json&list=random&rnlimit=13", function(data2){
    $.each(data2.query.random, function (){
      $("#contentDisplay").append('<div id="contentDisplaySquare" class="contentDisplaySquare col-xs-12"><a href="http://en.wikipedia.org/wiki/"' + encodeURIComponent(item.title) + ' target="_blank"><div class="col-xs-12"><h2 class="title">' + item.title + '</h2></div></a></div>');
    });
      });//function(data) close


});
lizzieshipton
@lizzieshipton
Mar 26 2016 00:17

@bitgrower sorry one last question. I got it right but don't really get why...here is the code:

for (var i = 0 ; i < contacts.length ; i++){
    if (contacts[i].firstName == firstName){
      if (contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }
      else {
        return "No such property";
      }
    }
  }
  return "No such contact";

so basically, it was exiting the function too early before, I think is what you were saying? but now...there are 3 return statements, and yet it doesn't seem to exit too early...? it seems like it checks for the name, if that's there, it checks for the prop, if that's there it returns contacts[i][prop] (and then wouldn't it exit??) And if either one is not true, it returns "No such property" (and still doens't exit??) - but how does it know which one isn't true..........this is not making any sense and i'm rambling. i'm just confused. super duper confused. is there somewhere I can go/something I can read to get a really clean understanding of this? because i really don't get it.

bitgrower
@bitgrower
Mar 26 2016 00:22
hmm ... so pythontutor.com/javascript.html didn't help ?
I"m having a bit of trouble understanding what you are having trouble with ...
lizzieshipton
@lizzieshipton
Mar 26 2016 00:27
@bitgrower I don't think I even know myself anymore. it's been a long day. basically I thought I understood how a for loop works...but it looks like I don't. yeah and the python thing....I didn't really get. typed in the code and hit visualize, and it just sort of reprinted my code and said "frames" and "objects".....
sorry for all the questions!
Brian Park
@dodgerdog05
Mar 26 2016 00:27
hi
James Bond
@Dman89
Mar 26 2016 00:28
yo dodger
bitgrower
@bitgrower
Mar 26 2016 00:28
@lizzieshipton -- if you haven't you may want to watch the video challenges at the bottom of the map ... also called "hikes" ... it may give you a basis for better understanding what you are seeing in pythontutor ...
Brian Park
@dodgerdog05
Mar 26 2016 00:29
yo dman
bitgrower
@bitgrower
Mar 26 2016 00:29
and if it's been a long day, I recommend taking a break ...
Brian Park
@dodgerdog05
Mar 26 2016 00:29
what's the best way to ask for help?
bitgrower
@bitgrower
Mar 26 2016 00:30
we don't really learn consciously, we learn unconsciously ... and your unconscious sometimes needs time to process ... that's why you can be doing the dishes or wake up in the morning with an "aha!"
lizzieshipton
@lizzieshipton
Mar 26 2016 00:30
@bitgrower thanks!
CamperBot
@camperbot
Mar 26 2016 00:30
lizzieshipton sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: lizzieshipton already gave bitgrower points
bitgrower
@bitgrower
Mar 26 2016 00:30
just ask, @dodgerdog05
yw @lizzieshipton happy coding ...
Brian Park
@dodgerdog05
Mar 26 2016 00:30
cool
i'm havin trouble with this waypoint....
adding a default option in switch statements
Andrew Charlebois
@andrewchar
Mar 26 2016 00:31
@bitgrower how was work
bitgrower
@bitgrower
Mar 26 2016 00:32
good, which reminds me, I gotta send something off ... :)
be back in a few .. .
Kevin Mulligan
@kmulligan
Mar 26 2016 00:32
@lizzieshipton don't know if this helps but we've all been there. I had a long frustrating day two days ago. Took a break. Had time to think. Figured it out. I agree with @bitgrower
bitgrower @bitgrower practices what she preaches ... takes breaks, comes back and revises work ...
Andrew Charlebois
@andrewchar
Mar 26 2016 00:32
@bitgrower good thing i asked? lol
Brian Park
@dodgerdog05
Mar 26 2016 00:33
nevermind, i got it to work haha!
bitgrower
@bitgrower
Mar 26 2016 00:33
LOL ... yeah, I would have remembered .. or someone would have hit me up ...
YAY !!!
Andrew Charlebois
@andrewchar
Mar 26 2016 00:33
take breaks, yes. i do a lot more of that now when im stuck
bitgrower
@bitgrower
Mar 26 2016 00:33
it's extremely productive ... LOL ... it just doesn't feel like it is ...
Andrew Charlebois
@andrewchar
Mar 26 2016 00:34
you see my beautiful regexp
i think its quite lovely lol
bitgrower
@bitgrower
Mar 26 2016 00:39
LOL ... funny guy ...
Lucky charm
@luckycharm223
Mar 26 2016 00:40
can somebody help me with this challenge please?
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];
bitgrower
@bitgrower
Mar 26 2016 00:41
what challenge is that, @luckycharm223 ?
lizzieshipton
@lizzieshipton
Mar 26 2016 00:43
@kmulligan thanks!
CamperBot
@camperbot
Mar 26 2016 00:43
lizzieshipton sends brownie points to @kmulligan :sparkles: :thumbsup: :sparkles:
:star: 298 | @kmulligan | http://www.freecodecamp.com/kmulligan
Andrew Charlebois
@andrewchar
Mar 26 2016 00:43
@bitgrower i wasn't being funny!
mansinjny
@mansinjny
Mar 26 2016 00:53
could someone help me with the challenge nesting for loops
bitgrower
@bitgrower
Mar 26 2016 00:56
sorry, @andrewchar
Cian
@ciant
Mar 26 2016 00:56

Hey I'm doing a basic algorithm, I've come up with a good way of solving it, but trying to also make another one of my ideas get the same result but can't make it work.

```

Amin
@aminghz
Mar 26 2016 01:00
Hi everyone
Micah Bales
@micahbales
Mar 26 2016 01:01
Does this code look right to folks?
          var d = document.getElementsByClassName("profile");
          d.className = " offline";
Amin
@aminghz
Mar 26 2016 01:01
I'm doing the "Seek and Destroy" algorithm. I can solve it without using Array.filter() but I have no idea how to solve it using the "Array.filter()"
Micah Bales
@micahbales
Mar 26 2016 01:02
Here's the html:
<div class='profile'></div>
Amin
@aminghz
Mar 26 2016 01:03
@micahbales It seems fine! except you have one space before offline
Micah Bales
@micahbales
Mar 26 2016 01:04
@aminghz Yeah, actually, that should be there. But it's supposed to read "d.className += ' offline';"
I'm wanting to add a class "offline" to the existing div, without getting rid of the other class.
Amin
@aminghz
Mar 26 2016 01:05
if that's the case then you are right!
Micah Bales
@micahbales
Mar 26 2016 01:05
It's not doing what I want it to. Here's the full pen: http://codepen.io/micahbales/pen/ONmXry?editors=0010
Amin
@aminghz
Mar 26 2016 01:05
d.className += " offline"
Micah Bales
@micahbales
Mar 26 2016 01:06
the divs still have only "profile" as their class
Amin
@aminghz
Mar 26 2016 01:20
you are right
Lucky charm
@luckycharm223
Mar 26 2016 01:21
@absinthian i tried it, its not working
@absinthian did it work for you?
Moisés Man
@moigithub
Mar 26 2016 01:28
@micahbales where this comes from ?? <img class='logo' src='" + offlineData.logo + "' />"
are u sure there are a logo key/property ?? checked with console.log (...) ??
i see a lot of <img class="logo" src="undefined"> on ur html source
@micahbales u could probably use addClass/removeClass or toggleClass from jquery to add/remove classes to ur html element
Elbert Cortez
@trip16661
Mar 26 2016 01:43
can anyone help me out here?
//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 lookUp(firstName, prop){
// Only change code below this line
  for (a = 0; a < contacts.length; a++){

    if (contacts[a].firstName === firstName || contacts[a].hasOwnProperty(prop) === true){
      if(contacts[a].firstName !== firstName){
        return "No such contact";

      }
      else if (contacts[a].hasOwnProperty(prop) === false){
        return "No such property";
      }

    }

    else if (contacts[a].firstName === firstName && contacts[a].hasOwnProperty(prop)){
      return contacts[a].prop;
    }

  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
not sure what im doing wrong
Ben
@ReductioAbsurdum
Mar 26 2016 01:53

I've been playing around with Heap's algorithm and I'm trying to understand it... I can't grasp this part of it, though. Here is the code:

function permAlone(str) { 

  return heap(str);

  function heap(string) {
  var arr = string.split(''),
                    permutations = [];      

    gen(4);

  function gen(n) {
   if(n === 1){
   permutations.push("first");
   }else{
   for(i=0; i != n; i++){
   gen(n - 1);
   permutations.push("hi");
   }
   }
  }
  return permutations;
}
}
permAlone('aab');

Why does the permutations array return: ["first", "hi", "first", "hi", "hi"] instead of what I thought it would do: ["first", "hi", "first", "hi", "first", "hi"]... it's like it skips the gen(n - 1); on the third time through the gen function.

Elbert Cortez
@trip16661
Mar 26 2016 02:07
//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 lookUp(firstName, prop){
// Only change code below this line
  for (a = 0; a < contacts.length; a++){

    if (contacts[a].firstName === firstName || contacts[a].hasOwnProperty(prop) === true){
      if(contacts[a].firstName !== firstName){
        return "No such contact";

      }
      else if (contacts[a].hasOwnProperty(prop) === false){
        return "No such property";
      }

    }

    else if (contacts[a].firstName === firstName && contacts[a].hasOwnProperty(prop)){
      return contacts[a].prop;
    }

  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
help me please dunno what im doing wrong
CamperBot
@camperbot
Mar 26 2016 02:07
no wiki entry for: me please dunno what im doing wrong
bitgrower
@bitgrower
Mar 26 2016 02:10
you only know when there's no such contact after you've looked at every element of your array ... but you return in the middle of your loop before that can happen ...
Matt Green
@mattxgreen
Mar 26 2016 02:15
@trip16661 you are always returning something (and exiting your for loop) on the first iteration
Elbert Cortez
@trip16661
Mar 26 2016 02:15
@mattxgreen what do you mean ?
Matt Green
@mattxgreen
Mar 26 2016 02:16
@trip16661 You should not return no such contact until you have exhausted all possibilities
Elbert Cortez
@trip16661
Mar 26 2016 02:17
so instead of being inside of the if
it should be an else?
else if
Matt Green
@mattxgreen
Mar 26 2016 02:17
@trip16661 There should be an additional condition
@trip16661 to ensure you have searched ALL possibilities
Elbert Cortez
@trip16661
Mar 26 2016 02:18
an aditional condition?
I feel so dumb D:
Matt Green
@mattxgreen
Mar 26 2016 02:19
@mattxgreen ok, there are 3 cases to happen, so your statement are a bit overcomplicated
@trip16661
@trip16661 I'll pseudo-code it
Elbert Cortez
@trip16661
Mar 26 2016 02:21
That would be really helpful man and sorry for being this slow
Matt Green
@mattxgreen
Mar 26 2016 02:23
@trip16661
if this contact equals the contact requested AND it has the property
//return the property
//
//else if this contact equals the contact requested (and won't have the property because first statement did'nt match)
//return no such property
//
//else if this is the last contact in our object
//return no such user
@trip16661 easy?
Elbert Cortez
@trip16661
Mar 26 2016 02:28
why if it's the last contact?
should't be if it doesn't have that contact at all'
?
Matt Green
@mattxgreen
Mar 26 2016 02:28
because you don't want to return no such user until you have searched all of your contacts for a match
Currently you are checking ONE contact, and if it's not a match you are returing no such user. your for loop never actually loops
@trip16661 Is this making sense?
Physiix
@Physiix
Mar 26 2016 02:32
Did you figure out how to solve it ?
@mattxgreen is right
Matt Green
@mattxgreen
Mar 26 2016 02:33
@trip16661 If the first contact doesn't match, check the 2nd, if that's not a match check the 3rd, if the 3rds not a match, and we have no more contacts return no such user.
Elbert Cortez
@trip16661
Mar 26 2016 02:33
I don't get the last part D:
Physiix
@Physiix
Mar 26 2016 02:33
All right
here : for (a = 0; a < contacts.length; a++)
You're beginning the loop, right ?
Elbert Cortez
@trip16661
Mar 26 2016 02:34
y
Physiix
@Physiix
Mar 26 2016 02:34
and just after that, you're making this assertion : if(contacts[a].firstName !== firstName)
Let's say, the contacts[a].firstName is "test" ; and firstName is "test" too
so the condition here is false
what you want to do is to check for the next contact
Elbert Cortez
@trip16661
Mar 26 2016 02:38
but the first one checks if it's either first name or propertie that are equal to the argument
and after that the if that you mention comes
not first
Matt Green
@mattxgreen
Mar 26 2016 02:41

@trip16661

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

// Only change code above this line
}

That should work

if could be further simplified, but that's pretty readable
Elbert Cortez
@trip16661
Mar 26 2016 02:43
so if after all the loops nothing happen is when you return contacts
Matt Green
@mattxgreen
Mar 26 2016 02:43
The for loop iterates over all possibilities and returns (exiting the function) if there is a match found. If no match is found the code falls through to the return "No such contact" and voila... problem solved
I gotta run, gl
Elbert Cortez
@trip16661
Mar 26 2016 02:44
@mattxgreen thanks and sorry
CamperBot
@camperbot
Mar 26 2016 02:44
trip16661 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 378 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Blake Harris
@bharris62
Mar 26 2016 03:02
hey hey hey
how is everyone
Physiix
@Physiix
Mar 26 2016 03:05
Yo
Awesome
you ?
Andrews
@frempongandrews
Mar 26 2016 03:12
Hi guys
a little help
Paul Borawski
@iAmNawa
Mar 26 2016 03:13
ok
Andrews
@frempongandrews
Mar 26 2016 03:13
to eliminate punctation, symbols etc I found this
replace(/[.,\/#!$%\^&*;:{}=-_`~()]/g, "")
what is the "g" for?
When I remove it, the method does't work anymore. An explanation would be incredibly appreciated. Thanks!
DJ
@qualitymanifest
Mar 26 2016 03:16
@frempongandrews it's the global flag. without it the replace would stop at the first match. http://www.w3schools.com/jsref/jsref_regexp_g.asp
Paul Borawski
@iAmNawa
Mar 26 2016 03:18
hello
Andrews
@frempongandrews
Mar 26 2016 03:18
@qualitymanifest oh okay, thanks!!
CamperBot
@camperbot
Mar 26 2016 03:18
frempongandrews sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1116 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Og-Morrow
@Og-Morrow
Mar 26 2016 03:34
Hey guys need some help on calling the function to the output, Iterate Through an Array with a For Loop.
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];

// Only change code below this line
var total = 0;

for(var x = 0; x < myArr.legnth; x++) {
  total += myArr[x];
}
it outputs total = 0
Stephen
@stephepush
Mar 26 2016 03:38
This message was deleted
CamperBot
@camperbot
Mar 26 2016 03:38
:bulb: to format code use backticks! ``` more info
Stephen
@stephepush
Mar 26 2016 03:40
This message was deleted
Og-Morrow
@Og-Morrow
Mar 26 2016 03:40
use three backticks then shift enter then copy paste then control enter. @7speter
Micah Bales
@micahbales
Mar 26 2016 03:41
thanks @moigithub
CamperBot
@camperbot
Mar 26 2016 03:41
micahbales sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 783 | @moigithub | http://www.freecodecamp.com/moigithub
DJ
@qualitymanifest
Mar 26 2016 03:41
@7speter you had an extra closing curly brace }
Stephen
@stephepush
Mar 26 2016 03:42
// Example
function ourFunction(isItTrue) {
  if (isItTrue) { 
    return "Yes, it's true";
  }
  return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

  // Only change code below this line.

  if (wasThatTrue) {
    return "That was true";
  }
  return "That was false";
 }

  // Only change code above this line.

}

// Change this value to test
myFunction(true);
Og-Morrow
@Og-Morrow
Mar 26 2016 03:42
yup the one below the second return
Stephen
@stephepush
Mar 26 2016 03:42
Ah, I got it
Blake Harris
@bharris62
Mar 26 2016 03:43
I am doing challenege 191, push and item on the back and pop off the front
i currently have this code, but I do not understand what it wants me to do.
function queue(arr, item) {
  // Your code here
  testArr.push(item);
  testArr.pop();
  return testArr;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Stephen
@stephepush
Mar 26 2016 03:43
thanks @Og-Morrow
CamperBot
@camperbot
Mar 26 2016 03:43
7speter sends brownie points to @og-morrow :sparkles: :thumbsup: :sparkles:
:star: 226 | @og-morrow | http://www.freecodecamp.com/og-morrow
Blake Harris
@bharris62
Mar 26 2016 03:43
i have changed somethings around, but not having any luck
Og-Morrow
@Og-Morrow
Mar 26 2016 03:43
thanks @qualitymanifest hes the one who called it first
CamperBot
@camperbot
Mar 26 2016 03:43
og-morrow sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1117 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Mar 26 2016 03:44
@Og-Morrow haha. thanks :+1:
CamperBot
@camperbot
Mar 26 2016 03:44
qualitymanifest sends brownie points to @og-morrow :sparkles: :thumbsup: :sparkles:
:star: 227 | @og-morrow | http://www.freecodecamp.com/og-morrow
Og-Morrow
@Og-Morrow
Mar 26 2016 03:45
I still need help with Iterating through an array with a for loop
Matt Green
@mattxgreen
Mar 26 2016 03:47
@Og-Morrow I"ll do it!!!
@Og-Morrow type-o myArr.legnth
Og-Morrow
@Og-Morrow
Mar 26 2016 03:54
HAHA thats awesome
thanks @mattxgreen
CamperBot
@camperbot
Mar 26 2016 03:55
og-morrow sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 379 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
EternalPractice
@EternalPractice
Mar 26 2016 03:56
Good evening fellow campers.
Anyone here pass the Basic Algorithm "Check for Palindromes" portion?
AudioGen
@AudioGen
Mar 26 2016 04:02
Yah
EternalPractice
@EternalPractice
Mar 26 2016 04:03
I'm having an issue understanding why the last test ("0_0 (: /-\ :) 0-0") should return true.
(ugh, I have to check for escape characters and now emojis)
AudioGen
@AudioGen
Mar 26 2016 04:04
@EternalPractice IIRC I stored a ton of variables, definitely not the most efficient code but you want to post your code and show me what you mean
?
EternalPractice
@EternalPractice
Mar 26 2016 04:05
Well, if you look at it and it's reverse, it's not the same.
0_0 (: /-\ :) 0-0
AudioGen
@AudioGen
Mar 26 2016 04:06
@EternalPractice You have to get rid of all the white space or spaces and also you have to use a method to make all the letters the same case
EternalPractice
@EternalPractice
Mar 26 2016 04:06
0-0 ): -/ :( 0_0
So _ and - should be the same case?
Jesus Arteaga
@HecticHiccups
Mar 26 2016 04:06
myVar = myVar++;
this is how you increment right?
cause i think i'm getting an error.
AudioGen
@AudioGen
Mar 26 2016 04:07
@HecticHiccups you don't need to assign myVar you can just use the increment or right hand side you have there
EternalPractice
@EternalPractice
Mar 26 2016 04:07
@HecticHiccups You can either increment with myVar = MyVar + 1 or just myVar++
Jesus Arteaga
@HecticHiccups
Mar 26 2016 04:07
Okay thanks.
AudioGen
@AudioGen
Mar 26 2016 04:09
@EternalPractice no, there are methods that convert characters to all upper case or all lower case
letters are considered characters here
EternalPractice
@EternalPractice
Mar 26 2016 04:09
I'm not sure I'm asking the question correctly.
if you only compare the first and last 3, you are comparing 0-0 to 0_0
The middle character in each is not the same, so it should not be a palidrome, but it states it should return true.
AudioGen
@AudioGen
Mar 26 2016 04:10
@EternalPractice which one?
@AudioGen Check the last test, stating it should return true.
Paul Borawski
@iAmNawa
Mar 26 2016 04:13
I Am NAWA!
AudioGen
@AudioGen
Mar 26 2016 04:14
@EternalPractice Oh ok, you got to remove the non-alphanumeric characters
EternalPractice
@EternalPractice
Mar 26 2016 04:14
So in that case I'm comparing 0's essentially?
AudioGen
@AudioGen
Mar 26 2016 04:14
I used a Regular Expression, I kind of knew that before FreeCodeCamp tho
Yah
EternalPractice
@EternalPractice
Mar 26 2016 04:14
Ah...that makes sense.
AudioGen
@AudioGen
Mar 26 2016 04:15
@EternalPractice do you know regular expressions?
EternalPractice
@EternalPractice
Mar 26 2016 04:15

"A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing."

Key note: ignoring punctuation.

@AudioGen Yeah, enough to solve this or google what I don't know.
AudioGen
@AudioGen
Mar 26 2016 04:15
@EternalPractice Oh ok
EternalPractice
@EternalPractice
Mar 26 2016 04:16
Thanks for the clarification, I've been banging my head against this desk for 3 hours.
^.^ Have a great rest of your evening/day.
AudioGen
@AudioGen
Mar 26 2016 04:16
Thanks you too
Slava Ustiuzhanin
@ustiuzhanin
Mar 26 2016 04:21
wiki Make Object Properties Private
CamperBot
@camperbot
Mar 26 2016 04:21

:point_right: challenge make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

Another example:

:pencil: read more about challenge make object properties private on the FCC Wiki

Jorge
@dokeet
Mar 26 2016 04:24
hello
wiki truncate a string
CamperBot
@camperbot
Mar 26 2016 04:27

:point_right: algorithm truncate a string [wiki]

Explanation:

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

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

Jorge
@dokeet
Mar 26 2016 04:27
i dont know why this challenge isnt working, the solution is correct.
function truncate(str, num) {
  if (num > 3) {
     if(str.length > num) {
        str = str.slice(0,num-3) + "...";
      }
  } else {
        str = str.slice(0,num) + "...";
  }
  return str;
}

truncate("Absolutely Longer", 2);
Jesus Arteaga
@HecticHiccups
Mar 26 2016 04:28
Wiki
CamperBot
@camperbot
Mar 26 2016 04:28
usage:
wiki $topic info on that topic
Jorge
@dokeet
Mar 26 2016 04:29
it doest return what the challenge is asking, i dont know what is wrong
harpoon747
@harpoon747
Mar 26 2016 04:31

``` (shift+enter for line break)
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

return collection;
}

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

Can some one help me with the above code. I am getting the error collection.id undefined error
Jorge
@dokeet
Mar 26 2016 04:32
how is the name of that challenge?
Tien Anh Nguyen
@tienanh2007
Mar 26 2016 04:35
Is there a way to see my upcoming lesson on freecodecamp instead of just doing it aimlessly ?
Boris
@boris-in-london
Mar 26 2016 04:37

I'm learning about the classic module pattern, closures and the Object.create() method.

function tstr() {
  var tstrObj = {};
  function innerTstr() {
    var blah = { "Key": "Value" };
    Object.create( tstrObj, blah );
  }
  innerTstr();  
  return tstrObj;
}
}

Any idea why my code throws back errors?

my aim is to get blah variable out of the innerTstr and as a return value of tstr(); when invoked.
Jorge
@dokeet
Mar 26 2016 04:44
@boris-in-london is really inactive this chat right now haha
Paul Borawski
@iAmNawa
Mar 26 2016 04:45
I’m here!
Boris
@boris-in-london
Mar 26 2016 04:46
lol @dokeet , i'll take it as a sign to get some sleep. Hope everyone has a great long weekend. Night all. :)
Paul Borawski
@iAmNawa
Mar 26 2016 04:47
What’s up Dexter! @dokeet
Olawale Akinseye
@brainyfarm
Mar 26 2016 04:47
Or more coffee @iAmNawa ;)
Jorge
@dokeet
Mar 26 2016 04:47
@iAmNawa oh hi!
dacahill7
@dacahill7
Mar 26 2016 04:48
Could somebody look at their Counting Cards program and see if they used multiple switch functions inside of the cc function?
Paul Borawski
@iAmNawa
Mar 26 2016 04:48
How was everyone’s day today?
Islam Ibakaev
@dagman
Mar 26 2016 04:52
@boris-in-london
function tstr() {
  var tstrObj;
  function innerTstr() {
    var blah = { "Key": "Value" };
    tstrObj = Object.create(blah);
  }
  innerTstr();  
  return tstrObj['Key'];
}

tstr();
Traplord Ses
@TrapSes
Mar 26 2016 04:54
hey guys, on Introducing JS Object Notation JSON:
Add a new album to the myMusic JSON object. Add artist and title strings, release_year number, and a formats array of strings
and i got but so far no go
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  myMusic.artist = "Neon Indian";
  myMusic.title = "VEGA INTL. Night School";
  myMusic.release_year = "2015";
  myMusic.formats = "['CD', 'Vinyl', 'LP',]";
];
Olawale Akinseye
@brainyfarm
Mar 26 2016 04:54
@dacahill7, you only need a switch statement, a global count variable and one conditional to confirm what to do based on the value of count.
Islam Ibakaev
@dagman
Mar 26 2016 04:55
@TrapSes chould do it this way
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
Olawale Akinseye
@brainyfarm
Mar 26 2016 04:55
@TrapSes, myMusic is an array of objects so you have to push in stuff into it.
Traplord Ses
@TrapSes
Mar 26 2016 04:55
@brainyfarm ahhh okok
@brainyfarm can i push that chunk of code at once?
Islam Ibakaev
@dagman
Mar 26 2016 04:56
@TrapSes you dont should push
you should type json object manyally
dacahill7
@dacahill7
Mar 26 2016 04:57
@brainyfarm Oh duh. I was trying only to use the switch. Thanks for your help!
CamperBot
@camperbot
Mar 26 2016 04:57
dacahill7 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1684 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Islam Ibakaev
@dagman
Mar 26 2016 04:57
like above
Traplord Ses
@TrapSes
Mar 26 2016 04:58
@dagman huh?
Islam Ibakaev
@dagman
Mar 26 2016 04:58
@TrapSes you cant push it
@TrapSes should create new json object behind existing
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:00
@dagman?
@TrapSes, like @dagman said, you can create new objects inside the array and you might not need to push for this challenge.
Islam Ibakaev
@dagman
Mar 26 2016 05:01
@brainyfarm
  {
    "artist": "Neon Indian",
    "title": "VEGA INTL. Night School",
    "release_year": 2015,
    "formats": [ 
      "CD", 
      "Vinyl", 
      "LP" ],
  }
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:02
You are right @dagman.
Islam Ibakaev
@dagman
Mar 26 2016 05:02
@brainyfarm its not about you neednt push you are not able to do it
Traplord Ses
@TrapSes
Mar 26 2016 05:03
@dagman ah i see cuz when u myMusic1
@dagman didnt put it together at first
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:05
@dagman, I see they only want you to manually create a new object item.
Islam Ibakaev
@dagman
Mar 26 2016 05:05
@brainyfarm absolutely true
Traplord Ses
@TrapSes
Mar 26 2016 05:07
i get syntax error: unexpected token {
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:07
Thanks for the clarification @dagman and happy coding @TrapSes (Sorry, I almost mislead you) :D
CamperBot
@camperbot
Mar 26 2016 05:07
brainyfarm sends brownie points to @dagman and @trapses :sparkles: :thumbsup: :sparkles:
:star: 358 | @dagman | http://www.freecodecamp.com/dagman
:star: 219 | @trapses | http://www.freecodecamp.com/trapses
Traplord Ses
@TrapSes
Mar 26 2016 05:08
not sure where it is cuz everything looks fine tho
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:08
You can share your code here @TrapSes.
Traplord Ses
@TrapSes
Mar 26 2016 05:09
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
    {
    "artist": "Neon Indian",
    "title": "VEGA INTL. Night School",
    "release_year": 2015,
    "formats": [ 
      "CD", 
      "Vinyl", 
      "LP" ],
  }// Add record here
];
Kyle Morton
@kmorton1988
Mar 26 2016 05:09
I'm so lost with geolocation. Anyone able to help?
Islam Ibakaev
@dagman
Mar 26 2016 05:09
@TrapSes maybe comma after "formats"
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:09
What about it @kmorton1988?
Kyle Morton
@kmorton1988
Mar 26 2016 05:09
TBH, I don't even know. all i wanna do is get a location and convert it to a Zip code.
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:10
Are you working on one of the projects here @kmorton1988?
Islam Ibakaev
@dagman
Mar 26 2016 05:10

@TrapSes

```
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
    {
    "artist": "Neon Indian",
    "title": "VEGA INTL. Night School",
    "release_year": 2015,
    "formats": [ 
      "CD", 
      "Vinyl", 
      "LP" ]
  }// Add record here
];

```

try it
Kyle Morton
@kmorton1988
Mar 26 2016 05:10
Yeah, display weather.
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:11
Why do you need zip code conversion @kmorton1988?
Traplord Ses
@TrapSes
Mar 26 2016 05:11
@dagman AHH WAT U CHANGE?!
Kyle Morton
@kmorton1988
Mar 26 2016 05:11
i don't know. That's part of what I'm looking into.
The whole concept of geolocation is confusing to me.
Islam Ibakaev
@dagman
Mar 26 2016 05:11
@TrapSes comma beetween object
Kyle Morton
@kmorton1988
Mar 26 2016 05:11
not sure where the location actually gets defined or how to even assign that info to a variable.
Traplord Ses
@TrapSes
Mar 26 2016 05:11
@dagman thanks a lot
CamperBot
@camperbot
Mar 26 2016 05:11
trapses sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 359 | @dagman | http://www.freecodecamp.com/dagman
Islam Ibakaev
@dagman
Mar 26 2016 05:12
@TrapSes welcome
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:12
@kmorton1988, geolocation helps you get your user approximate location in longitude and latitude.
Kyle Morton
@kmorton1988
Mar 26 2016 05:12
yeah, I got that part, but I can't figure out how to assign that to a variable.
or what to do with it after that
I've looked into weather API's, but they all seem to want zip code or citys as inputs
Islam Ibakaev
@dagman
Mar 26 2016 05:13
@kmorton1988 i did this way to find coordinates
(function() {
    var coords = {};
    $.getJSON('http://ipinfo.io', function(data){
        var location = data.loc;
        location = location.split(',');
        coords.latitude = parseFloat(location[0], 10);
        coords.longitude = parseFloat(location[1], 10);
        console.log(coords);
})
})();
Kyle Morton
@kmorton1988
Mar 26 2016 05:13
oh you did it the IP address way
I'm trying to use html5's geolocation method
Islam Ibakaev
@dagman
Mar 26 2016 05:13
@kmorton1988 you shouldnt
Kyle Morton
@kmorton1988
Mar 26 2016 05:14
sigh
yeah, I'm seeing that.
Islam Ibakaev
@dagman
Mar 26 2016 05:14
@kmorton1988 it supposed to get permission from user
Kyle Morton
@kmorton1988
Mar 26 2016 05:14
yeah, and for the sake of this demo, if you're trying to find the weather, who wouldn't give permission?
every modern browser has a built-in method of confirming or denying permission from the user
Islam Ibakaev
@dagman
Mar 26 2016 05:15
@kmorton1988 its not the best way
Kyle Morton
@kmorton1988
Mar 26 2016 05:15
Still feel like it'd be important to learn it.
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:15
@kmorton1988, don't assign to a variable so as to use outside of your callback. You should make your API call when you get the position and yes, I did the project using geolocation. Your code does not show you getting the location.
Kyle Morton
@kmorton1988
Mar 26 2016 05:16
my code? I haven't posted any code yet.
not in gitter, anyway
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:16
Sorry @kmorton1988.
Mix up.
Islam Ibakaev
@dagman
Mar 26 2016 05:16
@kmorton1988 the task is supposed to show weather immideately after user open codepen
Kyle Morton
@kmorton1988
Mar 26 2016 05:16
yeah, I know.
Brian
@BrianCodes33
Mar 26 2016 05:16
how do i publish a site i hand coded on my text editor to the web and start making money off of it?
Islam Ibakaev
@dagman
Mar 26 2016 05:17
@kmorton1988 that s why i did it that way
Kyle Morton
@kmorton1988
Mar 26 2016 05:17
2 different people are talking about this to me.
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:17
@BrianCodes33, you are going to host it so as to put it online.
Islam Ibakaev
@dagman
Mar 26 2016 05:17
@kmorton1988 i was thinking to use geo api firstly too
Kyle Morton
@kmorton1988
Mar 26 2016 05:17
it's pretty complicated, but I really want to understand it.
it's actually exactly what I need to learn in order to build something I was contemplating.
Islam Ibakaev
@dagman
Mar 26 2016 05:18
@kmorton1988 what do you mean
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:18
@kmorton1988, you should learn geolocation even if you go the ip way and it is not complicated.
Kyle Morton
@kmorton1988
Mar 26 2016 05:18
@dagman I mean I want to understand the geolocation methods that are available in HTML5.
@brainyfarm You're probably right, I just don't have my head around it yet.
Islam Ibakaev
@dagman
Mar 26 2016 05:18
you can read about it on mdn
Kyle Morton
@kmorton1988
Mar 26 2016 05:19
I have.
it shows demos, but I have NO idea how the demos accomplish what they're doing.
Even going in line by line, trying to decipher just what the basic javascript is doing is confusing to me.
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:19
Try writing your own code @kmorton1988.
Kyle Morton
@kmorton1988
Mar 26 2016 05:19
@brainyfarm I am do just that, but in order for me to write code, I have to understand what I'm writing and why.
that's where I"m at a loss.
Using the Geolocation API and Methods, I have NO idea what they're doing
Islam Ibakaev
@dagman
Mar 26 2016 05:21
@kmorton1988
navigator.geolocation.getCurrentPosition(function(position) {
  do_something(position.coords.latitude, position.coords.longitude);
});
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:21
@kmorton1988, the best way to learn is by doing, try understand it one line at a time and then write your code, you will see where you get it wrong.
I start some challenges even having no idea how I am supposed to write the code.
Kyle Morton
@kmorton1988
Mar 26 2016 05:24
hmm.
Alright. Well, here we go.
Bartek
@dyczol
Mar 26 2016 05:30
@BrianCodes33 you tell us, especially the money making part :)
sayan
@sayan1991
Mar 26 2016 05:30
help Record Collection
CamperBot
@camperbot
Mar 26 2016 05:30

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

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

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

For the given id in collection:

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

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

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

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

Paul Borawski
@iAmNawa
Mar 26 2016 05:31

function myTest(val) {
var answer = "";
// Only change code below this line

switch (val) {
case "bob":
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1:
answer = "There is no #1";
break;
case 99:
answer = "Missed me by this much!";
break;
case 7:
answer = "Ate Nine";
// Only change code above this line
return answer;
}
}
// Change this value to test
myTest("bob");

This code is not working
myTest(7) is properly showing the result but none of the other are, they are displaying just a blank space
Olawale Akinseye
@brainyfarm
Mar 26 2016 05:33
Lol @dyczol.
Islam Ibakaev
@dagman
Mar 26 2016 05:33
@kmorton1988 try to use it in your console
 function getCoords(position) {
     var coords = {};
    coords.latitude  = position.coords.latitude;
    coords.longitude = position.coords.longitude;
    console.log(coords);
  }
  navigator.geolocation.getCurrentPosition(getCoords);
Bartek
@dyczol
Mar 26 2016 05:34
@brainyfarm hehe
Islam Ibakaev
@dagman
Mar 26 2016 05:36
@brainyfarm have you done with quote machine
dacahill7
@dacahill7
Mar 26 2016 05:36
@iAmNawa Which one is that? I know I did that recently and got it figured out.
Paul Borawski
@iAmNawa
Mar 26 2016 05:39
i figured it out thanks!! @dacahill7
CamperBot
@camperbot
Mar 26 2016 05:39
iamnawa sends brownie points to @dacahill7 :sparkles: :thumbsup: :sparkles:
:star: 209 | @dacahill7 | http://www.freecodecamp.com/dacahill7
hemantknayak
@hemantknayak
Mar 26 2016 05:42
anybody worked out the javascript profile lookup solution?
i got stuck in it

var code = "function lookUp(firstName, prop){

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

if( (contacts[i].firstName === firstName) && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];

}

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

if(!contacts[i].hasOwnProperty(prop)){return "No such property";}

}
}";

hemantknayak
@hemantknayak
Mar 26 2016 05:47
but its not satisfying all the 5 conditions
Kyle Morton
@kmorton1988
Mar 26 2016 05:49
I give up.
for tonight.
hemantknayak
@hemantknayak
Mar 26 2016 05:50
:smile:
gud nite
Radhika Kapoor
@kapoorradhika
Mar 26 2016 06:34
Hello World
CamperBot
@camperbot
Mar 26 2016 06:34

welcome to FreeCodeCamp @kapoorradhika!

Radhika Kapoor
@kapoorradhika
Mar 26 2016 06:35
im working on the intermediate algorithim drop it.. and below is a screenshot of my code. Please tell me what im doing wrong
Screen Shot 2016-03-25 at 11.36.14 PM.png
Screen Shot 2016-03-25 at 11.36.27 PM.png
Screen Shot 2016-03-25 at 11.39.38 PM.png
Richard Corbett
@reacorbett
Mar 26 2016 06:57
anyone here well versed in jQuery? I am having trouble with getting my twitter button to change images on hover. can someone take a look and help me figure out what I am doing wrong?
http://codepen.io/reacorbett/pen/EPzmqY
the twitter button is at the bottom of the page.
maotao
@maotao1
Mar 26 2016 07:02

function palindrome(str) {
// Good luck!
var n =str.length;
str=str.toLowerCase();
for (var i=0;i<n/2;i++){
if (str[i]==str[n-i-1])
{
return true;
}else{
return false;
}
}
}

palindrome("almostomla");

where is wrong?
please tell me !thank you!
Richard Corbett
@reacorbett
Mar 26 2016 07:04
@maotao1
help format
CamperBot
@camperbot
Mar 26 2016 07:04

: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

maotao
@maotao1
Mar 26 2016 07:04
i am little bai
V Arun Kumar
@arunvkumr
Mar 26 2016 07:07
@maotao1 .. your if condition checks for the first char and if they are equal returns true.. without checking for the entire string
@maotao1 :point_up: March 26, 2016 12:34 PM.. format your code please
@maotao1 you can use if as if the chars are not equal then return false.. and after for loop return true.. this makes your code work.
maotao
@maotao1
Mar 26 2016 07:10

function palindrome(str) {
// Good luck!
var n =str.length;
str=str.toLowerCase();
for (var i=0;i<n/2;i++){
if (str[i]==str[n-i-1])
{
return true;
}
return false;
}

}

palindrome("applo");

in these way??
V Arun Kumar
@arunvkumr
Mar 26 2016 07:12
@maotao1 it's still the same code.. in if condition check if they are not equla and return false.. and out of for loop return true..
like this..
    for (var i=0;i<n/2;i++){
        if(str[i]!=str[n-i-1]){ //<- != instead of == 
            return false; //<- and false the condition will be true only when the chars are not equal.
        }
    }
    return true; //<- this will run when all the chars match.
Richard Corbett
@reacorbett
Mar 26 2016 07:12
anyone here well versed in jQuery? I am having trouble with getting my twitter button to change images on hover. can someone take a look and help me figure out what I am doing wrong?
http://codepen.io/reacorbett/pen/EPzmqY
maotao
@maotao1
Mar 26 2016 07:14
also unwork

function palindrome(str) {
// Good luck!
var n =str.length;
str=str.toLowerCase();
for (var i=0;i<n/2;i++){
if (str[i]!==str[n-i-1])
{
return false;
}
return true;

}

}
palindrome("applo");

V Arun Kumar
@arunvkumr
Mar 26 2016 07:15
@maotao1 move return true.. outside the for loop.. and please format your code, before pasting..
maotao
@maotao1
Mar 26 2016 07:16
can you write ?please!
thank you
function palindrome(str) {
// Good luck!
var n =str.length;
str=str.toLowerCase();
for (var i=0;i<n/2;i++){
if (str[i]!==str[n-i-1])
{
return false;
}
}
return true;
}
palindrome("applo");
this way?do not work~
Subhankar Ghosh
@rdx1subhankar
Mar 26 2016 07:20
"I am a "double quoted" string inside "double quotes"" . This has two written using four escaped double quotes .. how ???
*to be written
Robert Axelsen
@robaxelsen
Mar 26 2016 07:37
help Using Objects for Lookups
CamperBot
@camperbot
Mar 26 2016 07:37

: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

kirbyedy
@kirbyedy
Mar 26 2016 07:38
@rdx1subhankar you have to use the escape \ before the "
Naro
@Narosen
Mar 26 2016 07:41
https://www.freecodecamp.com/challenges/record-collection#?solution=%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20update(id%2C%20prop%2C%20value)%20%7B%0A%20%20if(value!%3D%3D%22%22%20%26%26%20prop!%3D%3D'tracks')%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20collection.id%5Bprop%5D%3Dvalue%3B%0A%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%20%20else%20if(prop%3D%3D'tracks'%20%26%26%20value!%3D%3D%22%22)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20collection.id%5Bprop%5D%3Dvalue.push()%3B%0A%20%20%20%20%7D%0A%20%20else%20if(value%3D%3D%3D%22%22)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20delete%20collection.id%5Bprop%5D%3B%0A%20%20%20%20%7D%0A%20%20%0A%0A%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0Aupdate(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
collection.id[prop]=value; is not working in the above link
Tien Anh Nguyen
@tienanh2007
Mar 26 2016 07:45
help Falsy Bouncer
CamperBot
@camperbot
Mar 26 2016 07:45

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

Naro
@Narosen
Mar 26 2016 07:48
typeError: Cannot Set property 'artist' of undefined is shown when I type collection.id[prop]=value; in RecordCollection Challenge. HELP
Subhankar Ghosh
@rdx1subhankar
Mar 26 2016 07:52
@kirbyedy : i need to use exactly two double quotes and 4 escaped double quotes to get this output : "I am a "double quoted" string inside "double quotes"" . kindly help m stuck on this
Naro
@Narosen
Mar 26 2016 07:53
"I am a \"double quoted\" string inside \"double quotes\""
Subhankar Ghosh
@rdx1subhankar
Mar 26 2016 07:56
@Narosen : i have to use /" infront of I and at the end /" . to get the output i require to pass the challenge . that makes six escaped double quotes . but i have do it in 4
Naro
@Narosen
Mar 26 2016 07:56

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

// Only change code below this line
function update(id, prop, value) {
if(value!=="" && prop!=='tracks')
{

  collection.id[prop]=value;

}

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

return collection;
}

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

this code is not working. HELP
It shows the error "typeError: Cannot Set property 'artist' of undefined "
@rdx1subhankar 'I am a \"double quoted\" string inside \"double quotes\"' then use this
Subhankar Ghosh
@rdx1subhankar
Mar 26 2016 08:00
@Narosen nt working yet
Naro
@Narosen
Mar 26 2016 08:01
@rdx1subhankar show me your line
kirbyedy
@kirbyedy
Mar 26 2016 08:02
note that \ and / are different signs
V Arun Kumar
@arunvkumr
Mar 26 2016 08:03
@maotao1 that's because you have to remove all special chars using regexp and then use your code it will work..
kirbyedy
@kirbyedy
Mar 26 2016 08:03
@rdx1subhankar you have to write it inline
kirbyedy
@kirbyedy
Mar 26 2016 08:03
and watch for the spaces
quoted"string
you need a space here
after the quote
Subhankar Ghosh
@rdx1subhankar
Mar 26 2016 08:05
@kirbyedy : can you write the entire line here .. so that i can rectify my mistake
Naro
@Narosen
Mar 26 2016 08:05
@rdx1subhankar var myStr="I am a \"double quoted\" string inside \"double quotes\"";
kirbyedy
@kirbyedy
Mar 26 2016 08:06
"I am a \"double quoted\" string inside \"double quotes\"";
Naro
@Narosen
Mar 26 2016 08:09
someone help me with JSON
Subhankar Ghosh
@rdx1subhankar
Mar 26 2016 08:09
thank you @kirbyedy and @Narosen ..
CamperBot
@camperbot
Mar 26 2016 08:09
rdx1subhankar sends brownie points to @kirbyedy and @narosen :sparkles: :thumbsup: :sparkles:
:star: 744 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
:star: 220 | @narosen | http://www.freecodecamp.com/narosen
V Arun Kumar
@arunvkumr
Mar 26 2016 08:13

@maotao1 something like...
this is your code..

function palindrome(str) {
    str = str.replace(/[\W|_]/g,'').toLowerCase(); //<- you need this to remove all the special chars including underscore..
    var n =str.length;
    for (var i=0;i<n/2;i++)
        if (str[i]!==str[n-i-1])
        return false;
    return true;
}
palindrome("race car");

another way to do is.. using inbuilt functions, like..

function palindrome(str) {
    str = str.replace(/[\W|_]/g,'').toLowerCase();
    var rstr = str.split('').reverse().join('');
    return (str === rstr);
}
palindrome("race car");
maotao
@maotao1
Mar 26 2016 08:22
function largestOfFour(arr) {
// You can do this!
var a=[];
var highnumber=0;
for (var i=0;i<arr.length;i++){
for (var j=0;j<arr[i].length;j++){
if(highnumber<arr[i][j]){
highnumber=arr[i][j];
}
}
a.push(highnumber);
}
return a;
}
i got it
what's wrong?
Olawale Akinseye
@brainyfarm
Mar 26 2016 08:23

@brainyfarm have you done with quote machine

Yes I have done it @dagman .

Matt Green
@mattxgreen
Mar 26 2016 08:23
anyone have an opinion on these 2 solutions for diff(ing) 2 arrays?
function diff1(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  arr1.map(callback.bind(null,arr2));
  arr2.map(callback.bind(null,arr1));
  return newArr;

  function callback(testArr,val){
    if (testArr.indexOf(val) === -1){ newArr.push(val);}
  }
}

function diff(arr1, arr2) {
  Array.prototype.diff = function(a) {
    return this.filter(function(i) {return a.indexOf(i) < 0;});
  };
  return arr2.diff(arr1).concat(arr1.diff(arr2));
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:26
@mattxgreen
It feels a bit too “smart”. In arr1.map()I would expect you to map over items, but you use testArr and also newArr from the outside, which isn’t very clean.
oh in first diff I meant
diff1
Matt Green
@mattxgreen
Mar 26 2016 08:28
@marcusnielsen Yeah, I could pass newArr around
@marcusnielsen That was my first solution, then I did some searching, and found the 2nd. 2nd is elegant, but I think slower
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:28
@mattxgreen have you learnt how to use reduce?
Matt Green
@mattxgreen
Mar 26 2016 08:29
sure, I know reduce
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:29
use that for solution 1 and use newArr as the starting value. that might be better.
Matt Green
@mattxgreen
Mar 26 2016 08:30
@marcusnielsen I'll do it, and see how it looks
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:30
cool
Matt Green
@mattxgreen
Mar 26 2016 08:30
@marcusnielsen thanks
CamperBot
@camperbot
Mar 26 2016 08:30
mattxgreen sends brownie points to @marcusnielsen :sparkles: :thumbsup: :sparkles:
:star: 38 | @marcusnielsen | http://www.freecodecamp.com/marcusnielsen
Jason
@jpr00
Mar 26 2016 08:31
@maotao1 What are you trying to do?
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:43
stuck on "assignment with a returned value". anyone got any ideas?
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:43
@patrickocr what’s your issue?
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:43
i have brain freeze and don't get it. kind of need baby steps walk thru.
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:44
sorry, I haven’t done many of the laborations. I’m just a developer helping out new people
you have to give me the assignment
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:45
Instructions == Call the process function with an argument of 7 and assign its return value to the variable processed.

Example == var changed = 0;

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

changed = change(10);

@marcusnielsen any pointers?
Aks1610
@Aks1610
Mar 26 2016 08:46
@patrickocr what does this process function do?
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:47
I think they mean var magicNumber = 7;
magicNumber = change(magicNumber);
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:47
i think it's about assigning a new output to a start variable in a looping way
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:47
but that was one heck of a cryptic language they used.
and I don’t like reassigning variables, but that’s a different story I guess. Most laborations do some stuff wrong to get a simple point through.
@patrickocr Let’s pick it apart...
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:48
ok, thanks
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:49
Do you know which is the “process function”?
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:50
@marcusnielsen this is what i'm working with so far...

@marcusnielsen var processed = 0;

function process(num) {
return (num + x) / y;
}

processed = process(z);

Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:50
oh, so you need to create one?
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:50
@marcusnielsen think i need to find x,y,z if structure is right based on examples
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:50
shouldn’t var processed be = 7?
argument is what a function takes in as a parameter. so you should call process(7)
but the text above doesn’t make a statement about x and y, so I can’t guess what to do there.
don’t you have some test-points to fullfill to finish the assignment? can you share those?
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:53
@marcusnielsen here's where i'm now at -

@marcusnielsen var processed = 7;

function process(7) {
return (num + / 2;
}

processed = process(2);

am i on right path, and only need to structure num + 7 / x to get 2 output on process?
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:57
function process(7) {should be function process(num) {
João Castanho
@joaocastanho
Mar 26 2016 08:57
num is the argument @patrickocr
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:57
ok, getting my head round jscript
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:57
return (num + / 2; should be return (num + 1 / 2; or some other number than 1
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 08:57
thanks @joaocastanho @marcusnielsen
CamperBot
@camperbot
Mar 26 2016 08:57
patrickocr sends brownie points to @joaocastanho and @marcusnielsen :sparkles: :thumbsup: :sparkles:
:star: 39 | @marcusnielsen | http://www.freecodecamp.com/marcusnielsen
:star: 291 | @joaocastanho | http://www.freecodecamp.com/joaocastanho
João Castanho
@joaocastanho
Mar 26 2016 08:58
@marcusnielsen he forgot the ) at the end
no problem @patrickocr
Marcus Nielsen
@marcusnielsen
Mar 26 2016 08:58
@patrickocr that’s fine. You are doing well just struggling. It’s hard in the beginning.
@joaocastanho oh right
@patrickocr return (num + 1) / 2; or something else than 1
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 09:00
@joaocastanho so here's what i have now:-

@marcusnielsen @joaocastanho var processed = 7;

function process(num) {
return (num + 5) / 2;
}

processed = process();

João Castanho
@joaocastanho
Mar 26 2016 09:00
not correct
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 09:00
do i need to work thru what replaces 5?
or add 2 to process()
João Castanho
@joaocastanho
Mar 26 2016 09:00
what about the 7 ?
what should be the answer @patrickocr ?
Miguel T Rivera
@mtrivera
Mar 26 2016 09:02
wiki seek
CamperBot
@camperbot
Mar 26 2016 09:02

:point_right: algorithm seek and destroy [wiki]

Explanation:

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

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

Patrick O'Connor-Read
@patrickocr
Mar 26 2016 09:03
@marcusnielsen @joaocastanho i played with nos and put in return (num + 1) /4;} processed = process(7); and it ran
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:03
so it went well?
Patrick O'Connor-Read
@patrickocr
Mar 26 2016 09:04
so thanks @marcusnielsen @joaocastanho i think i'm starting to get brain wired in the right way, but it's taking a while!! objective was to get num (7) + 1 to divide by a no (4) to get 2 which ran.
CamperBot
@camperbot
Mar 26 2016 09:04
patrickocr sends brownie points to @marcusnielsen and @joaocastanho :sparkles: :thumbsup: :sparkles:
:warning: patrickocr already gave marcusnielsen points
:warning: patrickocr already gave joaocastanho points
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:04
great job @patrickocr
If anyone here has any random question about javascript and web development, I will start an AMA (Ask Me Anything) in 55 mins at https://plus.google.com/u/0/events/cbu9a9i5ov17ts6lhdu58crte3o
João Castanho
@joaocastanho
Mar 26 2016 09:06
@patrickocr good job ;)
@marcusnielsen any tips to find a job?
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:08
yeah, I live in stockholm, but I can give some hints. If you want I can try to cover it on the videocast. Anything more specific or just in general?
if you can give me your background that would help.
or just join the hangout and we will cover it live :-)
ali
@ahamidizadeh
Mar 26 2016 09:09
can someone help me with this?

var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = testObj[16]; /

João Castanho
@joaocastanho
Mar 26 2016 09:09
well, I'm European. I just finished High School, in a Professional Programming Course
I finished High School last year
And I'm looking for a job
I do have the skill set, but dont have portfolio. And I think that's not helping me in the interviews I do
Olawale Akinseye
@brainyfarm
Mar 26 2016 09:11
@ahamidizadeh
var player = testObj[playerNumber];
Jakub Adamec
@jadamec16
Mar 26 2016 09:11
Hi quys, how can I define statement - element haven't ID in JS? :D
Matt Green
@mattxgreen
Mar 26 2016 09:12
@marcusnielsen So, I've been working on this reduce for some time now, and I cant figure out how to reduce an array into a smaller array... got some syntax for me?
ali
@ahamidizadeh
Mar 26 2016 09:12
@brainyfarm thanks
CamperBot
@camperbot
Mar 26 2016 09:12
ahamidizadeh sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1687 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Jakub Adamec
@jadamec16
Mar 26 2016 09:12
if (elm.id == "undefined")?
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:13
@mattxgreen I’m doing a live AMA session soon. I can cover it there.
Matt Green
@mattxgreen
Mar 26 2016 09:13
I'm on PST... won't be awake much longer
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:14
@mattxgreen don’t worry, it’s recorded.
Matt Green
@mattxgreen
Mar 26 2016 09:14
ok
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:14
but donät have time now
João Castanho
@joaocastanho
Mar 26 2016 09:14
@marcusnielsen did you checked what I said?
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:15
@joaocastanho oh sorry, yeah I did. I copied what you said for reference. I will cover it on the cast.
João Castanho
@joaocastanho
Mar 26 2016 09:16
okay Thanks
Constantijn Asamoah
@constantijn-asamoah
Mar 26 2016 09:16
Hi guys, I just completed the "Stand In Line" - challenge, but it was really difficult for me and I couldn't have done it without google the solution. Is that bad?
Is it just me or are the instructions for that challenge just not that clear to understand
Bil
@thebiltheory
Mar 26 2016 09:19
Hiiiiii
How's everyone?
Would someone take a moment to explain me this
Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
Please please please
João Castanho
@joaocastanho
Mar 26 2016 09:27
can someone tell me how can I check if a checkbox is checked?
Bil
@thebiltheory
Mar 26 2016 09:28
Is everyone hangovered or what? :D
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:33
@joaocastanho document.querySelector('[type="checkbox"]').checked
Mohammad Umar
@umargithub
Mar 26 2016 09:34
```js
sorry
could you help!

function myTest(val) {
if (val) { // Change this line
return "Over 100";
}

if (val > 12 ) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
myTest(10);

João Castanho
@joaocastanho
Mar 26 2016 09:37
@marcusnielsen in jquery?
Matt Green
@mattxgreen
Mar 26 2016 09:39
@marcusnielsen got it, and I get it. Don't really understand why you would use reduce over filter in this case.
function diff(arr1, arr2) {
  var newArr=arr1.reduce(callback.bind(null,arr2),[]);
  return arr2.reduce(callback.bind(null,arr1),newArr);

  function callback(testArr,p,val){
    if (testArr.indexOf(val) < 0) {
      p.push(val);
    }
    return p;
  }
}
@marcusnielsen BUT I do see why the .map solution kinda sucked
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:41

@mattxgreen I thought about it myself. I don’t remember you filter solution, but it was good enough. I would then try to do the filter one but with reduce, but in the end, filter is either good enough, or you need to google for max perfomant algorithm.

Reduce though, is the mother of map and filter. You can do both map and filter with reduce, so that’s why I would try out that instead. It’s normal to try and optimize with reduce.

tl;dr: stick with filter. It’s good enough and readable for others :-)
Matt Green
@mattxgreen
Mar 26 2016 09:42
@marcusnielsen Alright, thanks for the direction
CamperBot
@camperbot
Mar 26 2016 09:42
mattxgreen sends brownie points to @marcusnielsen :sparkles: :thumbsup: :sparkles:
:star: 40 | @marcusnielsen | http://www.freecodecamp.com/marcusnielsen
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:43
@joaocastanho eh, I basically never use jQuery, sorry. But they have good docs right? :-)
Daniel Strijdom
@daansteraan
Mar 26 2016 09:44
HEY FOLKS.... so for the roman numeral converter exercise
Marcus Nielsen
@marcusnielsen
Mar 26 2016 09:44
jQueryelm[0] should give you the dom element too, so checkbox$[0].checked will work, but it’s not the way to do it with jQuery.
Daniel Strijdom
@daansteraan
Mar 26 2016 09:44
i did a whole bunch of while loops
wqhich sucks
João Castanho
@joaocastanho
Mar 26 2016 09:45
well, no problem. I'll figure it out
Daniel Strijdom
@daansteraan
Mar 26 2016 09:45
to refactor i thought the best way would be to loop to a dictionary with key value pairs; is there a better way to do this?
ali
@ahamidizadeh
Mar 26 2016 09:46
can someone help me with this?

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

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

bravo:"boston",

charlie:"Chicago",

delta:"Denver",
echo:"Easy",
foxtrot:"Frank"

};

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

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

João Castanho
@joaocastanho
Mar 26 2016 09:47
result = lookup.val;
Aleksander Gębicki
@Takumar
Mar 26 2016 09:48
@ahamidizadeh assign value from your lookup object to result variable.
Because val is a parameter you have to use bracket notation to access that property.
Nick S.
@sherbakov1
Mar 26 2016 09:52
Hello! Can someone explain me how to make a tusk Seek and Destroy?
ali
@ahamidizadeh
Mar 26 2016 09:52
@Takumar how do I do that?
Aleksander Gębicki
@Takumar
Mar 26 2016 09:53

@ahamidizadeh @joaocastanho showed you that, but instead of dot you have to use bracket notation:

result = lookup[val];

You would use dot if val was name of property of lookup object, but val is parameter which contain name of property.

ali
@ahamidizadeh
Mar 26 2016 09:54
@Takumar thanks!
@Takumar thanks
CamperBot
@camperbot
Mar 26 2016 09:54
ahamidizadeh sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2876 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Mar 26 2016 09:55
@ahamidizadeh no problem :-)
Petru Conduraru
@bluecondor
Mar 26 2016 10:32
help title case a sentence
CamperBot
@camperbot
Mar 26 2016 10:32

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Olawale Akinseye
@brainyfarm
Mar 26 2016 10:34
@bluecondor str.split() is your friend :+1:
Petru Conduraru
@bluecondor
Mar 26 2016 10:35
that one was the easy part
:)
@brainyfarm You have any tip about how do I capitalize each first letter?
I know I can use replace
Sukhjinder Singh
@sssuk2
Mar 26 2016 10:38
hello
does anyone know how to approach the exercise 27
Petru Conduraru
@bluecondor
Mar 26 2016 10:38
on the splitted words
Sukhjinder Singh
@sssuk2
Mar 26 2016 10:39
Convert Celsius to Fahrenheit
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 10:40
@bluecondor you could access the first char in word like first element in array
Brendan Kinahan
@BKinahan
Mar 26 2016 10:41
@sssuk2 if you are familiar with declaring variabes, assigning values to them, and arithmetical operators (+,-,*,/), then that one is quite straightforward if you know the formula for converting between the two temperature scales.
Sukhjinder Singh
@sssuk2
Mar 26 2016 10:42
should i wirte it like this
var fehrniet;
fahrniet = 9/5*c=32;
Petru Conduraru
@bluecondor
Mar 26 2016 10:42
@paulharfenmeister no need for Regex then?
João Castanho
@joaocastanho
Mar 26 2016 10:42
@sssuk2 no
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 10:42
@bluecondor yes
Petru Conduraru
@bluecondor
Mar 26 2016 10:42
@paulharfenmeister nice
João Castanho
@joaocastanho
Mar 26 2016 10:42
@help convert celsius
Petru Conduraru
@bluecondor
Mar 26 2016 10:42
@paulharfenmeister ty
@paulharfenmeister thanks
CamperBot
@camperbot
Mar 26 2016 10:43
bluecondor sends brownie points to @paulharfenmeister :sparkles: :thumbsup: :sparkles:
João Castanho
@joaocastanho
Mar 26 2016 10:43
help convert celsius
CamperBot
@camperbot
Mar 26 2016 10:43

:point_right: checkpoint convert celsius to fahrenheit [wiki]

Details

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

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

:pencil: read more about checkpoint convert celsius to fahrenheit on the FCC Wiki

:star: 265 | @paulharfenmeister | http://www.freecodecamp.com/paulharfenmeister
João Castanho
@joaocastanho
Mar 26 2016 10:43
@sssuk2 9/5 plus 32
Sukhjinder Singh
@sssuk2
Mar 26 2016 10:44
Can you send me the code @joaocastanho plz.?
João Castanho
@joaocastanho
Mar 26 2016 10:45
@sssuk2 fahrenheit = celsius * (9 / 5) + 32;
Check if that works
@sssuk2 "The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32."
Harsh Khandelwal
@harsh2602
Mar 26 2016 10:48
http://codepen.io/harsh2602/pen/xVrxyj why does my code not work when I click on offline and online tabs to filter streams
Sukhjinder Singh
@sssuk2
Mar 26 2016 10:48

@joaocastanho function convert(celsius) {
// Only change code below this line
var Fahrenheit= celsius*9/5+ 32;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

its saying fahrenheit is not defined
Ashish Acharya
@anarchyrucks
Mar 26 2016 10:49
guys how to change between session and break in pomodoro?
João Alves
@JADSN
Mar 26 2016 10:49
how i escaped a backslash?
how can i resolve the "Escape Sequences in Strings"?
João Castanho
@joaocastanho
Mar 26 2016 10:50
@JADSN look at the example in the left?
Robert Axelsen
@robaxelsen
Mar 26 2016 10:50
You simply "escape" it with another backslash.
João Castanho
@joaocastanho
Mar 26 2016 10:51
@sssuk2 Fahrenheit like fahrenheit
it should be lowercase
João Alves
@JADSN
Mar 26 2016 10:53
@robeerob thanks
CamperBot
@camperbot
Mar 26 2016 10:53
jadsn sends brownie points to @robeerob :sparkles: :thumbsup: :sparkles:
:star: 281 | @robeerob | http://www.freecodecamp.com/robeerob
Robert Axelsen
@robaxelsen
Mar 26 2016 11:01
You are most welcome, @JADSN :)
Olawale Akinseye
@brainyfarm
Mar 26 2016 11:12
wiki friendly
CamperBot
@camperbot
Mar 26 2016 11:12

:point_right: algorithm friendly date ranges [wiki]

Problem Explanation:

  • Create a program that will take two dates and convert them into a more easy to understand date such as January 1st, 2017. It will also check the difference between them, and handles cases with no difference, more than a day, more than a month, more than a year, and more than a month and less than a year respectively.
:pencil: read more about algorithm friendly date ranges on the FCC Wiki
Brendan Kinahan
@BKinahan
Mar 26 2016 11:16
wiki unfriendly
CamperBot
@camperbot
Mar 26 2016 11:16
no wiki entry for: unfriendly
Olawale Akinseye
@brainyfarm
Mar 26 2016 11:27
Friendly date Stupid code :(
It works but I do not like it
function makeFriendlyDates(arr) {

var date1 = arr[0].split("-");
var date2 = arr[1].split("-");

var date1Day = date1[2];
var date2Day = date2[2];

var date1Month = date1[1];
var date2Month = date2[1];

var date1Year = date1[0];
var date2Year = date2[0];  


// Here is a sub function I made to convert number cardinal into ordinal numbers.
function getOrdinal(num){

var series = ["st","nd","rd", "th"];

num = parseInt(num);

  return num > 20 || num == 1 || num == 3 ? num % 10 <= 3 ? num + series[num % 10 - 1] : num + series[3] : num + series[3];

}

// List of months to enable smooth conversion later.
var month = ["January","February","March","April","May","June","July",
    "August","September","October","November","December"];

// Dates as JS date.
var firstDate = new Date(arr[0]);
var secondDate = new Date(arr[1]); 

// Dates value in timestamp
var firstDateNum = firstDate.getTime();
var secondDateNum = secondDate.getTime();

// Difference between dates in time stamp
  // (1000 * 60 * 60 * 24) converts to regular 24 hours day.
var differenceInDates =  Math.round((secondDateNum - firstDateNum) / (1000 * 60 * 60 * 24));

if(differenceInDates === 0){
    return [month[date1Month -1] + " " + getOrdinal(date1Day) +", " + date1Year];    
}

if(differenceInDates === 365 || differenceInDates === 366 && date1Month === date2Month && date1Day === date2Day){
  return [month[date1Month -1] + " " + getOrdinal(date1Day) + ", " + date1Year, month[date2Month -1] + " " + getOrdinal(date2Day) + ", " + date2Year];

}
if(date1Year === date2Year && date1Month === date2Month ){
        return [month[date1Month -1] + " " + getOrdinal(date1Day),  getOrdinal(date2Day)];
}

if(differenceInDates > 365 && date1Month !== date2Month){
        return [month[date1Month -1] + " " + getOrdinal(date1Day) + ", " + date1Year, month[date2Month -1] + " " + getOrdinal(date2Day) + ", " + date2Year];
}
if(differenceInDates < 365 && date1Year !== date2Year){
  if(differenceInDates < 90){
            return [month[date1Month -1] + " " + getOrdinal(date1Day) , month[date2Month -1] + " " + getOrdinal(date2Day) ];

  }

        return [month[date1Month -1] + " " + getOrdinal(date1Day) + ", " + date1Year, month[date2Month -1] + " " + getOrdinal(date2Day) ];

}

  if(differenceInDates < 365 && date1Year == date2Year){

     return [month[date1Month -1] + " " + getOrdinal(date1Day) + ", " + date1Year, month[date2Month -1] + " " + getOrdinal(date2Day) ];

  }
    //return differenceInDates;
}
//yyyy-mm-dd
makeFriendlyDates(["2017-03-01", "2017-05-05"]);
ajaybti
@ajaybti
Mar 26 2016 11:49

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0;i<arr.length;i++) {
for(var j=0;j<arr[i].length;j++)

product= product*arr([i][j]);
// Only change code above this line
return product;
}
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

stucked here.gives error arr is not a function..help plz

Olawale Akinseye
@brainyfarm
Mar 26 2016 11:50
@ajaybti
product= product*arr[i][j];
And remember @ajaybti to return product outside of the loop otherwise, the loop would only run once.
ajaybti
@ajaybti
Mar 26 2016 11:54
ya its works thanks alot@brainyfarm
@brainyfarm thanks
CamperBot
@camperbot
Mar 26 2016 11:54
ajaybti sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1689 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Mar 26 2016 11:55
Interesting @ajaybti :D
Pete
@petegarvin1
Mar 26 2016 11:55
hi all, can someone help me understand why this code doesn't return the right value? it works for the sub 12 category... and the elderly one, but anything in-between isn't working...
function describeAge(age) {
  var ages = ["You're a(n) kid", "You're a(n) teenager", "You're a(n) adult", "You're a(n) elderly"];
  var respond = age<=12 ? ages[0] : (ages<=17 ? ages[1] : (ages<=64 ? ages[2] : ages[3]));
return respond;
}

describeAge(16);
Olawale Akinseye
@brainyfarm
Mar 26 2016 11:58
@Spacecamel100
Your conditions are not correct.
Pete
@petegarvin1
Mar 26 2016 11:59
@brainyfarm thats what i assumed. can't tell why though...
@brainyfarm I've never used ternary conditions before, never mind trying to nest them
Olawale Akinseye
@brainyfarm
Mar 26 2016 12:02
I think the order of your condition is the problem @Spacecamel100 .
Hold on.
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 26 2016 12:07
Hi everyone, I'm doing the Falsy Bouncer challenge and I'm stuck: my code isn't working:
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  arr = arr.filter(function(value){
  switch(value){
    case false:
    case null:
    case 0:
    case "":
    case undefined:
    case NaN:
    bool = false;
      break;
    default:
      bool = true;
  }
  return bool;
});
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:10
Can I get some help with the “Show the Local Weather” challenge?
Olawale Akinseye
@brainyfarm
Mar 26 2016 12:14
@thomlom
You cannot reliable check for NaN using a switch statement because you have to check for type as well.
Did you fix your code already @Spacecamel100 ?
What issue do you have @ramsaysewell ?
Pete
@petegarvin1
Mar 26 2016 12:15
@brainyfarm nope still trying
@brainyfarm trying to rule our a parenthesis position issue
@brainyfarm got it!
:D
lockee14
@lockee14
Mar 26 2016 12:18
hi freecode
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:18
@brainyfarm Working with the API.
lockee14
@lockee14
Mar 26 2016 12:19
i'm failing at calling the json object for the weather page i have to do
and i'm sure it's because of a stupide mistake...
should i kill myself?
negyvenketto
@negyvenketto
Mar 26 2016 12:21
@lockee14 definitely not
@lockee14 codepen link?
lockee14
@lockee14
Mar 26 2016 12:22
i do exactly the same as in the tutorial, just replace the link "api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=1111111111" by this one for example
negyvenketto
@negyvenketto
Mar 26 2016 12:23
@lockee14 can you pls show us your pen with the code?
lockee14
@lockee14
Mar 26 2016 12:24
$(document).ready(function() {
    $.getJSON("api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=1111111111", function(json) {
        $("#weather").html(JSON.stringify(json));
    });
});
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:25
You don’t have a #weather div set up...
lockee14
@lockee14
Mar 26 2016 12:26
nop it's note that, i just have save the pen and replace weather
there was an other thing
negyvenketto
@negyvenketto
Mar 26 2016 12:26
@lockee14 that's not a valid APPID at the end of your link
@lockee14 you need your own
lockee14
@lockee14
Mar 26 2016 12:27
that's not the problem, it should answer me something
like
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}
Olawale Akinseye
@brainyfarm
Mar 26 2016 12:27
@Spacecamel100
function describeAge(age) {
  var ages = ["You're a(n) kid", "You're a(n) teenager", "You're a(n) adult", "You're a(n) elderly"];
  var respond = (age > 64 ) ?  ages[3] :  age > 17 ? ages[2] : age > 12 ? ages[1] : age > 0 ? ages[0] : "";

  return respond;
}
describeAge(18);
sorry
Olawale Akinseye
@brainyfarm
Mar 26 2016 12:28

should i kill myself?

No @lockee14 :P

Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:28
should be $(‘.weather')
lockee14
@lockee14
Mar 26 2016 12:28
crap not that too xD also forget to put id
in place of class
still doesnt work
<div id="weather">reheh</div>

$(document).ready(function() {
  $.getJSON("api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=1111111111", function(json) {
    $("#weather").html(JSON.stringify(json));
  });
});
maybe i should ask to a shaman or some kind of voodoo wizard...
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:31
@lockee14 I’m stuck on the same one. No idea where to start. Need to do some w3chools revision.
negyvenketto
@negyvenketto
Mar 26 2016 12:31
@lockee14 try putting "http://" in front of your link?
lockee14
@lockee14
Mar 26 2016 12:31
already done before
negyvenketto
@negyvenketto
Mar 26 2016 12:32
@lockee14 i think you have multiple issues
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:32
it has to be something wrong with the JSON.stringify()
put the link in your browser.
with the correct apikey
negyvenketto
@negyvenketto
Mar 26 2016 12:32
@lockee14 i mean i tried in my own code: it doesn't work without the http:// it doesn't work without the correct api key
lockee14
@lockee14
Mar 26 2016 12:33
@ramsaysewell with the correct api key the browser show me the object, like it should do
ok
i try
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:33
@lockee14 yes, so there must be something wrong with the stringify()
lockee14
@lockee14
Mar 26 2016 12:34
i can see the object with my browser, but it still dont work in my code
negyvenketto
@negyvenketto
Mar 26 2016 12:34
@lockee14 try using a document ready?
nevermind
you are using it...
@lockee14 actually, the problem is before the stringify. it won't even console.log the data
lockee14
@lockee14
Mar 26 2016 12:38
i really dont know where the issue is supose to be...
negyvenketto
@negyvenketto
Mar 26 2016 12:39
i'm still looking at it. and feeling determined.
copied your link in my code. codepen's console said "Log Skipped: Sorry, this log was too large for our console. You might need to use the browser console instead." @lockee14
but your's doesn't say that, so there's something with the rest of the code
negyvenketto
@negyvenketto
Mar 26 2016 12:44
@lockee14 have you added jquery in the settings?
lockee14
@lockee14
Mar 26 2016 12:44
yep
holy fuck
noooooooo
it work!
hahahaha
negyvenketto
@negyvenketto
Mar 26 2016 12:45
yaaaaay
lockee14
@lockee14
Mar 26 2016 12:45
i was sure it was a stupid thing xD
thank you very much @negyvenketto
CamperBot
@camperbot
Mar 26 2016 12:45
lockee14 sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 322 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
lockee14
@lockee14
Mar 26 2016 12:45
i was stuck on it since yesterday...
i'm feeling so dumb right no xD
negyvenketto
@negyvenketto
Mar 26 2016 12:45
i made the same mistake with bootstrap, and needed help to find that... :D
lockee14
@lockee14
Mar 26 2016 12:46
no i can go forward : D
now*
negyvenketto
@negyvenketto
Mar 26 2016 12:46
:+1:
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:47
@lockee14 I’m still a step behind you ;(
lockee14
@lockee14
Mar 26 2016 12:48
you still cant to call the json object? @ramsaysewell
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:48
@lockee14 I’m looking at your code and I need to understand what it’s doing before I move on. It works but… Want to get my head round it.
negyvenketto
@negyvenketto
Mar 26 2016 12:49
@ramsaysewell do you have specific questions?
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:51
@negyvenketto Where can I learn about JSON lol.
negyvenketto
@negyvenketto
Mar 26 2016 12:52
@ramsaysewell oh, well, that's a very good question. after reading about it for hours i made a developer explain it to me...
Pete
@petegarvin1
Mar 26 2016 12:52
@brainyfarm thanks - i got there in the end! code won't pass however, apparently it needs to be sub 137 characters!!
CamperBot
@camperbot
Mar 26 2016 12:52
spacecamel100 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1690 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:52
@negyvenketto and… what did they say?
negyvenketto
@negyvenketto
Mar 26 2016 12:53
@ramsaysewell ok, i'll try to explain it shortly, and hopefully it won't be too unprofessional
@ramsaysewell an api call looks like this: $.getJSON("url", function(data) {things you want to do with your data})
what happens, is that you use a link, at the end of which there's some data that you need, and if you use it in this format, it will magically end up un the argument of your function, ready for you to work with
Ramsay Sewell
@ramsaysewell
Mar 26 2016 12:57
@negyvenketto Okay, so with the current example, how would I get say… the city?
negyvenketto
@negyvenketto
Mar 26 2016 12:58
@ramsaysewell i suggest using coordinates instead of city id, and for that there was a challenge
getting geolocation or something like that
@ramsaysewell "Get Geo-location Data"
and you can use those coordinates in the link of the weather api call
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:00
@negyvenketto Okay, thanks!
CamperBot
@camperbot
Mar 26 2016 13:00
ramsaysewell sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 323 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
negyvenketto
@negyvenketto
Mar 26 2016 13:01
@ramsaysewell glad to help :)
Sander Visser
@sanderfish
Mar 26 2016 13:11
Does anyone ever uses switch statements in real coding project?
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:13
@negyvenketto This is as far as I got? How I then select what I want from the object? http://codepen.io/sewellramsay/pen/xVrqPM?editors=0010
Aleksandar B.
@aleksandar-b
Mar 26 2016 13:14
@sanderfish yes
in react with redux or flux
Sander Visser
@sanderfish
Mar 26 2016 13:15
@samosale so they are more useful there than in vanilla JS?
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 26 2016 13:15
Can someone help me for the challenge Falsy bouncer?
function bouncer(arr) {

arr = arr.filter(function(value){
  if (value === false || value === undefined || value === 0 || value === null || value === ""){
    return false;
  }
  else{
    return true;
  }
});
  return arr;
} 

bouncer([false, null, 0, NaN, undefined, ""])
Sander Visser
@sanderfish
Mar 26 2016 13:15
because I have never seen them in vanilla JS before
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 26 2016 13:16
I don't know how to filter NaN
Aleksandar B.
@aleksandar-b
Mar 26 2016 13:16
@sanderfish i don't know, they are the same thing as if else but, it is more readable than if else, also it is used in other languages
@thomlom you can't
Brendan Kinahan
@BKinahan
Mar 26 2016 13:17
@thomlom there is an isNaN() method, but filter will coerce values to booleans anyway, so you only need to know about falsy in javascript.
Aleksandar B.
@aleksandar-b
Mar 26 2016 13:17
@thomlom there is a strange thing with Nan
Nan is never equal to NaN :stuck_out_tongue:
Josh Lee
@jleewebdev
Mar 26 2016 13:17
Are there any good sources for learning sessions and authentication?
Sander Visser
@sanderfish
Mar 26 2016 13:17
Ah I see. The way FCC writes them in the explanation makes them still unreadable in my opinion.
This message was deleted
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 26 2016 13:19
@BKinahan I know there is an isNaN method but then strings are filtered too!
@samosale So how do I filter NaN then ? :)
Aleksandar B.
@aleksandar-b
Mar 26 2016 13:20
@BKinahan said to you
it will coerse values to booleans because they are all falsey values
google about falsey values in js
Brendan Kinahan
@BKinahan
Mar 26 2016 13:21
wiki falsy
CamperBot
@camperbot
Mar 26 2016 13:21

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 26 2016 13:22
@samosale @BKinahan I see, I've resolved the challenge! Thanks a lot for your help :)
CamperBot
@camperbot
Mar 26 2016 13:22
thomlom sends brownie points to @samosale and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 580 | @samosale | http://www.freecodecamp.com/samosale
:star: 1151 | @bkinahan | http://www.freecodecamp.com/bkinahan
negyvenketto
@negyvenketto
Mar 26 2016 13:22
@ramsaysewell there's a trick to see if you are getting your data: try to console.log it as is. that way you will see that your geolocation is working just fine, but you are not getting your weather data
Brendan Kinahan
@BKinahan
Mar 26 2016 13:22
That 'falsy' link in blue there has more info about falsy :)
Aleksandar B.
@aleksandar-b
Mar 26 2016 13:23
@jleewebdev i am trying to find out that also
negyvenketto
@negyvenketto
Mar 26 2016 13:28
@ramsaysewell there are 2 reasons for this.
1: you are trying to use a variable (lat, lon) outside the function you created them in.
2: api calls are asynchronous, meaning that it takes time for your data to arrive, so your computer uses that time by executing the rest of your code. this means that while you are waiting for your coordinates to arrive, your weather api call is already being made. solution: put everything inside the function in your api call.
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:28
@negyvenketto Okay, I see where I went wrong.
@negyvenketto But how do I retrieve specific data?
negyvenketto
@negyvenketto
Mar 26 2016 13:29
@ramsaysewell what do you mean?
you will have an object with the data for the position you've given in the api call
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:37
@negyvenketto And what do I use to get specific elements in that object?
negyvenketto
@negyvenketto
Mar 26 2016 13:38
@ramsaysewell you use object notation. either object.property or object[property]
it behaves just like every object you encountered in the ffc challenges
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:39
Ah okay, thank you.
negyvenketto
@negyvenketto
Mar 26 2016 13:39
yw
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:40
and what’s the object called? json.property?
negyvenketto
@negyvenketto
Mar 26 2016 13:41
@ramsaysewell in your case it's called json, because that's what you've put as the argument of the function
Ramsay Sewell
@ramsaysewell
Mar 26 2016 13:42
@negyvenketto I seeee! Should have just tried that in the first place.
Violet.Lee
@Violet-Bora-Lee
Mar 26 2016 13:51
thanks @leftynaut for your help with Checkpoint: Record Collection
CamperBot
@camperbot
Mar 26 2016 13:51
violet-bora-lee sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 457 | @leftynaut | http://www.freecodecamp.com/leftynaut
Theodore P.
@Ierofantis
Mar 26 2016 14:14


function chunkArrayInGroups(arr, size) {
  // Break it up.

  var slice=arr.slice(0, size);
  var arrpush=slice.push(arr);

  for(var i=0; arr.length; i++)

 { 
  return slice;
 }

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
where Am I wrong
the output is

["a","b",["a","b","c","d"}}
]] in the end not }}
Javier Sanchez
@javiermxmd
Mar 26 2016 14:18
You don't neet the variable slice
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 26 2016 14:23
@Ierofantis Maybe you should use splice instead of slice
Javier Sanchez
@javiermxmd
Mar 26 2016 14:24
    • declare a new empty arr
Theodore P.
@Ierofantis
Mar 26 2016 14:25
@javiermxmd @thomlom I will first do that with the empty array It sounds a good Idea and after I will test It later with splice thanks
CamperBot
@camperbot
Mar 26 2016 14:25
ierofantis sends brownie points to @javiermxmd and @thomlom :sparkles: :thumbsup: :sparkles:
:star: 263 | @javiermxmd | http://www.freecodecamp.com/javiermxmd
:star: 278 | @thomlom | http://www.freecodecamp.com/thomlom
Javier Sanchez
@javiermxmd
Mar 26 2016 14:26
then declare another var size = 0 to compare with arr size
you can use for or while to check the increments .
Maddah Anass
@unlimiworks
Mar 26 2016 14:28
there is always more than 1 way though.
Hello everyone !
Javier Sanchez
@javiermxmd
Mar 26 2016 14:30
while (i < arr.length){
newArr.push(arr.slice(0,size));
     i = i+size;
}
Marcus Nielsen
@marcusnielsen
Mar 26 2016 14:31
@joaocastanho: https://medium.com/@marcus.nielsen82/how-do-you-get-a-job-as-a-web-developer-494aec72c4f4#.74bpkxpw5
Just something to answer your question of how to get a job. Don’t know if it’s detailed enough for you.
We also covered it a bit on the video cast, somewhere in the end I think: https://www.youtube.com/watch?v=4yPypTUfW7A&index=1&list=PLtF1CGLB1pfMaVZkoTEXmLCvQ5G3Ide_A
If you think you are ready to apply for jobs, you can tweet me @marcusnielsen for an online trial interview, but then I want a complete CV, sample code, introductory letter and all ;-)
Theodore P.
@Ierofantis
Mar 26 2016 14:44
I did something like this. It is correct in some points but It has some mistakes

function chunkArrayInGroups(arr, size) {
  // Break it up.

  var slice=arr.slice(0, size);
  var slice1=arr.slice( size);
  var array=[];


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

 {  
  array.push(slice,slice1);


  return array;
 }
}
Muluberhan Yonas
@Howmuchadollarcost
Mar 26 2016 14:48
Yo people im stuck in the counting card challegne
challenge
Ramsay Sewell
@ramsaysewell
Mar 26 2016 14:49
What is the difference between JSON.stringify and JSON.parse?
Jesus Arteaga
@HecticHiccups
Mar 26 2016 14:53
how do i post the code i'm working on here?
cuz i need some assistance. :x:
:worried:
Ramsay Sewell
@ramsaysewell
Mar 26 2016 14:54
help format
CamperBot
@camperbot
Mar 26 2016 14:54

: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

Eric Murta
@murtinha
Mar 26 2016 14:54
guys, on Twitch.tv JSON API there are some channels that return string null, I saw that you have to do a json inside other json... how does it work?
arcjackson06
@arcjackson06
Mar 26 2016 14:55
var p = 0;
function chunkArrayInGroups(arr, size) {
  // Break it up.

  function setUpArr(){
  var newArr = [];
  for (i=0; i < Math.ceil(arr.length/size); i++){
    newArr.push([]);

     }
       return newArr;
  }

  function arrayPass(){

       var val = arr[p];
       p = p + 1;
      return val;



  }

 var toChunk = setUpArr();



 for (j = 0; j < toChunk.length; j++){
    for ( k = 0; k < size; k++){
    if (arr[p] !== null){
     toChunk[j].push(arrayPass());
      }
    }
  }

return toChunk;



}

chunkArrayInGroups( [0 , 1, 2, 3, 4, 5], 4);
Can someone tell me why the program continues to .push null elements?
Jesus Arteaga
@HecticHiccups
Mar 26 2016 14:56

```// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. " + "This is the second sentence.";

nope got it wrong

`// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. " + "This is the second sentence.";`

hmm
Eric Murta
@murtinha
Mar 26 2016 14:57
shift enter after the 3 backticks
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 14:58
@HecticHiccups and you forgot the closing backticks
Jesus Arteaga
@HecticHiccups
Mar 26 2016 14:59

```
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. " + "This is the second sentence.";

``

Ramsay Sewell
@ramsaysewell
Mar 26 2016 14:59
http://codepen.io/sewellramsay/pen/xVrqPM?editors=0010 what would I need to use to get the main element for this?
Jesus Arteaga
@HecticHiccups
Mar 26 2016 14:59
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. " + "This is the second sentence.";
yay
okay so i need to concat using "+="
GoranM88
@GoranM88
Mar 26 2016 15:00
Hi, would need help on Where art thou javascript problem.
Jesus Arteaga
@HecticHiccups
Mar 26 2016 15:00
Concatenating Strings with the Plus Equals Operator
Markus Kiili
@Masd925
Mar 26 2016 15:00
@GoranM88 Ask away.
Jesus Arteaga
@HecticHiccups
Mar 26 2016 15:01
thats the example
i'm on
anyone help :o: ?
GoranM88
@GoranM88
Mar 26 2016 15:03
′′′
Niko Salonen
@nikosalonen
Mar 26 2016 15:03
@HecticHiccups you are not using Plus Equals
GoranM88
@GoranM88
Mar 26 2016 15:03

′′′
function where(collection, source) {
var arr = [];
// What's in a name?
//var check = Object.keys(source).length;
//var final_match = [];
var source_keys = Object.keys(source);
//var final_match = [];
var match = [];

for (var i = 0; i < collection.length; i++) {
var collection_keys = Object.keys(collection[i]);
var c = 0;
if (collection_keys.length >= source_keys.length) {
for (var key1 in collection_keys) {
for (var key2 in source_keys) {
if (key1 == key2 && collection[i][key1] == source[key2]) {
c += 1;
}
}
}
}
if (c == Object.keys(source).length) {
match.push(collection[i]);
}
}
return match;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
′′′

I can get correct answer only for two of the problems
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:05
@HecticHiccups try to do the same like in the example above
@HecticHiccups you need two lines of code
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:06
@Masd925 Can you help with this please? http://codepen.io/sewellramsay/pen/xVrqPM?editors=0010
Markus Kiili
@Masd925
Mar 26 2016 15:06
@GoranM88 You should have a loop through collections and inside that another loop through the source keys. Then check if the property values match.
@GoranM88 You can use loops or array iterators.
GoranM88
@GoranM88
Mar 26 2016 15:06
i use two for loops
i also have a counter
Bil
@thebiltheory
Mar 26 2016 15:07
Heyyyy
I managed to finish JS!
GoranM88
@GoranM88
Mar 26 2016 15:07
so that all the keys in the source have to be in the object
Bil
@thebiltheory
Mar 26 2016 15:07
Algorithmic
is quite different haha
function palindrome(str) {
  // Good luck!

  var strSplit = str.split("");
  var strRev = strSplit.reverse();
  var strJoin = strRev.join("");
  var palinCheck = strJoin.toLowerCase(strJoin);

  if(str === palinCheck){
     console.log(palinCheck); 
    return true;
  }else {
    console.log(palinCheck);
    return false;
  }



}
Can someone review this please?
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:08
@thebiltheory Does it not work?
hrokr
@hrokr
Mar 26 2016 15:09
@constantijn-asamoah -- this is one of two lesson so far that I've found to not be as easily graspable at the rest. I think it could be explained better but that really is the point of an OS program -- it can be modified and improved.
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:09
@ramsaysewell what's your problem?
Jesus Arteaga
@HecticHiccups
Mar 26 2016 15:09
thanks i just realized ...
:shipit:
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:09
@paulharfenmeister How would I print out the main component?
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:11
@ramsaysewell try to remove the JSON.stringify
Markus Kiili
@Masd925
Mar 26 2016 15:11
@GoranM88 You have three loops there. Two nested loops and a check is enough.
Micah Bales
@micahbales
Mar 26 2016 15:12
Can anyone explain why the logos aren't showing up for my offline streams in this pen? http://codepen.io/micahbales/pen/ONmXry?editors=0010
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:13
@paulharfenmeister But see how it’s printing out [{“id”: blah “main”, “Blah"}]
GoranM88
@GoranM88
Mar 26 2016 15:13
@Masd925 I have one loop to go through the object in collection, second to go through the keys in the object and the third to go through the keys in the source.
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:13
@ramsaysewell How would I get the ”main”?
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:14
@ramsaysewell you have to navigate throught the object and arrays
Markus Kiili
@Masd925
Mar 26 2016 15:14
@GoranM88 You don't need a loop through the keys of the object in collection. You only need to check the source keys.
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:14
@paulharfenmeister How do I get an object inside of an array?
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:15
@ramsaysewell like getting the first element of an array
GoranM88
@GoranM88
Mar 26 2016 15:15
@Masd925 How do I then check if all the source keys are in the object?
Markus Kiili
@Masd925
Mar 26 2016 15:16
@GoranM88 By looping source keys and comparing the property values of object and source.
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:16
@paulharfenmeister so like main[1]? That isn’t working….
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:17
@ramsaysewell hm
@ramsaysewell print out the whats in variable json
@ramsaysewell and you have a leading JSON, this has to be removed
GoranM88
@GoranM88
Mar 26 2016 15:21

@Masd925 function where(collection, source) {
var arr = [];
// What's in a name?
var match = [];

for (var i = 0; i < collection.length; i++) {
var c = 0;
for (var key in Object.keys(source)) {
if (key in Object.keys(collection[i])) {
c += 1;
}
}
if (c == Object.keys(source).length) {
match.push(collection[i]);
}
}
return match;
}

Micah Bales
@micahbales
Mar 26 2016 15:21
Can anyone explain why the logos aren't showing up for my offline streams in this pen? http://codepen.io/micahbales/pen/ONmXry?editors=0010
Markus Kiili
@Masd925
Mar 26 2016 15:22
@GoranM88 Ok. I check it.
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:22
@paulharfenmeister What do you mean a leading JSON? I’ve got JSON.stringify(son.main[1].main);
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:24
@ramsaysewell first take a look at your json-data by displaying JSON.stringify(json)
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:24
@paulharfenmeister yes?
asaki444
@asaki444
Mar 26 2016 15:24
```
Bil
@thebiltheory
Mar 26 2016 15:25
@ramsaysewell work's for some part but now everything
sotol007
@sotol007
Mar 26 2016 15:25
Hello, please help me with this tsk, thx. Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
function queue(arr, item) { queue (arr, item);
}
queue.push();
queue = queue.pop([0]);
// Test Setup
var testArr = [1,2,3,4,5];
asaki444
@asaki444
Mar 26 2016 15:25
function diff(arr1, arr2) {
  var newArr = [];
  for(var i = 0; i < arr2.length; i++){
    if(arr2.indexOf(arr1[i]) == -1){
      newArr.push(arr1[i]);
    }
    else if(arr1.indexOf(arr2[i])== -1)
      {
        newArr.push(arr2[i]);
      }
  }
  // Same, same; but different.
  return newArr.filter(Boolean);
}

diff([], ["snuffleupagus", "cookie monster", "elmo"]);
This runs for a couple but does not pass all checks
Markus Kiili
@Masd925
Mar 26 2016 15:25
@GoranM88 You are checking only that the source keys exist. The property values should also be checked to be same.
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:25
@ramsaysewell could you paste your json-content here
asaki444
@asaki444
Mar 26 2016 15:26
this is the diff of arr algorithms
Javier Sanchez
@javiermxmd
Mar 26 2016 15:26
@sotol007 to remove first element you need to use
 arr.shift()
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:27
{"coord":{"lon":-3.96,"lat":56.19},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"cmc stations","main":{"temp":290.56,"pressure":984,"humidity":87,"temp_min":283.15,"temp_max":299.15},"wind":{"speed":5.1,"deg":190},"rain":{"3h":4.065},"clouds":{"all":92},"dt":1459003800,"sys":{"type":3,"id":5122,"message":0.0032,"country":"GB","sunrise":1458971966,"sunset":1459017847},"id":2650769,"name”:"blah","cod":200}
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:28
@ramsaysewell remember, first element of array has index 0, not 1
ali
@ahamidizadeh
Mar 26 2016 15:28
can someone help me ?

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

function checkObj(checkProp) {
myObj.hasOwnProperty("gift");// Your Code Here

return myObj["gift"];
}

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

Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:29
@paulharfenmeister I’m trying to get where it says, “Rain"
Jesus Arteaga
@HecticHiccups
Mar 26 2016 15:29
does anyone know how to implement number of hits to a webpage?
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:29
@ramsaysewell so you want: json.weather[0].main
sotol007
@sotol007
Mar 26 2016 15:29
@javiermxmd how do i assign removed item to a queue
In this case
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:30
@paulharfenmeister You’re a wizard.
@paulharfenmeister How can I remove the quotation marks?
Javier Sanchez
@javiermxmd
Mar 26 2016 15:31
@sotol007 do it before you remove the first element
arr2.push(arr1[0]);
 arr1.shift();
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:31
@ramsaysewell remove the JSON.stringify completly
GoranM88
@GoranM88
Mar 26 2016 15:32

@Masd925 function where(collection, source) {
var arr = [];
// What's in a name?
var match = [];

for (var i = 0; i < collection.length; i++) {
var c = 0;
for (var key in Object.keys(source)) {
if ((key in Object.keys(collection[i])) && source[key] == collection[i][key]) {
c += 1;
}
}
if (c == Object.keys(source).length) {
match.push(collection[i]);
}
}
return match;
}

Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:33
@ramsaysewell looks good!
GoranM88
@GoranM88
Mar 26 2016 15:33
@Masd925 Still not working
Ben Da Rosa
@b3nasaurus
Mar 26 2016 15:34
having a problem displaying data from this api request, any help?
$.getJSON("api.openweathermap.org/data/2.5/weather?q=" + city + "," + country + "&APPID=c533034f949ce42829f55e8a828b7c36", function(data) {
    $(".json").append("<h3>"+data.name+"</h3>")
  })
ali
@ahamidizadeh
Mar 26 2016 15:34
how do I text objects for properties?
test
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:36
@b3nasaurus how is the data looking
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:36
@paulharfenmeister You see the temperature? How it’s 291… Do I need to convert this into something or use a function?
Ben Da Rosa
@b3nasaurus
Mar 26 2016 15:37
well the object returns :
{"coord":{"lon":-71.18,"lat":42.37},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"base":"cmc stations","main":{"temp":277.08,"pressure":1027,"humidity":60,"temp_min":275.15,"temp_max":278.15},"wind":{"speed":2.1,"deg":20},"clouds":{"all":90},"dt":1459002921,"sys":{"type":1,"id":1272,"message":0.006,"country":"US","sunrise":1458988540,"sunset":1459033502},"id":4954611,"name":"Watertown","cod":200}
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:38
@ramsaysewell looks like the temp is in kelvin
Ramsay Sewell
@ramsaysewell
Mar 26 2016 15:38
@paulharfenmeister Very well done!
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:40
@b3nasaurus should work
Ben Da Rosa
@b3nasaurus
Mar 26 2016 15:40
right, but i cant get it to display in my html
ali
@ahamidizadeh
Mar 26 2016 15:40
can someone help me with testing objects for properties?
Paul Harfenmeister
@paulharfenmeister
Mar 26 2016 15:41
@b3nasaurus have you a link to your codepen?
wait
lol
forgot to save it
its g