These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Jun 2016
Moisés Man
@moigithub
Jun 18 2016 00:00

@mafelix
Mashape supports the following Authentication types:

Query Parameters
HTTP Headers
HTTP Basic
OAuth 1.0a
OAuth 2.0

FM
@mafelix
Jun 18 2016 00:00
https://market.mashape.com/andruxnet/random-famous-quotes
Moisés Man
@moigithub
Jun 18 2016 00:00
probably query parameters would be easier :)
FM
@mafelix
Jun 18 2016 00:01
hmm...
the docs for the api I want to use don't talk about that
Moisés Man
@moigithub
Jun 18 2016 00:02
@mafelix here example using javascript
http://docs.mashape.com/javascript
FM
@mafelix
Jun 18 2016 00:02
@moigithub thanks that's what I needed.
CamperBot
@camperbot
Jun 18 2016 00:02
mafelix sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: mafelix already gave moigithub points
David Halls
@DavidHalls
Jun 18 2016 00:03
@twhite96 you need a loop because you dont know how many items you will see
Josh Terry
@jaywikid
Jun 18 2016 00:04
@aryandua
heres my code

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

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

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

wont return Not Found
Norvin Burrus
@ndburrus
Jun 18 2016 00:05
@jaywikid which challenge is this?
Josh Terry
@jaywikid
Jun 18 2016 00:05
@ndburrus Testing Objects for Properties
Moisés Man
@moigithub
Jun 18 2016 00:06
@jaywikid if(myObj.hasOwnProperty("gift")){ u still hardcoding values (like gift, pet)
u should use the variable.. to make the code more "generic"
Norvin Burrus
@ndburrus
Jun 18 2016 00:07
@jaywikid the function checkObj uses a variable. it does not appear that it is needed? :smile: the variable is accepted by the function, then returned - unchanged?
Josh Terry
@jaywikid
Jun 18 2016 00:07
Ok soi am only using variables, got it. Thanks @ndburrus @moigithub @aryandua
CamperBot
@camperbot
Jun 18 2016 00:07
jaywikid sends brownie points to @ndburrus and @moigithub and @aryandua :sparkles: :thumbsup: :sparkles:
:cookie: 571 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 344 | @aryandua |http://www.freecodecamp.com/aryandua
:star2: 1451 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 18 2016 00:08
@jaywikid the variable checkProp contains whatever value u passing tothe function
checkObj("pet"); <-- calling
function checkObj(checkProp) { <-- function header
in this example... checkProp would be "pet"
Norvin Burrus
@ndburrus
Jun 18 2016 00:08
@jaywikid nice work :sparkles:
Josh Terry
@jaywikid
Jun 18 2016 00:09
Once i realized I was just supposed to be setting the functions variable change off to .hasOwnProperty it made since to me
markom93
@markom93
Jun 18 2016 00:10
im still stuck on the lookUpProfile function guys
anybody care to help?
tried it with a for loop, didn't work
Diego Mayer
@Chrono79
Jun 18 2016 00:11
@markom93 pm your code
markom93
@markom93
Jun 18 2016 00:11
now i've tried it with a while loop, it still doesn't work fully
@Chrono79
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
  while (i<contacts.length) {
    if(contacts[i].firstName == firstName){
      if (contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }
      else if (contacts[i].hasOwnProperty(prop) === false && i<contacts.length){
        i++;
      }
      else {
        return "No such property";
      }
    }
    else if (contacts[i].firstName !== firstName && i<contacts.length){
      i++;
    }
    else {
      return "No such contact";
    }
  }



// Only change code above this line
}
Norvin Burrus
@ndburrus
Jun 18 2016 00:12
@twhite96 hmmm.... conceptually, i used a while loop to iterate through the array (in sizes equal to size)... clear as mud? :sparkles: so, this is the current code ouput:
array: b,c,d
newArray: ,b,c,d
=> [ [], [ 'b', 'c', 'd' ] ]
markom93
@markom93
Jun 18 2016 00:13
so last time i did it with a for loop, it gave me errors with existing properties and now it gives me error with the non existent ones
Moisés Man
@moigithub
Jun 18 2016 00:14
@markom93 if u find the contact if(contacts[i].firstName == firstName){
u only need to care if have or not the property...
Stephen James
@sjames1958gm
Jun 18 2016 00:14
@markom93 so if you were going through a stack of business cards, would you quit after the first one that didn't have the correct name, or after going through all the cards?
markom93
@markom93
Jun 18 2016 00:16
@sjames1958gm how does that apply here lol
Moisés Man
@moigithub
Jun 18 2016 00:16
return no contact AFTER the loop @markom93
FM
@mafelix
Jun 18 2016 00:18
@moigithub I'm getting back an object object back.
markom93
@markom93
Jun 18 2016 00:18
can someone paste me their code so i can see where i made a mistake, because i don't get what you guys are trying to say
FM
@mafelix
Jun 18 2016 00:18
@moigithub I forget what that means
Moisés Man
@moigithub
Jun 18 2016 00:18
console.log to check its values @mafelix
MrBurks
@mrburks
Jun 18 2016 00:19

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

case 1:
 val = "alpha";
  break;

case 2:
 val = "beta";
  break;

case 3:
 val =  "gamma";
  break;

case 4:
 val =  "delta";

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

// Change this value to test
caseInSwitch(1);

FM
@mafelix
Jun 18 2016 00:19
@moigithub I'm trying to. codepen is sending me an object object alert
Moisés Man
@moigithub
Jun 18 2016 00:19
@mafelix probably u getting something like this
soo u need to use ur bracket/dot notation to access whatever data u wanna show
FM
@mafelix
Jun 18 2016 00:19
  $('#quoteBtn').on('click',function(){
    $('.quote').html('Fuck you man!');

  //ajax post request to random quotes API
    $.ajax({
      url: 'https://andruxnet-random-famous-quotes.p.mashape.com/',
      type: 'POST',
      dataType: 'json',
      data: {cat: 'movies'},
      beforeSend: function(xhr){
        xhr.setRequestHeader('X-Mashape-Key','7gu7hESgwNmshUcYT0SWBAxoko2Zp1OIdlejsnfVwEe22E3xRC');
      },
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);

      }
    })
});
Moisés Man
@moigithub
Jun 18 2016 00:19
post ur codepen
FM
@mafelix
Jun 18 2016 00:20
let me change the vulgar text first
hahha
Diego Mayer
@Chrono79
Jun 18 2016 00:20
@mrburks it should be answer = "alpha" not val = "alpha",
also, you're missing a } to close your switch
markom93
@markom93
Jun 18 2016 00:20
nevermind, got it
thanks @moigithub
CamperBot
@camperbot
Jun 18 2016 00:20
markom93 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1452 | @moigithub |http://www.freecodecamp.com/moigithub
David Halls
@DavidHalls
Jun 18 2016 00:20
@StayGoldDylan look at your assignment operators
Moisés Man
@moigithub
Jun 18 2016 00:21
@markom93 :+1:
Stephen James
@sjames1958gm
Jun 18 2016 00:21
@markom93 Looks like you are really working hard to put the no such contact inside your loop
Norvin Burrus
@ndburrus
Jun 18 2016 00:21
@StayGoldDylan ...should the var/iable be defined before or after it is used? :)
FM
@mafelix
Jun 18 2016 00:21
@ndburrus before
MrBurks
@mrburks
Jun 18 2016 00:21
@StayGoldDylan get rid of the =2 on the first line
FM
@mafelix
Jun 18 2016 00:22
@ndburrus how do you use a variable that's not defined?
Dylan Wells
@StayGoldDylan
Jun 18 2016 00:22
@Byzgig and @mrburks Thank you!
CamperBot
@camperbot
Jun 18 2016 00:22
staygolddylan sends brownie points to @byzgig and @mrburks :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @byzgig |http://www.freecodecamp.com/byzgig
:cookie: 202 | @mrburks |http://www.freecodecamp.com/mrburks
Dylan Wells
@StayGoldDylan
Jun 18 2016 00:22
don't know how I was missing that!!!
Moisés Man
@moigithub
Jun 18 2016 00:22
@mafelix missing a closing }); at the end
FM
@mafelix
Jun 18 2016 00:22
@moigithub kk let me fix that
Moisés Man
@moigithub
Jun 18 2016 00:22
@mafelix after i click the button i get this
Object {quote: "I am big! It's the pictures that got small.", author: "Sunset Blvd.", category: "Movies"}
Norvin Burrus
@ndburrus
Jun 18 2016 00:23
@StayGoldDylan well, it will be defined. why would you want it to not be defined? also, note @mrburks 's comment about the multiple asignment operator... sorry, posted to wrong camper
FM
@mafelix
Jun 18 2016 00:23
@moigithub maybe the closing tags were the only thing I was missing then
cuz I'm getting back objects now
Moisés Man
@moigithub
Jun 18 2016 00:23
:D @mafelix
FM
@mafelix
Jun 18 2016 00:23
a;ojaoiwejgoi;ajga34othq305023hy2h3yqhfaweu4wlo9mhLTK23t2qTl2mt3k dhQ239
I WISH LINTERS WERE ON CODEPEN CATCHING IT
Moisés Man
@moigithub
Jun 18 2016 00:24
@mafelix using chrome ?
FM
@mafelix
Jun 18 2016 00:25
@moigithub yessir
@ndburrus by defined what do you mean?
Norvin Burrus
@ndburrus
Jun 18 2016 00:26
@mafelix posted to wrong camper, sorry.. :+1:
MrBurks
@mrburks
Jun 18 2016 00:26

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

case 1:
 val = "alpha";
  break;

case 2:
 val = "beta";
  break;

case 3:
 val =  "gamma";
  break;

case 4:
 val =  "delta";

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

// Change this value to test
caseInSwitch(1);

FM
@mafelix
Jun 18 2016 00:26
no worries
Moisés Man
@moigithub
Jun 18 2016 00:26
@mafelix when some error.. sometimes codepen shows a red circle with a !
also u can control +shift +j to open browser console to check for errors
Diego Mayer
@Chrono79
Jun 18 2016 00:26
@mrburks :point_up: 17 de junio de 2016 21:20
FM
@mafelix
Jun 18 2016 00:26
@moigithub cool thanks.
CamperBot
@camperbot
Jun 18 2016 00:26
:warning: mafelix already gave moigithub points
mafelix sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
MrBurks
@mrburks
Jun 18 2016 00:27
@Chrono79 huh?
FM
@mafelix
Jun 18 2016 00:27
cmd control i for macs
Diego Mayer
@Chrono79
Jun 18 2016 00:27
@mrburks read, already told you what to fix there
Moisés Man
@moigithub
Jun 18 2016 00:27
@mrburks u overriding val variable u should work with answer instead
Norvin Burrus
@ndburrus
Jun 18 2016 00:27
This message was deleted
MrBurks
@mrburks
Jun 18 2016 00:30
@Chrono79 yeah i did it with just alpha and not val=alpha the first 15 times.
Diego Mayer
@Chrono79
Jun 18 2016 00:30

@mrburks

@mrburks it should be answer = "alpha" not val = "alpha",
also, you're missing a } to close your switch

Did I say just alpha?
Norvin Burrus
@ndburrus
Jun 18 2016 00:31
@mrburks reference the instructions sets answer for the following conditions: :)
MrBurks
@mrburks
Jun 18 2016 00:31
ok fixed the val= part and the } part. still no workie
Diego Mayer
@Chrono79
Jun 18 2016 00:31
let's see it now
MrBurks
@mrburks
Jun 18 2016 00:32
@ndburrus that tells me nothing. I don't even know what this function is supposed to do
Diego Mayer
@Chrono79
Jun 18 2016 00:32
copy and paste your code again @mrburks
MrBurks
@mrburks
Jun 18 2016 00:32
what am i supposed to do with this var answer = ""; statement

@Chrono79
function caseInSwitch(val) {
var answer = " ";
// Only change code below this line
switch (val) {

case 1:
  "alpha";
  break;

case 2:
 "beta";
  break;

case 3:
   "gamma";
  break;

case 4:
  "delta";

// Only change code above this line
return answer;
}
}
// Change this value to test
caseInSwitch(1);

Diego Mayer
@Chrono79
Jun 18 2016 00:33
you haven't fixed it
and the } should be added above return answer, not below it
case 1:
  answer = "alpha";
  break;
