These are chat archives for FreeCodeCamp/HelpJavaScript

27th
May 2016
Carly
@cbogsin
May 27 2016 00:00
@coymeetsworld but the problem is that I can't get the channel name for the call if I put the loop inside the call. How will the call know what channel to put in the URL?
Thompson Ike
@hubhubace
May 27 2016 00:00
@coymeetsworld hi
Carly
@cbogsin
May 27 2016 00:00
@coymeetsworld oh hm
Thompson Ike
@hubhubace
May 27 2016 00:00
pls check this out
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:00
Hello, I am working on Bonfire-Binary-Agents challenge and I was wondering if there is any way I can make this more simple?
'01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111’
    .split` `
        .map(str => String.fromCharCode([...str].reverse().reduce((prev, next, i) => +prev + +next * Math.pow(2, i))))
        .join``
Thompson Ike
@hubhubace
May 27 2016 00:00
js

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

function checkObj(checkProp) {
  // Your Code Here

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

// Test your code by modifying these values
checkObj("pet");
Coy Sanders
@coymeetsworld
May 27 2016 00:00
you can use the data you grabbed from first call (i.e. thumb is what you're calling it)
sorry @hubhubace have to go real quick early dinner
bbl
Thompson Ike
@hubhubace
May 27 2016 00:01
ok then enjoy
Carly
@cbogsin
May 27 2016 00:01
@coymeetsworld but even thumb needs to know which channel to call doesn't it?
Coy Sanders
@coymeetsworld
May 27 2016 00:01
its in there
Thompson Ike
@hubhubace
May 27 2016 00:01
guys anyone have idea on this?
challenge testing Object properties
Dan Couper
@DanCouper
May 27 2016 00:03

@poigirl2001 the console prints messages re stuff happening on the page as well, so when you’re building things, you log errors/info, and the messages appear there.

And you can access elements on the webpage you have a console open on, and manipulate them if you want. For example, if you’ve got freecodecodecamp open, it uses jQuery as one of the JS libraries (along with D3 and RXJS) - you have access to jQuery (and the rest of the libraries as well) in the console, so you can play around with their functionality.

Diego Mayer
@Chrono79
May 27 2016 00:03
@usandfriends
return str.split(" ").map(el => String.fromCharCode(parseInt(el, 2))).join("");
Thompson Ike
@hubhubace
May 27 2016 00:03
@Chrono79 hi
pls look at this
js

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

function checkObj(checkProp) {
  // Your Code Here

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

// Test your code by modifying these values
checkObj("pet");
Testing Objects for Properties
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:04
@Chrono79 Yeah, that’s what I went with first. Then I gave myself a challenge to not use parseInt
Diego Mayer
@Chrono79
May 27 2016 00:04
@usandfriends you like to suffer eh? ;)
Thompson Ike
@hubhubace
May 27 2016 00:04
@Chrono79 lol
Diego Mayer
@Chrono79
May 27 2016 00:05

@hubhubace

  myObj.hasOwnProperty("checkProp"); //remove the quotes
    if (checkProp === true) { // and put the above line inside this brackets replacing what's inside now

Also, you can't use dot notation here: return myObj.checkProp;

Ken Haduch
@khaduch
May 27 2016 00:06
@hubhubace - when you have a function argument checkProp, and you want to use it within a function, you do not want to use it as a string value, that is, you DO NOT want to write "checkProp" - you want it without the quotes. That is one thing that you have incorrect here.
Thompson Ike
@hubhubace
May 27 2016 00:06
ok
next please?
what next?
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:07
@Chrono79 Yeah ahaha. Okay, got it a bit more simpler by using bit shift:
'01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111'
    .split` `
        .map(str => String.fromCharCode([...str].reverse().reduce((prev, next, i) => +prev + (next << i))))
        .join``
Dan Couper
@DanCouper
May 27 2016 00:08
oh god my eyes
Diego Mayer
@Chrono79
May 27 2016 00:08
@usandfriends yes, when working with binary bit shift becomes useful
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:08
Anyone here code golfs?
Daniel Godigna
@DGAcode
May 27 2016 00:09
Hello guys
Brendan Kinahan
@BKinahan
May 27 2016 00:10
howdy
Daniel Godigna
@DGAcode
May 27 2016 00:10
having some problems here " Introducing JavaScript Object Notation JSON "
Thompson Ike
@hubhubace
May 27 2016 00:10
@khaduch got that
what next?
Daniel Godigna
@DGAcode
May 27 2016 00:10

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

var myMusic = [
  {
    "artist": "Nirvana",
    "title": "Nervermind",
    "release_year": 1991,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
Diego Mayer
@Chrono79
May 27 2016 00:10
@33hawk add the second object inside var myMusic, the first one
Brendan Kinahan
@BKinahan
May 27 2016 00:11
@33hawk you should add another object inside the myMusic array, which already exists, and not declare it again.
Thompson Ike
@hubhubace
May 27 2016 00:11
Why is no one helpin me?
hope we are all equal here?
Diego Mayer
@Chrono79
May 27 2016 00:11
@hubhubace did you fixed what I told you?
Daniel Godigna
@DGAcode
May 27 2016 00:11
@Chrono79 I see thanks a lot I think this one is confusing because the message
CamperBot
@camperbot
May 27 2016 00:11
33hawk sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 881 | @chrono79 |http://www.freecodecamp.com/chrono79
Brendan Kinahan
@BKinahan
May 27 2016 00:12
@33hawk note that you have declared an (already-declared) variable within an array. This is a no-no :P
Thompson Ike
@hubhubace
May 27 2016 00:12
i came before some people with my problem but beign neglected
Diego Mayer
@Chrono79
May 27 2016 00:12
@hubhubace Also, you can't use dot notation here: return myObj.checkProp;
Daniel Godigna
@DGAcode
May 27 2016 00:12
@BKinahan I know but it was because the struggling hahahaha
Thompson Ike
@hubhubace
May 27 2016 00:12
@Chrono79 i fixed the quotation
Brendan Kinahan
@BKinahan
May 27 2016 00:12
@33hawk gotcha ;)
Daniel Godigna
@DGAcode
May 27 2016 00:12
@BKinahan anyway thanks you also
CamperBot
@camperbot
May 27 2016 00:12
33hawk sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1525 | @bkinahan |http://www.freecodecamp.com/bkinahan
Diego Mayer
@Chrono79
May 27 2016 00:13
@hubhubace fix the line where you use dot notation and you can't
Yev
@ymb456
May 27 2016 00:13
Hello All! Can someone please review my random quote ? https://codepen.io/ymb456/full/jqgOWj/
Thompson Ike
@hubhubace
May 27 2016 00:13
@Chrono79 i cant use dot notation ok got that
so what should i use?
i removed the double quotes
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:14
@ymb456 Nice, but I can see the text change before the animation starts.
Diego Mayer
@Chrono79
May 27 2016 00:14
@hubhubace if it's not dot notation, what other notation you know that is used with objects?
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:14
@ymb456 Might want to change the text while the animation is going.
Thompson Ike
@hubhubace
May 27 2016 00:14
brackets
Yev
@ymb456
May 27 2016 00:14
@usandfriends : thank you. Do you know how to do that?
CamperBot
@camperbot
May 27 2016 00:14
ymb456 sends brownie points to @usandfriends :sparkles: :thumbsup: :sparkles:
:cookie: 45 | @usandfriends |http://www.freecodecamp.com/usandfriends
Diego Mayer
@Chrono79
May 27 2016 00:14
bingo, do it
Thompson Ike
@hubhubace
May 27 2016 00:14
which i did but not working
i will post again
Diego Mayer
@Chrono79
May 27 2016 00:14
let's see your code again
Suraj
@suraj-davariya
May 27 2016 00:15
Hello, can anyone tell me what to do here ?
https://www.freecodecamp.com/challenges/word-blanks
Its word blanks challenge
Dan Couper
@DanCouper
May 27 2016 00:16
@ymb456 don’t write prefixes in CSS, go to pen settings, and select autoprefixer then delete all the prefixed versions
Brendan Kinahan
@BKinahan
May 27 2016 00:16
@suraj-davariya Sure, do you know what the instructions mean by 'Mad Libs'?
Thompson Ike
@hubhubace
May 27 2016 00:16
it tells me checkProp is better written in dot notation
Diego Mayer
@Chrono79
May 27 2016 00:16
@hubhubace code please
Thompson Ike
@hubhubace
May 27 2016 00:16

```
js

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

function checkObj(checkProp) {
// Your Code Here

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

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

``

Daniel Godigna
@DGAcode
May 27 2016 00:16
@Chrono79 now I can't see it
Thompson Ike
@hubhubace
May 27 2016 00:17
js


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

function checkObj(checkProp) {
  // Your Code Here

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

// Test your code by modifying these values
checkObj("pet");
Daniel Godigna
@DGAcode
May 27 2016 00:17
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  {
    "artist": "Nirvana",
    "title": "Nervermind",
    "release_year": 1991,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
];
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:17
@ymb456 Yes, wrap the code that changes the quote text with a setTimeout
Brendan Kinahan
@BKinahan
May 27 2016 00:17
@hubhubace that's the improper use of bracket notation. use the variable checkProp, not the string "checkProp"
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:17
Try 200 ms timeout
Thompson Ike
@hubhubace
May 27 2016 00:17
lol
ok
Dan Couper
@DanCouper
May 27 2016 00:17

@ymb456 also, maybe fade the quote out and then back in on a new one - there’s an obvious jump as it spins that’s a bit jarring.

Really nice, though

Yev
@ymb456
May 27 2016 00:17
@DanCouper Nah, I think this will make it harder to move from codepen to fiddler
Brendan Kinahan
@BKinahan
May 27 2016 00:17
@33hawk array elements are separated by commas :D
Yev
@ymb456
May 27 2016 00:17
but thanks for your input
@usandfriends : Thank you! I will definetely do that
CamperBot
@camperbot
May 27 2016 00:18
ymb456 sends brownie points to @usandfriends :sparkles: :thumbsup: :sparkles:
:warning: ymb456 already gave usandfriends points
Daniel Godigna
@DGAcode
May 27 2016 00:18
@BKinahan f** thanks!
CamperBot
@camperbot
May 27 2016 00:18
33hawk sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: 33hawk already gave bkinahan points
Diego Mayer
@Chrono79
May 27 2016 00:18
@hubhubace
myObj.hasOwnProperty(checkProp); // I told you to replace checkProp === true for this line
    if (checkProp === true) {

//like this
    if (myObj.hasOwnProperty(checkProp)) {
Thompson Ike
@hubhubace
May 27 2016 00:18
js

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

function checkObj(checkProp) {
  // Your Code Here

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

// Test your code by modifying these values
checkObj("pet");
Daniel Godigna
@DGAcode
May 27 2016 00:18
done!
Brendan Kinahan
@BKinahan
May 27 2016 00:18
@33hawk awesome
Thompson Ike
@hubhubace
May 27 2016 00:18
but still no luck
us͡an̸df͘rien͜ds͠
@usandfriends
May 27 2016 00:18
@ymb456 I just tried it at 300 ms timeout, it looks really slick. Nice job.
Yev
@ymb456
May 27 2016 00:19
@usandfriends : I will try settimeout stuff. Thanks again!.
CamperBot
@camperbot
May 27 2016 00:19
ymb456 sends brownie points to @usandfriends :sparkles: :thumbsup: :sparkles:
:warning: ymb456 already gave usandfriends points
Brendan Kinahan
@BKinahan
May 27 2016 00:19
@hubhubace myObj.hasOwnProperty(checkProp) should be within that if condition, because it evaluates to either true or false depending on whether myObj has checkProp as one of its own properties.
Dan Couper
@DanCouper
May 27 2016 00:20
@ymb456 is that not set up for autoprefixer as well? Just find it crackers that you need to manually write prefixes, but v0v.
That’s really, really nice though, ridiculously smooth
Yev
@ymb456
May 27 2016 00:20
@DanCouper Thank you. It might be set for autoprefixer. I was thinking in general - how to move this stuff to different hosting...
CamperBot
@camperbot
May 27 2016 00:20
ymb456 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 124 | @dancouper |http://www.freecodecamp.com/dancouper
Thompson Ike
@hubhubace
May 27 2016 00:21
@BKinahan so i should have 2 if statements?
Diego Mayer
@Chrono79
May 27 2016 00:21
@hubhubace no, only one
Brendan Kinahan
@BKinahan
May 27 2016 00:21
@hubhubace no, just one.. replace if (checkProp === true) (checkProp will probably never be the boolean value true anyway)
Thompson Ike
@hubhubace
May 27 2016 00:21
ok
thanks
@BKinahan thanks
CamperBot
@camperbot
May 27 2016 00:21
hubhubace sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1526 | @bkinahan |http://www.freecodecamp.com/bkinahan
Thompson Ike
@hubhubace
May 27 2016 00:22
@Chrono79 thanks
CamperBot
@camperbot
May 27 2016 00:22
hubhubace sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 882 | @chrono79 |http://www.freecodecamp.com/chrono79
elminsterrr
@elminsterrr
May 27 2016 00:24

Hi Guys, can anyone give me a hint what I am missing here?

/ <div id="currentWeather"></div> /

var weather = new XMLHttpRequest();

weather.open("GET", "api.openweathermap.org/data/2.5/weather?lat=50.824180000000005&lon=16.268914499999998&appid=a68f6031804b4a06c46e4944a5599012", false);
weather.send(null);

/* WHAT SHOULD I PUT HERE ??? */


document.getElementById("currentWeather").innerHTML = currentWeather;
Dan Couper
@DanCouper
May 27 2016 00:24
@ymb456 ya, I suppose that is a fair point; I just always build locally then port across to other stuff, and build with Autoprefixer/Babel/Sass/etc. Which is basically what you’re doing here anyway, just manually - I just don’t think I've seen my CSS with prefixes (or my JS in transpiled form) for about 3 years now :\
Yev
@ymb456
May 27 2016 00:24
@DanCouper Make sense.
elminsterrr
@elminsterrr
May 27 2016 00:25
API looks like this: {"coord":{"lon":16.27,"lat":50.82},"weather":[{"id":741,"main":"Fog","description":"fog","icon":"50n"}],"base":"stations","main":{"temp":283.14,"pressure":1017,"humidity":100,"temp_min":280.37,"temp_max":284.82},"visibility":250,"wind":{"speed":0.5},"clouds":{"all":20},"dt":1464308092,"sys":{"type":1,"id":5375,"message":0.0332,"country":"PL","sunrise":1464317456,"sunset":1464375242},"id":3099974,"name":"Dworzysko","cod":200}
Dan Couper
@DanCouper
May 27 2016 00:25
slightly worrying now I think about it, I don’t have a perfect idea of what the end result of my coding looks like...
Joe
@joemanriquez
May 27 2016 00:26
Working on a Waypoint called "Multiple Identical Options in Switch Statements." 1 - 3 is "Low", 4-6 is "Mid", 7-9 is "High." Not sure what I"m doing wrong. Please help.
function sequentialSizes(val) {
  var answer = "";
  // Only change code below this line
  switch(val) {
    case 1:
    case 2:
    case 3:
      result = "Low";
      break;
    case 4:
    case 5:
      result = "Mid";
      break;
    case 7:
    case 8:
    case 9:
      result = "High";
      break;

  }


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

// Change this value to test
sequentialSizes(1);
Dan Couper
@DanCouper
May 27 2016 00:27
You haven’t assigned the result to the answer
I assume it should work if that happens
elminsterrr
@elminsterrr
May 27 2016 00:27
how can I connect this? So far I conneted 1 API to my code, but with openweathermap.org I can't figure it out
Joe
@joemanriquez
May 27 2016 00:29
@DanCouper Thanks!!
CamperBot
@camperbot
May 27 2016 00:29
joemanriquez sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 125 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
May 27 2016 00:30
:thumbsup:
Stephen Mansfield
@StephenMansfield
May 27 2016 00:34
Ah yea guys, just completed Title Case a Sentence! but I do have some questions about chaining with . if anybody in here groks java..
Thompson Ike
@hubhubace
May 27 2016 00:35
getting tazed
guys check this
js
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


   if  myObj.hasOwnProperty(checkProp); {
    return myObj[checkProp];
  } else  {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("pet");
getting syntax error
anyone done the testing objects for properties?
elminsterrr
@elminsterrr
May 27 2016 00:37
@hubhubace hi delete this ";"
here -> if myObj.hasOwnProperty(checkProp) >; < {
Thompson Ike
@hubhubace
May 27 2016 00:38
@elminsterrr you mean the quotation on Not Found?
Stephen Mansfield
@StephenMansfield
May 27 2016 00:38
@hubhubace he means on the line of the if statement
elminsterrr
@elminsterrr
May 27 2016 00:38
no, delete this semicolon
Thompson Ike
@hubhubace
May 27 2016 00:38
ok
and?
anymore?
i get error
"" is not a function
Stephen Mansfield
@StephenMansfield
May 27 2016 00:39
@hubhubace with if statemeants
the first thing you do is set up paren
elminsterrr
@elminsterrr
May 27 2016 00:39
you don't neet to use if with hasOwnProperty
Stephen Mansfield
@StephenMansfield
May 27 2016 00:40
so if( )
Thompson Ike
@hubhubace
May 27 2016 00:40
ok
Stephen Mansfield
@StephenMansfield
May 27 2016 00:40
you need if(myObj.hasOwnProperty(checkProp))
Thompson Ike
@hubhubace
May 27 2016 00:40
@StephenMansfield you mean i use so if?
Stephen Mansfield
@StephenMansfield
May 27 2016 00:40
yea anytime you use if
the setup is
elminsterrr
@elminsterrr
May 27 2016 00:40
if myObj will have property "hasOwnProperty" will give you true, if not - it will give you false
Thompson Ike
@hubhubace
May 27 2016 00:40
ok
Stephen Mansfield
@StephenMansfield
May 27 2016 00:41
if (stuff goes here){
code goes here

}
Thompson Ike
@hubhubace
May 27 2016 00:41
@StephenMansfield its what i have
js
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


   if  myObj.hasOwnProperty(checkProp); {
    return myObj[checkProp];
  } else  {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("pet");
sorry without the semki colon
js
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


   if  myObj.hasOwnProperty(checkProp) {
    return myObj[checkProp];
  } else  {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("pet");
Diego Mayer
@Chrono79
May 27 2016 00:42
@hubhubace if (myObj.hasOwnProperty(checkProp)) {
Thompson Ike
@hubhubace
May 27 2016 00:42
ok
i still det syntax error
get
Diego Mayer
@Chrono79
May 27 2016 00:43
@hubhubace let's see your code again, edit the above post
Thompson Ike
@hubhubace
May 27 2016 00:44

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

function checkObj(checkProp) {
// Your Code Here

if myObj.hasOwnProperty(checkProp) {
return myObj[checkProp];
} else {
return "Not Found";
}
}

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

```

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

function checkObj(checkProp) {
  // Your Code Here


   if  myObj.hasOwnProperty(checkProp) {
    return myObj[checkProp];
  } else  {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("pet");
Stephen Mansfield
@StephenMansfield
May 27 2016 00:44
still no parenthesis @hubhubace
Thompson Ike
@hubhubace
May 27 2016 00:45
oh
ok
Stephen Mansfield
@StephenMansfield
May 27 2016 00:45
@hubhubace you see what im talking about?
Thompson Ike
@hubhubace
May 27 2016 00:46
js
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


   if  (myObj.hasOwnProperty(checkProp)) {
    return myObj[checkProp];
  } else  {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("pet");
@StephenMansfield thanks
CamperBot
@camperbot
May 27 2016 00:46
hubhubace sends brownie points to @stephenmansfield :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @stephenmansfield |http://www.freecodecamp.com/stephenmansfield
Thompson Ike
@hubhubace
May 27 2016 00:47
@Chrono79 thanks
CamperBot
@camperbot
May 27 2016 00:47
hubhubace sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: hubhubace already gave chrono79 points
Stephen Mansfield
@StephenMansfield
May 27 2016 00:47
No problem man
Thompson Ike
@hubhubace
May 27 2016 00:47
@elminsterrr thanks
CamperBot
@camperbot
May 27 2016 00:47
hubhubace sends brownie points to @elminsterrr :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @elminsterrr |http://www.freecodecamp.com/elminsterrr
Thompson Ike
@hubhubace
May 27 2016 00:47
thanks all
Cian
@ciant
May 27 2016 00:48
I am doing the random quote project, one issue I'm having with my api is that is that it isn't very random and will often give the same quote 2-3 times in a row for some reason meaning there is no change when you click(the library of quotes seems large but this still happens). I was trying to think of a way of incorporating an if statement possibly that would restart the function if the new response === currently displayed quote, but I am not sure how I would go about that.
$(document).ready(function() {

  /*API GET function, adds quote to html if successful, otherwise adds error*/
  function callAjax() {
    $.ajax({
      url: 'http://www.quotzzy.co/api/quote?format=json',
      data: {
        format: 'json'
      },

      error: function() {
        $('#quote p').html('Oh...damn...that is not supposed to happen');
      },

      success: function(resp){
        console.log(resp.text);
        $('blockquote p').text(resp.text);
        $('footer').text('- '+resp.author.name); 
        $('#wiki').html('<a href="' + resp.author.wiki +'" target="_blank"><i class="fa fa-wikipedia-w" aria-hidden="true"></i></a>');
      },
      type: 'GET'  
      });
  }; 

  /*Loads quote on page when user first visits*/
  callAjax();

  /*new quote request on btn click*/
  $('#quotebtn').click(function() {
    callAjax();
     });
});
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 00:48
i've been stuck on the truncate a string. i've tried a few things but not really having any luck with figuring out what to do with arr.push(str); num = arr.length; return num; could anyone give a clue?
Stephen Mansfield
@StephenMansfield
May 27 2016 00:49
@kakalak-lumberJack Sorry man havnt got to to that one yet
Diego Mayer
@Chrono79
May 27 2016 00:50
@kakalak-lumberJack if it's truncate a string, why are you using array methods?
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 00:50
sorry wrong code: this is whats confusing truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)
Diego Mayer
@Chrono79
May 27 2016 00:51
@kakalak-lumberJack forget that test case if that confuses you, work with the instructions
"A-tisket a-tasket A green and yellow basket".length is a number (too lazy to tell you which one ;) )
bitgrower
@bitgrower
May 27 2016 00:51
@kakalak-lumberJack -- can you post your code? I know I (and MANY others) had trouble because we didn't read the instructions in detail ... there's one instruction that's a bit unexpected ...
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 00:53
@Chrono79 i don't understand how to get the "str".length to translate into something. thats the only part of challenge I am not passing and the directions don't seem to address that, @bitgrower will post code...
Diego Mayer
@Chrono79
May 27 2016 00:54
@kakalak-lumberJack "abcd".length is 4, it's the number of chars that compose the string
bitgrower
@bitgrower
May 27 2016 00:55
however, if you are trying to get the length of a string variable, str, putting quotes around it won't work ... it would just be str.length
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 00:55

```function truncateString(str, num) {

if (num < 3) {
str = str.slice(0, num);
return str + "...";
} else if (num > 2) {
str = str.slice(0, num - 3);
return str + "...";
} else {

str = str.slice(0, num);
return ;

}
}
```

Stephen James
@sjames1958gm
May 27 2016 00:55
What up FCC !
Peter Weinberg
@no-stack-dub-sack
May 27 2016 00:56
help mutations
CamperBot
@camperbot
May 27 2016 00:56

:point_right: algorithm mutations [wiki]

Algorithm Mutations

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 00:57
@bitgrower, that is how the challege tests the code, with quotes...thats what i don't understand. how to make that translate into something that the function can process
Tarundeep Singh
@virk369
May 27 2016 01:00
hey guys , can anyone help me with this
Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

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

// Only change code above this line

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

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

Diego Mayer
@Chrono79
May 27 2016 01:01
@virk369 evaluate b too and remove quotes around undefined
Tarundeep Singh
@virk369
May 27 2016 01:02

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

// Only change code above this line

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

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

Stephen James
@sjames1958gm
May 27 2016 01:03
@virk369 Other than undefined with quotes.
Tarundeep Singh
@virk369
May 27 2016 01:03
@Chrono79 Thanks a lot man
CamperBot
@camperbot
May 27 2016 01:03
virk369 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 883 | @chrono79 |http://www.freecodecamp.com/chrono79
Tarundeep Singh
@virk369
May 27 2016 01:04
@sjames1958gm Yeah, removing the quotes helped.
Dan Couper
@DanCouper
May 27 2016 01:04
@ciant it’s not a large corpus it looks like, running the request gives me the same quotes over and over. You could have a variable outside your getAjax function that you set to the text response on each call; then before you render anything, check it’s not the same as the new request text; if it is, run getAjax again, if not set the variable to the new text and render out
Stephen James
@sjames1958gm
May 27 2016 01:05
@virk369 I see @Chrono79 was helping you so you were in good hands.
Diego Mayer
@Chrono79
May 27 2016 01:05
don't make me blush
Sometimes it helps to elaborate the answer, I'm just more direct to the point
Cian
@ciant
May 27 2016 01:05
@DanCouper thanks! good idea!
CamperBot
@camperbot
May 27 2016 01:05
ciant sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 126 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
May 27 2016 01:06
:+1:
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 01:09

if i had to guess, my code is never getting to the final else statement ``` function truncateString(str, num) {

if (num < 3) {
str = str.slice(0, num);
return str + "...";
} else if (num > 2) {
str = str.slice(0, num - 3);
return str + "...";
} else {
num = str.length;
str = str.slice(0, num);
return str;
}
}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length); ``` yay or nay?

Ryan
@ispeakcomputer
May 27 2016 01:11
@kakalak-lumberJack i commonly replace my returns with console.logs to see where the logic breaks down .
Ken Haduch
@khaduch
May 27 2016 01:11
@ALMY91 hi - currently tied up but I'll be back in a few minutes...
Ryan
@ispeakcomputer
May 27 2016 01:11
then I run the code automaticly over and over in sublime /atom while making changes .
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 01:13
@needsMoreCoffee I'll try that. thanks
CamperBot
@camperbot
May 27 2016 01:13
kakalak-lumberjack sends brownie points to @needsmorecoffee :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @needsmorecoffee |http://www.freecodecamp.com/needsmorecoffee
Diego Mayer
@Chrono79
May 27 2016 01:13

@kakalak-lumberJack num<3, num could be 0,1,2 and num > 2 the rest, it never pass that
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

  if (num<str.length) {
    if (num<=3) {
     //something
    } else {
     //something else
    }  
  } else //something else 2
Ryan
@ispeakcomputer
May 27 2016 01:14
I was hoping you guys could tell me why I can write the first example but not the second

function destroyer(arr) {
console.log(arr);

for(var i = 1; i < arr.length;i++){
  var search = arguments[i];

  function ismatch(value){
  return value !== search;
  }

 arr = arr.filter(ismatch);

}
console.log(arr);

return arr;
}

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

see "var search = arguments[i]:''
here is the second example that passes and works .

function destroyer(arr) {
console.log(arr);

for(var i = 1; i < arr.length;i++){
  /*remove this --> var search = arguments[i]; */


  function ismatch(value){
    /* and add this line below*/
  return value !== arguments[i];
  }

 arr = arr.filter(ismatch);

}
console.log(arr);

return arr;
}

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

Stephen James
@sjames1958gm
May 27 2016 01:16
@needsMoreCoffee i relates to the size of arr, but you are trying to use it for the size of arguments -
@needsMoreCoffee Or maybe you meant arguments.length in your for loop
Ryan
@ispeakcomputer
May 27 2016 01:17
ah wait so arguments inside the ismatch function is something else. its a scope thing or whatever .
arguments inside ismatch function is the "value"
maybe thats it .
Diego Mayer
@Chrono79
May 27 2016 01:18
@needsMoreCoffee yes, nice username btw, I'll change mine to needsMoreMoney ;)
Stephen James
@sjames1958gm
May 27 2016 01:18
@needsMoreCoffee yes. each function defines its own arguments
Ryan
@ispeakcomputer
May 27 2016 01:18
aaaahhhhhh,,, duh ok thanks ! I got you more question for you guys .
buiphuking
@buiphuking
May 27 2016 01:19
@Chrono79
do you have free time? , look at my js a bit, plz.......
Stephen James
@sjames1958gm
May 27 2016 01:19
@needsMoreCoffee If you do this remArgs = Array.from(arguments).slice(1); then remArgs is a real array with the remaining args
OceanMountains
@OceanMountains
May 27 2016 01:19
Hey all, I am trying to finish the Caesar's cipher exercise and feel I'm very close. Yet, when I run my program the only output I can get is ' or NaN. I don't see why that should be happening. Any smart people out there know why?
function rot13(str) { // LBH QVQ VG
  var caesarChar = '';  
  for (i = 0; i < str.length; i++) {
    var convertChar =  str.charCodeAt(i);
    if (convertChar >= 65 && convertChar <= 90) {
      caesarChar += String.fromCharCode(convertChar + 13 + 65) % 26 + 65;}
    return caesarChar;
    }
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Diego Mayer
@Chrono79
May 27 2016 01:19
@buiphuking which js are you talking about?
Stephen James
@sjames1958gm
May 27 2016 01:20
@OceanMountains Make sure you don't return inside your for loop
martina carrington
@MartinaCarrington
May 27 2016 01:20

i need help // Example
var array = ["John", 23];

// Only change code below this line.
var sandwich = ["peanut butter", "jelly", "bread"];

Ryan
@ispeakcomputer
May 27 2016 01:20
before this version of code my line "arr = arr.filter(ismatch);" was wrote like this --->var filterArr = arr.filter(ismatch); and I returned filterArr but that didnt work .does that have to do with the fact filterArr wasn't difined as a array?
buiphuking
@buiphuking
May 27 2016 01:21
@Chrono79
pomorodo clock,
http://codepen.io/Dordan/pen/GpVvXm?editors=0010
i want to ask something
Stephen James
@sjames1958gm
May 27 2016 01:21
@needsMoreCoffee if it wasn't you will get an error that filter is not a function on whatever thing it wasn't
kakalak-lumberJack
@kakalak-lumberJack
May 27 2016 01:21
@Chrono79 thanks. for some reason i thought that the string in quotes followed by .length was not generating a numerical value but apparently it is
CamperBot
@camperbot
May 27 2016 01:21
kakalak-lumberjack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 884 | @chrono79 |http://www.freecodecamp.com/chrono79
Ryan
@ispeakcomputer
May 27 2016 01:22
thanks for the pointers @sjames1958gm . Those are great.
CamperBot
@camperbot
May 27 2016 01:22
needsmorecoffee sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1292 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 27 2016 01:22
@OceanMountains Also you need to save the non-letter characters on your otuput string
Diego Mayer
@Chrono79
May 27 2016 01:22
@kakalak-lumberJack :+1:
Ryan
@ispeakcomputer
May 27 2016 01:22
clears it right up .
huge help!
bitgrower
@bitgrower
May 27 2016 01:22
@needsMoreCoffee -- good on you for remembering about scopes & arguments ... nothing brings it home quite like stumbling over the issue in a problem ... you may not forget that too soon now, and it's rather important ... :)
Ryan
@ispeakcomputer
May 27 2016 01:23
@bitgrower it really is ! Thanks
CamperBot
@camperbot
May 27 2016 01:23
needsmorecoffee sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
OceanMountains
@OceanMountains
May 27 2016 01:23

All right, @sjames1958gm I did that. I now realize that was affecting short-circuiting my loop.

But now the output for my function is crazy. "NaNNaNNaNNaNNaNNaNNaN65NaNNaN"

CamperBot
@camperbot
May 27 2016 01:23
:star2: 1067 | @bitgrower |http://www.freecodecamp.com/bitgrower
Diego Mayer
@Chrono79
May 27 2016 01:25
@buiphuking it seems to work, is there anything I should check?
buiphuking
@buiphuking
May 27 2016 01:27
@Chrono79
when i click the button, sec = seshTime or sec = breakTime, take your time, very important.
Randy Goldsmith
@Dueldrawer8
May 27 2016 01:36
anyone tell me why my parameter url isnt working inside my function onlineBorders()?
http://codepen.io/duel_drawer8/pen/QNxyNq?editors=1111
Stephen James
@sjames1958gm
May 27 2016 01:38
@Dueldrawer8 You need a space between url and target - if you hover and look at the link it will be missing that (also put a closing quote)
@Dueldrawer8 Also an opening quote (use double quotes for the url href
$(format).append('<a href="' + url + '" target="_blank"'
Deepak Yadav
@ydeepk
May 27 2016 01:41

Wikipedia App Challange:

Can Anybody help me with this

I'm receving search result form wiki using $.ajax({ }) method in json format, but dont know this

upon success: function (data) { }

for getting title value of WIKI article and Its description value..

data.query.title / data.query.search.title, Neither working for me.

How do I read its value.

My codepen http://codepen.io/ydeepk/pen/BKXjXR

Randy Goldsmith
@Dueldrawer8
May 27 2016 01:42
@sjames1958gm thank you
CamperBot
@camperbot
May 27 2016 01:42
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1293 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
robertky
@robertky
May 27 2016 01:46

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor



  str=str.split(" ");
  if(str.length===1)
  {
    if(str[0].substr(str[0].length-1)===target)
    {
      return true;
    }
    else
    {
      return false;
    }
  }
  else
  {
    if(str[str.length-1]===target)
    {
      return true;
    }
    else
    {
      return false;
    }
  }
}




confirmEnding("He has to give me a new name", "name")
For the "confirm the ending" challenge, the above code passes it.
Stephen James
@sjames1958gm
May 27 2016 01:46
@Dueldrawer8 :+1:
robertky
@robertky
May 27 2016 01:46
But It claims I fail a code that I pass.
Is there a glitch in this?
Challenge?
Ryan
@ispeakcomputer
May 27 2016 01:47
@ydeepk cant help you but cool design
im taking notes .
Randy Goldsmith
@Dueldrawer8
May 27 2016 01:48
@sjames1958gm im noticing my account closed channels actually are using storbecks page. Since the account closed don't have a link.. im going to do a ternary but i don't know what to put in the beginning. it should be something like if channel.data === null?
Richard Viskovic
@DrMerkwurdigliebe
May 27 2016 01:52
Hey people.
Stephen James
@sjames1958gm
May 27 2016 01:52
@Dueldrawer8 it looks like url is undefined for those cases. maybe juset pass a dummy url.
@robertky How would your code pass when the target is a partial word like 'me'
Ken Haduch
@khaduch
May 27 2016 01:53
@robertky - which test is it failing?
Mariusz Bachurski
@embahr
May 27 2016 01:53
find confirm the ending
CamperBot
@camperbot
May 27 2016 01:53

find confirm the ending

:zero: algorithm confirm the ending

Ken Haduch
@khaduch
May 27 2016 01:57
@robertky - looks like it's this one: confirmEnding("He has to give me a new name", "me") - you are returning false, and it should be true, because the str ends in me.
Stephen James
@sjames1958gm
May 27 2016 01:58
@DrMerkwurdigliebe Hey-
Greg Munker
@Gmunker
May 27 2016 01:59
having some trouble with "Stand in Line". Maybe i'm missing a different way of doing this.
function nextInLine(arr, item) {
  // Your code here
  var removed = arr[0];
  arr.push(item);
  arr.shift();
  return removed;
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
nextInLine([], 1) should return 1
thats the only one thats not passing
instructions are "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
Ken Haduch
@khaduch
May 27 2016 02:00
@Gmunker - if you look at that test, they are passing an empty array for arr, so you have to do something to that before you remove anything from it...
Greg Munker
@Gmunker
May 27 2016 02:00
gotcha
@khaduch thank you
CamperBot
@camperbot
May 27 2016 02:01
gmunker sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1192 | @khaduch |http://www.freecodecamp.com/khaduch
Greg Munker
@Gmunker
May 27 2016 02:01
passed :)
Bobby McDonald
@BobbyMcWho
May 27 2016 02:02
sheesh, finally got all the new icons working in my weather app
Ken Haduch
@khaduch
May 27 2016 02:03
@Gmunker - you're welcome. One piece of advice that I like to give is that studying the test cases and thinking about your code helps to answer some questions...
Randy Goldsmith
@Dueldrawer8
May 27 2016 02:04
@sjames1958gm it wont let me do a hover effect if i do a:hover in my css
@sjames1958gm do i need to add an id or class inside my javascript onlineBorders() function
Stephen James
@sjames1958gm
May 27 2016 02:11
@Dueldrawer8 I think it is doing it but for some reason not visible
@Dueldrawer8 I don't know this is more out of my expertise
Randy Goldsmith
@Dueldrawer8
May 27 2016 02:12
@sjames1958gm interesting, i don't want it to change colors, i just want whenever you hover over it, the rectangles sort of have a popout effect
Mariusz Bachurski
@embahr
May 27 2016 02:13
function confirmEnding(str, target) {
  var length = target.length; 
      if (str.substr(0 - length) == target) {       
          return true;
       }
          return false;
}

confirmEnding("Bastian", "n");
@robertky I was able to clear this challenge with the above code. I did just find a way to remove some redundancies though
Randy Goldsmith
@Dueldrawer8
May 27 2016 02:13
@sjames1958gm alright thanks anyway
CamperBot
@camperbot
May 27 2016 02:13
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave sjames1958gm points
Ken Haduch
@khaduch
May 27 2016 02:14
@Dueldrawer8 - I think that it is hidden in some way behind the div that is there. I changed the hover rule (or added to it) with a border: 5px solid green; and it did something. It was weird, but it did something.
Stephen James
@sjames1958gm
May 27 2016 02:14
@embahr You could go as far as just this
function confirmEnding(str, target) {
    return str.substr(-target.length) === target;
  }
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 27 2016 02:15

Hi, I have a question... for json when do we use

json.forEach(function(var){});

and when do we use

json.each(function(var){});

?
I use json.ForEach in my random quote machine and it worked. I'm using it again from my weather app but chrome says that
json.ForEach(function(var){}) is not a function.

Mariusz Bachurski
@embahr
May 27 2016 02:15
@sjames1958gm Yes, that's the solution I just came across after completing the challenge. So much simpler! thanks!
CamperBot
@camperbot
May 27 2016 02:15
embahr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1294 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Randy Goldsmith
@Dueldrawer8
May 27 2016 02:16
@khaduch yeah it is weird lol.. thanks tho ill probably post problem on stackoverflow
CamperBot
@camperbot
May 27 2016 02:16
dueldrawer8 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1193 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
May 27 2016 02:17
@Dueldrawer8 - well, this probably isn't related, but you cannot (at least not correctly) assign the same ID value of rectangles to each of those divs - you could make it a class, though. Maybe it should be a class?
maybe true for other IDs there, like "profilePic" - probably should be a class.
Randy Goldsmith
@Dueldrawer8
May 27 2016 02:18
@khaduch thanks will change it
CamperBot
@camperbot
May 27 2016 02:18
dueldrawer8 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave khaduch points
TheIcyStar
@TheIcyStar
May 27 2016 02:21

Ok, so, array.filter() requires a function to filter things.

var Arr = [1,7,20,25];
function filterFunc(arg){
  return arg >= 15;
};
...
var filtered = Arr.filter(filterFunc); //filters numbers >= 15

Instead of having a function outside of the .filter(), can it be inside of it?

var Arr = [1,7,20,25];
var filtered = Arr.filter(function(arg){
    return arg >= 15;
});
or something of that sort, syntax may be off
Stephen James
@sjames1958gm
May 27 2016 02:22
@TheIcyStar yes it can
TheIcyStar
@TheIcyStar
May 27 2016 02:22
@sjames1958gm syntax ok?
Stephen James
@sjames1958gm
May 27 2016 02:22
@TheIcyStar :+1:
TheIcyStar
@TheIcyStar
May 27 2016 02:22
@sjames1958gm alrighty, perfect. Thanks
CamperBot
@camperbot
May 27 2016 02:22
theicystar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1295 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Luis Amador
@MrLuisAmador
May 27 2016 02:24
Why are arrays mutable? Meaning because of it's place in the stack being a reference?
Ken Haduch
@khaduch
May 27 2016 02:25
@Dueldrawer8 - I kind of got it working by changing things around a bit. I don't know if I should fork your project and just post the link, or try to tell you what I changed? Maybe easy enough just to put the change in here...
Thompson Ike
@hubhubace
May 27 2016 02:26
hi guys
please help me here
js
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }

  myMusic.artist = "Michel Jackson";
  myMusic.tittle = "Beat It";
  myMusic.release_year = 1982;
  myMusic.formats = ["CS","LP","CD"];


];
Ramon Vizcarra
@ahandyman
May 27 2016 02:27
myMusic.title is mispelled what is your question?
Thompson Ike
@hubhubace
May 27 2016 02:29
I am etting syntax error
Ken Haduch
@khaduch
May 27 2016 02:29

@Dueldrawer8 - this is what I changed - the code for generating the rows now looks like this:

$(format).append('<a href="' + url + '"  target="_blank"' + '>' + '<div class="row rectangles ' + status + '"><div id="profilePic" class="col-xs-2">' + '<img class="img-responsive" src=' + displayLogo + '>' + '</div><div class="col-xs-3 text"><p class="name">' + displayName + '</p>' + '</div>' + '<div class="description col-xs-7">' + infoStreaming + '</div></div>' + '</a>')
}

Basically changed the class settings, made "rectangles" a class, and put it in the class attribute list.

Then change the CSS:

/* this is now a class instead of an ID */
.rectangles {
  margin: 3px;
}

/* change the thing for the hover to this: */
.rectangles:hover{
  background-color:red;
/*   border: 5px solid green; */
}

And it looks like it is better, at least doing what I think you were trying to do.

Thompson Ike
@hubhubace
May 27 2016 02:29
getting syntax error
ok will check again
Ken Haduch
@khaduch
May 27 2016 02:30
@hubhubace - what are you supposed to be doing? Are you supposed to add a new object to the array?
Thompson Ike
@hubhubace
May 27 2016 02:30
getting error : unexpected identifier
Stephen James
@sjames1958gm
May 27 2016 02:31
@hubhubace You are supposed to create an object in the same format as that above your code. It is supposed to add a second entry to the arrsy.
Thompson Ike
@hubhubace
May 27 2016 02:31
add a new album to the object MyMusic
Ramon Vizcarra
@ahandyman
May 27 2016 02:32
thats right you are adding to array @hubhubace
Thompson Ike
@hubhubace
May 27 2016 02:32
@sjames1958gm ok
@ahandyman ok
so create another object?
Ken Haduch
@khaduch
May 27 2016 02:33

@hubhubace - if you are supposed to add a new object, you should put a comma after the closing brace of the first object, the "Piano Man" object, and then copy that structure again with your own information, so you have something like this:

var myMusic = [
{
// first object
},
{
// your object
}
];

basically duplicate the first one, change the values to your new values (leave the properties alone). Should be done then!

Thompson Ike
@hubhubace
May 27 2016 02:33
ok opt it
got it
Puja
@Pujachaubey
May 27 2016 02:33
hello frds; i got stuck in Profile Lookup any one have completed this challenge plz help me to figure out where my code is wrong.
Thompson Ike
@hubhubace
May 27 2016 02:33
but does not make sense
suppose to add to the object
but now have to create another object
Helena
@poigirl2001
May 27 2016 02:34
I'm so confused on the stand in line challenge can I have a little hint to get me started?
Ken Haduch
@khaduch
May 27 2016 02:34
@hubhubace - you are adding an object to the array of objects, so making a second "record" in the array.
Thompson Ike
@hubhubace
May 27 2016 02:34
@poigirl2001 please paste your code
@khaduch ok
like this?
js
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }


var myMusic = [
  {
    "artist": "Micheal Jackson",
    "title": "Beat It",
    "release_year": 1982,
    "formats": [ 
      "CS", 
      "LP", 
      "CD" ],


];
Ramon Vizcarra
@ahandyman
May 27 2016 02:37
missing a comma after first object
},
Thompson Ike
@hubhubace
May 27 2016 02:38
ok
Ramon Vizcarra
@ahandyman
May 27 2016 02:38
also don't need to over write var my music look back @khaduch example
Thompson Ike
@hubhubace
May 27 2016 02:39
thanks all
ok
@ahandyman thanks
CamperBot
@camperbot
May 27 2016 02:39
hubhubace sends brownie points to @ahandyman :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @ahandyman |http://www.freecodecamp.com/ahandyman
Thompson Ike
@hubhubace
May 27 2016 02:39
@khaduch thanks
CamperBot
@camperbot
May 27 2016 02:39
hubhubace sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1194 | @khaduch |http://www.freecodecamp.com/khaduch
Thompson Ike
@hubhubace
May 27 2016 02:39
@sjames1958gm thanks
CamperBot
@camperbot
May 27 2016 02:39
hubhubace sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1296 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ken Haduch
@khaduch
May 27 2016 02:41
@hubhubace - you're welcome
Thompson Ike
@hubhubace
May 27 2016 02:41
glad to know you guys
kudos
now makes sense
lol
without you guys JSON would be Jarons Object Script Notation
Jargons
thanks god it is still Javascript
so far
please what is difference between JAVA AND JAVASCRIPT?
Stephen Mansfield
@StephenMansfield
May 27 2016 02:46
@hubhubace java is a back end programming langauge, it happens on the server
javascript is run in browser by the browser
Thompson Ike
@hubhubace
May 27 2016 02:46
like PHP?
Ken Haduch
@khaduch
May 27 2016 02:46
@hubhubace - everything is different between Java and JavaScript - I think that it was a bad move that they took part of the name. (I think that Java was first.)
Thompson Ike
@hubhubace
May 27 2016 02:47
@khaduch lol
yeah
because it seems like unidentical twins
ok got it
Ken Haduch
@khaduch
May 27 2016 02:48
@hubhubace - I do not think that there is any comparison that can be made between them, other than that they are both programming languages, and both have "Java" as part of the name.
Thompson Ike
@hubhubace
May 27 2016 02:48
but with html.css and JavaScript one can set up a fully functional website?
Samuel Cupidon
@Zerazera
May 27 2016 02:49
@khaduch It's actually deliberate. Javascript was originally called Livescript but when Oracle bought Netscape they changed the name for branding purposes.
Other than some minor syntax similarities there's really no relationship between Java and Javascript
Thompson Ike
@hubhubace
May 27 2016 02:50
who owns JAVA?
Matthew Hand
@mmhand123
May 27 2016 02:50
oracle does
Thompson Ike
@hubhubace
May 27 2016 02:50
and java script?
Stephen Mansfield
@StephenMansfield
May 27 2016 02:50
there is actually big lawsuit going on right now
Matthew Hand
@mmhand123
May 27 2016 02:50
they lost @StephenMansfield
for now
oracle did
Stephen Mansfield
@StephenMansfield
May 27 2016 02:50
between google and oracle over java
o really
did not realize
Thompson Ike
@hubhubace
May 27 2016 02:51
so google owns it now?
Matthew Hand
@mmhand123
May 27 2016 02:51
no
Stephen Mansfield
@StephenMansfield
May 27 2016 02:51
not owns it
Matthew Hand
@mmhand123
May 27 2016 02:51
oracle was suing google
oracle doesn't own javascript just java
Thompson Ike
@hubhubace
May 27 2016 02:51
ok
wow
Ken Haduch
@khaduch
May 27 2016 02:52
yes, Oracle holds the reins. I don't know if anyone really owns javascript - there is a standard and some common javascript "engines" (I think) - I haven't really delved into that level of understanding about javascript.
Prabuddha Tuladhar
@coder077
May 27 2016 02:52

Hi i am trying to find the lowest index at which a value (second argument)should be inserted into an array once it has been sorted.
function getIndexToIns(arr, num) {
arr.sort();
for(var i=0;i<arr.length;i++){
if(num<=arr[i]){
return i;
}
}
return arr.length;
}

getIndexToIns([3,3,5,20],20);

Thompson Ike
@hubhubace
May 27 2016 02:52
at least need to know who owns this stuff I am battling with
lol
Prabuddha Tuladhar
@coder077
May 27 2016 02:52
it gives me wrong values
can someone help me
Thompson Ike
@hubhubace
May 27 2016 02:52
there should be a creator
original writer
for javascript
Coy Sanders
@coymeetsworld
May 27 2016 02:53
No one owns Java, java is a free language
Ken Haduch
@khaduch
May 27 2016 02:53
@coder077 - you have to change your array.sort() call to use a function to get it to sort in numerical order. Check it out here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Thompson Ike
@hubhubace
May 27 2016 02:53
@coymeetsworld wow
Coy Sanders
@coymeetsworld
May 27 2016 02:53
Oracle was suing Google over API use
Prabuddha Tuladhar
@coder077
May 27 2016 02:53
@khaduch thanks!
CamperBot
@camperbot
May 27 2016 02:53
coder077 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1195 | @khaduch |http://www.freecodecamp.com/khaduch
Thompson Ike
@hubhubace
May 27 2016 02:54
why sue when no one has a riht?
right
Coy Sanders
@coymeetsworld
May 27 2016 02:54
APIs they said were intellectual property
Thompson Ike
@hubhubace
May 27 2016 02:54
property of who?
Coy Sanders
@coymeetsworld
May 27 2016 02:54
of Oracles
Thompson Ike
@hubhubace
May 27 2016 02:54
google?
ok
so much to handle
lol
Coy Sanders
@coymeetsworld
May 27 2016 02:55
Google used the same names and structures of 37 APIs, they used roughly 11k lines of code from Oracle
but Android is over 10 million lines
Thompson Ike
@hubhubace
May 27 2016 02:55
and why are they the ones suing?
sorry
my mistake
Coy Sanders
@coymeetsworld
May 27 2016 02:56
because Google is making alot of money of Android and Oracle didn't
Thompson Ike
@hubhubace
May 27 2016 02:56
bad beats
lol
Coy Sanders
@coymeetsworld
May 27 2016 02:56
Oracle tried getting into mobile market long time ago and failed, and they can't make money off of java, they paid over 5 billion to Sun for it
so they're just trying to recoup their losses
Thompson Ike
@hubhubace
May 27 2016 02:56
so they want royalty?
Ramon Vizcarra
@ahandyman
May 27 2016 02:56
@poigirl2001 did you get it?
Coy Sanders
@coymeetsworld
May 27 2016 02:56
i dont think its royalty, just damages
Matthew Hand
@mmhand123
May 27 2016 02:56
they wanted 9 billion
Coy Sanders
@coymeetsworld
May 27 2016 02:56
yes
up to 9 billion, they wouldn't have got that even if they won the suit
Thompson Ike
@hubhubace
May 27 2016 02:57
i guess they deserve it from whats on the plate
craftylamma
@craftylamma
May 27 2016 02:57
how does accessing objects properties with variables work?
Coy Sanders
@coymeetsworld
May 27 2016 02:57
who deserves it? Oracle?
Thompson Ike
@hubhubace
May 27 2016 02:57
yeah
Coy Sanders
@coymeetsworld
May 27 2016 02:57
no they dont
Thompson Ike
@hubhubace
May 27 2016 02:57
someone took part of what you have
Coy Sanders
@coymeetsworld
May 27 2016 02:57
they at one point were happy about Android
Thompson Ike
@hubhubace
May 27 2016 02:58
why?
Coy Sanders
@coymeetsworld
May 27 2016 02:58
they took API naming conventions thats essentially it
Matthew Hand
@mmhand123
May 27 2016 02:58
they took the declaration for api methods, not the implementation, from my understanding
Thompson Ike
@hubhubace
May 27 2016 02:58
android is an oposition
Coy Sanders
@coymeetsworld
May 27 2016 02:58
yes not the implementation
and the main reason they did that was so it would be easier for Java developers to get on board
Thompson Ike
@hubhubace
May 27 2016 02:58
oh i see
Coy Sanders
@coymeetsworld
May 27 2016 02:58
not because they couldn't write something better
Matthew Hand
@mmhand123
May 27 2016 02:58
so basically developers could interact with the apis in the same way, but the code under the hood was 100% googles
Coy Sanders
@coymeetsworld
May 27 2016 02:58
Oracle was all good with Android, for the most part
until they bought sun and didn't make any money off of Java
Thompson Ike
@hubhubace
May 27 2016 02:59
tough luck
bad decision
Coy Sanders
@coymeetsworld
May 27 2016 02:59
yeah well good thing they lost, because it wouldve changed alot
Thompson Ike
@hubhubace
May 27 2016 02:59
wrong call
Coy Sanders
@coymeetsworld
May 27 2016 02:59
anytime you use an API for anyone now you could get sued by an overbearing company
Matthew Hand
@mmhand123
May 27 2016 03:00
yea or fork code and implement a similar but functionally different api
Coy Sanders
@coymeetsworld
May 27 2016 03:00
would discourage alot of collaboration in software development, more people wasting time reinventing the wheel just to avoid pointless litigation battles
Thompson Ike
@hubhubace
May 27 2016 03:00
but fuctionality aint same
Coy Sanders
@coymeetsworld
May 27 2016 03:00
google v. oracle is now in its 6th year
and its not over yet still
Thompson Ike
@hubhubace
May 27 2016 03:00
guess it will nevver end
Coy Sanders
@coymeetsworld
May 27 2016 03:00
Linux btw also did something similar copying api from Unix
TheIcyStar
@TheIcyStar
May 27 2016 03:00
I need some help with getting array.filter() working correctly for the "seek and destroy" algorithm...
Coy Sanders
@coymeetsworld
May 27 2016 03:01
who knows what would happen there too
could have spelled the end for Linux and Android possibly
Thompson Ike
@hubhubace
May 27 2016 03:01
linux aint got nothing big yet from the copy
Matthew Hand
@mmhand123
May 27 2016 03:02
@TheIcyStar whats your question?
TheIcyStar
@TheIcyStar
May 27 2016 03:02
function destroyer(arr) {
  var args = Array.from(arguments); 
  var result = args[0];

  for (i=1; i < args.length; i++){
    result.filter(function(tester){ //this is the problem part
      return tester !== args[i]; //!== and == interchangable to fix/break as needed
     });
  }
  return result;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I'm not able to get filter() to overwrite result
Coy Sanders
@coymeetsworld
May 27 2016 03:02
Google did from Android, Red Hat gains from Linux enterprise
IBM invests alot in Linux too, alot of companies rely on it
and those are just the big ones
TheIcyStar
@TheIcyStar
May 27 2016 03:02
Seek and destroy algorithm
"You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments."
Ramon Vizcarra
@ahandyman
May 27 2016 03:03
how do you post code?
TheIcyStar
@TheIcyStar
May 27 2016 03:03
explain formating
CamperBot
@camperbot
May 27 2016 03:03
no wiki entry for: formating
Thompson Ike
@hubhubace
May 27 2016 03:03
oh well back to turture coding
lol
TheIcyStar
@TheIcyStar
May 27 2016 03:03
explain formatting
CamperBot
@camperbot
May 27 2016 03:03

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Coy Sanders
@coymeetsworld
May 27 2016 03:03
@TheIcyStar array.filter doesn't modify array in place
it returns a filtered array
Thompson Ike
@hubhubace
May 27 2016 03:03
why cant these coding terminologies be simpler?
Matthew Hand
@mmhand123
May 27 2016 03:04
@TheIcyStar filter loops through the array too so you don't need the extra for loop. try using it on the array itself
Coy Sanders
@coymeetsworld
May 27 2016 03:04
@mmhand123 yeah the loop is needed, to go through the arguments
which terminologies @hubhubace ?
Matthew Hand
@mmhand123
May 27 2016 03:04
not if you create an array of the rest of the args and compare them to the first!
Coy Sanders
@coymeetsworld
May 27 2016 03:05
you would still need to iterate through that array
robertky
@robertky
May 27 2016 03:05

I am doing the "Seek and Destroy" challenge in simple algorithms section. It is trying to have me use the .filter() function here.

LINK: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

Is there a way to pass that function a specific number to filter, but filter mulitple?

TheIcyStar
@TheIcyStar
May 27 2016 03:05
@mmhand123 alright, I'll see what I can do
Jaime Albarez
@albarezj
May 27 2016 03:05
I would like to see an implementation using the .filter() method, I gave up and did 2 loops.
robertky
@robertky
May 27 2016 03:06
Like filter out multiple number?
Matthew Hand
@mmhand123
May 27 2016 03:06
filter iterates @coymeetsworld
robertky
@robertky
May 27 2016 03:06
I'm unclear how to do this.
Coy Sanders
@coymeetsworld
May 27 2016 03:06
yeah but you have 2 arrays
you cant filter an array with another array with just one filter call
Matthew Hand
@mmhand123
May 27 2016 03:06
haha wow, sorry yeah, I read it wrong
I saw arr[0] and assumed it was one value
sorry !
TheIcyStar
@TheIcyStar
May 27 2016 03:07
@robertky I'm on this too, I think i'm gonna try placing the stuff to remove into an array, and then inside the filter() function I go through and try to find a match.
Coy Sanders
@coymeetsworld
May 27 2016 03:07
yeah, arr[0] is the array to filter from, the rest of it are individual numbers needed to be filtered out
Stephen Mansfield
@StephenMansfield
May 27 2016 03:07
quick question about array.sort
Coy Sanders
@coymeetsworld
May 27 2016 03:07
what she has is fine, just needs to reassign results to results.filter since Array.filter() returns a filtered array, doesn't modify the array itself in place
ALMY91
@ALMY91
May 27 2016 03:07
hi guys
Stephen Mansfield
@StephenMansfield
May 27 2016 03:08
can I use array[i].sort to access sub arrays?
ALMY91
@ALMY91
May 27 2016 03:08
is constructor a function used with the new keyword?
Stephen Mansfield
@StephenMansfield
May 27 2016 03:08
@ALMY91 a constructor function is a specific type of function
Coy Sanders
@coymeetsworld
May 27 2016 03:08
@ALMY91 no theyre different
Ramon Vizcarra
@ahandyman
May 27 2016 03:08
function updateRecords(id, prop, value) {

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

  if(collection.id.prop[value] === "") { //hasOwnProperty(value)
    delete collection.id.prop;
  }

 return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Coy Sanders
@coymeetsworld
May 27 2016 03:09
new creates a object, constructor tells you how to do that
you don't use the new keyword in the constructor
Ramon Vizcarra
@ahandyman
May 27 2016 03:09
Working on record collection trying to figure out my if statements and bracket notation but i'm missing something... suggestions
ALMY91
@ALMY91
May 27 2016 03:10
@coymeetsworld so which is the constructor in this code?
var Vehicle = function Vehicle() {
  // ...
}

var vehicle = new Vehicle();
Coy Sanders
@coymeetsworld
May 27 2016 03:10
the top
SarthakAdhikari
@SarthakAdhikari
May 27 2016 03:10
Anyone here?
Can anyone help me with the Mashape API? :)
ALMY91
@ALMY91
May 27 2016 03:11
@coymeetsworld even if there is no new keyword, it is still called a constructor? say if we take away the last line
Coy Sanders
@coymeetsworld
May 27 2016 03:12
the last line isn't the constructor no
the last line is creating a new instance of Vehicle and assigning it to a variable named Vehicle
those two lines do two separate things
ALMY91
@ALMY91
May 27 2016 03:13
@coymeetsworld yes i know but does a constructor have to be used tgt with a new keyword?
Coy Sanders
@coymeetsworld
May 27 2016 03:14
tgt?
ALMY91
@ALMY91
May 27 2016 03:15
@coymeetsworld together
Coy Sanders
@coymeetsworld
May 27 2016 03:15
no, first line defines what the object should look like, the second creates an instance of that object for you
you can define Vehicle but not instantiate it if you wanted
ALMY91
@ALMY91
May 27 2016 03:16
@coymeetsworld okay i think i get it , another thing i would like to ask is..
Coy Sanders
@coymeetsworld
May 27 2016 03:16
but then you wouldn't be using it in your code really
ALMY91
@ALMY91
May 27 2016 03:17
@coymeetsworld with regards to the previous code
Coy Sanders
@coymeetsworld
May 27 2016 03:17
it would in a way be like defining a new variable in your code like var x; but never doing anything with it
TheIcyStar
@TheIcyStar
May 27 2016 03:17
I got the algorithm to work, thanks for he suggestion @mmhand123
CamperBot
@camperbot
May 27 2016 03:17
theicystar sends brownie points to @mmhand123 :sparkles: :thumbsup: :sparkles:
:cookie: 138 | @mmhand123 |http://www.freecodecamp.com/mmhand123
ALMY91
@ALMY91
May 27 2016 03:17
 It sets the constructor property of the object to Vehicle.

This means two things:
vehicle.constructor == Vehicle  // true
vehicle instanceof Vehicle      // true
this was the previous code
var Vehicle = function Vehicle() {
  // ...
}

var vehicle = new Vehicle();
Matthew Hand
@mmhand123
May 27 2016 03:18
@coymeetsworld did more than I did @TheIcyStar ! glad you got it though
ALMY91
@ALMY91
May 27 2016 03:18
@coymeetsworld i dont really understand whys it vehicle.constructor
TheIcyStar
@TheIcyStar
May 27 2016 03:18
Oh, thanks to @coymeetsworld too
CamperBot
@camperbot
May 27 2016 03:18
theicystar sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 966 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 27 2016 03:19
lol well if you listened to @mmhand123 and didn't see what i wrote then thanks to him @TheIcyStar lol
CamperBot
@camperbot
May 27 2016 03:19
coymeetsworld sends brownie points to @mmhand123 and @theicystar :sparkles: :thumbsup: :sparkles:
:cookie: 139 | @mmhand123 |http://www.freecodecamp.com/mmhand123
:cookie: 285 | @theicystar |http://www.freecodecamp.com/theicystar
ALMY91
@ALMY91
May 27 2016 03:19
@coymeetsworld is constructor a kind of keyword?
Coy Sanders
@coymeetsworld
May 27 2016 03:19
its a property name
Thompson Ike
@hubhubace
May 27 2016 03:19
hji friends
Coy Sanders
@coymeetsworld
May 27 2016 03:19
like remember how objects have properties and values?
Matthew Hand
@mmhand123
May 27 2016 03:20
new is syntatic sugar that sets up prototypal inheritance for you
you can create a constructor without the new keyword but it's easier
Coy Sanders
@coymeetsworld
May 27 2016 03:20
constructor property is one that gets defined implicitly when you use new keyword
Thompson Ike
@hubhubace
May 27 2016 03:20
please why cant var gloveBoxContent be a string?

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = myStorage.car.inside["glove box"]; // Change this line
i am learning
want to know the logic
i will go back to review when done with JSON
ALMY91
@ALMY91
May 27 2016 03:21
@coymeetsworld but its weird that the book states specifically .constructor? shouldn't it have placed the .property instead its confusing
Coy Sanders
@coymeetsworld
May 27 2016 03:21
which book?
ALMY91
@ALMY91
May 27 2016 03:21
@coymeetsworld i actually got it from a website sorry
Thompson Ike
@hubhubace
May 27 2016 03:22
can anyone answer the question?
Thompson Ike
@hubhubace
May 27 2016 03:22
please why cant var gloveBoxContent be a string?
ALMY91
@ALMY91
May 27 2016 03:22
@coymeetsworld its so confusing
Coy Sanders
@coymeetsworld
May 27 2016 03:23
gloveBoxContent or gloveBoxContents?
what challenge is that again @hubhubace ?
constructor is the name of a property @ALMY91,
Thompson Ike
@hubhubace
May 27 2016 03:24
Accessing Nested objects in JSON
gloveBoxContents?
gloveBoxContents
ALMY91
@ALMY91
May 27 2016 03:25
@coymeetsworld why dont they just put vehicle.property instead
Coy Sanders
@coymeetsworld
May 27 2016 03:25
because constructor is the name of that particular property
objects can have more than one property, thats why they're not named "property"
whats the issue @hubhubace ?
looks ok to me what you have
that should return a String
Thompson Ike
@hubhubace
May 27 2016 03:26
it passed
its ok
Coy Sanders
@coymeetsworld
May 27 2016 03:26
ok
Norvin Burrus
@ndburrus
May 27 2016 03:26
@hubhubace it is a string
Thompson Ike
@hubhubace
May 27 2016 03:27
but just wondering why the result cant be a string?
oh really?
Norvin Burrus
@ndburrus
May 27 2016 03:27
@hubhubace in the test case it (the result) is "maps"
ALMY91
@ALMY91
May 27 2016 03:27
@coymeetsworld why isn it ==Vehicle.constructor then?
Thompson Ike
@hubhubace
May 27 2016 03:27
ok lol
Norvin Burrus
@ndburrus
May 27 2016 03:27
@hubhubace ...make sense?
Thompson Ike
@hubhubace
May 27 2016 03:27
yeah
Norvin Burrus
@ndburrus
May 27 2016 03:28
@hubhubace ok, super! :sparkles:
Matthew Hand
@mmhand123
May 27 2016 03:28
the var vehicle = new Vehicle(); has a .constructor property that is === Vehicle because it was created with the Vehicle constructor function @ALMY91
Thompson Ike
@hubhubace
May 27 2016 03:29
please another question
Coy Sanders
@coymeetsworld
May 27 2016 03:29
@ALMY91 im not sure how far you are on FCC but maybe you shouldn't sweat this too much
Thompson Ike
@hubhubace
May 27 2016 03:29
how many objects in this code?
js
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = ""; // Change this line
Coy Sanders
@coymeetsworld
May 27 2016 03:30
something you can pick up later after you go through more JavaScript
SarthakAdhikari
@SarthakAdhikari
May 27 2016 03:30
@coymeetsworld Hey there. Can I PM you? I need a little help with the Mashape API :)
Thompson Ike
@hubhubace
May 27 2016 03:30
seem to be confused with the term object
Coy Sanders
@coymeetsworld
May 27 2016 03:30
idk what Mashape is
SarthakAdhikari
@SarthakAdhikari
May 27 2016 03:30
API hub :_
ALMY91
@ALMY91
May 27 2016 03:30
@coymeetsworld im actually done with basic Javascript.. thats all
Thompson Ike
@hubhubace
May 27 2016 03:31
js
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = ""; // Change this line
Matthew Hand
@mmhand123
May 27 2016 03:31
@hubhubace looks like an array of 2 objects
ALMY91
@ALMY91
May 27 2016 03:31
@coymeetsworld for the FCC.. im on the definitive guidebook..
Thompson Ike
@hubhubace
May 27 2016 03:31
ok understood
Coy Sanders
@coymeetsworld
May 27 2016 03:31
array is an object too though
Thompson Ike
@hubhubace
May 27 2016 03:31
hmm
so you saying there are 3 objects?
Coy Sanders
@coymeetsworld
May 27 2016 03:32
so technically 5?
Ken Haduch
@khaduch
May 27 2016 03:32
@hubhubace - I would look at that structure (an Array) and say that there are two objects. But if you look into it more, there are arrays (which are "objects") and in fact myPlants is an Array (which is an "object"). So the answer is probably 5 objects, but you are really concerned with the two that are contained within the outer array.
Thompson Ike
@hubhubace
May 27 2016 03:32
wow
Matthew Hand
@mmhand123
May 27 2016 03:32
yes, technically in javascript, but a different data structure really
Thompson Ike
@hubhubace
May 27 2016 03:32
ok got it
so if we need to evaluate an object which takes precedencde?
Matthew Hand
@mmhand123
May 27 2016 03:33
if you need to evaluate the number of objects I would not count arrays as objects
Coy Sanders
@coymeetsworld
May 27 2016 03:34
precedence in what?
Thompson Ike
@hubhubace
May 27 2016 03:34
value
accessing value
Coy Sanders
@coymeetsworld
May 27 2016 03:34
im not sure what you mean
Ken Haduch
@khaduch
May 27 2016 03:34
@hubhubace - they want the object that contains "trees" in this problem, so you really want the one that has trees contained in the list.
Thompson Ike
@hubhubace
May 27 2016 03:34
yeah
ok
Norvin Burrus
@ndburrus
May 27 2016 03:35
@hubhubace i vote for 5 objects: myPlants, type, list/s (times two)
Thompson Ike
@hubhubace
May 27 2016 03:35
i just want to understand the object thing
Coy Sanders
@coymeetsworld
May 27 2016 03:35
yeah its 5, only things not Objects in JavaScript are primitive values
Thompson Ike
@hubhubace
May 27 2016 03:35
ok
Coy Sanders
@coymeetsworld
May 27 2016 03:35
primitives are string literals, numbers, booleans, null, undefined
I think something else in ES6 i forget what
Matthew Hand
@mmhand123
May 27 2016 03:36
what's the challenge that's from?
Ramon Vizcarra
@ahandyman
May 27 2016 03:36
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

  if(collection.id.prop[value] === "") { //hasOwnProperty(value)
    delete collection.id.prop;
  }

 return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Working on Record Collection. trying to figure out if my if statements are incorrect or if my bracket/dot notation is wrong. I think I'm on the right track...any help is appreciated
Thompson Ike
@hubhubace
May 27 2016 03:36
this talks about accessing nested arrays in JSON
ALMY91
@ALMY91
May 27 2016 03:36
@coymeetsworld i have another question...
vehicle;                          // {}

var FuzzyBear = function FuzzyBear() { };
vehicle.constructor = FuzzyBear;

vehicle;                          // { constructor: function FuzzyBear() }
vehicle.constructor == FuzzyBear; // true
Ramon Vizcarra
@ahandyman
May 27 2016 03:37
error message : can't read prop of undefined
Norvin Burrus
@ndburrus
May 27 2016 03:37
@ahandyman TypeError: Cannot read property 'prop' of undefined
khaduch @khaduch - I hate to be a party pooper, but I think that I have to say good night all... time to shut down for the night... happy coding!
Norvin Burrus
@ndburrus
May 27 2016 03:38
@ahandyman aah.... review/check the use of dot vs bracket notation ?:) this may be useful: MDN, Property accessors {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors }
ALMY91
@ALMY91
May 27 2016 03:38
@coymeetsworld this code.. i dont really understand. i thought constructors cld only be set to new objects?
Ryan
@ispeakcomputer
May 27 2016 03:39
@ndburrus later !
have a good one.
Norvin Burrus
@ndburrus
May 27 2016 03:39
@needsMoreCoffee cya!
Ramon Vizcarra
@ahandyman
May 27 2016 03:39
@ndburrus ... okay i'll give it another go ... i've gone back a few times. taking a quick coffee break
Coy Sanders
@coymeetsworld
May 27 2016 03:39
constructors and objects are not the same thing @ALMY91
a constructor is basically the instructions on how to build an object
if you want to create an instance of it, you use the new keyword
think of a constructor like a blueprint of something you want to build
Norvin Burrus
@ndburrus
May 27 2016 03:40
@ahandyman :+1:
Coy Sanders
@coymeetsworld
May 27 2016 03:40
and new is using that blueprint to actually building something
i haven't looked at that link you sent so I don't know what they're trying to teach
but I will say maybe you should just continue with rest of FCC before delving deeper into these topics, they're a little more advanced. I still need to learn alot more to be proficient in JS
and I almost finished the front-end curriculum
Norvin Burrus
@ndburrus
May 27 2016 03:42
@ahandyman id & prop should be referenced as variables. the input (id, prop) can change. make sense?
ALMY91
@ALMY91
May 27 2016 03:42
@coymeetsworld this is so confusing... i get what u mean, the new keyword is to build on what was previously in the constructor right
Coy Sanders
@coymeetsworld
May 27 2016 03:46
not build on, but build
you could for example build more than one Vehicle
var vehicle1 = new Vehicle();
var vehicle2 = new Vehicle();
each vehicle would be independent of each other
they would both be vehicles, but if you gave Vehicle its own variables or something then if you change those variables on vehicle1, vehicle2 would not also get those changes.
ALMY91
@ALMY91
May 27 2016 03:48
@coymeetsworld okay i would like to confirm for constructors that have yet to be initialized, are we able to set them to another constructor? from what i understand from the code, it seems like this is so
correct me if im wrong
vehicle;                          // {}

var FuzzyBear = function FuzzyBear() { };
vehicle.constructor = FuzzyBear;

vehicle;                          // { constructor: function FuzzyBear() }
vehicle.constructor == FuzzyBear; // true
Coy Sanders
@coymeetsworld
May 27 2016 03:49
you don't initialize a constructor
a constructor is a function of a prototype. To instantiate a prototype that constructor function is called to create it
still haven't seen that link so can't really help out any further about explaining what they're trying to do
ALMY91
@ALMY91
May 27 2016 03:53
@coymeetsworld but vehicle didn even had a function keyword to it initially..
@coymeetsworld i wld understood if the firstline had been var vehicle =function vehicle() { };
kwal0203
@kwal0203
May 27 2016 03:56
@ALMY91 what are you trying to do?
Ramon Vizcarra
@ahandyman
May 27 2016 03:57

@ndburrus Sorry I'm not following. If value is non-blank (value !== "") and prop is not "tracks" 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.

oops
ALMY91
@ALMY91
May 27 2016 03:58
@kwal0203 im just wondering why is vehicle recognized as a constructor here when it hadn been written as var vehicle =function vehicle() { };
Ramon Vizcarra
@ahandyman
May 27 2016 03:58
@ndburrus I understand what your saying but the directions and your comment have me a little confused
Norvin Burrus
@ndburrus
May 27 2016 03:59
@ahandyman ok, have you updated the dot/bracket notation?
kwal0203
@kwal0203
May 27 2016 03:59
@ALMY91 the constructor is inherited from the the objects prototype
Thompson Ike
@hubhubace
May 27 2016 03:59
hi friends
what di i do here?

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

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
kwal0203
@kwal0203
May 27 2016 04:00
@ALMY91 its a reference to the function that created the instance of the object
@ALMY91 vehicle is not a constructor
@ahandyman vehicle.constructor is a constructor
Thompson Ike
@hubhubace
May 27 2016 04:00
if statement?
help please?
CamperBot
@camperbot
May 27 2016 04:01

:point_right: algorithm no repeats please [wiki]

Algorithm No Repeats Please

Problem Explanation:

This task requires us to look at each possible permutation of a string. This can be done using a recursion function, but it is not the only way. A common interview question is building a function which collects all permutations of a string. So there is no shortage of tutorials out there on how to do this, in many different code languages.

:pencil: read more about algorithm no repeats please on the FCC Wiki

Ramon Vizcarra
@ahandyman
May 27 2016 04:01
@ndburrus not yet i'm going back and starting at accesing object properties with variables
David Halls
@DavidHalls
May 27 2016 04:01
it is an if statement, but how do we access the specific object andedit it
Thompson Ike
@hubhubace
May 27 2016 04:02
i need help
David Halls
@DavidHalls
May 27 2016 04:02
@hubhubace
Thompson Ike
@hubhubace
May 27 2016 04:02
lol
kwal0203
@kwal0203
May 27 2016 04:02
@ALMY91 in that example fuzzybear is the constructor for vehicle Objects
Thompson Ike
@hubhubace
May 27 2016 04:02
@Byzgig i need a lead
no idea
David Halls
@DavidHalls
May 27 2016 04:02
@hubhubace im working on that one now too
kwal0203
@kwal0203
May 27 2016 04:02
vehicle;

var FuzzyBear = function FuzzyBear() { new vehicle() }
vehicle.constructor = FuzzyBear;

vehicle;   
vehicle.constructor == FuzzyBear;
@ALMY91 so if vehicle is a class, FuzzyBear is a method of that class that creates new vehicle Objects
@ALMY91 does that make sense?
David Halls
@DavidHalls
May 27 2016 04:09

@hubhubace here is what i have so far function updateRecords(id, prop, value) {

if(value !== "" && prop !== "tracks"){

}

return collection;
}

plz help me
i got stuck here from yesterday.

for(var i=0;i<contacts.length;i++){
if(contacts[i].firstName === firstName){
if(contacts[i][prop]){
return contacts[prop];
}

else {
return "No Such property";
}}

}
return "No such contacts";
// Only change code above this line
}

this is my code.
Greg Duncan
@GregatGit
May 27 2016 04:15
This message was deleted
Ramon Vizcarra
@ahandyman
May 27 2016 04:15
@Byzgig Did that work? I didn't think it was that simple
David Halls
@DavidHalls
May 27 2016 04:15
@hubhubace no, still much more to figure out
Greg Duncan
@GregatGit
May 27 2016 04:16
@Pujachaubey here it is fomatted
for(var i=0;i<contacts.length;i++){
  if(contacts[i].firstName === firstName){
    if(contacts[i][prop]){
      return contacts[prop];
    }

  else {
    return "No Such property";
  }}

}
 return "No such contacts"; 
// Only change code above this line
}
Ramon Vizcarra
@ahandyman
May 27 2016 04:17
@Byzgig I was trying bracket notation but I'm coming up short "collection.id.prop[value]"
Piyush Deshmukh
@PiyushDeshmukh
May 27 2016 04:17
don't you think it should be return contacts[i][prop];? in 4h statement
Thompson Ike
@hubhubace
May 27 2016 04:18
does this make sense guys?
js

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

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !=="");
  (prop !== "tracks");
  return collection{"prop"};
  else if (prop=="track");
          (value !=="");
           collection.push(collection["prop"]);
  else delete collection.prop;

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
io need a lead
Greg Duncan
@GregatGit
May 27 2016 04:19
@hubhubace you are miss ing some {}
Thompson Ike
@hubhubace
May 27 2016 04:19
i am toasted
@GregatGit help
but the statements are ok?
Puja
@Pujachaubey
May 27 2016 04:20
i have already used this logic @GregatGit
Greg Duncan
@GregatGit
May 27 2016 04:20
@Pujachaubey I know - just made it easier to read
Piyush Deshmukh
@PiyushDeshmukh
May 27 2016 04:20
@Pujachaubey use contacts[i].hasOwnProperty()
Greg Duncan
@GregatGit
May 27 2016 04:21
@hubhubace No - its not right
Thompson Ike
@hubhubace
May 27 2016 04:21
please show
what do i do?
Greg Duncan
@GregatGit
May 27 2016 04:22
@hubhubace It takes a litte to get your head around but you need be more solid in how to access values and check for properties in objects
Miguel López
@miguelopezv
May 27 2016 04:22
@Pujachaubey you should return contacts[i][prop]
Zigantheshaman
@Zigantheshaman
May 27 2016 04:23
Hi guys I am stuck at "Next in line" exercise
Someone here to help me please ? :)
Greg Duncan
@GregatGit
May 27 2016 04:23
@hubhubace copy the object collection and paste it into the working area at https://repl.it/
Ramon Vizcarra
@ahandyman
May 27 2016 04:24
@GregatGit thanks for repl
CamperBot
@camperbot
May 27 2016 04:24
ahandyman sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 533 | @gregatgit |http://www.freecodecamp.com/gregatgit
Thompson Ike
@hubhubace
May 27 2016 04:25
@GregatGit ok
what do i do next?
Greg Duncan
@GregatGit
May 27 2016 04:25
@hubhubace the using console.log( ) try to target and dispay values and properties
Puja
@Pujachaubey
May 27 2016 04:25
i am not getting.
Zigantheshaman
@Zigantheshaman
May 27 2016 04:27
Capture.PNG
blob
blob
UtkarshShukla7
@UtkarshShukla7
May 27 2016 04:27
@Pujachaubey what is your new code
Greg Duncan
@GregatGit
May 27 2016 04:27
@hubhubace paste this in at repl.it
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"
    }
};