Norvin Burrus
@ndburrus
Jun 18 2016 00:34
MrBurks
@mrburks
Jun 18 2016 00:35
now see how was I supposed to get that from the explanation on this lesson. this is crap!
Moisés Man
@moigithub
Jun 18 2016 00:38
@mrburks if u already realized hows/what they wanna u to do... probably u can always propose HOW it should be explain.. from a starter point of view ;)
Josh Terry
@jaywikid
Jun 18 2016 00:48
is there a way to get a glossary of the pink color words/icons?
David Gagne
@david-gagne
Jun 18 2016 00:49
I need help completing the Profile Lookup challenge.
Here's my code:
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
switch (firstName) {
  case contacts[0].firstName:
  case contacts[1].firstName:
  case contacts[2].firstName:
  case contacts[3].firstName:
    return firstName;
  default:
    return "No such contact";
}
switch (prop) {
  case contacts[0].firstName, contacts[0].lastName:
  case contacts[1].firstName, contacts[1].lastName:
  case contacts[2].firstName, contacts[2].lastName:
  case contacts[3].firstName, contacts[0].lastName:
    return prop;
  default:
    return "No such property";
}


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
MrBurks
@mrburks
Jun 18 2016 00:49
@jaywikid google and luck.
if you're lucky you'll find a resource that will explain it to make sense they don't all make sense
Josh Terry
@jaywikid
Jun 18 2016 00:50
google dont like giving up secrets..... May just re-do all my javascript lessons and take notes.
David Gagne
@david-gagne
Jun 18 2016 00:50
I'm struggling with figuring out how to incorporate all of the required lookups.
Josh Terry
@jaywikid
Jun 18 2016 00:53
@mrburks thanks, this may sound like a stupid question but do u have to start at java to get to the things like C++? cause if its like a different database with different ways of programming that would be nice to know.
CamperBot
@camperbot
Jun 18 2016 00:53
jaywikid sends brownie points to @mrburks :sparkles: :thumbsup: :sparkles:
:cookie: 203 | @mrburks |http://www.freecodecamp.com/mrburks
MrBurks
@mrburks
Jun 18 2016 00:53
@moigithub ?
Moisés Man
@moigithub
Jun 18 2016 00:54

@mrburks u said...

now see how was I supposed to get that from the explanation on this lesson. this is crap!

MrBurks
@mrburks
Jun 18 2016 00:55
@moigithub [@mrburks if u already realized hows/what they wanna u to do... probably u can always propose HOW it should be explain.. from a starter point of view ;)]....that's the thing. some of these lessons don't make it abundantly clear what it is they want you to do. so there's no way of doing what you're suggesting. plus I don't think the people that created this site has an avenue for user feedback.
Moisés Man
@moigithub
Jun 18 2016 00:58
@mrburks i know, not every1 have the same background /understanding
some explanations are "too technical"
and thats why LOT of ppl gets frustrating
@mrburks n i think every feedback (constructive ) is welcome.. they redid lot of challenges, (maybe not enough for starters) but they continously(slowly) improving
Dave
@BeingDS
Jun 18 2016 01:14
Hey all. I'm working on https://www.freecodecamp.com/challenges/stand-in-line and I cannot for the life of me figure out what the third of the four criteria is asking for. This is overall a very confusing challenge, since it's so vaguely worded and unclear as to what it's asking for. Can anyone help?
Moisés Man
@moigithub
Jun 18 2016 01:18
@BeingDS u need to use push and shift array methods.. a good place to start is check the documentation, syntax, and examples
FM
@mafelix
Jun 18 2016 01:26
@moigithub you got time for a codereview?
Norvin Burrus
@ndburrus
Jun 18 2016 01:33
@BeingDS this one? nextInLine([5,6,7,8,9], 1) should return 5
vstrateman
@vstrateman
Jun 18 2016 01:34
Hey all... I got through the Card Counting Javascript module, but I can't help but wonder if (or suspect that) there is a more elegant way to deal with this. Codepen here : http://codepen.io/vicki410/pen/NrRGVq?editors=0010 I didn't use switch statements because, after reading up about them, it seems that they tend to take a long time to execute in ma
in many browsers*
If anyone has a suggestion, please let me know! Sorry this is split between several messages-- it's my first time using gitter
Sumit Kumar
@sumitk121
Jun 18 2016 01:36
hey everybody
Norvin Burrus
@ndburrus
Jun 18 2016 01:36
@sumitk121 hi
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 01:36
hi guys :) i have a problem in Seek and Destroy problem
Sumit Kumar
@sumitk121
Jun 18 2016 01:37
@ndburrus can u pls help in lookupprofile challange>>??
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 01:39
@sumitk121 what's your problem :)
DJ
@qualitymanifest
Jun 18 2016 01:39
@vstrateman you could put 10, J, Q, etc in an array and use indexOf to see if card is in that array, to shorten up your else if statement, but i don't know if that would really be any more efficient. your solution is fine
Sumit Kumar
@sumitk121
Jun 18 2016 01:39
i m unable to get last two things i.e "Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
@MohammedAhmed49
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 01:40
can i see your code ?
Norvin Burrus
@ndburrus
Jun 18 2016 01:41
@sumitk121 i believe they changed that one recently...
Sumit Kumar
@sumitk121
Jun 18 2016 01:41
sure.... @MohammedAhmed49 var i = 0;
while (i<contacts.length) {
if(contacts[i].firstName == firstName){
if (contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}
else if (contacts[i].hasOwnProperty(prop) === false && i<contacts.length){
i++;
}
else {
return "No such property";
}
}
else if (contacts[i].firstName !== firstName && i<contacts.length){
i++;
}
else {
return "No such contact";
}
}
DJ
@qualitymanifest
Jun 18 2016 01:41
@vstrateman oh also you don't need else count = count + 0;, its redundant and you can leave it out
Sumit Kumar
@sumitk121
Jun 18 2016 01:42
@ndburrus it may be....
Norvin Burrus
@ndburrus
Jun 18 2016 01:43
@vstrateman ...have you considered a switch statement?
vstrateman
@vstrateman
Jun 18 2016 01:43
@qualitymanifest Thanks! I don't have so much experience with arrays, so I may try that just to use them in a purposeful way. Also, I did recognize that about the "else" statement at the end... I only added that in when I was up against a mental block and couldn't figure out what was wrong, so I was trying a bunch of things ;)
CamperBot
@camperbot
Jun 18 2016 01:43
vstrateman sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1206 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Sumit Kumar
@sumitk121
Jun 18 2016 01:44
@ndburrus can u get me the codes pls
vstrateman
@vstrateman
Jun 18 2016 01:44
@ndburrus Hi Norvin: Under my code, I mentioned why I did not use a switch statement here. I believe if/else is just as valid in this context?
Norvin Burrus
@ndburrus
Jun 18 2016 01:47
@vstrateman i was just looking at the js section (codepen) - so, i must have missed the code comments... the code looks clean to me. actually, both the if & switch statements seem to require the same amount of typing (to account for the lettered cards). :sparkles: logically, they both accomplish the reuiqrement/s... ok, just read the comment/s above (efficiency concern)... according to this source - you made the right choice! If-Else vs If-If vs Switch Javascript Performance
vstrateman
@vstrateman
Jun 18 2016 01:50
@ndburrus yes, thanks! No worries, this format is a bit convoluted.
CamperBot
@camperbot
Jun 18 2016 01:50
vstrateman sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 572 | @ndburrus |http://www.freecodecamp.com/ndburrus
Greg Duncan
@GregatGit
Jun 18 2016 01:50

@vstrateman your code looks ok but at the end

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

you shouldn't have else if - just else and no condition

vstrateman
@vstrateman
Jun 18 2016 01:51
@GregatGit thanks
CamperBot
@camperbot
Jun 18 2016 01:51
vstrateman sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 602 | @gregatgit |http://www.freecodecamp.com/gregatgit
Abhishek Khurana
@abs-code-lab
Jun 18 2016 01:52
which API did you all use for the Random Quote Generator? The Forismatic API is denying my XMLHttpRequest and the TheySaidSo random quote API is private
Sumit Kumar
@sumitk121
Jun 18 2016 01:53
@ndburrus help me sir
Greg Duncan
@GregatGit
Jun 18 2016 01:53
also - one line statements don't require {} so
if (count > 0)
    return count + " Bet";
  else 
    return count + " Hold";
vstrateman
@vstrateman
Jun 18 2016 01:55
@GregatGit thanks-- I still struggle with redundancy regarding all of the punctuation
CamperBot
@camperbot
Jun 18 2016 01:55
vstrateman sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: vstrateman already gave gregatgit points
Mitul Shah
@mitul-s
Jun 18 2016 01:57
Hi anyone willing to help with a Kata on codewars?
Js
DJ
@qualitymanifest
Jun 18 2016 01:57
well shoot if we're going this far let's bust out the ternary and return count > 0 ? count + " Bet" : count + " Hold"
Greg Duncan
@GregatGit
Jun 18 2016 01:58
@vstrateman https://repl.it/ is a great place to cut and paste code into for practice -
jowright
@jowright
Jun 18 2016 01:59

/ can anyone explain why this passed with an error many who did things like this talked about a while loop but also said you could use a for loop. it did not pass with i < arr.length but did pass with i = arr.length. would it have been better to use the while loop to construct this or is there a way around this error that passed ie a conditional statement was expected but saw assignment the i<= did not pass either.

function chunkArrayInGroups(arr, size) {

var chunked= [];
for (var i=0; i= arr.length; i++){

chunked.push(arr.splice(0,size));

}
return chunked;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Norvin Burrus
@ndburrus
Jun 18 2016 02:00
@jowright have you accounted for the array numbering starting at zero?
vstrateman
@vstrateman
Jun 18 2016 02:01
@qualitymanifest @GregatGit grazie to both of you! I'll check these out tomorrow when I'm more awake, haha
jowright
@jowright
Jun 18 2016 02:02
how do you do that?
i < arr.length+1 is that an option?
Norvin Burrus
@ndburrus
Jun 18 2016 02:05
@jowright well, interpretting this line for (var i=0; i= arr.length; i++) it looks likt an iteration occurs from zero to the length of the array - which would appear to cause an error (becuase of the array numbering scheme)... check the logic & try it!
Sumit Kumar
@sumitk121
Jun 18 2016 02:05
@ndburrus still not geeting u
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:06
@sumitk121 sorry i can't find where the problem is :/
Sumit Kumar
@sumitk121
Jun 18 2016 02:06
send me the codes atlest
@MohammedAhmed49
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:07
the problem isn't in the code .. i can not even know the algorithm
or how to do it
Sumit Kumar
@sumitk121
Jun 18 2016 02:08
alrit fine boss....no prob
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:08
@sumitk121
it's ok
can any one help in Seek and Destroy ??
Tiffany White
@twhite96
Jun 18 2016 02:10
@ndburrus I used a for loop. I will try a while loop
Norvin Burrus
@ndburrus
Jun 18 2016 02:11
@twhite96 did you post code earlier?
jowright
@jowright
Jun 18 2016 02:11
there is an x on the screen it says that it expected a conditional expression and saw an assignment but the test passes with the error
MrBurks
@mrburks
Jun 18 2016 02:11

@moigithub . they redid lot of challenges, (maybe not enough for starters) but they continously(slowly) improving

yeah I know they are continuously improving. I guess I shouldn't really knock something that is free, especially when it has such an extensive support structure unlike other free options. I should be thankful. Thanks for setting me straight @moigithub.

CamperBot
@camperbot
Jun 18 2016 02:11
mrburks sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1453 | @moigithub |http://www.freecodecamp.com/moigithub
Tiffany White
@twhite96
Jun 18 2016 02:11
Yes. @ndburrus I originally had a for loop but cut it out
And so I posted the code without the for loop @ndburrus
MrBurks
@mrburks
Jun 18 2016 02:12
so I'm still getting errors and I still don't know why...LOL
Norvin Burrus
@ndburrus
Jun 18 2016 02:12
@twhite96 ok, which exercise is it? and can you post what you have now?
Tiffany White
@twhite96
Jun 18 2016 02:12
Chunky Monkey @ndburrus
MrBurks
@mrburks
Jun 18 2016 02:13

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

case 1:
  "alpha";
  break;

case 2:
 "beta";
  break;

case 3:
   "gamma";
  break;

case 4:
  "delta";

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

// Change this value to test
caseInSwitch(1);

Tiffany White
@twhite96
Jun 18 2016 02:13
function chunkArrayInGroups(arr, size) {

  var array = arr.slice(size.toString().length);

  var newArray = [[]];
    for (var i = 0; i < array.length; i++) {
      for (var j = 0; j < ; j++) {
         newArray.push([i][j]);
      } 
    }

  return newArray;

  // Break it up.

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
@ndburrus I am stuck as to what to put in the nested for loop
jowright
@jowright
Jun 18 2016 02:14
probably arr.length
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:14
@twhite96 you don't need to make 2 loops it simpler than that
apbowe
@apbowe
Jun 18 2016 02:14
what does a red dot in the result window mean?
Tiffany White
@twhite96
Jun 18 2016 02:15
Okay @MohammedAhmed49
Norvin Burrus
@ndburrus
Jun 18 2016 02:15
@mrburks ok, these type statements don't tell the code to do anything! "alpha"; what do you want to happen in these instances? hint: ...based on the input variable "val" in case 1, what should happen with "alpha"? :)
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:16
@twhite96 one loop will be enough but think how much steps will the loop jump every time
Tiffany White
@twhite96
Jun 18 2016 02:17
@MohammedAhmed49 that isn’t a fixed number. It depends on size
Norvin Burrus
@ndburrus
Jun 18 2016 02:18
@twhite96 why are we using a nested loop for a single array ?
Tiffany White
@twhite96
Jun 18 2016 02:18
@ndburrus I changed it
apbowe
@apbowe
Jun 18 2016 02:18
explain red dot
CamperBot
@camperbot
Jun 18 2016 02:18
no wiki entry for: red dot
Tiffany White
@twhite96
Jun 18 2016 02:18
@ndburrus where I am stuck is getting the length of size
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:18
@twhite96 yeah that's what i'm talking about it don't to to jump 1 step every time .. it need to jump i+=size ;)
apbowe
@apbowe
Jun 18 2016 02:18
explain fromCharCode
CamperBot
@camperbot
Jun 18 2016 02:18

:point_right: string.fromcharcode [wiki]

String.fromCharCode()

The static String.fromCharCode() method returns a string created by using the specified sequence of Unicode values.

:pencil: read more about stringfromcharcode on the FCC Wiki

Norvin Burrus
@ndburrus
Jun 18 2016 02:19
@twhite96 "size" is simply the, well, the size of array chunks that you want... so in the iteration you want to increment by the size variable... the result will be a 2 dimensional array (as opposed to 1 dimensional - like the inputted array)
Tiffany White
@twhite96
Jun 18 2016 02:22
So I should use a while loop then @ndburrus
Norvin Burrus
@ndburrus
Jun 18 2016 02:24
@twhite96 a while loop is useful for this exercise: For, While, and Do...While Loops in JavaScript it can control the number of iterations with respect to the array length... also, it can assist with iterating according to the chunk size needed/inputted (using the size variable)...
ranranking
@ranranking
Jun 18 2016 02:27
I have a question. In challenge 225, why I should use /\S/g instead of /\S+/g to count all non-space characters? While in the former challenges, I need to use /\s+/g to count all the white space in the string? I am confused with the + sign
Eric Crescioni
@ecam900
Jun 18 2016 02:29
I'm stuck in a similar problem: 263 (Check for palindrome). All is cool, until I check something with spaces and special characters. For example: "A man, a plan, a canal. Panama." returns 'false' when it should be true. Here's my code:

function palindrome(str) {
  // Good luck!
  var revString = str.split('').reverse().join('').toLowerCase().replace(/[. " ",\w]/g, "");

  if (revString == str) {
    return true;
  } else {
    return false;
  }
}



palindrome("kayak");
any insight?
my regex is definitely wrong but I'm not sure how
Norvin Burrus
@ndburrus
Jun 18 2016 02:32
@ranranking @ecam900 this may be useful in checking sample regex code: Regex101 :sparkles:
Eric Crescioni
@ecam900
Jun 18 2016 02:32
@ndburrus Awesome page. Thanks!
CamperBot
@camperbot
Jun 18 2016 02:32
ecam900 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 574 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 18 2016 02:33
@ecam900 you're welcome! enjoy :fire:
Tiffany White
@twhite96
Jun 18 2016 02:33
Where does slice come into the equation @ndburrus ? Did you use slice?
I have a better working model and I almost have it.
function chunkArrayInGroups(arr, size) {

    var newArray = [[]];
    for (var i = 0; i < arr.length; i += size) {
      newArray.push(i);
    }

  return newArray;

  // Break it up.

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Mohammed Ahmed
@MohammedAhmed49
Jun 18 2016 02:35
@twhite96 the sliced part from the old array should be pushed in the new array ... push(the sliced part)
Norvin Burrus
@ndburrus
Jun 18 2016 02:35
@twhite96 JavaScript - Array slice() Method slice assists with cutting out the chunks of the input array....
Tiffany White
@twhite96
Jun 18 2016 02:36
Yeah I know @ndburrus.
Norvin Burrus
@ndburrus
Jun 18 2016 02:37
@twhite96 ok, so we have the framework to handle the iterations. we now need to carve up the array and output the return... it looks like you have a destination (or receiving array) setup - newArray... so, what do we need now?
Tiffany White
@twhite96
Jun 18 2016 02:38
Yes. @ndburrus. Finding what to slice is throwing me, a little
I have var array = arr.slice();
Norvin Burrus
@ndburrus
Jun 18 2016 02:38
@twhite96 well, what are we given?
Tiffany White
@twhite96
Jun 18 2016 02:39
We are given arr and size
I am trying to slice arr
But that isn’t netting me the results I want. I will try size @ndburrus
Norvin Burrus
@ndburrus
Jun 18 2016 02:39
@twhite96 ok, great! and how do we want to slice arr? hint: into groups the length of size (second argument) trying "size" came from the good idea fairy, didn't it? :)
ranranking
@ranranking
Jun 18 2016 02:40
@ndburrus Thanks. /S means anything that's not whitespace. Now I got it.
CamperBot
@camperbot
Jun 18 2016 02:40
ranranking sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 575 | @ndburrus |http://www.freecodecamp.com/ndburrus
Tiffany White
@twhite96
Jun 18 2016 02:40
Hmmm
Norvin Burrus
@ndburrus
Jun 18 2016 02:40
@ranranking excellent work! nice job :+1:
Tiffany White
@twhite96
Jun 18 2016 02:40
arr.slice() @ndburrus but I am not sure if I need an argument
Norvin Burrus
@ndburrus
Jun 18 2016 02:42
@twhite96 hmmm.... this may be helpful:
Syntax
Its syntax is as follows −
array.slice( begin [,end] );
Parameter Details
begin − Zero-based index at which to begin extraction. As a negative index, start indicates an offset from the end of the sequence.
end − Zero-based index at which to end extraction.
Tiffany White
@twhite96
Jun 18 2016 02:42
Oooooh okay @ndburrus
melisa pettaway
@mpettaw2
Jun 18 2016 02:43
hello working on the profile lookup and i need some help. is there anyone avaliable
David Halls
@DavidHalls
Jun 18 2016 02:43
@mpettaw2 fire away
melisa pettaway
@mpettaw2
Jun 18 2016 02:43

```for(var i=0; i<contacts.length;i++){
var allObj=contacts[i];
var hasProp=allObj.hasOwnProperty(prop);
var hasName=allObj.hasOwnProperty("firstName");

if(firstName == allObj.firstName && hasProp===true){

  return allObj[prop];
}
else if(!hasProp){
  return "No such property";

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

}else{

return "error! figure it out";

}

}
// Only change code above this line
}

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

David Halls
@DavidHalls
Jun 18 2016 02:43
@twhite96 slice just makes a copy of the original array, i used splice, it removes the elements from the og array
melisa pettaway
@mpettaw2
Jun 18 2016 02:43

```for(var i=0; i<contacts.length;i++){
var allObj=contacts[i];
var hasProp=allObj.hasOwnProperty(prop);
var hasName=allObj.hasOwnProperty("firstName");

if(firstName == allObj.firstName && hasProp===true){

  return allObj[prop];
}
else if(!hasProp){
  return "No such property";

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

}else{

return "error! figure it out";

}

}
// Only change code above this line
}

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

ok sorry imma stop flooding the chat again
Richard
@codecampergg
Jun 18 2016 02:44

Here is my code


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

  // Only change code above this line

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

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

please help me

Nicole Archambault
@sofrlowi
Jun 18 2016 02:44
Hey y’all, anyone available to critique my code for the Weather App zipline? http://codepen.io/sofrlowi/pen/mEPRya
Feel free to PM me :)
Oh nice, none of the data even shows up in the preview. LOL
Carlota Pearl
@caep2015
Jun 18 2016 02:45
@mpettaw2 I just finished that one let me look at your code....
Norvin Burrus
@ndburrus
Jun 18 2016 02:45
@codecampergg which challenge is this? it appears that the if statements don't indicate for anything to be done if the condition/s is/are met! :)
David Halls
@DavidHalls
Jun 18 2016 02:46
@mpettaw2 it is called hasOwnProperty to check for the property
@mpettaw2 and why are you creating new variables when you have the contacts array already
melisa pettaway
@mpettaw2
Jun 18 2016 02:47
@caep2015 give me sec i don't want to flood the chat again
Norvin Burrus
@ndburrus
Jun 18 2016 02:47
@twhite96 did you resolve it? ...brb...
melisa pettaway
@mpettaw2
Jun 18 2016 02:47
@Byzgig oops on the hasOwn i will change that
and to condense my code
Tiffany White
@twhite96
Jun 18 2016 02:47
Still working on it with splice @ndburrus
melisa pettaway
@mpettaw2
Jun 18 2016 02:48
i don't want to write contacts[i]. blahblahblah all the time
Richard
@codecampergg
Jun 18 2016 02:48
@ndburrus is the "Return Early Pattern for Functions" challenge
I have no idea how to do it
melisa pettaway
@mpettaw2
Jun 18 2016 02:49
ok imma repost my code beware everyone.
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

  for(var i=0; i<contacts.length;i++){
    var allObj=contacts[i];
    var hasProp=allObj.hasOwnProperty(prop);
    var hasName=allObj.hasOwnProperty("firstName");

    if(firstName == allObj.firstName && hasProp===true){

      return allObj[prop];
    }
    else if(!hasProp){
      return "No such property";

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

    }else{

    return "error! figure it out";
  }


  } 
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
yay
Richard
@codecampergg
Jun 18 2016 02:52
nevermind, I already solved it
thanks anyway
melisa pettaway
@mpettaw2
Jun 18 2016 02:52
??
Carlota Pearl
@caep2015
Jun 18 2016 02:54
@mpettaw2 so you have: for var var var if return else if return else if. I have: for if if return else return return
melisa pettaway
@mpettaw2
Jun 18 2016 02:54
i feel like its something with the second else if statement. when it runs it become true because the firstname value of the first object does not equal some of the names in the pre-made test
@caep2015 so simply write everything out instead of assigning the iterated values to single named variables
that might work if thats what they are expecting
ok. imma try it thank you all
Carlota Pearl
@caep2015
Jun 18 2016 02:58
@mpettaw2 my 1st line looks the same second line I went with : if(contacts[I].firstName === firstName) {
Tiffany White
@twhite96
Jun 18 2016 02:58
Trying splice. My issue is not hardcoding things into the algorithm.
function chunkArrayInGroups(arr, size) {
    var array = arr.splice(0, size);

    var newArray = [[]];
    for (var i = 0; i < array.length; i += size) {
      newArray.push(size);
    }

  return newArray;

  // Break it up.

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Aaron Hanna
@AaronHanna
Jun 18 2016 02:59
function updateRecords(id, prop, value) {
var myId = id;
if (value !== "" && prop !== "tracks") {
collection[myId].prop = value;
}
good evening friends ... can someone please tell me why this code does not set the key to the prop argument? It just sets it as "prop"
David Halls
@DavidHalls
Jun 18 2016 03:00
@twhite96 put the splice in the for loop
Carlota Pearl
@caep2015
Jun 18 2016 03:00
@mpettaw2 on my computer now so I can type more and faster. Was on my phone earlier so was trying not to type it all ... here we go. are you following? ill give you the rest of the lines and you can change the variables to fit the way you want.
@mpettaw2 3rd line: if (!contacts[i][prop]) {
Tiffany White
@twhite96
Jun 18 2016 03:02
Ahhh! Okay
Carlota Pearl
@caep2015
Jun 18 2016 03:03
return "No such property"; { else { return contacts[i][prop]; } } }
@mpettaw2 I don't know how to put spaces within the code here
Norvin Burrus
@ndburrus
Jun 18 2016 03:04
@codecampergg do you see where there is no activity in the if statement?
Tiffany White
@twhite96
Jun 18 2016 03:04
@Byzgig It still isn’t passing. I am not sure of what index to use etc. I have 0, size but that isn’t it...
David Halls
@DavidHalls
Jun 18 2016 03:05
@twhite96 well, what are you pushing to newArray? size? won't it always be 2 then
Norvin Burrus
@ndburrus
Jun 18 2016 03:05
@twhite96 ...are you certain that 0, size?is accurate?
Brady
@BradyPainter
Jun 18 2016 03:05
Hello, I am struggling with the increment coding. I couldn't figure which right place to type it--" var myVar = 87; myVar + i++; " Is that right code?
David Halls
@DavidHalls
Jun 18 2016 03:06
@twhite96 0, size is right
Aaron Hanna
@AaronHanna
Jun 18 2016 03:07
@BradyPainter you can just put myVar++;
Norvin Burrus
@ndburrus
Jun 18 2016 03:07
@BradyPainter ok, don't think too much about this one - it's pretty straight forward... this i++; equals i = i + 1; see how that works?
Tiffany White
@twhite96
Jun 18 2016 03:08
Okay. I am not certain what index to start from? I tried -size.length, size.length. Not sure @ndburrus
Brady
@BradyPainter
Jun 18 2016 03:08
@ndburrus Thank so much!
CamperBot
@camperbot
Jun 18 2016 03:08
bradypainter sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 576 | @ndburrus |http://www.freecodecamp.com/ndburrus
Tiffany White
@twhite96
Jun 18 2016 03:08
So I am pushing array to newArray @Byzgig
Norvin Burrus
@ndburrus
Jun 18 2016 03:08
@BradyPainter you're welcome! nice work :sparkles:
Tiffany White
@twhite96
Jun 18 2016 03:08
I am stuck on the index to start from in the splice
Norvin Burrus
@ndburrus
Jun 18 2016 03:09
@twhite96 aahh... you're using splice (a different method) - i went with slice...
Tiffany White
@twhite96
Jun 18 2016 03:10
Yeah I tried slice @ndburrus
David Halls
@DavidHalls
Jun 18 2016 03:11
@twhite96 k, look at your for loop, you have i += size
Norvin Burrus
@ndburrus
Jun 18 2016 03:11
This message was deleted
Tiffany White
@twhite96
Jun 18 2016 03:11
Yes. @Byzgig
Aaron Hanna
@AaronHanna
Jun 18 2016 03:11
welp, I got this one. I think my brain is just broken right now lol
David Halls
@DavidHalls
Jun 18 2016 03:12
@twhite96 wont that make you exit the loop before your checked all values?
Norvin Burrus
@ndburrus
Jun 18 2016 03:12
@AaronHanna ...nothing a little break can't fix :+1:
Tiffany White
@twhite96
Jun 18 2016 03:12
Yes. @Byzgig
I swithced it to i++ @Byzgig
and have gotten better results but there are three arrays… @Byzgig
David Halls
@DavidHalls
Jun 18 2016 03:13
@twhite96 k, good, now you have i < array.length, but array is empty
@twhite96 actually, i might be looking at old code, could you paste what you have now
Tiffany White
@twhite96
Jun 18 2016 03:14
Yes @Byzgig
function chunkArrayInGroups(arr, size) {
    var newArray = [[]];
    for (var i = 0; i < arr.length; i++) {
      var array = arr.splice(0, size);
      newArray.push(array);
    }

  return newArray;

  // Break it up.

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
This gives me an empty array and the chunked arrays I need @Byzgig
David Halls
@DavidHalls
Jun 18 2016 03:16
@twhite96 k, look at how you have newArray declared, can youchange that?
Tiffany White
@twhite96
Jun 18 2016 03:17
Yes. @Byzgig
SuhailG
@suhailgme
Jun 18 2016 03:18
Hey all, I'm hoping some one can help me out with respect to sequential animations for the simon game. Here is my codepen: http://codepen.io/suhailg/full/VjKebO/
Tiffany White
@twhite96
Jun 18 2016 03:18
A few passed, a few haven’t @Byzgig
SuhailG
@suhailgme
Jun 18 2016 03:18
The issue is that the delay*index seems to be delaying for a long time when duplicate elements are present in my array. Any advice?
David Halls
@DavidHalls
Jun 18 2016 03:20
@twhite96 ok, so with splice, it actually deletes from the original array, so in the for loop, the i < arr.length changes each time you splice, so you either need to create a new var with arr.length or something like that
Anton Kaminsky
@nakamin
Jun 18 2016 03:20
@twhite96 since you're using splice your array size changes
@twhite96 iirc splice takes the arguments away from the front of the array
David Halls
@DavidHalls
Jun 18 2016 03:22
@twhite96 once you have that fixed, you'll notice that you get empty arrays on the end of the result, to fix this, you need to divide lenght by size
Tiffany White
@twhite96
Jun 18 2016 03:24
@Byzgig not sure what you mean?
Anton Kaminsky
@nakamin
Jun 18 2016 03:24
@twhite96 don't over complicate just use map
Tiffany White
@twhite96
Jun 18 2016 03:25
function chunkArrayInGroups(arr, size) {
    var newArray = [];
    var oldArray = arr.length;
    for (var i = 0; i < oldArray; i++) {
      var array = arr.splice(0, size);
      newArray.push(array);
    }

  return newArray;

  // Break it up.

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
Anton Kaminsky
@nakamin
Jun 18 2016 03:25
@Byzgig that's too confusing unnecessary
Tiffany White
@twhite96
Jun 18 2016 03:25
@nakamin?
David Halls
@DavidHalls
Jun 18 2016 03:25
@twhite96 var oldArray= arr.length/size;
@twhite96 and you should be done
Anton Kaminsky
@nakamin
Jun 18 2016 03:26
@twhite96 won't work since the old array is longer
@twhite96 array.map
Instead of for loop
Tiffany White
@twhite96
Jun 18 2016 03:26
@Byzgig thanks! Got it
CamperBot
@camperbot
Jun 18 2016 03:26
twhite96 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 333 | @byzgig |http://www.freecodecamp.com/byzgig
SuhailG
@suhailgme
Jun 18 2016 03:27
Anyone able to offer some advice?
David Halls
@DavidHalls
Jun 18 2016 03:28
@suhailgme with?
SuhailG
@suhailgme
Jun 18 2016 03:28
@Byzgig hey david
@Byzgig with the pen i posted: http://codepen.io/suhailg/full/VjKebO/
@Byzgig I am trying to get the animations to appear sequentially but duplicate values in my array seems to be increasing the delay more than it should
Donovan
@dnvn999
Jun 18 2016 03:30

Hi guys, I would like to ask what is the difference of closing the { by putting in different line. For examples,

function factorialize(num) {  
  var factorial = 1;

  for(num; num > 1; num--){
    factorial *= num;
  }
  return factorial;
}
factorialize(5);

and
```js
function factorialize(num) {
var factorial = 1;

for(num; num > 1; num--){
factorial *= num;

return factorial;
}
factorialize(5);

UtkarshShukla7
@UtkarshShukla7
Jun 18 2016 03:30
@suhailgme you can remove the index from constant delay or lower 1500
SuhailG
@suhailgme
Jun 18 2016 03:31
@UtkarshShukla7 if i remove index from the delay then the animations do not occur sequentially, they occur all at once
MrBurks
@mrburks
Jun 18 2016 03:31

What am I doing wrong::

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

case 1:
  answer = "apple";

case 2: 
  answer = "bird";
  break;

case 3:
  answer = "cat";
  break;

default:
  answer = "stuff";
  break;

}

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

// Change this value to test
switchOfStuff(1);

Donovan
@dnvn999
Jun 18 2016 03:31
second one is
function factorialize(num) {  
  var factorial = 1;

  for(num; num > 1; num--){
    factorial *= num;

  return factorial;
} // <<<
}
factorialize(5);
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 18 2016 03:32
Guys
UtkarshShukla7
@UtkarshShukla7
Jun 18 2016 03:32
@suhailgme then delay it with 1000*index or lower value
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 18 2016 03:32
Hi guys*
SuhailG
@suhailgme
Jun 18 2016 03:33
@UtkarshShukla7 that still produces the same result, duplicate entries delay more than 1000*index :(
UtkarshShukla7
@UtkarshShukla7
Jun 18 2016 03:34
@suhailgme ok let me check again
Norvin Burrus
@ndburrus
Jun 18 2016 03:34
@mrburks which @mrburks what should the function name be? :+1: (in Selecting from many options with Switch Statements)
SuhailG
@suhailgme
Jun 18 2016 03:34
@UtkarshShukla7 thanks :)
CamperBot
@camperbot
Jun 18 2016 03:34
suhailgme sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 644 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
David Halls
@DavidHalls
Jun 18 2016 03:34
@suhailgme can you reset the index after, it just keeps growing
SuhailG
@suhailgme
Jun 18 2016 03:35
@Byzgig Yeah the index gets larger in order to delay the animation a bit, if i reset the index or use just a number for the delay, all animations occur at the same time
MrBurks
@mrburks
Jun 18 2016 03:36
@ndburrus I have no clue what you're saying
Norvin Burrus
@ndburrus
Jun 18 2016 03:37
@mrburks in the code you posted you have: function switchOfStuff(val) {i was asking what the function name should be...
Nicolas Crumrine
@CrumrineCoder
Jun 18 2016 03:38
Hey I'm working on the Chunk Monkey problem, but it only passes the first two tests. When i==2 in the test run I have, for some reason it won't splice the rest of the argument onto the new array variable I made. Here's the code: http://pastebin.com/U6355FVm
Donovan
@dnvn999
Jun 18 2016 03:38

Hi guys, can anyone explain the difference of closing the { by putting it in different line? For examples,
function factorialize(num) {
var factorial = 1;

for(num; num > 1; num--){
factorial *= num;
} //<<<
return factorial;
}
factorialize(5);
and

function factorialize(num) {
var factorial = 1;
for(num; num > 1; num--){
factorial *= num;
return factorial;
   } ///<
}
factorialize(5);
Nicolas Crumrine
@CrumrineCoder
Jun 18 2016 03:40
@donovan In the first one your function will return it after the for loop, and the second one it will happen after the forloop is over
So in the second one, it'll finish before it can loop again
Since return kills the function
At least to my knowledge that's how it works
@dnvn999 ^^
Richard
@codecampergg
Jun 18 2016 03:41
In the Counting Cards challenge I should use "if" or "switch"?
David Halls
@DavidHalls
Jun 18 2016 03:41
@Tam-ing it is because splice deletes from the og array, so you never get to the third set
Nicolas Crumrine
@CrumrineCoder
Jun 18 2016 03:41
Shouldn't it make the original array empty then?
Donovan
@dnvn999
Jun 18 2016 03:41
@Tam-ing Thanks, I know where is my confusion already.
CamperBot
@camperbot
Jun 18 2016 03:41
dnvn999 sends brownie points to @tam-ing :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for tam-ing
David Halls
@DavidHalls
Jun 18 2016 03:42
@Tam-ing it would if it kept going, but since i > ((arr.length)/size), it never finishes reading the array, ((arr.length)/size) needs to be set as a var outside the loop
Nicolas Crumrine
@CrumrineCoder
Jun 18 2016 03:43
That fixed the mission, not sure how to send "brownie points" but thanks for the help
MrBurks
@mrburks
Jun 18 2016 03:45
@ndburrus That is the function name set by the lesson.. this is an exercise regarding switch statements. and I'm getting errors i don't understand
Norvin Burrus
@ndburrus
Jun 18 2016 03:49
help brownie points @Tam-ing if you need assistance, type "help (subject)" and camperbot will assist (if possible)
CamperBot
@camperbot
Jun 18 2016 03:49

: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

Norvin Burrus
@ndburrus
Jun 18 2016 03:51
@mrburks ...check & see if the same funcion name is used in the test/s calls, at the bottome of the exercise - i think those change sometimes...
MrBurks
@mrburks
Jun 18 2016 03:53
@ndburrus it is
SuhailG
@suhailgme
Jun 18 2016 03:54
@UtkarshShukla7 any luck?
MrBurks
@mrburks
Jun 18 2016 03:54
it's telling me "Expected a 'break statement' before case" but it's there
ok fixed that error. no errors showing in the code. at least no syntax errors. still not satisfying all the conditions of the lesson.
Tim Jung
@TJ2001
Jun 18 2016 04:01
Hello World!
CamperBot
@camperbot
Jun 18 2016 04:01

welcome to FreeCodeCamp @TJ2001!

Abhishek Khurana
@abs-code-lab
Jun 18 2016 04:03
@TJ2001 ayy welcome!
Hi all - do you have advice on how to add a "tweet quote" button for the quote generator project? I can't get the tweet link to dynamically change as the quote text changes, if that makes sense
UtkarshShukla7
@UtkarshShukla7
Jun 18 2016 04:04
@suhailgme still trying, man. tried with incrementing constant variables but it also caused different time-delays .Will tell you if find any constant delay method
Praneeth
@praneethkumarpidugu
Jun 18 2016 04:06
Hello World!
CamperBot
@camperbot
Jun 18 2016 04:06

welcome to FreeCodeCamp @praneethkumarpidugu!

Praneeth
@praneethkumarpidugu
Jun 18 2016 04:07
Could anyone provide me feedback for “stand in line” code challenge
This message was deleted
Oxide Debbarma
@oxide94Git
Jun 18 2016 04:15
hmm pair programming...
CruftMaster
@CruftMaster
Jun 18 2016 04:22
console.log("hello world!");
Meheret Egzerab
@mercyg
Jun 18 2016 04:22
Hi, could someone please help me with the stand in line challenge. I don't understand about this error nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
GaneshCloud
@GaneshCloud
Jun 18 2016 04:25
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
What we need from this?
Praneeth
@praneethkumarpidugu
Jun 18 2016 04:26
Hi Guys Could anyone provide me feedback for the "Stand in Line " challenge:

function nextInLine(arr, item) {
  // Your code here
  //var newItem = arr[0].remove();
  //var anotherItem = arr[4] + item;
  var newItem = arr;
  newItem.push(item);

  var i = newItem.indexOf(arr[0]);
  if (i != -1) {

     someNumber = newItem.splice(i, 1);
  }

  return someNumber;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Jesus Rivero
@jesusdaver86
Jun 18 2016 04:32
This message was deleted
himanshu mittal
@himanshu081996
Jun 18 2016 04:32
@praneethkumarpidugu why are you using splice in this challenge
Coy Sanders
@coymeetsworld
Jun 18 2016 04:33
@mercyg what do you have so far?
Shusil Banjade
@shusil123
Jun 18 2016 04:33
@praneethkumarpidugu , i guess you can simply do , arr.push(item); and then return arr.shift();
Praneeth
@praneethkumarpidugu
Jun 18 2016 04:33
@himanshu081996 I thought splice also removes the item
himanshu mittal
@himanshu081996
Jun 18 2016 04:33
@praneethkumarpidugu i can never be zero in your case
Shusil Banjade
@shusil123
Jun 18 2016 04:33
Good Morning , @coymeetsworld .
himanshu mittal
@himanshu081996
Jun 18 2016 04:33
so you can just shift
Coy Sanders
@coymeetsworld
Jun 18 2016 04:34
gm @shusil123, its nighttime for me actually
Praneeth
@praneethkumarpidugu
Jun 18 2016 04:34
hmm got it ! Thanks @himanshu081996
CamperBot
@camperbot
Jun 18 2016 04:34
praneethkumarpidugu sends brownie points to @himanshu081996 :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @himanshu081996 |http://www.freecodecamp.com/himanshu081996
himanshu mittal
@himanshu081996
Jun 18 2016 04:34
its just wastage of memory
Jesus Rivero
@jesusdaver86
Jun 18 2016 04:34

```
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var ending = str.slice(-2);
var ending2 = target.slice(-2);
var ends = ending.slice(-1);
var ends1 = ending2.slice(-1);

if (ending === ending2){
return true;
}
else if (ending !== ending2) {

return false;

}
else if (ends === ends1){
return true;
}
else {

  return false;

}
}
```

Meheret Egzerab
@mercyg
Jun 18 2016 04:34

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

return arr.push(item);
// Change this line

}

// Test Setup
var testArr = [5,6,7,8,9];
testArr.shift();

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

NixonRichard
@NixonRichard
Jun 18 2016 04:34
i m stucking at Make Object Properties Private
Meheret Egzerab
@mercyg
Jun 18 2016 04:34
this is what I have done so far
Shusil Banjade
@shusil123
Jun 18 2016 04:34
@coymeetsworld , :smile: . 10AM here in Nepal.
Coy Sanders
@coymeetsworld
Jun 18 2016 04:35
@mercyg you don't want to return arr.push
arr.push returns the new length of the array after the push is done, what you want to return is the first item of the array
himanshu mittal
@himanshu081996
Jun 18 2016 04:35
@mercyg your challenge is stand in line??
Coy Sanders
@coymeetsworld
Jun 18 2016 04:35
and remove it
Oxide Debbarma
@oxide94Git
Jun 18 2016 04:35
@shusil123 hello.. :smile: its 10:03 in india :smile:
Meheret Egzerab
@mercyg
Jun 18 2016 04:35
yea it is
Shusil Banjade
@shusil123
Jun 18 2016 04:36
Hello @oxide94Git .
Coy Sanders
@coymeetsworld
Jun 18 2016 04:36
so keep arr.push(item) @mercyg, but don't return that
you need to remove the first item of the array and return that, there is an array function that can do both for you
himanshu mittal
@himanshu081996
Jun 18 2016 04:36
in this challenge u have to add an item and reomove one element from starting of an array
Meheret Egzerab
@mercyg
Jun 18 2016 04:37
shift() method is removing the first item right
Oxide Debbarma
@oxide94Git
Jun 18 2016 04:38
@shusil123 i"ve reached cipher. thanks for your help.. :smile:
CamperBot
@camperbot
Jun 18 2016 04:38
oxide94git sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 479 | @shusil123 |http://www.freecodecamp.com/shusil123
Coy Sanders
@coymeetsworld
Jun 18 2016 04:38
yep @mercyg :thumbsup:
NixonRichard
@NixonRichard
Jun 18 2016 04:38
what s public and private methods ?
himanshu mittal
@himanshu081996
Jun 18 2016 04:38
@mercyg and to remove an element from starting u can use arr.shift();
Coy Sanders
@coymeetsworld
Jun 18 2016 04:38
that function also returns that first element its removing too
Shusil Banjade
@shusil123
Jun 18 2016 04:38
@oxide94Git , My pleasure . Keep going...
Jesus Rivero
@jesusdaver86
Jun 18 2016 04:38
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var ending = str.slice(-2);
var ending2 = target.slice(-2);
var ends = ending.slice(-1);
var ends1 = ending2.slice(-1);
if (ending === ending2){
return true;
}
else if (ending !== ending2) {
return false;
}
else if (ends === ends1){
return true;
}
else {
  return false;
}
}
Praneeth
@praneethkumarpidugu
Jun 18 2016 04:38
Thanks guys! Good Night and Happy coding to everyone!
himanshu mittal
@himanshu081996
Jun 18 2016 04:39
@praneethkumarpidugu gud ni8
Meheret Egzerab
@mercyg
Jun 18 2016 04:39
So I don't have to return anything to the function
himanshu mittal
@himanshu081996
Jun 18 2016 04:40
@jesusdaver86 what is your challenge??
Coy Sanders
@coymeetsworld
Jun 18 2016 04:40
yeah you do @mercyg
you need to return the element you removed from the array
the shift method will actually return that value for you and remove it
so you can simply return the result of that function and your code should work
Jesus Rivero
@jesusdaver86
Jun 18 2016 04:41
@himanshu081996 Confirm the Ending
Meheret Egzerab
@mercyg
Jun 18 2016 04:41
Still the error is the same
Shusil Banjade
@shusil123
Jun 18 2016 04:42
@jesusdaver86 , don't slice the target . Slice the array with the negative length of target and then compare them . Simple
Coy Sanders
@coymeetsworld
Jun 18 2016 04:43
what do you have now @mercyg ?
Meheret Egzerab
@mercyg
Jun 18 2016 04:43

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

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

// Test Setup
var testArr = [5,6,7,8,9];

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

Coy Sanders
@coymeetsworld
Jun 18 2016 04:43
you only want to operate on arr, not testArr
himanshu mittal
@himanshu081996
Jun 18 2016 04:44
@jesusdaver86 in this u have to first calculate your target length so no need to slice your target
Meheret Egzerab
@mercyg
Jun 18 2016 04:45
yea
thank you @coymeetsworld
CamperBot
@camperbot
Jun 18 2016 04:45
mercyg sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1176 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
himanshu mittal
@himanshu081996
Jun 18 2016 04:45
@mercyg u have to return arr.push(item).shift();
Coy Sanders
@coymeetsworld
Jun 18 2016 04:45
@himanshu081996 no, thats not right
you don't put it all on one line like that
Meheret Egzerab
@mercyg
Jun 18 2016 04:45
It worked
himanshu mittal
@himanshu081996
Jun 18 2016 04:46
@coymeetsworld okk
Coy Sanders
@coymeetsworld
Jun 18 2016 04:46
good @mercyg
:thumbsup: good job
MrBurks
@mrburks
Jun 18 2016 04:47
so, how does one know when you use a switch statement or or if/else statement?
:thumbsup:
Coy Sanders
@coymeetsworld
Jun 18 2016 04:48
switch is preferable to do over if/else, if possible @mrburks
himanshu mittal
@himanshu081996
Jun 18 2016 04:48
@coymeetsworld thanks
CamperBot
@camperbot
Jun 18 2016 04:48
himanshu081996 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1177 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 18 2016 04:48
since it requires less code and more readable, but it can't always be done
Helena
@poigirl2001
Jun 18 2016 04:49
Hello
MrBurks
@mrburks
Jun 18 2016 04:49
:thumbsup: @coymeetsworld
Helena
@poigirl2001
Jun 18 2016 04:49
I am stuck on the record collection challenge
Coy Sanders
@coymeetsworld
Jun 18 2016 04:50
also switch is used in cases youre checking only one variable and checking for discrete values, if/else statements can do more things
Helena
@poigirl2001
Jun 18 2016 04:50
It's so weird with these challenges. I'll be on a roll and then BOOM a roadblock
It's crazy
Coy Sanders
@coymeetsworld
Jun 18 2016 04:51
thats coding @poigirl2001 :) what do you need help with on the challenge?
MrBurks
@mrburks
Jun 18 2016 04:51
is anyone or did anyone else have any trouble getting past this switch statement stuff? it's seems like the code is right but still not satisfying all the conditions of the lesson...this is the second one I encountered, had to skip the last one.
Helena
@poigirl2001
Jun 18 2016 04:51
@coymeetsworld I'm just stuck. I'm not so sure about where to start
The directions also confuse me a bit ;)
MrBurks
@mrburks
Jun 18 2016 04:52
I just skipped it.
Helena
@poigirl2001
Jun 18 2016 04:52
:)
Coy Sanders
@coymeetsworld
Jun 18 2016 04:52
you shouldn't skip them @mrburks the lessons typically build on top of each other
himanshu mittal
@himanshu081996
Jun 18 2016 04:52
what is wrong in my code im getting [1,3,2,5,4] instead of [1,3,2,[5],[4]]
function uniteUnique(arr) {
  var array=arguments[0];
  for(var i=1;i<arguments.length;i++){
    for(var j=0;j<arguments[i].length;j++){
      if(array.indexOf(arguments[i][j])<0){
        array=array.concat(arguments[i][j]);
      }
    }
  }
  return array;
}

uniteUnique([1, 3, 2], [1, [5]], [2, [4]]);
Helena
@poigirl2001
Jun 18 2016 04:52
I've only skipped one lesson
Coy Sanders
@coymeetsworld
Jun 18 2016 04:53
@poigirl2001 was it related to JSON?
Helena
@poigirl2001
Jun 18 2016 04:53
it was the stand in line challenge
MrBurks
@mrburks
Jun 18 2016 04:53
@coymeetsworld what should I do, then?
Coy Sanders
@coymeetsworld
Jun 18 2016 04:53
do them all @mrburks :)
you can skip advanced algorithms at the very end since those are optional, although i would recommend doing those too
Helena
@poigirl2001
Jun 18 2016 04:53
@coymeetsworld I don't think so.
MrBurks
@mrburks
Jun 18 2016 04:53
no, I mean what should I do about this thing no accepting my answers
Coy Sanders
@coymeetsworld
Jun 18 2016 04:53
no @poigirl2001 that wasnt JSON
Helena
@poigirl2001
Jun 18 2016 04:54
@coymeetsworld it was just plain OOP I think
Coy Sanders
@coymeetsworld
Jun 18 2016 04:54
oh, what challenge @mrburks, what code and what are you failing tests on?
@poigirl2001 stand in line was just array functions
Helena
@poigirl2001
Jun 18 2016 04:54
Yes I realized that
Coy Sanders
@coymeetsworld
Jun 18 2016 04:54
i would still go back and do it but thats not related to record collection
Helena
@poigirl2001
Jun 18 2016 04:55
I looked up the answer to Stand in Line
Coy Sanders
@coymeetsworld
Jun 18 2016 04:55
for that challenge you need to be able to construct a series of if/else statements
Helena
@poigirl2001
Jun 18 2016 04:55
For record collection?
Coy Sanders
@coymeetsworld
Jun 18 2016 04:55
yes
MrBurks
@mrburks
Jun 18 2016 04:55

@coymeetsworld These: Adding a default option in Switch statements Incomplete

Multiple Identical Options in Switch Statements

Coy Sanders
@coymeetsworld
Jun 18 2016 04:55
also need to know a bit about JSON objects
how to access the properties, how to determine if the property exists, etc.
just start out small, try to pass one test at a time
Helena
@poigirl2001
Jun 18 2016 04:55
Yes I have been reviewing the other challenges I have passed
Jesus Rivero
@jesusdaver86
Jun 18 2016 04:56

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
 var ending = str.slice(-2);
 var ending2 = target.slice(-2);
 var ends = ending.slice(-1);
 var ends1 = ending2.slice(-1);

  if ((ends === ends1)&&(ending === ending2)){
    return true;
  }
  else {
    return false;
  }
}

confirmEnding("Bastian", "n"); //should return true. error
himanshu mittal
@himanshu081996
Jun 18 2016 04:56
This message was deleted
@jesusdaver86 there is no need to slice the target
what is wrong in my code im getting [1,3,2,5,4] instead of [1,3,2,[5],[4]]
function uniteUnique(arr) {
  var array=arguments[0];
  for(var i=1;i<arguments.length;i++){
    for(var j=0;j<arguments[i].length;j++){
      if(array.indexOf(arguments[i][j])<0){
        array=array.concat(arguments[i][j]);
      }
    }
  }
  return array;
}

uniteUnique([1, 3, 2], [1, [5]], [2, [4]]);
anyone here??
Jesus Rivero
@jesusdaver86
Jun 18 2016 05:01
@himanshu081996
I will correct later thanks
CamperBot
@camperbot
Jun 18 2016 05:01
jesusdaver86 sends brownie points to @himanshu081996 :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @himanshu081996 |http://www.freecodecamp.com/himanshu081996
MrBurks
@mrburks
Jun 18 2016 05:04
:thumbsup:
V Arun Kumar
@arunvkumr
Jun 18 2016 05:12
@himanshu081996 concat function concatenates two arrays so when i = 1 and j = 1 arguments[i][j] is [5] which is an array and array is already an array it just merges both the arrays. you can use push instead of concat. that might work.
@himanshu081996 remember that push returns a number i.e. length of the new array so assigning it back to array will cast array to integer so assignment is not required.. just array.push(arguments[i][j]) works.
Helena
@poigirl2001
Jun 18 2016 05:13
@coymeetsworld Am I on the right track?

// 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) {
// code i wrote is below this line
  if (value!=="" && prop!=="tracks")
    {
      collection[value]=prop;
    }
  else if (prop==="tracks" && value!=="")
    {

    }
// code I wrote is above this line
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Coy Sanders
@coymeetsworld
Jun 18 2016 05:13
close collection[value]=prop; that needs to be changed a bit
you need to use id, and value is what you want to set the property to. You're setting the value to the property
like for the function call below updateRecords(5439, "artist", "ABBA");
to set the object with id 5439 and property artist to ABBA, it would be this: collection[5439]["artist"] = "ABBA";
you have it so its collection["ABBA"] = "artist";
Helena
@poigirl2001
Jun 18 2016 05:15
Oh so should it be collection[prop]=value; ?
Is value always going to equal artist?
Coy Sanders
@coymeetsworld
Jun 18 2016 05:18
no prop is "artist"
value will be the name of artist
also you're missing id
remember that collections is a object of objects
each object is a album
Joe
@savewvwithcode1010
Jun 18 2016 05:18
does anyone pair program? what do you use ?
Coy Sanders
@coymeetsworld
Jun 18 2016 05:18
so its an object of albums really, and you need to refer to them by id
so look at what I had above where i included 5439
Helena
@poigirl2001
Jun 18 2016 05:20
so I would access it by collection[id][prop]=value ?
himanshu mittal
@himanshu081996
Jun 18 2016 05:20
@arunkumrv thnanks.thanks for great help
Coy Sanders
@coymeetsworld
Jun 18 2016 05:20
yes
V Arun Kumar
@arunvkumr
Jun 18 2016 05:20
@himanshu081996 np. :smile:
himanshu mittal
@himanshu081996
Jun 18 2016 05:20
@arunkumrv thankyou
CamperBot
@camperbot
Jun 18 2016 05:20
himanshu081996 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 556 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
MrBurks
@mrburks
Jun 18 2016 05:29
ok I'm supposed to change an if/else chain into a switch statement. trouble is that the if/else chain contains elements that I don't know what it means...

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

switch(val){

case 1:
answer = "Marley";
break;

case 2:
answer = "The Answer";
break;

case 3:
answer = "There is no #1";
break;

case 4:
answer = "Missed me by this much!";
break;

case 5:
answer = "Ate Nine";
}

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

// Change this value to test
chainToSwitch(1);

this is the original:

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

if (val === "bob") {
answer = "Marley";
} else if (val === 42) {
answer = "The Answer";
} else if (val === 1) {
answer = "There is no #1";
} else if (val === 99) {
answer = "Missed me by this much!";
} else if (val === 7) {
answer = "Ate Nine";
}

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

// Change this value to test
chainToSwitch(7);

the "===" if I recall is a strict assignment. which means it can't be anything else but the assigned val, correct/
?
No takers?
:thumbsup:
Coy Sanders
@coymeetsworld
Jun 18 2016 05:32
you need to change your case statements
its not 1,2,3,4,5
what case/switch does is it takes the variable val and compares it to cases
for instance, you need a case for "bob", you also need a case for 42, for 1, etc
Helena
@poigirl2001
Jun 18 2016 05:35
@coymeetsworld This answer got the first and last things checked off of the list. What can I do to improve?

// 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) {
//code i wrote is below this line
  if (value!=="" && prop!=="tracks")
    {
      collection[id][prop]=value;
    }
  else if (prop==="tracks" && value!=="")
    {
      collection[id][prop].push([value]);
    }
  else if (prop!=="tracks" && value!=="tracks" && id!=="tracks")
    {
      collection[id][""]="tracks";
    }
  else if (value==="")
    {
      delete collection[id][prop];
    }
//code I wrote is above this line
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Coy Sanders
@coymeetsworld
Jun 18 2016 05:36
you can nest your if else statements @poigirl2001
also id will never be tracks, its always a number
Helena
@poigirl2001
Jun 18 2016 05:36
Oh ok
How would I nest my if/else statements?
Coy Sanders
@coymeetsworld
Jun 18 2016 05:36
put if statements inside other if statements
Helena
@poigirl2001
Jun 18 2016 05:37
Oh right
Coy Sanders
@coymeetsworld
Jun 18 2016 05:37
like if you had if (value !== "") {
anything inside that block would only execute under the idea that value is not empty
Helena
@poigirl2001
Jun 18 2016 05:37
Oh yeah that's a good idea
Coy Sanders
@coymeetsworld
Jun 18 2016 05:37
yeah should save you a few lines of code
Helena
@poigirl2001
Jun 18 2016 05:43
@coymeetsworld I've noticed that my push function does not place the variable at the end of the array but it replaces the whole array instead. Why is this happening?
trần nguyễn minh anh
@Anntran2222
Jun 18 2016 05:44
what does it mean to read and save your variables?
Coy Sanders
@coymeetsworld
Jun 18 2016 05:44
think it may be because you're pushing an array into the array, you just want to push value, without brackets
but not 100% sure
what's the context @Anntran2222 ?
trần nguyễn minh anh
@Anntran2222
Jun 18 2016 05:49

Complete the code in the editor below. The variables and are already declared and initialized for you. You must declare variables: one of type int, one of type double, and one of type String. Then you must read lines of input from stdin and initialize your variables. Finally, you must use the
= operator to perform the following operations:

Print the sum of plus your int variable on a new line.
Print the sum of plus your double variable to a scale of one decimal place on a new line
Concatenate with the string you read as input and print the result on a new line.

// Declare second integer, double, and String variables.

// Read and save an integer, double, and String to your variables

// Print the sum of both integer variables on a new line.

// Print the sum of the double variables on a new lines ;

// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.

Coy Sanders
@coymeetsworld
Jun 18 2016 05:50
doesn't sound like this is from FreeCodeCamp, is this Java @Anntran2222 ?
trần nguyễn minh anh
@Anntran2222
Jun 18 2016 05:51
yes
Coy Sanders
@coymeetsworld
Jun 18 2016 05:52
so when they say read, they mean take the input from stdin and assign it to those variables
trần nguyễn minh anh
@Anntran2222
Jun 18 2016 05:52
it's a challenge from the website Hakerrank.com
Coy Sanders
@coymeetsworld
Jun 18 2016 05:52
assigning it to the variables is essentially saving it
so that's what it means
trần nguyễn minh anh
@Anntran2222
Jun 18 2016 05:52
thankyou!
Coy Sanders
@coymeetsworld
Jun 18 2016 05:52
no problem, good luck! haven't tried hackerrank out yet
himanshu mittal
@himanshu081996
Jun 18 2016 05:54
@coymeetsworld can u help me in spinal tap case challenge
spinalCase("thisIsSpinalTap") should return "this-is-spinal-tap"
Coy Sanders
@coymeetsworld
Jun 18 2016 05:55
yeah
himanshu mittal
@himanshu081996
Jun 18 2016 05:56
how to do that
Coy Sanders
@coymeetsworld
Jun 18 2016 05:56
look at the helpful links
youll need to use some regex
himanshu mittal
@himanshu081996
Jun 18 2016 05:56
yeah im doing that
Helena
@poigirl2001
Jun 18 2016 05:56
@coymeetsworld I'm having an issue with my if/else statements
himanshu mittal
@himanshu081996
Jun 18 2016 05:56
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  str=str.toLowerCase();
  str=str.replace(/\s/g,"-");
  return str;
}

spinalCase('This Is Spinal Tap');
Helena
@poigirl2001
Jun 18 2016 05:57

// 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!=="")
    {
      if (prop!=="tracks")
      {collection[id][prop]=value;}

       if (prop==="tracks")
       {collection[id][prop].push(value);}
    }
  else if (prop!=="tracks" && value!=="tracks")
    {
      collection[id][""]="tracks";
    }
  else if (value==="artist") //this would equal the same as the if statement nested in it :(
    {
      delete collection[id][value];
       if (value==="")
      {delete  collection[id][prop]; 

        }}


  return collection;
}

// Alter values below to test your code
updateRecords(1245, "tracks", "Addicted to Love");
Coy Sanders
@coymeetsworld
Jun 18 2016 05:57
that solves one test but you need to account for others
value will never be tracks @poigirl2001
Helena
@poigirl2001
Jun 18 2016 05:58
@coymeetsworld Oh ok
Coy Sanders
@coymeetsworld
Jun 18 2016 05:58
so you don't have to account for that
Chase
@Belax8
Jun 18 2016 06:02
Hey guys! Does anyone know of a web API that I can access that will allow me to view sports scores and stats for free?
himanshu mittal
@himanshu081996
Jun 18 2016 06:05
can anyone explain this code
str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
DC*
@desyncr
Jun 18 2016 06:07
@himanshu081996 It uses regex grouping to split a camelCase string into a space separated string, ie: "helloWorld" -> "hello world"
@himanshu081996 with ( and ) you group and with $1, $2, $n you reference the groups
Helena
@poigirl2001
Jun 18 2016 06:10
@coymeetsworld I feel like I'm over complicating this.

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

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

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

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

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




  return collection;
}

// Alter values below to test your code
updateRecords(2548, "artist", "");
himanshu mittal
@himanshu081996
Jun 18 2016 06:10
@desyncr $1,$2 ??
@desyncr okk i understand thank you for your help
CamperBot
@camperbot
Jun 18 2016 06:11
himanshu081996 sends brownie points to @desyncr :sparkles: :thumbsup: :sparkles:
:cookie: 149 | @desyncr |http://www.freecodecamp.com/desyncr
Darth Skywalker
@adityaparab
Jun 18 2016 06:23

@poigirl2001 : Technically, this code would work. However, you're missing a few vital things that this challenge wants you to consider.

First, you must check whether the property prop exists on the collection.id
So your first condiftion would be

if(collection[id].hasOwnProperty(prop)){
Helena
@poigirl2001
Jun 18 2016 06:25
Oh
Coy Sanders
@coymeetsworld
Jun 18 2016 06:27
@poigirl2001, ill say it again tracks will never be a value :)
so you don't need to do any value !== "tracks" or anything, it can be a property but the value would be the track name
Darth Skywalker
@adityaparab
Jun 18 2016 06:28

True!

collection[id][""]="tracks"; should be collection[id]["tracks"]=[];

Helena
@poigirl2001
Jun 18 2016 06:28
@adityaparab Oh so that's how I was supposed to create a new empty array
@coymeetsworld woops I forgot to delete the if (value!=="tracks") part
@adityaparab But what should happen if the condition has its own property?
SuhailG
@suhailgme
Jun 18 2016 06:32
@UtkarshShukla7 thanks I appreciate it
CamperBot
@camperbot
Jun 18 2016 06:32
suhailgme sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 645 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Chris Cullen
@123xylem
Jun 18 2016 06:34
Can you help me with my bottom function. It takes a value from till and takes that off change needed.. I commented it up.. Its crashing my browser at the minute though... I think I need somethin with---- chgArr.push(i)--- But possibly some other changes aswell..

function checkCashRegister(price, cash, cid) {
var val;
  var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;
  var arr=[];
  var change= money-cost;

  if(change<0){
  change=Math.abs(change);}//this makes change positive if its negative value
else change=change;


  for(i=0; i<till.length;i++){
   count+=till[i][1];}
    if(change>count){
    return "Insufficient Funds";
// Make a count that totals till values. If change is more than till then say so

  }  else{
  var chgCount=0;
    var chgArr=[];
  for(i=till.length-1;i<till.length;i--){ //go through till from highest to lowest
    while(change>chgCount){//while change is more than 0

      chgCount+=till[i][1]; //add number to change from till
      chgArr.push(till[i]);//put that in an array
      change-=till[i][1];//Take that number off change.
    }return chgArr;
  }


}
}

checkCashRegister(2000.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
the last else is the problem
DC*
@desyncr
Jun 18 2016 06:40
@123xylem My guess is the var chgCount=0; line, it should be inside the for () {}
Ogundele Olumide
@Lumexralph
Jun 18 2016 06:40
hey guys, can someone help with simple steps how to solve Profile LookUp challenge
SuhailG
@suhailgme
Jun 18 2016 06:41
@Lumexralph whats the problem?
MrBurks
@mrburks
Jun 18 2016 06:44

// Setup
function abTest(a, b) {
// Only change code below this line

// 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);

I didn't have a lesson that covered math functions
Chris Cullen
@123xylem
Jun 18 2016 06:45
@desyncr inside the {} or the actual () for loop bit?
DC*
@desyncr
Jun 18 2016 06:45
@123xylem I would put it inside the curly brackets {}
bitgrower
@bitgrower
Jun 18 2016 06:46
@Lumexralph -- definitely ... what have you tried and what are you having trouble with ?
Chris Cullen
@123xylem
Jun 18 2016 06:47
@desyncr tried it but it still crashes
Ogundele Olumide
@Lumexralph
Jun 18 2016 06:47
This message was deleted
bitgrower
@bitgrower
Jun 18 2016 06:47
@mrburks - I believe they give you some references for Math function pages on the Mozilla Developer Network, no ?
sooooo... @Lumexralph
  1. what are you being given?
  2. what are you requested to return?
  3. how to you get #2 from #1 ?
Ogundele Olumide
@Lumexralph
Jun 18 2016 06:51

@bitgrower i have an array of data containing 4 properties, I am to build a function to ......

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

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

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

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var j = 0; j < contacts.length; j++) { //iterate through the array
  for(var i in contacts[j]) {  //iterate through the object
   console.log(contacts[j]["firstName"]);
  }
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastNames");
That's my progress so far @bitgrower
Markus Kiili
@Masd925
Jun 18 2016 06:53
@Lumexralph You only need one loop through contacts array. Then two nested if's.
MrBurks
@mrburks
Jun 18 2016 06:53
this is crazy
Markus Kiili
@Masd925
Jun 18 2016 06:54
@Lumexralph First checks the firstname and the second checks if the property exists.
bitgrower
@bitgrower
Jun 18 2016 06:54
I'm groveling here ... I have 5 minutes to get a brownie point or break my 136 day streak ... anyone want to take pity on me and thank me ahead of time ? :)
SuhailG
@suhailgme
Jun 18 2016 06:55
@bitgrower thanks!
CamperBot
@camperbot
Jun 18 2016 06:55
suhailgme sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1105 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 18 2016 06:55
thank you @suhailgme ! I nearly panicked when I saw I had 15 minutes left ... :)
CamperBot
@camperbot
Jun 18 2016 06:55
bitgrower sends brownie points to @suhailgme :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @suhailgme |http://www.freecodecamp.com/suhailgme
SuhailG
@suhailgme
Jun 18 2016 06:55
hehe @bitgrower np! and thanks for all your help here
CamperBot
@camperbot
Jun 18 2016 06:55
suhailgme sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: suhailgme already gave bitgrower points
Ogundele Olumide
@Lumexralph
Jun 18 2016 06:56
@Masd925 how do I check if the property exists?
Markus Kiili
@Masd925
Jun 18 2016 06:56
@bitgrower Now to earn it by telling us why Object.length is 1 ?
bitgrower
@bitgrower
Jun 18 2016 06:56
hahaha
Markus Kiili
@Masd925
Jun 18 2016 06:56
@Lumexralph obj.hasOwnProperty(key)
bitgrower
@bitgrower
Jun 18 2016 06:56
@Lumexralph yeah, what he said ...
is that a universal property, or are you asking about someone's answer to a specific challenge ... :)
MrBurks
@mrburks
Jun 18 2016 06:57
@bitgrower so am i supposed to read that like an equation?
Ogundele Olumide
@Lumexralph
Jun 18 2016 06:58
wow.....believe you me I don't know how I didn't think of that @Masd925 @bitgrower
thanks guys.....
bitgrower
@bitgrower
Jun 18 2016 06:58
y'all are welcome, @Lumexralph
MrBurks
@mrburks
Jun 18 2016 06:58
@bitgrower so am i supposed to read that like an equation?
Ogundele Olumide
@Lumexralph
Jun 18 2016 06:59
let me work on that and hopefully I don't have to bug you guys for this challenge anymore
bitgrower
@bitgrower
Jun 18 2016 06:59
hang on ... I don't multi-task that well -- especially with a bunch of thought-provoking ideas bouncing thru my head ... :)
Steve Song
@SteveMSong
Jun 18 2016 06:59
anybody know React.js??
mos
@sophizo
Jun 18 2016 06:59
@Masd925

function findLongestWord(str) {

  var array = str.split(' ');

  array.sort(function(a,b) {
    return b.length - a.length;
  });

  return array[0].length;

}
this worked
Markus Kiili
@Masd925
Jun 18 2016 07:00
@HeumO Nice solution.
Chris Cullen
@123xylem
Jun 18 2016 07:00
IS this an infi loop ? js for(i=till.length-1;i<till.length;i--)
mos
@sophizo
Jun 18 2016 07:00
but can u tell me why we use }, 0);
bitgrower
@bitgrower
Jun 18 2016 07:00
@SteveMSong try the backend room ...
help rooms
CamperBot
@camperbot
Jun 18 2016 07:00

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

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

Choose the right room for your questions!

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

back to top ↑

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

mos
@sophizo
Jun 18 2016 07:00
what is the uses of that 0
Steve Song
@SteveMSong
Jun 18 2016 07:00
ok ty
Markus Kiili
@Masd925
Jun 18 2016 07:01
@HeumO It is an argument on some function call (most probably).
bitgrower
@bitgrower
Jun 18 2016 07:01
@123xylem it can depend on what happens inside the loop -- if till changes in length (especially increases) ... it certainly could be !!!
mos
@sophizo
Jun 18 2016 07:01
@Masd925 the code worked without it too
bitgrower
@bitgrower
Jun 18 2016 07:02
@HeumO it's probably initializing a value, which, if not specified, defaults to 0 -- which is why it works with or without
Markus Kiili
@Masd925
Jun 18 2016 07:02
@HeumO Sort has only one parameter, so the extra 0 argument does nothing.
mos
@sophizo
Jun 18 2016 07:03
@Masd925 sort has 2 parameters
bitgrower
@bitgrower
Jun 18 2016 07:03
ahh ... I hadn't seen the rest of the statement ... didn't realize it was sort ... a cruise thru the sort mdn page might be enlightening ...
mos
@sophizo
Jun 18 2016 07:03
a ,b
Markus Kiili
@Masd925
Jun 18 2016 07:03
@HeumO Those are parameters of the callback function.
@HeumO Sort syntax: arr.sort([compareFunction])
mos
@sophizo
Jun 18 2016 07:04
@Masd925 correct
Markus Kiili
@Masd925
Jun 18 2016 07:04
@HeumO Compare function has two parameters.
bitgrower
@bitgrower
Jun 18 2016 07:04
@Masd925 you crack me up -- I look at your name and it doesn't make me think of your username ... it always kinda trips me up ...
mos
@sophizo
Jun 18 2016 07:04
@Masd925 so that was good code , right ?
Markus Kiili
@Masd925
Jun 18 2016 07:04
@HeumO Yes.
bitgrower
@bitgrower
Jun 18 2016 07:06
what is written in the front end challenges hardly scratches the surface of good code, tbh -- in terms of defensive programming ... actually doing sanity checking on incoming parameters ...
mos
@sophizo
Jun 18 2016 07:07
@Masd925
MrBurks
@mrburks
Jun 18 2016 07:07
I'm so tired of this. all these exercises fail two conditions
bitgrower
@bitgrower
Jun 18 2016 07:07
I'm not knocking it, mind you ... you learn a lot ...
mos
@sophizo
Jun 18 2016 07:07
var findLongestWord = str => str.split(" ").reduce((a, b) => b.length > a ? b.length : a, 0);
i came across that code , can u tell me why that => does ?
bitgrower
@bitgrower
Jun 18 2016 07:08
@mrburks -- Math functions are actually your friends ... do you have a bit of math phobia ? (not meant to be insulting, just curious ... )
Oxide Debbarma
@oxide94Git
Jun 18 2016 07:08
random quote machine.. any suggestions or precautions :)
bitgrower
@bitgrower
Jun 18 2016 07:08
LOTS of folks are math-phobic ...
SuhailG
@suhailgme
Jun 18 2016 07:09
@oxide94Git check out the forismatic api
bitgrower
@bitgrower
Jun 18 2016 07:09
@oxide94Git -- using an API, or your own quotes ?
Markus Kiili
@Masd925
Jun 18 2016 07:09
@HeumO It is ES6 (future javascript arrow) function syntax.
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:09
can u help to solve the challenge of concatenation of string using +=
MrBurks
@mrburks
Jun 18 2016 07:10
@bitgrower I don't have a phobia. I have no idea what f-ing code is supposed to go in the box.
SuhailG
@suhailgme
Jun 18 2016 07:10
@Bhaargavi1 whats issues are you having?
Markus Kiili
@Masd925
Jun 18 2016 07:10
@HeumO THis is also a nice solution:
function findLongestWord(str) {
  return Math.max.apply(null, str.split(' ').map(function(elem){return elem.length;}));
}
bitgrower
@bitgrower
Jun 18 2016 07:10

myStr += " and the cat jumped over the moon."

myStr was equal to "The cat's in the cradle"

Tim Handy
@TimHandy
Jun 18 2016 07:10
Hi all! In the Profile Lookup challenge the solution is to use nested IF statements. I however am attempting to use an && statement like the following to say "if contacts.firstName is true, i.e. is in the collection AND contacts.prop is also in the collection". Not sure whether this will work but seems to do in one line what the solution does in several. Am I going way off track in thinking like this, or should I carry on trying to get it to work? I have no prior experience in coding.
if ((contacts.firstName) && (contacts.prop)) {
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:10
its not accpting the solution var myStr = "This is the first sentence.";
myStr += "This is the second sentence.";
bitgrower
@bitgrower
Jun 18 2016 07:10
Now it would say "The cat's in the cradle and the cat jumped over the moon."
Markus Kiili
@Masd925
Jun 18 2016 07:11
@TimHandy If the property key is in a variable, you have to use bracket notation.
bitgrower
@bitgrower
Jun 18 2016 07:11
@Bhaargavi1 Look CAREFULLY at how my quoted string in the equation starts ...
MrBurks
@mrburks
Jun 18 2016 07:11
screw this
Markus Kiili
@Masd925
Jun 18 2016 07:11
@TimHandy The proper way to test property existence is .hasOwnProperty() or .propertyIsEnumerable().
mos
@sophizo
Jun 18 2016 07:12
@Masd925 so its optional ? & that code first takes the b.length value then checks if it > a or not , right ?
SuhailG
@suhailgme
Jun 18 2016 07:12
@bitgrower what is your return value?
@bitgrower oops disregard wrong @ :D
@Bhaargavi1 Whats your return value?
Markus Kiili
@Masd925
Jun 18 2016 07:13
@HeumO That reduce has a running value that is always the larger of the (old) running value and element being iterated.
bitgrower
@bitgrower
Jun 18 2016 07:13

sorry @mrburks -- programming can often be frustrating ... part of learning to code is learning to deal with the frustration ... as I read in one blog written for newbie coders ... "you will always have frustration ... however it lessens and it gets better over time...and you learn to expect and deal with it" ... (paraphrased, but generally idea) ...

Having spent something like 20 years in industry, I'd say that's an accurate assessment ...

Tim Handy
@TimHandy
Jun 18 2016 07:14
@Masd925 ahh! Now I remember the [] notation
, thanks... I'll try that... so I'm ok to use the && in this case? Guess I'll try and see what happens!
CamperBot
@camperbot
Jun 18 2016 07:14
timhandy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1911 | @masd925 |http://www.freecodecamp.com/masd925
Chris Cullen
@123xylem
Jun 18 2016 07:14
@bitgrower I want the for loop to start at the end and go to the beginning but this makes I go forever as i never gets more than arr.length
bitgrower
@bitgrower
Jun 18 2016 07:14
@suhailgme aha ... the gitter autocomplete bit another one ...
Markus Kiili
@Masd925
Jun 18 2016 07:14
@TimHandy The simplest structure is two nested if's. Firstname and property existence checks.
bitgrower
@bitgrower
Jun 18 2016 07:14
@123xylem do you know which test case ?
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:15
i am getting an output which is mystr="This is the the first sentence.This is the second sentence."
mos
@sophizo
Jun 18 2016 07:15
@Masd925 yes but in an array of words , some future words might be bigger as well ?
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:15
Now how & what should i correct
Tim Handy
@TimHandy
Jun 18 2016 07:15
@Masd925 ok, I'll take your word for it and use if statements. thanks again.
CamperBot
@camperbot
Jun 18 2016 07:15
timhandy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: timhandy already gave masd925 points
bitgrower
@bitgrower
Jun 18 2016 07:16
I ran what you posted in pythontutor, and, with the exception of complaining about i not being defined, after I fixed that, it ran ... but don't know about other test cases...
mos
@sophizo
Jun 18 2016 07:16
@Masd925 what if the running value is smaller ? it then returns the current val i guess,
bitgrower
@bitgrower
Jun 18 2016 07:16
@Bhaargavi1 look at the string ... WHAT is it missing ?
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:16
nothing is missing
Chris Cullen
@123xylem
Jun 18 2016 07:16
@bitgrower yes exact change
bitgrower
@bitgrower
Jun 18 2016 07:16
Yes, it is ... LOOK carefully ...
Markus Kiili
@Masd925
Jun 18 2016 07:17
@HeumO It compares the running value to element and the next running value is the largest of the two.
bitgrower
@bitgrower
Jun 18 2016 07:17
VERY carefully...
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:17
What is it??
bitgrower
@bitgrower
Jun 18 2016 07:18
look, if I tell you, you really won't like it ... if YOU find it, you will learn a great lesson in finding subtle errors ... which programming is full of ... (I don't mean to be an ass here, but this is important...)
Carl P.
@alofacarl
Jun 18 2016 07:18
Why do we need an 'else if' statement if the code works without it?
function testElseIf(val) {
  if (val > 10) {
    return "Greater than 10";
  }

  if (val < 5) {
    return "Smaller than 5";
  }

  return "Between 5 and 10";
}

// Change this value to test
testElseIf(7);
bitgrower
@bitgrower
Jun 18 2016 07:19
@123xylem I was trying to give you some ideas on what you, personally,, might try (hint: other test cases, hint: use pythontutor.com/javascript.html )
mos
@sophizo
Jun 18 2016 07:19
@Masd925 in [ a, ab ,abcd ,abcde ] it first compares a & ab ,returns ab cause its bigger, then again ab & abc and goes on ,
Markus Kiili
@Masd925
Jun 18 2016 07:19
@alofacarl Elses are often optional.
Carl P.
@alofacarl
Jun 18 2016 07:20
@Masd925 Oh ok thank you.
CamperBot
@camperbot
Jun 18 2016 07:20
alofacarl sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1912 | @masd925 |http://www.freecodecamp.com/masd925
mos
@sophizo
Jun 18 2016 07:20
but that is a perfect ascending array , so we need 'if' to return the bigger value, right ?
bitgrower
@bitgrower
Jun 18 2016 07:20
@Bhaargavi1 -- Look at every sentence people write here in conversation. then look at the sentences your code outputs ...
Markus Kiili
@Masd925
Jun 18 2016 07:20
@HeumO The callback function tells reduce to keep the larger value.
mos
@sophizo
Jun 18 2016 07:22
var findLongestWord = str => str.split(" ").reduce((a, b) => b.length > a ? b.length : a, 0);
Markus Kiili
@Masd925
Jun 18 2016 07:22
@HeumO Parameters of reduce callback function are prev (running value) and curr (the element being iterated by reduce). The callback return value is the new running value.
mos
@sophizo
Jun 18 2016 07:22
why that ' ? ' there
Markus Kiili
@Masd925
Jun 18 2016 07:22
@HeumO Ternary operator (similar to if).
mos
@sophizo
Jun 18 2016 07:23
@Masd925 yup , so it returns either b.length or a ,
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:23
i hav corrected the code yet i dont know what was the mistake
Chris Cullen
@123xylem
Jun 18 2016 07:23
@bitgrower what is that for?
Markus Kiili
@Masd925
Jun 18 2016 07:23
@HeumO Yes, the length of the element, or the old running value.
mos
@sophizo
Jun 18 2016 07:24
@Masd925 whichever is bigger
Markus Kiili
@Masd925
Jun 18 2016 07:24
@HeumO Yes.
mos
@sophizo
Jun 18 2016 07:24
@Masd925 thanks
CamperBot
@camperbot
Jun 18 2016 07:24
heumo sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1913 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 18 2016 07:25
@HeumO With that callback function, you can actually define any array operation. Any .filter(), .map(), .every() etc, can be written with .reduce(). It is the mother of all array operations.
bitgrower
@bitgrower
Jun 18 2016 07:27
@Bhaargavi1 does it pass now ?
Markus Kiili
@Masd925
Jun 18 2016 07:27
@HeumO But it is usually better to use those specialized methods when possible, because the intention is clearer with them (and less code usually).
bitgrower
@bitgrower
Jun 18 2016 07:27
@123xylem sorry? to what are you referring ... (I am talking to more than 1 person here ... )
Helena
@poigirl2001
Jun 18 2016 07:28
I have to check whether tracks exists or not and if it doesn't i have to create an empty array. is this correct?
if (collection.hasOwnProperty("tracks")===false)
    {
      collection.id["tracks"]=[""];
    }
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:28
yes it did nd i think it was the spaces
bitgrower
@bitgrower
Jun 18 2016 07:29
yep -- that's the problem ... subtle, isn't it ?
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:30
yes
Chris Cullen
@123xylem
Jun 18 2016 07:30
@bitgrower I was asking why this was crashing the browser.. Most likely coming from the else statement at the bottom. I think its something to do with the push(i) part but im not sure
function checkCashRegister(price, cash, cid) {
var val;
  var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;
  var arr=[];
  var change= money-cost;

  if(change<0){
  change=Math.abs(change);}//this makes change positive if its negative value
else change=change;


  for(i=0; i<till.length;i++){
   count+=till[i][1];}
    if(change>count){
    return "Insufficient Funds";
// Make a count that totals till values. If change is more than till then say so

  }  else{
  var chgCount=0;
    var chgArr=[];
  for(i=till.length-1;i>0;i--){ //go through till from highest to lowest
    while(change>chgCount){//while change is more than 0

      chgCount+=till[i][1]; //add number to change from till
      chgArr.push(till[i][0]+till[i][1]);//put that in an array
      change-=till[i][1];//Take that number off change.
    }
  }return chgArr;


}
}

checkCashRegister(2000.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
bitgrower
@bitgrower
Jun 18 2016 07:30
now, are you mad at me for making you find it @Bhaargavi1 ? :)
@123xylem so it crashes your browser on THAT test case specifically? Or when you go to run all the test cases in FCC ?
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:33
no thanks alot
this is the best way to help
bitgrower
@bitgrower
Jun 18 2016 07:33
:)
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:34
but tell me are you a teacher of programming
bitgrower
@bitgrower
Jun 18 2016 07:34
...no, but I held my first programming job some 36 years ago ... :) so I've been around code a long, long time ...
or, I should say, no, not formally ...
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:36
so you are in around late 50's
bitgrower
@bitgrower
Jun 18 2016 07:36
I wish !
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:36
means ??
bitgrower
@bitgrower
Jun 18 2016 07:36
means, I'm older ... :)
Bhaargavi1
@Bhaargavi1
Jun 18 2016 07:36
ok!!
but thanks again
bitgrower
@bitgrower
Jun 18 2016 07:39
you are most welcome ... some people get mad at me ... because they want answers ... but when you learn to find your own answers, you are 100x or more better off ... in industry, it's true, that if you get really stuck, you might ask one of your colleagues to take a look -- or, better yet, you'll either be explaining the problem, or your colleague will ask questions ... and a lightbulb goes off ...
Oxide Debbarma
@oxide94Git
Jun 18 2016 07:39
 @bitgrower sorry slow network :worried: how about using an api
bitgrower
@bitgrower
Jun 18 2016 07:39
...and sometimes you just need to take a break and walk around ... work on the same problem too long ... your brain gets stuck ...and you need to pull it out of the problem for a bit ...
@oxide94Git -- you'll want to look at CORS
I dunno ... I'm not sure the one api someone mentioned above may help you get around CORS issues .. there are a few of them ... both MDN and questions on stackoverflow, you can find more information about CORS ...
...basically, you have to overcome a security measure ... it's where a fair number of folks have issues ... and there are a few different solutions, as I say ...
@123xylem -- one of the FCC testcases is such that the amount on the drawer looks like you should be able to make change ... but what happens is, there isn't anough of the right denominations to create the change ... so it's a usage case your code needs to handle ...
MrBurks
@mrburks
Jun 18 2016 07:46
seems no matter what I put inside the function, it only seems to react based on the numerical param i plug into the function call.
and it's usually 8
bitgrower
@bitgrower
Jun 18 2016 07:51
LOL ... I can understand the frustration ... that's a big kinda ugly looking statement there, for sure ...
can you post your code again ? It's a bit quieter now ... might be able to sort things out enough to see if we can help you find an answer ...
but I'm yawning wide ... so if you wanna catch me ... better act quickly ... @mrburks
k, sorry ... times up ... not to be rude, but gotta get some sleep here ... good luck & happy coding ...
Abhijit
@blackbirdabhi
Jun 18 2016 07:57
Challenge: Check for palindrome. what's wrong here?
function palindrome(str) {
// Good luck!
var len=str.length;
for(var i=0; i<Math.floor(len/2); i++){
if(str[i]!==str[len-1-i]){
return false;
}
}
return true;
}
palindrome("eye");
Mihajlo Krsmanović
@rektix
Jun 18 2016 07:58
hey i need help
my page refreshes after clicking button that has some jquery functions
Prashant Sharma
@30Prashant
Jun 18 2016 08:01

var Bike = function() {

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

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

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

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);
myBike.getGear();

what's wrong in it?
can anyone help?
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:02
@30Prashant whats your task?
Prashant Sharma
@30Prashant
Jun 18 2016 08:03
@rektix Make Object Properties Private
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:06
you need to set initial value to gear
like var gear = 10;
Shusil Banjade
@shusil123
Jun 18 2016 08:07
@30Prashant , you have to return this.gear; in getGear method. Otherwise, it's fine
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:08
@30Prashant and in setGear function try not using gear name in parameters of function
@shusil123 he can use return gear too, it worked for me
Shusil Banjade
@shusil123
Jun 18 2016 08:09
@rektix , because he is using parameter and setting this.gear = gear; he has to return this.gear; I guess
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:09
yeah
Tony Johnson
@tnyjhnsn
Jun 18 2016 08:09
I am starting the TwitchTV challenge. I can present data, but if i click on the link, I just get part of the twitch page. If I right click and select open in new tab, the page works. Any obvious errors here?
http://codepen.io/tony_tosp/full/yJaeWj/
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:09
i used num instead of gear
@shusil123 btw have you done wikipedia page?
Prashant Sharma
@30Prashant
Jun 18 2016 08:10
@rektix i don't think variable name matters
Shusil Banjade
@shusil123
Jun 18 2016 08:10
@rektix , that won't affect. js can recognize the passed parameter and value.
Prashant Sharma
@30Prashant
Jun 18 2016 08:10
@shusil123 this.gear, i'll check it out
Shusil Banjade
@shusil123
Jun 18 2016 08:10
@rektix , No i haven't . Not in the mood to do projects. Completed algorithms
Exams are coming. So
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:11
@shusil123 could you tell me why my page is refreshing after i click search buton
Bhaargavi1
@Bhaargavi1
Jun 18 2016 08:11
what does it mean to pass words separated by non-ord characters
Bhaargavi1
@Bhaargavi1
Jun 18 2016 08:11
non-word
Prashant Sharma
@30Prashant
Jun 18 2016 08:11
@shusil123 myBike.gear should remain undefined.
how to do this?
Shusil Banjade
@shusil123
Jun 18 2016 08:12
@30Prashant , define both methods inside Bike, like this :
var Bike = function() {

  // Only change code below this line.
  this.getGear = function() {
    return this.gear;
  };

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

};
Should work
Prashant Sharma
@30Prashant
Jun 18 2016 08:13
@shusil123 it ain't working
where should gear be defined?
khanh19934
@khanh19934
Jun 18 2016 08:15
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(num<=3&&num>=0){
    str=str.slice(0,num);
    str+="...";
  }
  else{
    str=str.slice(0,num-3);
    str+="...";
  }
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
i dont know why i'm wrong :(
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:17
@khanh19934 that problem isnt that simple, i needed like 30 mins to solve it
khanh19934
@khanh19934
Jun 18 2016 08:17
oh i know my problem . else if num >=str.length should return str
@rektix im fixed, and it is working :D
Mihajlo Krsmanović
@rektix
Jun 18 2016 08:19
@khanh19934 good job :D
Prashant Sharma
@30Prashant
Jun 18 2016 08:19
myBike.gear should remain undefined
anybody, help?
khanh19934
@khanh19934
Jun 18 2016 08:19
@30Prashant gear need to be defined and gear is private variable
Prashant Sharma
@30Prashant
Jun 18 2016 08:20

var Bike = function() {

// Only change code below this line.
var gear;
this.setGear = function(gear) {
this.gear= gear;
};

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

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(4);
myBike.getGear();

@khanh19934 what's wrong in it?