console.log(collection[2548]);
then try to console log just"ABBA Gold"
Puja
@Pujachaubey
May 27 2016 04:28
only i have changed return contacts[i][prop];
Thompson Ike
@hubhubace
May 27 2016 04:28
ok
it shows the object
UtkarshShukla7
@UtkarshShukla7
May 27 2016 04:30
@Pujachaubey use if(contacts[i].hasOwnProperty(prop)) instead of if(contacts[i][prop])
Greg Duncan
@GregatGit
May 27 2016 04:30
@hubhubace try displaying 'ABBA Gold'
Puja
@Pujachaubey
May 27 2016 04:30
ok
Thompson Ike
@hubhubace
May 27 2016 04:31
it shows up with incomplete info
just like the original code
ALMY91
@ALMY91
May 27 2016 04:31
@kwal0203 not really .. i got more confused haha
Vehicle.prototype.wheelCount =4;
var vehicle = new Vehicle;
console.log(vehicle.wheelCount)
Eldar Tinjić
@EldarT90
May 27 2016 04:31
var Markdown = React.createClass({
  getDefaultProps: function() {
    return {text: "blablabla"}
  },
  handleChange: function(e) {
   this.setState({text: e.target.text}) 
  },
  render: function() {
    return (<div> <textarea onChange={this.handleChange}>{this.props.text}</textarea> 
        <div className="result">{this.props.text}</div>
      </div>)
  }
})


ReactDOM.render(<Markdown />, document.body)
why am i not getting updated div
Puja
@Pujachaubey
May 27 2016 04:32
still it's not completed.
David Halls
@DavidHalls
May 27 2016 04:33
@GregatGit ty for the link to repl.it, it's helping
CamperBot
@camperbot
May 27 2016 04:33
byzgig sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 534 | @gregatgit |http://www.freecodecamp.com/gregatgit
Thompson Ike
@hubhubace
May 27 2016 04:34
@Byzgig how are you using it?
Greg Duncan
@GregatGit
May 27 2016 04:35
@hubhubace there is a run button on it
David Halls
@DavidHalls
May 27 2016 04:35
@hubhubace work with the console log to try to get the output that you want
Thompson Ike
@hubhubace
May 27 2016 04:35
yeah i gut the run
@Byzgig but what is your code like?
Puja
@Pujachaubey
May 27 2016 04:36
@GregatGit hey plz help me.
David Halls
@DavidHalls
May 27 2016 04:36
@camperbot how do i send brownies
UtkarshShukla7
@UtkarshShukla7
May 27 2016 04:37
@Pujachaubey paste your code once again please
help brownie
CamperBot
@camperbot
May 27 2016 04:37

:point_right: brownie points [wiki]

Brownie Points

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

A user profile picture next to a with Brownie Points score

There are two ways you can get Brownie Points:

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

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

They also add to your Streak.

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

Puja
@Pujachaubey
May 27 2016 04:37

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 contacts";
// Only change code above this line
}

David Halls
@DavidHalls
May 27 2016 04:37
thanks @GregatGit
CamperBot
@camperbot
May 27 2016 04:37
byzgig sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: byzgig already gave gregatgit points
David Halls
@DavidHalls
May 27 2016 04:38
@hubhubace change to this console.log(collection[5439].album); that prints just abba gold
Thompson Ike
@hubhubace
May 27 2016 04:39
what is your if statement like?
UtkarshShukla7
@UtkarshShukla7
May 27 2016 04:39
@Pujachaubey your return messages should be "No such property" and "No such contact" exactly
and even if(contacts[i][prop]) works
Puja
@Pujachaubey
May 27 2016 04:40
yes
David Halls
@DavidHalls
May 27 2016 04:40
@hubhubace still working on that part but this for now
if(value !== "" && prop !== "tracks"){
collection[id].artist = value;
}
Thompson Ike
@hubhubace
May 27 2016 04:41
ok
@Byzgig thanks
CamperBot
@camperbot
May 27 2016 04:41
hubhubace sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @byzgig |http://www.freecodecamp.com/byzgig
Shohanur Rahaman
@shohan4556
May 27 2016 04:41
Hi
I need little help
I want to choose random object
random subobject more specifically
any idea
UtkarshShukla7
@UtkarshShukla7
May 27 2016 04:42
@shohan4556 remember Math.random()
ALMY91
@ALMY91
May 27 2016 04:43
                                                              hi guys                                                                                                                                
whys there an error msg in my codeee

vehicle;                          // {}

var FuzzyBear = function FuzzyBear() { };
vehicle.constructor = FuzzyBear;

Vehicle.prototype.wheelCount =4;
var vehicle = new Vehicle;
console.log(vehicle.wheelCount)
Uncaught TypeError: Cannot set property 'constructor' of undefined
Shohanur Rahaman
@shohan4556
May 27 2016 04:45
@UtkarshShukla7 yes I know math.random but I think my situation is bit different

here is code snipet
var obj = {
subObj1 : {
name:'balloon1',
type:'ordinary'
},

subObj2 : {
  name: 'balloon2',
  type: 'special'
}

};

UtkarshShukla7
@UtkarshShukla7
May 27 2016 04:48
@shohan4556 I'll have to go but I think Object.keys() and MAth.random() would solve your problem
Shohanur Rahaman
@shohan4556
May 27 2016 04:49
thanks I will try
ALMY91
@ALMY91
May 27 2016 04:50
hello zz
Shohanur Rahaman
@shohan4556
May 27 2016 04:51
hi
Zach
@Moose1551
May 27 2016 04:51
Is there a way to use charCodeAt() to get the unicode value of all elements in a string? For example str.charCodeAt(0, str.length - 1)?
That doesn't work, obviously, but is there a way?
kwal0203
@kwal0203
May 27 2016 04:52
@ALMY91 I think the variable needs to have a type to change it's constructor
ALMY91
@ALMY91
May 27 2016 04:53
@kwal0203 this is so difficult..... i think i wld be spending one whole day just on prototypes :/
Ramon Vizcarra
@ahandyman
May 27 2016 04:53
@Byzgig any luck seems like I'm close but keep getting error can't get past first if statement
NixonRichard
@NixonRichard
May 27 2016 05:01
help nesting for loops
CamperBot
@camperbot
May 27 2016 05:01

:point_right: challenge nesting for loops [wiki]

Challenge Nesting For Loops

If you have a multi-dimensional array, you can use the same logic as the prior Challenge to loop through both the array and any sub-arrays. Here is an example:

    var arr = [
      [1,2], [3,4], [5,6]
    ];
    for (var i=0; i < arr.length; i++) {
      for (var j=0; j < arr[i].length; j++) {
        console.log(arr[i][j]);
      }
    }

This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array.

:pencil: read more about challenge nesting for loops on the FCC Wiki

NixonRichard
@NixonRichard
May 27 2016 05:01
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++)console.log)(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]]);
what s wrong with my code ?
ThaleSelaht
@ThaleSelaht
May 27 2016 05:03
there's a console.log inside ur for structure
@NixonRichard actually u are missing brackets at ur second for structure
kwal0203
@kwal0203
May 27 2016 05:05
@ALMY91 what exactly are you trying to do? is this an FCC challenge? where are you getting the code from?
ThaleSelaht
@ThaleSelaht
May 27 2016 05:05
@NixonRichard try to get used to indent ur code, so we can see it clearly
NixonRichard
@NixonRichard
May 27 2016 05:11
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
 for (var i=0;i < product.length;i++){for (var j=0;j < product[i].length;j++)
   console.log(product[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]]);
ALMY91
@ALMY91
May 27 2016 05:11
@kwal0203 Lol no it isn i got it from a website
NixonRichard
@NixonRichard
May 27 2016 05:11
still wrong sorry
David Halls
@DavidHalls
May 27 2016 05:11
@nguyenquangha no, still working on it, and im out for the night, gonna play some league
Ramon Vizcarra
@ahandyman
May 27 2016 05:12
@Byzgig go get 'em
ALMY91
@ALMY91
May 27 2016 05:12
@kwal0203 im trying to get vehicle.wheelCount to console.log the same value as Vehicle.wheelCount
kwal0203
@kwal0203
May 27 2016 05:12
function Vehicle(name, wheels) {
   this.name = name,
   this.wheels = wheels
}

var vehicle_1 = new Vehicle('BMW', 4);

console.log(vehicle_1.wheels)
@ALMY91 does that help?
Thompson Ike
@hubhubace
May 27 2016 05:12
someone please help
js
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection.prop;
}
  else if (prop=="track" && value !=="") {

           collection.push(collection.prop);
}
  else {delete collection.prop;

       }
  return collection.id;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
kwal0203
@kwal0203
May 27 2016 05:12
@ALMY91 in your code there is no Vehicle.wheelCount
ALMY91
@ALMY91
May 27 2016 05:13
@kwal0203 Vehicle.prototype.wheelCount?
@kwal0203 is that the same?
kwal0203
@kwal0203
May 27 2016 05:13
@ALMY91 what is Vehicle?
ALMY91
@ALMY91
May 27 2016 05:13
@kwal0203 what do u mean
ThaleSelaht
@ThaleSelaht
May 27 2016 05:14
@NixonRichard still missing the brackets of ur second for structure
eeflores
@eeflores
May 27 2016 05:14
@hubhubace the collection object is made up of 4 elements. You would use id (using bracket notation) to access the values from collection
kwal0203
@kwal0203
May 27 2016 05:14
@ALMY91 where have you defined Vehicle?
NixonRichard
@NixonRichard
May 27 2016 05:15
{for (var j=0;j < product[i].length;j++)
which brakets ?
Thompson Ike
@hubhubace
May 27 2016 05:15
@eeflores ok
ThaleSelaht
@ThaleSelaht
May 27 2016 05:15
@NixonRichard yes
Markus Kiili
@Masd925
May 27 2016 05:16
@hubhubace First try to figure out how to access a particular record with given id.
ThaleSelaht
@ThaleSelaht
May 27 2016 05:16
@NixonRichard and second
Thompson Ike
@hubhubace
May 27 2016 05:16
@Masd925 ok
ThaleSelaht
@ThaleSelaht
May 27 2016 05:16
@NixonRichard u must use ur for to run through the arr array
Markus Kiili
@Masd925
May 27 2016 05:16
@hubhubace Also .prop and .iddon't work because
The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
ThaleSelaht
@ThaleSelaht
May 27 2016 05:17
@NixonRichard look at this also https://en.wikipedia.org/wiki/Indent_style
kwal0203
@kwal0203
May 27 2016 05:19
@ALMY91 show me the page your looking at
NixonRichard
@NixonRichard
May 27 2016 05:23
 for (var i=0;i < product.length;i++)
 {for (var j=0;j < product[i].length;j++)
   console.log(product[i][j]);}

  // Only change code above this line
plz i cant see anywhere to put the brackets
richiedSIS
@richiedSIS
May 27 2016 05:23
Hi there. I'm having trouble with Falsy Bouncer. I think it's a problem with how I'm using the filter function. Any suggestions?
function bouncer(arr) {

  var filterFunc = function(item){

      return (item === false || item===null || isNaN(item) || item===undefined || item===""||item ===0);
  };
  return arr.filter(filterFunc);
}
//bouncer([false, null, 0, NaN, undefined, ""]);
bouncer([7, "ate", "", false, 9]);
Markus Kiili
@Masd925
May 27 2016 05:24
@richiedSIS isNaN() is not a test for value NaN. It coerces the value first to type number and then tests for NaN, so returning true for many other values besides NaN.
ThaleSelaht
@ThaleSelaht
May 27 2016 05:25
@NixonRichard for(){ for(){ } }
NixonRichard
@NixonRichard
May 27 2016 05:25
see that
var arr = [
  [1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
cuz of the example
they covered the brackets before console.log
Markus Kiili
@Masd925
May 27 2016 05:26
@richiedSIS Also the callback should return true for those elements you like to keep.
ThaleSelaht
@ThaleSelaht
May 27 2016 05:27
@NixonRichard at u second for structure u are checking if (j < arr[i].length) instead of (j < arr[j].length)
richiedSIS
@richiedSIS
May 27 2016 05:31
@Masd925 Oh that makes sense with the results I was getting. I changed it and the only thing now is it's not removing null. I looked around online and it says that testing for variable === null should work, but it's not here.
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  var filterFunc = function(item){

       if(item === false || item===null ||  item===undefined || item===""||item ===0)
         return false;
       else 
         return true;
  };

  return arr.filter(filterFunc);

}
bouncer([false, null, 0, NaN, undefined, ""]);
Markus Kiili
@Masd925
May 27 2016 05:31
@richiedSIS It is NaN you are not removing. FCC shows it as null.
@richiedSIS Doing !(item === false || ....) is easier than those if and else.
Nick Robson
@nickrobson
May 27 2016 05:39
If you prefer a complete solution,
var bouncer=a=>a.filter(a=>!!a);
richiedSIS
@richiedSIS
May 27 2016 05:39
@Masd925 How can I test for NaN? when I try item ===NaN the little yellow warning comes up saying to use isNaN(). Do I have to convert it first to something?
Eli
@elisspace
May 27 2016 05:40
meta question: is it okay to cross post to different rooms if you're looking for help?
Nick Robson
@nickrobson
May 27 2016 05:40
@richiedSIS Use isNaN(myVar)
Markus Kiili
@Masd925
May 27 2016 05:40
@richiedSIS item!==item tests item for value NaN
Nick Robson
@nickrobson
May 27 2016 05:40
@Masd925 No, since NaN != NaN and NaN !== NaN will both return true lol.
Dan Couper
@DanCouper
May 27 2016 05:40
@richiedSIS Don't test them individually going if...else, just test the item once with: ThisIsTheThingItTellsYouToLookAtInTheInstructions(item), the one that avoids ever having to explicitly check for NaN
Jonathan
@jcadle
May 27 2016 05:40
I have a very basic Javascript question
Nick Robson
@nickrobson
May 27 2016 05:41
@jcadle shoot
Markus Kiili
@Masd925
May 27 2016 05:41
@nickrobson item!==item is true for only item value NaN. Therefore it tests for NaN.
@nickrobson And isNaN is not a test for value NaN. isNaN("fajn"); // true
Jonathan
@jcadle
May 27 2016 05:41
I've noticed that a lot of tutorials declare functions like this: var foo = function(x){ return nothing;}
Nick Robson
@nickrobson
May 27 2016 05:41
@NixonRichard Ah right, that works I suppose.
Jonathan
@jcadle
May 27 2016 05:42
why do they do that, instead of function foo(x){return nothing;} ?
Nick Robson
@nickrobson
May 27 2016 05:42
isNaN(0)
>> false
isNaN("")
>> false
isNaN(NaN)
>> true
@Masd925 it works. ^
Markus Kiili
@Masd925
May 27 2016 05:42
@nickrobson isNaN("fajn"); // true
Nick Robson
@nickrobson
May 27 2016 05:43
ew
Markus Kiili
@Masd925
May 27 2016 05:43
@nickrobson If you combine isNaN with type check, it becomes a test for NaN
Nick Robson
@nickrobson
May 27 2016 05:43
typeof(myVar) == "NaN" then? idk lol, easier to do your way
Although mine is still the best.. :3
var bouncer=a=>a.filter(a=>!!a);
Markus Kiili
@Masd925
May 27 2016 05:44
@nickrobson It is better to fix his code and then help him to find better solutions.
Nick Robson
@nickrobson
May 27 2016 05:44
bouncer([false, null, 0, NaN, undefined, ""]); // => []
Nick Robson
@nickrobson
May 27 2016 05:45
@Masd925 ofc, I'm just pointing out that !! is better in this case
kwal0203
@kwal0203
May 27 2016 05:45
@nickrobson what is !!?
Nick Robson
@nickrobson
May 27 2016 05:45
It is basically an "is it falsey" operator.
@kwal0203 It turns the variable into a boolean. If it's truthy, it becomes true, and otherwise it becomes false
kwal0203
@kwal0203
May 27 2016 05:45
@nickrobson so it's asking if a is falsey?
Nick Robson
@nickrobson
May 27 2016 05:46
@kwal0203 yup :)
richiedSIS
@richiedSIS
May 27 2016 05:46
I was able to complete it with item!==item , but I don't understand what that's testing for. Can you explain it?
Jonathan
@jcadle
May 27 2016 05:46
@ThaleSelaht Yes, I know that's the "correct" way to declare a function; it's just odd to me that tutorials do it the other way.
kwal0203
@kwal0203
May 27 2016 05:46
@nickrobson wow, cool
Jonathan
@jcadle
May 27 2016 05:46
Both work, but is there any benefit to doing it one way or the other?
Nick Robson
@nickrobson
May 27 2016 05:47
@kwal0203 An easy way to think of it is as if it's a pseudo code function:
!!(a) {
   if a is truthy, return true
   if a is falsey, return false
}
Jonathan
@jcadle
May 27 2016 05:47
Ah, I see, you did answer my questions. Thanks @ThaleSelaht
CamperBot
@camperbot
May 27 2016 05:47
jcadle sends brownie points to @thaleselaht :sparkles: :thumbsup: :sparkles:
:cookie: 209 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
ThaleSelaht
@ThaleSelaht
May 27 2016 05:47
@jcadle =P
kwal0203
@kwal0203
May 27 2016 05:47
@nickrobson yeah i see. I love the new bracket notation
@nickrobson I hadn't seen !! before
ThaleSelaht
@ThaleSelaht
May 27 2016 05:47
@jcadle anytime mate
Jonathan
@jcadle
May 27 2016 05:48
Though I have trouble imagining a situation where being able to rename the variable assigned to a function would be helpful
Nick Robson
@nickrobson
May 27 2016 05:48
It's really just doing !(!(a)) :3
Jonathan
@jcadle
May 27 2016 05:48
I mean, I've never wanted to rename a function in the middle of a program before
Nick Robson
@nickrobson
May 27 2016 05:48
or in long notation
var a = ....;
a = !a;
a = !a;
Markus Kiili
@Masd925
May 27 2016 05:48
@nickrobson Those !! are actually redundant, because filter has automatic coercion to boolean.
Nick Robson
@nickrobson
May 27 2016 05:48
@Masd925 Yeah, but that depends on the JS VM
Gecko and V8 do type coercion
but some don't for some reason
shrugs
ThaleSelaht
@ThaleSelaht
May 27 2016 05:49
@jcadle yeah, it would be a very specific situation, so don't worry about it
kwal0203
@kwal0203
May 27 2016 05:51
@Masd925 ah cool, can write filter functions with so little code now
96street
@96street
May 27 2016 05:54
how do I convert a number to a whitespace?
if(arr[i] == 45){
      arr[i] == arr[i].toString(" ");
    }
this is wrong
kwal0203
@kwal0203
May 27 2016 05:55
@96street need to .push into the arr array?
96street
@96street
May 27 2016 05:56
what do you mean?
kwal0203
@kwal0203
May 27 2016 05:56
let str = ' ';
if(arr[i] == 45) {
      arr[i] = str;
}
@96street also you gotta change == to =
Markus Kiili
@Masd925
May 27 2016 05:57
@nickrobson Your suggestion for NaN check typeof(myVar) == "NaN" doesn't work because NaN has type "number". Perhaps you could check your solutions before posting on help channel.
kwal0203
@kwal0203
May 27 2016 05:58
@96street see my edit
@96street does that work?
96street
@96street
May 27 2016 05:59
no it doesn't @kwal0203
is let the same as creating a variable? @kwal0203
Can someone tell me why this isn't working (Caesars Cipher)
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var ws = " ";

  for(var i = 0;i < str.length;i++) {
    arr.push(str[i].charCodeAt());
    if(arr[i] > 46) {
    arr[i] -= 13;
    }
    else if(arr[i] == 45){
      arr[i] = ws;
    }
    else {arr[i] += 13;}

  }

  return arr.map(x => String.fromCharCode(x)).join(' ');
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Ramon Vizcarra
@ahandyman
May 27 2016 06:05

Record Collection: Update/set value for prop -

function updateRecords(id, prop, value) {

if (value !== "" && prop !== "tracks") {

    console.log("value: " +value);
    console.log("prop: "+ prop);

    console.log(collection[id]);

    collection.id[prop] = value;
//    console.log(collection);

}

 return collection;
}

using repl to test-- error : cannot set property 'artist' of undefined. I've been stuck on this and I've made some progress but I am still confused. Any suggestions for a next step would be helpful

  1. how come prop: artist is undefined??
Markus Kiili
@Masd925
May 27 2016 06:11
@ahandyman .id doesn't work because
The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
So .id looks for property key "id", not the key stored in parameter id.
Ramon Vizcarra
@ahandyman
May 27 2016 06:15
@Masd925 my brain is fried =( i read that earlier and now I'm reading it again. I see words but ... nothing going for more coffee quick break be right back
JimmyBonez
@JimmyBonez
May 27 2016 06:16

function findLongestWord(str) {
  var x = str.split();

  for(var i = 0;i < x.length;i++){
    return i;
  }

}

findLongestWord("The quick brown fox jumped over the lazy dog")
The for loop isn't iterating through, and providing the length of i? What is it that I am doing wrong? I mean when I return i it should give me the number 44 but it gives me 0, this could be lack of sleep.
Markus Kiili
@Masd925
May 27 2016 06:17
@JimmyBonez First of all, use .split(" ");
You are also returning on loop i=0 so it ends the function execution.
Ramon Vizcarra
@ahandyman
May 27 2016 06:17
@Masd925 it just clicked property key... okay lets see if i can work with that. thank you
CamperBot
@camperbot
May 27 2016 06:17
ahandyman sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1624 | @masd925 |http://www.freecodecamp.com/masd925
Dan Couper
@DanCouper
May 27 2016 06:19
@kwal0203 don't just aim to use as little code as possible; more readable solution is to use Boolean(val)instead of !!val(where val is the current value you're filtering). !! is fine, I use it quite a bit to cut down code length, but Booleanis much more explicit and you're more likely to remember what your code does if you look at it in a day or a week's time. You're also less likely to mistype. !!! does a different thing to !! does a different thing to ! but none are syntax errors, whereas 'Boobian' is going to immediately give and easy-to-locate error.
Markus Kiili
@Masd925
May 27 2016 06:19
@ahandyman Bracket notation is the general way to access property values. Dot notation works only on one special case when you know the key string and write is after the dot.
JimmyBonez
@JimmyBonez
May 27 2016 06:19
@Masd925 hmm so I thought a for loop iterates through an array and if you set the string to .length it would count. Maybe ditch digging would be a better use of my time.
Markus Kiili
@Masd925
May 27 2016 06:20
@DanCouper var bouncer=a=>a.filter(a=>a); also works. Or var bouncer=a=>a.filter(Boolean);
Jonathan Schwob
@JonathanSchwob
May 27 2016 06:21
var x = str.split();
jimmy that will only return the number that i iterates to
which is the length of the array
JimmyBonez
@JimmyBonez
May 27 2016 06:22
it isn't giving me a number
that is the problem it spits out zero
ThaleSelaht
@ThaleSelaht
May 27 2016 06:24
@JimmyBonez remember that the split() function must receive a param, like split('')
Jonathan Schwob
@JonathanSchwob
May 27 2016 06:24
even so you don’t want a number, you want to return the string that is the longest word
JimmyBonez
@JimmyBonez
May 27 2016 06:24
I did that still comes out to zero
I am not to the point of what is the longest word, if the for loop wont even count through the string.
96street
@96street
May 27 2016 06:25
Can someone tell me how I would write this using a function?
return arr.map(x => String.fromCharCode(x)).join(' ')
Dan Couper
@DanCouper
May 27 2016 06:26
@Masd925 I'm not quite convinced on the first; you need to know that filter itself coerces. a => Boolean(a) is obvs doing the same thing but is more explicit imo, and leads to the second solution .
Markus Kiili
@Masd925
May 27 2016 06:26
@96street It is using a function ;) You mean non-ES6 way?
96street
@96street
May 27 2016 06:26
Yes^
prefer using the other way
Markus Kiili
@Masd925
May 27 2016 06:26
@DanCouper Yes, Boolean(a) is the most readable way.
@96street
return arr.map(function(x){
    return String.fromCharCode(x);
}).join(' ');
96street
@96street
May 27 2016 06:32
How come this doesn't work? @Masd925
   arr.map(function(x) {
    String.fromCharCode(x);
  });

  return arr;
wait i left out the join() one sec
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var ws = " ";

  for(var i = 0;i < str.length;i++) {
    arr.push(str[i].charCodeAt());
    if(arr[i] > 77) {
    arr[i] -= 13;
    }
    else if(arr[i] == 32){
      arr[i] = arr[i];
    }
    else {arr[i] += 13;}

  }

    arr.map(function(x) {
    String.fromCharCode(x);      
  }).join(' ');

  return arr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
@Masd925 can you have a look at this?
the for loop is all correct just the map(); not working
Markus Kiili
@Masd925
May 27 2016 06:35
@96street Use arr=arr.map(...) maybe.
96street
@96street
May 27 2016 06:36
Tried it it returns nothing
Markus Kiili
@Masd925
May 27 2016 06:36
This message was deleted
Darth Skywalker
@adityaparab
May 27 2016 06:37

@96street : .map returns modified array. It doesn't modify the original array.

It creates an array with the elements returned from the callback you provide to the .map function. Currently, you aren't returning anything.

So the correct way is,

arr  = arr.map(function(x) {
     return String.fromCharCode(x);      
  }).join(' ');
96street
@96street
May 27 2016 06:38
Yeah that worked ty @adityaparab
CamperBot
@camperbot
May 27 2016 06:38
96street sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
May 27 2016 06:38
Sweet!
96street
@96street
May 27 2016 06:38
So the code works now but it's failing the tests
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var ws = " ";

  for(var i = 0;i < str.length;i++) {
    arr.push(str[i].charCodeAt());
    if(arr[i] > 77) {
    arr[i] -= 13;
    }
    else if(arr[i] == 32){
      arr[i] = arr[i];
    }
    else {arr[i] += 13;}

  }

  arr  = arr.map(function(x) {
     return String.fromCharCode(x);      
  }).join(' ');

  return arr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
that returns "FREE CODE CAMP" like it should
Markus Kiili
@Masd925
May 27 2016 06:39
@96street Use .join("") <- no space here
Darth Skywalker
@adityaparab
May 27 2016 06:39
@96street : can you tell me whats the challenge. I only fixed the syntax issues there. But I see many semantic errors here.
96street
@96street
May 27 2016 06:40
Ahh yes thanks it pasted the first test @Masd925
CamperBot
@camperbot
May 27 2016 06:40
:star2: 1625 | @masd925 |http://www.freecodecamp.com/masd925
96street sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
96street
@96street
May 27 2016 06:40
Caesars Cipher @adityaparab i'm failing everything but the first test
Mithun reddy
@mithunreddyt
May 27 2016 06:40
When I am typing on load event function in my laptop it's not poping up but when tried the same code different laptop it's showing may I know wat may be the reason
Markus Kiili
@Masd925
May 27 2016 06:41
@96street Something wrong with the charcode mapping.
96street
@96street
May 27 2016 06:42
Ah yep I don't think i've taken into account punctuations etc
Will be back
Darth Skywalker
@adityaparab
May 27 2016 06:42
@96street : you step and wrap each characters by 13 places? Should it be case sensitive or case insensitive?
96street
@96street
May 27 2016 06:43
Insensitive, all the tests are capitals
the for loop works for everything except question, exclamation marks etc
kirbyedy
@kirbyedy
May 27 2016 06:44
@RemoJohnson You should have two single quotes ' and four double quotes ", Remove all the backslashes ()
RemoJohnsonRJ
@RemoJohnsonRJ
May 27 2016 06:47
@kirbyedy how can i use quotes without backslash ?
help me with that @kirbyedy
CamperBot
@camperbot
May 27 2016 06:47
no wiki entry for: me with that @kirbyedy
kirbyedy
@kirbyedy
May 27 2016 06:47
@RemoJohnson you have to replace the " with '
Dan Couper
@DanCouper
May 27 2016 06:47
@96street You only need A-Z, which is in the range 65-90 inclusive; you shouldn't need to deal with punctuation
kirbyedy
@kirbyedy
May 27 2016 06:47
and remove the \
96street
@96street
May 27 2016 06:47
Completed
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var ws = " ";

  for(var i = 0;i < str.length;i++) {
    arr.push(str[i].charCodeAt());
    if(arr[i] > 77) {
    arr[i] -= 13;
    }
    else if(arr[i] < 65){
      arr[i] = arr[i];
    }
    else {arr[i] += 13;}

  }

  arr  = arr.map(function(x) {
     return String.fromCharCode(x);      
  }).join('');

  return arr;
}

// Change the inputs below to test
rot13("SERR CVMMN!");
Can you just explain this code again?
arr = arr.map(function(x) { return String.fromCharCode(x); }) @adityaparab
Dan Couper
@DanCouper
May 27 2016 06:49
@96street ah,
Darth Skywalker
@adityaparab
May 27 2016 06:51
@96street : What do you think? Much faster and less iterations and repeating code ;)

function rot13(str) { // LBH QVQ VG!
  return Array.prototype.map.call(str, function(a){
    var charCode = a.charCodeAt();
    if(charCode > 77){
      return String.fromCharCode(charCode -= 13);
    } else if(charCode < 65){
      return String.fromCharCode(charCode);
    } else {
      return String.fromCharCode(charCode += 13);
    }
  });
}
96street
@96street
May 27 2016 06:52
Damn, much better @adityaparab
Roy
@AMD-Roy
May 27 2016 06:52
who can help me

Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.

For the purpose of this exercise, you should also capitalize connecting words like "the" and "of".

titleCase("I'm a little tea pot") should return a string.
titleCase("I'm a little tea pot") should return "I'm A Little Tea Pot".
titleCase("sHoRt AnD sToUt") should return "Short And Stout".

function titleCase(str) {

var uw=str.toLowerCase().split(" ");
var xx='';
for(var i=0;i<uw.length;i++){
//var xxx=uw[i].toLowerCase();
xx=xx+' '+uw[i].substring(0,1).toUpperCase()+uw[i].substring(1);
}
//return word.substring(0,1).toUpperCase()+word.substring(1);}
//
return xx;
}

titleCase("sHoRt AnD sToUt");

this is my code
but can't pass to next
Markus Kiili
@Masd925
May 27 2016 06:54
@96street The charcode mapping can also be done with single remainder operation:
function rot13(str) {
  return str.split("").map(function(char){
      var cc = char.charCodeAt(0);
      return (cc>64 && cc<91) ? String.fromCharCode(cc%26+65) : char;
  }).join("");
}
Dan Couper
@DanCouper
May 27 2016 06:56
Ah, that is nice
96street
@96street
May 27 2016 06:56
Jeez that's good as
Ramon Vizcarra
@ahandyman
May 27 2016 06:56
@Masd925 just about solved it 3/4. thank you!!!!!!!
CamperBot
@camperbot
May 27 2016 06:56
ahandyman sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: ahandyman already gave masd925 points
Darth Skywalker
@adityaparab
May 27 2016 06:56

@96street : Take a look at this.

.map function return an array from the values you return from it's callback function. So


var arr = ['a','b','c','d'];

console.log(arr); //["a", "b", "c", "d"]

arr = arr.map(function(x){ return x.charCodeAt()});

console.log(arr); //[97, 98, 99, 100]

arr = arr.map(function(x) { return String.fromCharCode(x); });

console.log(arr); //["a", "b", "c", "d"]
96street
@96street
May 27 2016 06:59
Thanks that's a really clear example @adityaparab
CamperBot
@camperbot
May 27 2016 06:59
96street sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: 96street already gave adityaparab points
Darth Skywalker
@adityaparab
May 27 2016 07:02

@96street : String.fromCharCode(x) will return you the character that has ASCII code equal to value of x.

ASCII is a character map. Each character on keyboard has a unique code mapped to it's character representation.

So the charCodeAt takes ASCII code as input and returns it's equivalent character.

.map will just get the characters returned from the callback fruntion and make and array out of it.

read more about ASCII mapping here - http://www.ascii-code.com/

If you notice, the A is 65 and Z is 90 (to the base 10, that is on decimal scale)

Same is for a to z (97 to 122)

Having said that, you can now also modify your original code to make it case sensitive. :)

Surbhi Oberoi
@surbhioberoi
May 27 2016 07:04
hey, can someone help me with how to send a XML http request to the server to fetch the data as JSON objects
Something like ajax i guess, not sure
Markus Kiili
@Masd925
May 27 2016 07:05
@surbhioberoi JS or jquery?
Surbhi Oberoi
@surbhioberoi
May 27 2016 07:05
js
Markus Kiili
@Masd925
May 27 2016 07:09
@surbhioberoi Here is one example: http://www.w3schools.com/json/json_http.asp
Surbhi Oberoi
@surbhioberoi
May 27 2016 07:10
@Masd925 This is exactly what I wanted to know, thank you! :)
CamperBot
@camperbot
May 27 2016 07:10
surbhioberoi sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1626 | @masd925 |http://www.freecodecamp.com/masd925
Ramon Vizcarra
@ahandyman
May 27 2016 07:12

'''
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

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

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

return collection;
}

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

CamperBot
@camperbot
May 27 2016 07:12
:bulb: to format code use backticks! ``` more info
Ramon Vizcarra
@ahandyman
May 27 2016 07:13
sorry
Markus Kiili
@Masd925
May 27 2016 07:13
@ahandyman When prop is tracks, push the value.
96street
@96street
May 27 2016 07:15
What's the difference between Array.prototype.map() and Array.map()
Ramon Vizcarra
@ahandyman
May 27 2016 07:16
@Masd925 push? I was following the example in 'Add New Properties to a JavaScript Object' it worked in repl not in camp. but I'll give it a shot you have steered me wrong =)
Markus Kiili
@Masd925
May 27 2016 07:16
@96street There is no Array.map()
Ramon Vizcarra
@ahandyman
May 27 2016 07:16
*haven't
Markus Kiili
@Masd925
May 27 2016 07:17
@ahandyman You see that the tracks property value of each record is an array. You need to push the value if prop is tracks. That is one of the use cases.
96street
@96street
May 27 2016 07:18
Can you give an example with and without prototype? @Masd925
I've tried looking up what it does but MDN explanation was hard to understand
Ramon Vizcarra
@ahandyman
May 27 2016 07:19
@Masd925 I see it lol, you're the best
Darth Skywalker
@adityaparab
May 27 2016 07:19

@96street : To understand that, you need to first understand prototype object in JS.

Have you worked with any Object Oriented Programming Language other than JS? Like Java, C++, C# etc?