These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Jun 2016
Anthony
@Coding-in-progress
Jun 06 2016 00:01
Why does this pass the challenge(Selecting from many options with Switch statements) but is different than what I am seeing elsewhere?

switch (val) {
case (val = 1):
answer = "alpha";
break;

case (val = 2): 
  answer = "beta";
  break;

case (val = 3):
  answer = "gamma";
  break;

case (val = 4):
  answer = "delta";
 break;


           }

return answer;
}

Diego Mayer
@Chrono79
Jun 06 2016 00:06
@Coding-in-progress val = 1 is returning 1 at the end so, it's the same as case 1
var val=2;
switch (val) {
case (foo = 1):
answer = "alpha";
break;
case (foo = 2): 
  answer = "beta";
  break;

case (foo = 3):
  answer = "gamma";
  break;

case (foo = 4):
  answer = "delta";
 break;
}
flindip
@flindip
Jun 06 2016 00:07
Doing "Title Case a Sentence" Trying to figure out how a pathway to capitalize the first letter of all the elements in my array. Can't quite seem to figure it out. I tried with Index Of method but it no luck...
Here is my code:
function titleCase(str) {
var string2="";
var array=[];
if(str.indexOf(" ")!=1){
    array=str.split(" ");
}
for(var i=0; i<array.length;i++){
    array[i].charAt(0).toUpperCase();
       string2=array.join(" ");

}

return string2;    
}



titleCase("I'm a little tea pot");
Diego Mayer
@Chrono79
Jun 06 2016 00:07
@flindip string immutability
help string immutability
CamperBot
@camperbot
Jun 06 2016 00:08

:point_right: challenge understand string immutability [wiki]

Challenge Understand String Immutability

In Javascript, String values are immutable, which means that they cannot be altered once created.

:pencil: read more about challenge understand string immutability on the FCC Wiki

asaki444
@asaki444
Jun 06 2016 00:08
function addTogether() {
var a = arguments[0];

  if(typeof arguments[0] !== "number"|| typeof arguments[1] !== "number")
  {return undefined;}
  else if(arguments.length === 2){
    return a + arguments[1];
  }
  else{
     var addStuff = function(b){
    return addTogether(a,b);
     };
    return addStuff;
    }
}

addTogether(2)([3]);
it keeps returning not the function
this is the arguments optional
one
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 00:08

@flindip ..I used dis logic..

str=str.toLowerCase().split(" ");
for(var i=0;i<str.length;i++)
{
str[i]=str[i].split('');
str[i][0]=str[i][0].toUpperCase();
str[i]=str[i].join('');
}
return str.join(" ");
..and it worked

flindip
@flindip
Jun 06 2016 00:08
@Chrono79 I understand that strings are immutable. Thats why it needed converted into an array...
Stephen James
@sjames1958gm
Jun 06 2016 00:09
@asaki444 if there is only one argument then arguments[1] is not a number and you return undefined
@flindip Your toUppercase() returns a value not changes a value - that value is not captured
Diego Mayer
@Chrono79
Jun 06 2016 00:09
@flindip you're also doing some weird things there, just split to get the words, capitalize the first letter and lowercase the rest, concatenate that... and the rest is for you to think about
flindip
@flindip
Jun 06 2016 00:10
ok, thanks @Chrono79 @sjames1958gm @Alfarhanz
CamperBot
@camperbot
Jun 06 2016 00:10
flindip sends brownie points to @chrono79 and @sjames1958gm and @alfarhanz :sparkles: :thumbsup: :sparkles:
:star2: 1031 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 252 | @alfarhanz |http://www.freecodecamp.com/alfarhanz
:star2: 1457 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
asaki444
@asaki444
Jun 06 2016 00:11
@sjames1958gm I got it thanks!
CamperBot
@camperbot
Jun 06 2016 00:11
:star2: 1458 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
asaki444 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Anthony
@Coding-in-progress
Jun 06 2016 00:11
@Chrono79 Ok I was kinda thinking that...is my solution improper syntax?
Taylor Bostick
@Taylorbostick32
Jun 06 2016 00:11
im stuck on this madlib. Having a hard time figuring out what I am supposed to be doing
Diego Mayer
@Chrono79
Jun 06 2016 00:12
I would go with the case 1: syntax @Coding-in-progress
Anthony
@Coding-in-progress
Jun 06 2016 00:12
Ok thanks for the reply :)
Diego Mayer
@Chrono79
Jun 06 2016 00:12
@Taylorbostick32 did you read the mad libs link?
Stephen James
@sjames1958gm
Jun 06 2016 00:12
@Coding-in-progress That is weird It must be comparing val to the result of val = 1 which is similar to case 1:
Diego Mayer
@Chrono79
Jun 06 2016 00:12
@sjames1958gm That's exactly what it's doing
Stephen James
@sjames1958gm
Jun 06 2016 00:13
@Chrono79 I guess it must use the value of val before the assignment
Taylor Bostick
@Taylorbostick32
Jun 06 2016 00:13

i read it. this is what i have function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = 'Saturday morning the "myNoun " unfortunately "myVerb " and now is the "myAdjective " thing who "myAdverb " gets around.';

// Your code above this line
return result;
}

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

Maximus112
@Maximus112
Jun 06 2016 00:13
Hello I'm on the WordBlanks challenge and have absolutely no idea what to write inside the function? Any help would be much appreciated
Stephen James
@sjames1958gm
Jun 06 2016 00:14
@Taylorbostick32 Recall the exercise where you created one string from two strings, what operator did you have to use?
Diego Mayer
@Chrono79
Jun 06 2016 00:14
@Taylorbostick32 https://www.freecodecamp.com/challenges/constructing-strings-with-variables review this challenge
also, beware of how you alternate between single and double quotes
rphares
@rphares
Jun 06 2016 00:14
you just build a sentence, @Maximus112 ,
by concatenating the parameters, AND also concatenating in some non-word characters (i suggest spaces) in between each param
so that the result isn't bigdogranquickly ;)
Maximus112
@Maximus112
Jun 06 2016 00:15
Thanks @rphares
CamperBot
@camperbot
Jun 06 2016 00:15
maximus112 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
rphares
@rphares
Jun 06 2016 00:15
(you can add more words in between, to make it a silly sentence like a real madlib if you are feeling ambitious :blush: )
CamperBot
@camperbot
Jun 06 2016 00:15
:star2: 5045 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
Jun 06 2016 00:15
sure thing~ Happy coding!
Anthony
@Coding-in-progress
Jun 06 2016 00:16
@sjames1958gm Yea very strange!
Diego Mayer
@Chrono79
Jun 06 2016 00:18

it evaluates the expression before comparing it

var val=true;
switch (val) {
    case (14%2 === 0):
    answer = "alpha";
    break;
}

answer value will be "alpha"

iccomq
@iccomq
Jun 06 2016 00:19
hey guys im currently sitting at Where art thou, trying to make 3 nested loops work together, but maaybe, maybe there is some simple solution that is flying over my head, maybe someone can point me in better direction? I don't really want any solution.. but 3 loops just seem kind of counterproductive.
Diego Mayer
@Chrono79
Jun 06 2016 00:19
@iccomq you can do it with only 2 as @sjames1958gm says
Stephen James
@sjames1958gm
Jun 06 2016 00:20
@iccomq Should only need two loops - one for the array and one inside that for the source object
Taylor Bostick
@Taylorbostick32
Jun 06 2016 00:20
@sjames1958gm the plus operator
Stephen James
@sjames1958gm
Jun 06 2016 00:21
@Taylorbostick32 Yes
iccomq
@iccomq
Jun 06 2016 00:23
@sjames1958gm @Chrono79 well, i guess i tend to make things complicated, thanks guys :) also, thats probably why this refuses to work too^^
CamperBot
@camperbot
Jun 06 2016 00:23
iccomq sends brownie points to @sjames1958gm and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1459 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1032 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Jun 06 2016 00:24
@iccomq If it seems too complicated, step back up it probably is.
ogunoye adebamigbe john
@adebamigbejohn
Jun 06 2016 00:25
hello please i need help with switch statements
Diego Mayer
@Chrono79
Jun 06 2016 00:25
@adebamigbejohn what do you need help with?
ogunoye adebamigbe john
@adebamigbejohn
Jun 06 2016 00:25
caseInSwitch(1);
Selecting from many options with Switch Statements
Diego Mayer
@Chrono79
Jun 06 2016 00:26
and your code is?
ogunoye adebamigbe john
@adebamigbejohn
Jun 06 2016 00:26

'
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case caseInSwitch(1):
"alpha";

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

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

'

Creative Shin
@CreativeShin
Jun 06 2016 00:27
anyone doing the beginning js?
Diego Mayer
@Chrono79
Jun 06 2016 00:28

@adebamigbejohn I see, a switch statement consist of something like this:

switch(varName) {
  case somevalue: 
    do_something;
    break;
  case someOtherValue: 
    do_something_else;
    break;
}

caseInSwitch is your function name

Stephen James
@sjames1958gm
Jun 06 2016 00:29
@adebamigbejohn Look at the sample code.
switch (num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  case valueN:
    statementN;
    break;
}
Will Power
@restartedwill
Jun 06 2016 00:33
Wrote this in the front end channel with no ideas. I think I'm missing something simple when doing a $.json call or $(document).ready {}. If you look at the $.json snippet here: http://pastebin.com/LCMJRaT7 it writes the results of the "2:" code as 0,0, and then only after the whole $(document).ready that called this function is done, does it write the two inner console.log's. So the result is that I'm not getting variables assigned until the code completes, and I'm really confused what I'm doing wrong. So any ideas are greatly appreciated.
ogunoye adebamigbe john
@adebamigbejohn
Jun 06 2016 00:34
still not working
i didnt get it
Taylor Bostick
@Taylorbostick32
Jun 06 2016 00:36
@sjames1958gm thank you for the help and directing me to that part o f the map.
CamperBot
@camperbot
Jun 06 2016 00:36
taylorbostick32 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1460 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Taylor Bostick
@Taylorbostick32
Jun 06 2016 00:37
@Chrono79 thank you for the link.
CamperBot
@camperbot
Jun 06 2016 00:37
taylorbostick32 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1033 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 06 2016 00:39
@adebamigbejohn your switch would start like this:
switch (val) { // val is the var you are evaluating
  case 1:
ogunoye adebamigbe john
@adebamigbejohn
Jun 06 2016 00:43
thanks @Chrono79
CamperBot
@camperbot
Jun 06 2016 00:43
adebamigbejohn sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1034 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 06 2016 00:45
@restartedwill the getJSON is called and the code keeps running before you get the results, you should use the results inside the getJSON instead to make sure you get them
Will Power
@restartedwill
Jun 06 2016 00:47
@Chrono79 Oh! I expected it to be synchronous. Does the same thing go for $(document).ready? So I can't decompose algorithms into subfunctions?
Diego Mayer
@Chrono79
Jun 06 2016 00:48
@restartedwill getJSON is a shorthand for an AJAX call, and the last one is an acronym for Asynchronous JavaScript And XML
when manipulating dom objects you should always use $(document).ready
DarioRebirth
@DarioRebirth
Jun 06 2016 00:50
Is this a real world purpose for ++ and --?
Will Power
@restartedwill
Jun 06 2016 00:51
@Chrono79 Thanks. I'll have to redo my coding then. I try to write self-documenting code, but I won't be able to with the AJAX or the $(document).ready.
CamperBot
@camperbot
Jun 06 2016 00:51
restartedwill sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1035 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 06 2016 00:51
@DarioRebirth what do you mean?
DarioRebirth
@DarioRebirth
Jun 06 2016 00:52
Is it possible to do something else with ++ than just add 1?
Diego Mayer
@Chrono79
Jun 06 2016 00:52
I guess no, that's what it does
DarioRebirth
@DarioRebirth
Jun 06 2016 00:53
Do you know why you would actually use that in any scenario though?
Bobby McDonald
@BobbyMcWho
Jun 06 2016 00:53
use ++?
to increment through a for loop?
to add 1 to a variable
Diego Mayer
@Chrono79
Jun 06 2016 00:54
to not write + 1, it's a shorthand
bscyrpt
@bscyrpt
Jun 06 2016 00:54
@DarioRebirth in other languages ++var and var++ can control when you add 1 to a var, in js using ++ shorthand is can be more efficient to save script size
DarioRebirth
@DarioRebirth
Jun 06 2016 00:55
oh, I see now, just a shorthand thanks
Diego Mayer
@Chrono79
Jun 06 2016 00:56
@bscyrpt in js it also can be used as preincrement and posincrement
Increment (++) Unary operator. Adds one to its operand. If used as a prefix operator (++x), returns the value of its operand after adding one; if used as a postfix operator (x++), returns the value of its operand before adding one. If x is 3, then ++x sets x to 4 and returns 4, whereas x++ returns 3 and, only then, sets x to 4.
bscyrpt
@bscyrpt
Jun 06 2016 00:56
ah ok , so it works same as in other languages
Moses Samuel
@MosesSupposes
Jun 06 2016 00:57
Can someone help me w/ this palindrome challenge? I have to create a function that returns true if the inputted string is the same forwards as it is backwards (ex: 'race car'). Here's my code:

function palindrome(str) {
  Tested_String = new RegExp('/\\W\\D\\s/', 'gi'); // RegExp that matches all non-alphanumeric chars.
  var str_Replaced = str.replace(Tested_String, ""); // Deletes all non-alphanumeric chars.
  var str_LowerCased = str_Replaced.toLowerCase(); // Lower-cases previous string.

  // These next 3 lines reverse the string
  var str_Split = str_LowerCased.split(""); 
  var str_Reversed = str_Split.reverse(); 
  var str_Joined = str_Reversed.join(""); 

  // Here I reassign variable names for convenience.
  var str_PreReversed = str_LowerCased; 
  var str_PostReversed = str_Joined; 

  if (str_PreReversed === str_PostReversed) {
    return true;
  }
  else {
    return false;
  } 

  console.log(str_Final);

}


palindrome("A man, a plan, a canal. Panama");
Ignore the console.log line
Diego Mayer
@Chrono79
Jun 06 2016 00:59
@MosesSupposes your regex isn't working
Moses Samuel
@MosesSupposes
Jun 06 2016 00:59
why not?
Diego Mayer
@Chrono79
Jun 06 2016 00:59
it's not right
try it here: regex101.com
Moses Samuel
@MosesSupposes
Jun 06 2016 00:59
what's it supposed to look like
ok
DJ
@qualitymanifest
Jun 06 2016 00:59
too many escapes \
Moses Samuel
@MosesSupposes
Jun 06 2016 01:00
ahh
what should i do to simplify it
DJ
@qualitymanifest
Jun 06 2016 01:00
to fix your current one, you would do \W\D\s however, \D and \s are unnecessary because they are covered in \W. what \W doesn't cover, is underscores
Moses Samuel
@MosesSupposes
Jun 06 2016 01:00
I have to delte any non alphanumeric chars
Diego Mayer
@Chrono79
Jun 06 2016 01:00
if you use \W , \D isn't needed
Moses Samuel
@MosesSupposes
Jun 06 2016 01:00
gotcha
wait, it covers spaces too?
DJ
@qualitymanifest
Jun 06 2016 01:01
yes, spaces are not considered a word character. underscores are though
Moses Samuel
@MosesSupposes
Jun 06 2016 01:01
I see. Thanks
Blake Harris
@bharris62
Jun 06 2016 01:07
Dylan Zitzmann
@dtzitz
Jun 06 2016 01:09
hey guys, i know I keep asking about the same stupid challenge, but I keep ending up at the same spot https://gist.github.com/dtzitz/cceafb41e9ac9a23e92da2fef850f44c
it doesn't seem to catch the scenario where the first part of the object matches but the last part doesn't
Moses Samuel
@MosesSupposes
Jun 06 2016 01:13
I fixed the reg exp using reegexp101.com and it still isn't working. Are there any other problems?

function palindrome(str) {
  Tested_String = new RegExp('/\W', 'g'); // RegExp that matches all non-alphanumeric chars.
  var str_Replaced = str.replace(Tested_String, ""); // Deletes all non-alphanumeric chars.
  var str_LowerCased = str_Replaced.toLowerCase(); // Lower-cases previous string.

  // These next 3 lines reverse the string
  var str_Split = str_LowerCased.split(""); 
  var str_Reversed = str_Split.reverse(); 
  var str_Joined = str_Reversed.join(""); 

  // Here I reassign variable names for convenience.
  var str_PreReversed = str_LowerCased; 
  var str_PostReversed = str_Joined; 

  if (str_PreReversed === str_PostReversed) {
    return true;
  }
  else {
    return false;
  } 

}


palindrome("A man, a plan, a canal. Panama");
Moisés Man
@moigithub
Jun 06 2016 01:14
@dtzitz not passing ?? which test failing ??
Diego Mayer
@Chrono79
Jun 06 2016 01:15
@MosesSupposes that regex isn't working, write console.log(str_Replaced); below var str_Replaced to check it
Dylan Zitzmann
@dtzitz
Jun 06 2016 01:16
@moigithub the last 2
Moisés Man
@moigithub
Jun 06 2016 01:16
@dtzitz what are the input for those ?
ie.. whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Diego Mayer
@Chrono79
Jun 06 2016 01:16
@dtzitz you push repeated values like that, I would use a counter to see if all the values match before pushing
Greg Duncan
@GregatGit
Jun 06 2016 01:17
@dtzitz it looks like you are pushing them into the array if only one matches where both are meant to match
Moses Samuel
@MosesSupposes
Jun 06 2016 01:17
@Chrono79 I did. Nothing's changed. It just returns false like it did before.
Diego Mayer
@Chrono79
Jun 06 2016 01:18
@MosesSupposes the regex isnt right, if you see the value of str_Replaced, nothing was replaced
Greg Duncan
@GregatGit
Jun 06 2016 01:19
@dtzitz I think you need to look at filter() - filter out everything that donesn't have his prop and value and then again
Moses Samuel
@MosesSupposes
Jun 06 2016 01:20
@Chrono79 I dont get it. is the syntax off?
Diego Mayer
@Chrono79
Jun 06 2016 01:20
@MosesSupposes yes, the quotes aren't needed (otherwise you're trying to match the literal string '/\W'), you're also missing one / at the end and you have to get rid of the underscores too
Moisés Man
@moigithub
Jun 06 2016 01:22
@dtzitz u could also use .every()
Gaston Lenotre
@GLenotre
Jun 06 2016 01:24
@moigithub If you don't my returning to your earlier response...
Moisés Man
@moigithub
Jun 06 2016 01:25
@GLenotre sry im lost :P
Moses Samuel
@MosesSupposes
Jun 06 2016 01:26
@Chrono79 ```
Tested_String = new RegExp(/\W/, g);
It's saying g is not defines
Gaston Lenotre
@GLenotre
Jun 06 2016 01:27
@moigithub

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

  // Only change code below this line

    alpha:"Adams",
    bravo: "Boston",
    charlie: "Chicago",
    delta: "Denver",
    echo: "Easy",
    foxtrot: "Frank",

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

// Change this value to test
phoneticLookup("charlie");
Moisés Man
@moigithub
Jun 06 2016 01:27
g needquotes
Diego Mayer
@Chrono79
Jun 06 2016 01:27
@MosesSupposes in the g, keep the quotes, they weren't needed in the \W part
Moisés Man
@moigithub
Jun 06 2016 01:27
@GLenotre ahh that one :)
ur object sill need a variable name
Gaston Lenotre
@GLenotre
Jun 06 2016 01:27
@moigithub You're saying that I need a variable before the key:value pairs...
but that still doesn't work
Abdul-Samii Ajala Olalekan
@jalasem
Jun 06 2016 01:28

given this list of objects I created and fill inside an array

function UnilorinSports(participants){
    this.sportMembers = participants;
}
football = new UnilorinSports(23);
swimming = new UnilorinSports(34);
marathon = new UnilorinSports(43);
karate = new UnilorinSports(78);
var arr = [football,swimming,marathon,karate];

how do I sort each sports base on the number of participant they have from the biggest to the smallest

Moisés Man
@moigithub
Jun 06 2016 01:28
var theObj = {
    a: "somethig",
    b: "otehr thing"
}
@GLenotre
Moses Samuel
@MosesSupposes
Jun 06 2016 01:28
@Chrono79 Thanks. I now have a check on all but one: palindrome("0_0 (: /-\ :) 0-0") should return true.
CamperBot
@camperbot
Jun 06 2016 01:28
mosessupposes sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1036 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 06 2016 01:29
@MosesSupposes yes, you need to get rid of the underscore, you could modify your regex or use a second replace, do as you see fit
Gaston Lenotre
@GLenotre
Jun 06 2016 01:29
@moigithub right

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

  // Only change code below this line
  var name = {
    alpha:"Adams",
    bravo: "Boston",
    charlie: "Chicago",
    delta: "Denver",
    echo: "Easy",
    foxtrot: "Frank",
};
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
but ^ doesn't work either
Moses Samuel
@MosesSupposes
Jun 06 2016 01:30
@Chrono79 I already removed it. I checked on that regexp101.com and everything
Moisés Man
@moigithub
Jun 06 2016 01:30
@GLenotre ok.. thats good :)
now.. if u see that code is returning result
sooo u need to assign some value to result first...
based on the object u have name and the argument val
soo when u call ur function with "charlie" it return "Chicago"
Diego Mayer
@Chrono79
Jun 06 2016 01:31
@GLenotre @moigithub your var name should be lookup, not name
Gaston Lenotre
@GLenotre
Jun 06 2016 01:31
@moigithub ah, like this result = name[val];
Moisés Man
@moigithub
Jun 06 2016 01:31
u need to use object access notation
yes
Gaston Lenotre
@GLenotre
Jun 06 2016 01:31
thanks @moigithub
CamperBot
@camperbot
Jun 06 2016 01:31
glenotre sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1356 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 06 2016 01:32
@Chrono79 dont remember if the object name needs to be lookup :) but might be @GLenotre
Diego Mayer
@Chrono79
Jun 06 2016 01:32
Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Gaston Lenotre
@GLenotre
Jun 06 2016 01:32
no it doesn't
it doesn't matter what the var name is
Moisés Man
@moigithub
Jun 06 2016 01:32
if the test cases dont check that.. then doesnt matter :P
Diego Mayer
@Chrono79
Jun 06 2016 01:33
Rebels, rebels everywhere
Gaston Lenotre
@GLenotre
Jun 06 2016 01:33
@Chrono79 , OK, but ya know
Moisés Man
@moigithub
Jun 06 2016 01:33
if it works.. dont need to be fixed :P
Diego Mayer
@Chrono79
Jun 06 2016 01:33
:P
Also a note on trailing commas, it works there, but in JSON they won't
Moisés Man
@moigithub
Jun 06 2016 01:36
yea.. i was testing eslint just like 10min ago.. and got soooo many warnings.. extra comma everywhere :P
Abdul-Samii Ajala Olalekan
@jalasem
Jun 06 2016 01:38

given this list of objects I created and fill inside an array

function UnilorinSports(participants){
    this.sportMembers = participants;
}
football = new UnilorinSports(23);
swimming = new UnilorinSports(34);
marathon = new UnilorinSports(43);
karate = new UnilorinSports(78);
var arr = [football,swimming,marathon,karate];

how do I sort each sports base on the number of participant they have from the biggest to the smallest

Justina
@jfuller30
Jun 06 2016 01:39
Need some help with the Stand in Line lesson. Up to this point I have pretty much understood what I needed to do but I can't seem to even get a start on how to solve this. I need to Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Moisés Man
@moigithub
Jun 06 2016 01:41
arr.sort(function(oa,ob){return oa.sportMembers - ob.sportMembers });
@jalasem
or probably ob first then oa
Abdul-Samii Ajala Olalekan
@jalasem
Jun 06 2016 01:42
dont understand @moigithub
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 01:42
Hey guys, working on my rando code generator, can someone take a look at this JS ? See the commented out lines for what I am struggling with. I can post the link to my pen if it helps to see it in context... Thanks!
$(document).ready(function() {
  $("#getQuote").on("click", function() {
    $(".zQuote").html(quotes[quoteKey].quote); // I want functions below the next comment to also run on button click, before this, so that the var [quoteKey] will be different on each click.
    $(".zName").html(quotes[quoteKey].person);
    });
  });

var quotes = {
    "quote1": {
      "person": "-Some Guy",
      "quote": "abc"
    },
    "quote2": {
      "person": "-Another Guy",
      "quote": "I say..."
    },
    "quote3": {
      "person": "-Jarvis",
      "quote": "This is a quote!"
    },
    "quote4": {
      "person": "-Santana",
      "quote": "I play guitar!"
    }
  };

// How would I make everything below execute on button click before the other jquery above???
var keyArr = Object.keys(quotes);

function shuffle(a) {
    var j, x, i;
    for (i = a.length; i; i -= 1) {
        j = Math.floor(Math.random() * i);
        x = a[i - 1];
        a[i - 1] = a[j];
        a[j] = x;
    }
};

shuffle(keyArr)

for (i = 0; i < keyArr.length; i++) {
  var quoteKey = keyArr[i];
}
Moisés Man
@moigithub
Jun 06 2016 01:43
all those are objects @jalasem
and those objects have a property named sportMembers (which is number)
passing a callback function to sort allow u specify the sort mode..
check the sort documentation
Josh Nelsson-Smith
@Svensk-Xavier
Jun 06 2016 01:43
This message was deleted
CamperBot
@camperbot
Jun 06 2016 01:43
:bulb: to format code use backticks! ``` more info
Abdul-Samii Ajala Olalekan
@jalasem
Jun 06 2016 01:44
will that give me a new array containing each object arranges based on the property sportMemebers? @moigithub
Moisés Man
@moigithub
Jun 06 2016 01:44
sort mutates the array u applying to
Darren Jansen
@DarrenJansen
Jun 06 2016 01:44
var Bike = function() {

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


var myBike = new Bike();
myBike.setGear(4);
Hi folks, I'm in "make object properties private." All the tests seem to work out ok, but it still won't let me pass. Any idea what is going on here?
Diego Mayer
@Chrono79
Jun 06 2016 01:45
@DarrenJansen fix this: gear += change; you shouldn't increment gear, you should set it
Moisés Man
@moigithub
Jun 06 2016 01:49
@no-stack-dub-sack using an array for ur quotes instead of an object
will be easier :)
Darren Jansen
@DarrenJansen
Jun 06 2016 01:49
Ah, Ok. I see. Thanks @Chrono79 . That makes sense.
CamperBot
@camperbot
Jun 06 2016 01:49
darrenjansen sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1037 | @chrono79 |http://www.freecodecamp.com/chrono79
Moisés Man
@moigithub
Jun 06 2016 01:50
var quotes = [ {person: "aaa", quote : "aaaaa"}, {person:"bbb": quote :"bbbbbbb"} ];
and instead of shuffle..u just use math.random
var quoteKey = Math.floor(Math.random() * quotes.length);
@no-stack-dub-sack
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 01:51
@moigithub but the way I have it set up now, works right? I just need to get those functions execution on the button click, it should work if so, no?
@moigithub ahhh, I see. Ok, I can try that
@moigithub thanks
CamperBot
@camperbot
Jun 06 2016 01:51
no-stack-dub-sack sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1357 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 06 2016 01:53
KISS :)
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 01:58
@moigithub wait, but this will only give me # right? var quoteKey = Math.floor(Math.random() * quotes.length);
Moisés Man
@moigithub
Jun 06 2016 01:59
yes that give u a random num
u should also put that when u click
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 01:59
so I would use the random # to access that index of the array?
Moisés Man
@moigithub
Jun 06 2016 01:59
yep
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 02:00
gotcha
Iskya
@iskya
Jun 06 2016 02:00
Hi i have an issue with my local weather challenge, can someone help me? I want to put nicest icons than the openweathermap icons, i've found owf font, but im not sure how to use it.. help
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 02:00
so my first question still stands then I guess, how to make multiple things occur on the click...
Moisés Man
@moigithub
Jun 06 2016 02:00
put ur code inside the click callback function
Peter Weinberg
@no-stack-dub-sack
Jun 06 2016 02:00
let me try and mess around now that I have it simplified though, if I can't figure it out, I'll come back
@moigithub nevermind, I totally got it with that. Your way was super easy compared to mine, much appreciated!
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:20

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

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

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
little help :o:
^^
eeflores
@eeflores
Jun 06 2016 02:24
push to collection
return collection
GitUp93
@GitUp93
Jun 06 2016 02:31
Hi guys, i just started on js
for the challenge i have to declare only a local myVar and not a global myVar variable

function myLocalScope() {
var myVar ='strict';

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

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

my code is this but it says i have a global myVar? Appreciate if any1 can help!
tommy
@tommygebru
Jun 06 2016 02:32
anyone else feeling tired..... I made my text white over my white background.... thought there was something wrong with Javascript
@GitUp93 reset the challenge
GitUp93
@GitUp93
Jun 06 2016 02:34
Cant seem to work still:(
Corey Lovett-Hendrey
@corza334
Jun 06 2016 02:35

function convertHTML(str) {
  // &colon;&rpar;
  str = str.replace(/&+/g,function(match){
    return '&amp;';
  });

    str = str.replace(/<+/g,function(match){
    return '&lt;';
  });

    str = str.replace(/>+/g,function(match){
    return '&gt;';
  });

    str = str.replace(/"+/g,function(match){
    return '&quot;';
  });

      str = str.replace(/'+/g,function(match){
    return '&apos;';
  });
  return str;
}

convertHTML("Dolce & Gabbana");
Is there a better way to do this? haha
The way I've done it just seems silly
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:36

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

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

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Corey Lovett-Hendrey
@corza334
Jun 06 2016 02:36
I figure I could have done it with a loop, but would there be an even better way?
Marian Menschig
@mmenschig
Jun 06 2016 02:38
Hi All, can someone help me with a small JS function? :)
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:44
SURE.
@mmenschig
Marian Menschig
@mmenschig
Jun 06 2016 02:44
```
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:44
ABOUT @mmenschig
Marian Menschig
@mmenschig
Jun 06 2016 02:44
    $("#searchfield").on("keyup change", function() {
        delay(function() {
            console.log("time elapsed");
            search(this.value);
            }, 1000);
    });
CamperBot
@camperbot
Jun 06 2016 02:44
:cookie: 304 | @mmenschig |http://www.freecodecamp.com/mmenschig
Marian Menschig
@mmenschig
Jun 06 2016 02:45
the value parsed into my search() function is undefined. How do i parse the search term from #searchfield into the delay() function?
Greg Duncan
@GregatGit
Jun 06 2016 02:46
@mmenschig $('#searchfield').val - i think
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 02:49

I am stuck at for loop condition. What is the problem here?

function mutation(arr) {
var str1 = arr[0].toLowerCase();
var str2 = arr[1].toLowerCase();
var len = str2.length;
if(str1.indexOf(str2)!=-1) {
return true;
}
else {
for(i=0;i<len;i++){
if(str1.indexOf(str2[i])!==-1){
return true;
}
else{
return false;
}
}
}
}

mutation(["hello", "hey"]);

Greg Duncan
@GregatGit
Jun 06 2016 02:49
$('#searchfield').val()
Marian Menschig
@mmenschig
Jun 06 2016 02:49
Hey @GregatGit - thanks bro <3
CamperBot
@camperbot
Jun 06 2016 02:50
mmenschig sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
Marian Menschig
@mmenschig
Jun 06 2016 02:50
:)
CamperBot
@camperbot
Jun 06 2016 02:50
:cookie: 563 | @gregatgit |http://www.freecodecamp.com/gregatgit
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:50

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

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

    return tracks;
}
  if (value === ""){
   delete collection.prop;
    return prop;
  }
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
little help
Marian Menschig
@mmenschig
Jun 06 2016 02:50
.val didn't work but .va() was correct
Greg Duncan
@GregatGit
Jun 06 2016 02:50
@mmenschig :+1:
Marian Menschig
@mmenschig
Jun 06 2016 02:50
.val()
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:50
sorry, i'm not as for as you @mmenschig
you said little function so i thought it was simple.
but i'm not familiar with parsing yet.
Greg Duncan
@GregatGit
Jun 06 2016 02:52
@HecticHiccups if (value !== "" value of what?
Marian Menschig
@mmenschig
Jun 06 2016 02:54
@HecticHiccups it is a little function ;)
Jesus Arteaga
@HecticHiccups
Jun 06 2016 02:56
this is record collection excercise.
Greg Duncan
@GregatGit
Jun 06 2016 02:56
@HecticHiccups so when you wrote 'value' what did you have in mind
Marian Menschig
@mmenschig
Jun 06 2016 02:56
Hey @HecticHiccups one advice I would like to give you is to be consistent with your level of indentation. your updateRecords function has varying levels in it (in the if else statement)
Michael Mullen
@mmullen200
Jun 06 2016 02:57
Having an issue with Summing All Numbers in a Range. Code works when I plug in different numbers, but it's still saying my solution is incorrect:
var newArr = [];

var total = 0;

function sumAll(arr) {
  var lowest = Math.min(arr[0], arr[1]);

  var highest = Math.max(arr[0], arr[1]);

  for (var i = lowest; i <= highest; i++) {
    newArr.push(i);
  }

  for (var j = 0; j < newArr.length; j++){
    total+=newArr[j];
  }

  return total;
}
sumAll([10, 5]);
Tulio Natale
@tuliodnw
Jun 06 2016 02:57
@tuliodnw
btw, use console to play its easier
people im doing the tic-tac-toe challenge, im just starting, two thing i would like advice is one, how can i clean all the inputs when win/lose, how do create the ai? ideas, you can play now singleplayer lol
http://codepen.io/tuliodnw/pen/OXVYvL?editors=1011
btw use console to play its easier
Greg Duncan
@GregatGit
Jun 06 2016 02:59
@mmullen200 I think it has to be for (var i = lowest; i <= highest + 1 ; i++)
Jesus Arteaga
@HecticHiccups
Jun 06 2016 03:01
@GregatGit i'm stating that the value isn't blank?
because the value is being passed by the user.
so i'm controlling the user input by manipulating the value?
unless i'm wrong?
Greg Duncan
@GregatGit
Jun 06 2016 03:03
@HecticHiccups Yes - what you are saying with those inputs is if ("ABBA" != "")
which will always be true
Michael Mullen
@mmullen200
Jun 06 2016 03:03
@GregatGit, no that gives a wrong result. I'm getting correct results when I plug in numbers to my current version.
Jesus Arteaga
@HecticHiccups
Jun 06 2016 03:04
yeah but if you see the test cases there are some cases where the value = ""
btw how do you make that type of emphasis on your writting?
where you put "if (Abba")...
Greg Duncan
@GregatGit
Jun 06 2016 03:07
@mmullen200 what should 10, 5 give?
Michael Mullen
@mmullen200
Jun 06 2016 03:07
@GregatGit 45
Greg Duncan
@GregatGit
Jun 06 2016 03:08
and what numbers arent working?
Michael Mullen
@mmullen200
Jun 06 2016 03:09
@GregatGit It's showing that all the sums are incorrect, even though I'm getting the right sums: 10, 10, 45, 45
Greg Duncan
@GregatGit
Jun 06 2016 03:10
@mmullen200 can you post the link to the challenge
Diego Mayer
@Chrono79
Jun 06 2016 03:10
@mmullen200 that's because you're using globals
The next time the function is called the globals keep the previous value
Tommy567295
@Tommy567295
Jun 06 2016 03:11
Could someone help me out with the Word Blanks module from Java?
I'm stuck and do not know what to do in order to pass.
Michael Mullen
@mmullen200
Jun 06 2016 03:12
@Chrono79 Ah, ok, that fixed it. @GregatGit, it was because I was using globals.
Greg Duncan
@GregatGit
Jun 06 2016 03:12
@mmullen200 ha
Michael Mullen
@mmullen200
Jun 06 2016 03:12
Thanks @Chrono79 @GregatGit
CamperBot
@camperbot
Jun 06 2016 03:12
mmullen200 sends brownie points to @chrono79 and @gregatgit :sparkles: :thumbsup: :sparkles:
:star2: 1038 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 564 | @gregatgit |http://www.freecodecamp.com/gregatgit
Diego Mayer
@Chrono79
Jun 06 2016 03:13
no problem
@Tommy567295 read mad libs link and review this challenge: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
You have to create a sentence with your parameters and some more words you want.
Greg Duncan
@GregatGit
Jun 06 2016 03:14
@mmullen200 Also - you don't need that second loop - instead of putting them in an array you can just add them to the total
Tommy567295
@Tommy567295
Jun 06 2016 03:15
yeah I reviewed that already but I don't understand what i'm supposed to have the var be in order to get the right answer.
Diego Mayer
@Chrono79
Jun 06 2016 03:15
let's see your code
Greg Duncan
@GregatGit
Jun 06 2016 03:15
@HecticHiccups Have you used https://repl.it/
Tommy567295
@Tommy567295
Jun 06 2016 03:17
Because I was thinking that the answer would be: var wordBlanks = "my" + myNoun + "is" + myAdjective + "and she" + myVerb + myAdverb;
Diego Mayer
@Chrono79
Jun 06 2016 03:18
@Tommy567295
let's look at the code you start with:
  var result = "";
  // Your code below this line


  // Your code above this line
  return result;
So, you have to work with result = , not var wordBlanks, that's your function name
Next, if you see the challenge I posted, you have to add spaces between vars, otherwise they end up like this "mydogisbigand sheranquickly"
WannabeProdigy
@WannabeProdigy
Jun 06 2016 03:21

Hello, having trouble with "Record Collection" challenge. Can't seem to put the value as the last element when
updateRecords(5439, "tracks", "Take A Chance With Me");

This is quite difficult for me, as there's no set property of "tracks" yet.

I tried doing this:
if (prop === "tracks" && value !== "" && collection[id][prop] === undefined) {
collection[id][prop] = value;
}

But it doesn't show as the last element.

Greg Duncan
@GregatGit
Jun 06 2016 03:22
@HecticHiccups you need to be accessing the values of the properties inside collection - so when you say value - one value is collection[2548].album (which is "slippery when wet")
Diego Mayer
@Chrono79
Jun 06 2016 03:22
@WannabeProdigy you should make tracks an array
Brett Guillory
@kurzninja
Jun 06 2016 03:23
/music
CamperBot
@camperbot
Jun 06 2016 03:23
Brett Guillory
@kurzninja
Jun 06 2016 03:23
argh
someone else come DJ at plug.dj/freecodecamp
I'm all by myself :/
WannabeProdigy
@WannabeProdigy
Jun 06 2016 03:24
@Chrono79 OH RIGHT. Thank you so much!
CamperBot
@camperbot
Jun 06 2016 03:24
wannabeprodigy sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1039 | @chrono79 |http://www.freecodecamp.com/chrono79
Tommy567295
@Tommy567295
Jun 06 2016 03:24
thank you @Chrono79
CamperBot
@camperbot
Jun 06 2016 03:24
tommy567295 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1040 | @chrono79 |http://www.freecodecamp.com/chrono79
Brett Guillory
@kurzninja
Jun 06 2016 03:25
I feel like starting this Weather App over from scratch
these weather APIs suck :/
how am I supposed to know all the different values that they will send back for "weather"?
Alexander Køpke
@alexanderkopke
Jun 06 2016 03:26

@tuliodnw you can make a function that set the value of all ids to "", for example function resEt(){
for(var i = 0; i < 9; i++){
document.getElementById("pos"+i).value = "";

}
}
and then you can call this functions when there is a win

Tulio Natale
@tuliodnw
Jun 06 2016 03:26
nice idea thanks, doing that @alexanderkopke
CamperBot
@camperbot
Jun 06 2016 03:26
tuliodnw sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 663 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Jun 06 2016 03:28
@kurzninja you can console.log the response and analyze it. Usually it is jsons and so it should be relatively easy finding the data. I think the hard part of apis is getting it to send the right data and displaying it.
Asma
@asma8867
Jun 06 2016 03:32
anyone here knows why my code does not work for getting every array element size? thanks for taking a look.

function findLongestWord(str) {

  var split=[];
  var count=[];

  split=str.split(/\s/);

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

    count=split[i].length;
    return count;

  }



}
findLongestWord("The quick brown fox jumped over the lazy dog");
Zane Bettis
@youngzb
Jun 06 2016 03:35
Can someone please help me with the convert celcius to fahrenheit?
celsius
M
@raydiatur
Jun 06 2016 03:35
whatcha got @youngzb
Zane Bettis
@youngzb
Jun 06 2016 03:36
wait nvm i got it haha thanks anyway
M
@raydiatur
Jun 06 2016 03:36
no worries
i had trouble on that one too lol
anyone here with more skill than I that can help with the record collection? this one always stumps me and has impeded my progress with fcc
Ken Haduch
@khaduch
Jun 06 2016 03:37
@raydiatur - I have five minutes - want to post your code and I'll see if i can help you?
M
@raydiatur
Jun 06 2016 03:38
sure
im not too far along and i think my problem probably needs more than 5 and i dont want to waste your time though, just a heads up
Ken Haduch
@khaduch
Jun 06 2016 03:38
@asma8867 - I don't see any place where you are comparing the length of the words to save the longest one?
M
@raydiatur
Jun 06 2016 03:38
 if (value !== "" && prop != "tracks")


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

  return collection;
}
Ken Haduch
@khaduch
Jun 06 2016 03:38
@raydiatur - give me a shot - I'm an expert on this one... :)
Brett Guillory
@kurzninja
Jun 06 2016 03:38
@alexanderkopke yeah that's great if I'm always expecting the same data, but when I'm testing weather in my local area, it's only going to give me data here, which means the weather won't change from test to test
M
@raydiatur
Jun 06 2016 03:39
excellent! just what i needed :)
ill admit i had looked at other solutions to go past it and semi understood but im trying to do it from scratch this time around because once i got past this one i was stumped almost immediately with future ones
Help me
CamperBot
@camperbot
Jun 06 2016 03:41

:point_right: adding snippets to sublime text [wiki]

Adding Snippets To Your Sublime Text Installation

If you are a user of sublime text (I hope you are, it kicks ass. You can get it here), then you may have already noticed some of the tab completion capabilities. For example, when you are opening an html tag such as <p>, it automatically closes the tag as soon as you type /. You can get similar functionality for pieces of code you end up re-writing over and over, and it's surprisingly easy!

Here's an example, which activates after typing div and then tab:

alt text

:pencil: read more about adding snippets to sublime text on the FCC Wiki

Tzvetlin Velev
@tvelev92
Jun 06 2016 03:41
I wnat to use this API
but I am having isssues here is what I have
Tzvetlin Velev
@tvelev92
Jun 06 2016 03:42

``js
$(document).ready(function()
{

$("#getQuote").on("click", function()
{
$.getJSON("http://quotes.stormconsultancy.co.uk/random.json", function(json) {
$(".message").html(JSON.stringify(json));
});

});
});//ready fun
``

Ritvik Raj
@ritvikraj14
Jun 06 2016 03:42
Can anyone give code of above?
Chris Cullen
@123xylem
Jun 06 2016 03:42
function uniteUnique(arr) {
//  var count=0;
 // var newArr=[];

  var all =Array.prototype.slice.call(arguments);

 var total= all.reduce (function(a,b){
            if(a===b){
              return total -b;}});


return total ;}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Can you tell me what Im doing wrong with my reduce functin? It returns nothing!?!?
Norvin Burrus
@ndburrus
Jun 06 2016 03:44
This message was deleted
Brett Guillory
@kurzninja
Jun 06 2016 03:44
@123xylem you might need to put a space between the - and the b
it might be looking at it as -b
Chris Cullen
@123xylem
Jun 06 2016 03:45
@kurzninja nice try but nope :(
Asma
@asma8867
Jun 06 2016 03:46
@khaduch in this step I just want to count every element in the array, if it works then I would do the next step to find the longest one.
Brett Guillory
@kurzninja
Jun 06 2016 03:46
I'm not sure what you're trying to do, but it doesn't look right, you shouldn't be accessing var total inside of the reduce function
especially since at the time you're calling all.reduce, total doesn't yet equal anything
that's probably why you're not getting anything back
i'm surprised you're not getting an error
/wiki uniteUnique
CamperBot
@camperbot
Jun 06 2016 03:50
no wiki entry for: uniteunique
Chris Cullen
@123xylem
Jun 06 2016 03:50
help sorted union
CamperBot
@camperbot
Jun 06 2016 03:50

:point_right: algorithm sorted union [wiki]

Algorithm Sorted Union

Problem Explanation:

  • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
:pencil: read more about algorithm sorted union on the FCC Wiki
Ken Haduch
@khaduch
Jun 06 2016 03:51

@raydiatur - okay - you have a lot to do, but I can try to set you on the right track, and someone can come along to help, I'm sure.

I'll focus on what you have and maybe you'll get the idea.

this portion of the code:

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

Value is the new value (in the case of the "tracks" property, a new song title to add to the array.) You cannot use value.push() because value is a scalar value, not an Array. You need to push onto an array.

The way that you reference the objects in the collection - and they are objects - is to use either dot notation or bracket notation. There are very special restrictions on when you can use dot notation, review the lesson on using variables to access object properties and values. (I just looked at the lesson description, and they did add a reminder about this and a link to the appropriate lesson to review.) But you want to be using notation for this challenge that looks like this:

collection[id]

to access one of the objects in the collection that is given by the argument id - note that there are no times in the test when they give you an id that doesn't exist in the collection.

Also note that you else if (prop = "tracks" ... is not using the comparison operator == or ===, but is using the assignment operator - the single =. That will silently cause a problem in your test.

Just to give you one more solid hint - for your first case, your test looks like it would be correct, but you have no action (probably a place where you are stuck) so you would end up writing some code to assign the new value to a new or currently existing property. That code would look like this - definitely a place where you have to use bracket notation (again - see that lesson that they link to) but you want to combine the collection[id] to refer to the object in the collection with the notation (bracket notation) to use the property given in prop - the result collection[id][prop] = value; That form (and variations on it) will be used throughout this exercise to make changes to the collection objects.

Okay - my time is up - I hope that helps and I see some regulars that might be here to help you along with further questions and help. Good luck!

Andrew
@AjSchaff
Jun 06 2016 03:51
having trouble with "Record Collection"
M
@raydiatur
Jun 06 2016 03:53
@khaduch thank you, im already starting to see some stuff there!
CamperBot
@camperbot
Jun 06 2016 03:53
raydiatur sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1267 | @khaduch |http://www.freecodecamp.com/khaduch
Mahade Walid
@walidmahade
Jun 06 2016 03:55

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

// Only change code below this line
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {
     value = "walid";
  }else if( value !== "" && prop == "tracks" ) {
     id.tracks.push(value);
  }else if ( value === "" ){
    pop( value );
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Js test " Record collection "
That is what made sense to me
Can any one help
Ken Haduch
@khaduch
Jun 06 2016 03:56

@asma8867 - you can just determine the longest word in the array while you are looping through, or else I am missing something that you are trying to do. There is no need to count the elements in the array other than what you are doing to control your for loop - you need to get the length of each word and keep track of the longest one - I think you just have to return the length of the longest word?

I have to run - give that a go and post here, someone will help you along with additional questions, if you have them. Good luck!

@walidmahade - scroll up a few comments - I made a note to help someone else with this very problem, maybe my hints there will give you some help? I am going to be signing off - someone will help you, but my comment gives some direction on how to proceed with this. Good luck!
Paolo
@mav1283
Jun 06 2016 03:58

same here can't move on from record collection, tried solutions here: FreeCodeCamp/FreeCodeCamp#8970

but to no avail

Mahade Walid
@walidmahade
Jun 06 2016 03:58
Thanks @khaduch
CamperBot
@camperbot
Jun 06 2016 03:58
walidmahade sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1268 | @khaduch |http://www.freecodecamp.com/khaduch
Aryan
@aryandua
Jun 06 2016 04:01
Is my podomoro clock supposed to infinitely loop between session and break? if so how
Ken Haduch
@khaduch
Jun 06 2016 04:02

@mav1283 - can you post your code here in the markdown coding format so that someone can see where you are with this? I think that a common problem that I'm seeing with the most recent few is a new testcase that was added, where one of the collection objects does not have a tracks property, which means that you have to test for that condition, and then create a new property with an array as the value - then make sure that the new song is added as the array member for that new tracks property / array.

Someone here can help if you post the code, but I'm leaving - you'll get help from someone, though! Good luck!

Paolo
@mav1283
Jun 06 2016 04:04

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

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

return collection;
}

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

Ritvik Raj
@ritvikraj14
Jun 06 2016 04:05

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++){
if(contacts[i].firstname)
{
if(contacts[i].prop)
return contacts[i].prop;
else
return "No such property";
}
else
return "No such contact";
}
// Only change code above this line
}

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

Help me
CamperBot
@camperbot
Jun 06 2016 04:05

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

Via Command Line

Refer to this answer on Super User.

:pencil: read more about adding environment variables on the FCC Wiki

Michael
@Womper-Dev
Jun 06 2016 04:06
Paolo, the .push does not work. You need to set collection[id][prop] = [value];
just figured that out myself
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:06
Please help. I am messaging 3rd time
Michael
@Womper-Dev
Jun 06 2016 04:07
What part are you having trouble with Ritvik?
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:08
check my code....It is not giving correct output @Womper-Dev
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstname)
{
if(contacts[i].prop)
return contacts[i].prop;
else
return "No such property";
}
else
return "No such contact";
}
Xavier Velez
@JonSnow08
Jun 06 2016 04:08
anybody got a second to help me out with the random quote machine
trying to get this twitter button working
Paolo
@mav1283
Jun 06 2016 04:09
Thanks @Womper-Dev man, i wonder why it does not work.. thanks anyways
CamperBot
@camperbot
Jun 06 2016 04:09
mav1283 sends brownie points to @womper-dev :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @womper-dev |http://www.freecodecamp.com/womper-dev
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:09
@Womper-Dev ?
Xavier Velez
@JonSnow08
Jun 06 2016 04:09
if anybody has a second to check it out please
Michael
@Womper-Dev
Jun 06 2016 04:10
@ritvikraj14 still looking, i havent made it to that exercise yet so i dont think ill be able to help, if i come to it shortly ill get back to you
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:11
okay @Womper-Dev
Xavier Velez
@JonSnow08
Jun 06 2016 04:11
@ritvikraj14 what're you on?
maybe I can help
Mahade Walid
@walidmahade
Jun 06 2016 04:12

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

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Mahade Walid
@walidmahade
Jun 06 2016 04:12
is there anything wrong with my if statements ?
Michael
@Womper-Dev
Jun 06 2016 04:12
@mav1283 the .push does not work because you can only use it on an Array. When you do collection[id][prop] you are trying to .push on "tracks", thats not what we want to do. Think of how to set up the object. you would do "tracks" : ["song titles]
David
@Nachlawi
Jun 06 2016 04:12
For the Random Quote Generator, where is the documentation for the API?
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:13
@walidmahade which topic?
Xavier Velez
@JonSnow08
Jun 06 2016 04:13
@david one second
Mahade Walid
@walidmahade
Jun 06 2016 04:13
Record collection @ritvikraj14
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:13
@JonSnow08 If you can help please help me?
Michael
@Womper-Dev
Jun 06 2016 04:13
@walidmahade the last else if isnt necessary, if the first two fail then you can just do else {delete collection[id][prop];} P.S. check spelling of collection in last else/if
Chris Cullen
@123xylem
Jun 06 2016 04:13

function uniteUnique(arr) {
  var all=[];

  for(i=0;i<arguments.length;i++){ 
    all.push(arguments[i]);
  }
  // Put args into 1 array

  all.reduce(function(a,b){
    if(all.indexOf(arguments[i])<0){
      all.push(b);
    }
  });
  return all;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Quick Question: why isnt this reduce funciton working??
Mahade Walid
@walidmahade
Jun 06 2016 04:14
okay @Womper-Dev
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:14

@walidmahade function updateRecords(id, prop, value) {

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

check your spelling @walidmahade
Xavier Velez
@JonSnow08
Jun 06 2016 04:15
Mahade Walid
@walidmahade
Jun 06 2016 04:15
Thanks a lot @Womper-Dev @ritvikraj14
CamperBot
@camperbot
Jun 06 2016 04:15
walidmahade sends brownie points to @womper-dev and @ritvikraj14 :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @womper-dev |http://www.freecodecamp.com/womper-dev
:cookie: 229 | @ritvikraj14 |http://www.freecodecamp.com/ritvikraj14
Mahade Walid
@walidmahade
Jun 06 2016 04:15
and a big LOL
:smile:
Xavier Velez
@JonSnow08
Jun 06 2016 04:15
@ritvikraj14 okay post your code
David
@Nachlawi
Jun 06 2016 04:15
@JonSnow08 Thanks! And there's me thinking that you new nothing :D
CamperBot
@camperbot
Jun 06 2016 04:15
nachlawi sends brownie points to @jonsnow08 :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @jonsnow08 |http://www.freecodecamp.com/jonsnow08
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:16
@JonSnow08 ? wait
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstname)
{
if(contacts[i].prop)
return contacts[i].prop;
else
return "No such property";
}
else
return "No such contact";
}
// Only change code above this line
}
Xavier Velez
@JonSnow08
Jun 06 2016 04:16
@Nachlawi hahaha I'm know next to nothing, but im trying to learn
i*
Mahade Walid
@walidmahade
Jun 06 2016 04:17
one more thing; @Womper-Dev push() only works with arrays,
How do I add a string to a variable ?
@ritvikraj14
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:17
Don't judge anyone bro here. Many are here to learn. @Nachlawi
Xavier Velez
@JonSnow08
Jun 06 2016 04:18
@ritvikraj14 he's talking about game of thrones
@ritvikraj14 my name is a character from it and another character tells him "You know nothing Jon Snow"
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:19
Hahaha....I got it. :smile:
@JonSnow08 Try to help me .
Xavier Velez
@JonSnow08
Jun 06 2016 04:20
@ritvikraj14 I need you to post your code
that link shows me what challenge youre on but my code is what shows up when I click it
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:21
@JonSnow08
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstname)
{
if(contacts[i].prop)
return contacts[i].prop;
else
return "No such property";
}
else
return "No such contact";
}
// Only change code above this line
}
Xavier Velez
@JonSnow08
Jun 06 2016 04:21
help format
CamperBot
@camperbot
Jun 06 2016 04:21

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Xavier Velez
@JonSnow08
Jun 06 2016 04:21
for future reference @ritvikraj14
Andrew
@AjSchaff
Jun 06 2016 04:21
how do you append something as the last item?
Mahade Walid
@walidmahade
Jun 06 2016 04:22
record collection?
Andrew
@AjSchaff
Jun 06 2016 04:22
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
yeah
Mahade Walid
@walidmahade
Jun 06 2016 04:22
LOL
I am stuck at the same specific problem
Andrew
@AjSchaff
Jun 06 2016 04:22
this chat is for that problem :)
Mahade Walid
@walidmahade
Jun 06 2016 04:22
Lets try googling ?
Andrew
@AjSchaff
Jun 06 2016 04:23
surprisingly, not much on JSON updating via variable
Mahade Walid
@walidmahade
Jun 06 2016 04:23
:worried:
Andrew
@AjSchaff
Jun 06 2016 04:23
they all point back to this problem lol
Mahade Walid
@walidmahade
Jun 06 2016 04:23
:smile:
Ritvik Raj
@ritvikraj14
Jun 06 2016 04:23
Paste your code @walidmahade @AjSchaff
Andrew
@AjSchaff
Jun 06 2016 04:23
collection[id][prop] += value;
Xavier Velez
@JonSnow08
Jun 06 2016 04:23
@ritvikraj14 your first if statement is your first issue i see
Mahade Walid
@walidmahade
Jun 06 2016 04:24

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

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Andrew
@AjSchaff
Jun 06 2016 04:24

function updateRecords(id, prop, value) {

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

return collection;
}

Mahade Walid
@walidmahade
Jun 06 2016 04:24
problem is in the second conditional statement
Andrew
@AjSchaff
Jun 06 2016 04:25
I know we can't use push, someone else answered above that this can only be used for array alterations
Xavier Velez
@JonSnow08
Jun 06 2016 04:25
@walidmahade a hint, you need a loop
@AjSchaff what array would you even want to push something onto?
Mahade Walid
@walidmahade
Jun 06 2016 04:25
@AjSchaff yup , thanks
CamperBot
@camperbot
Jun 06 2016 04:25
walidmahade sends brownie points to @ajschaff :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @ajschaff |http://www.freecodecamp.com/ajschaff
Andrew
@AjSchaff
Jun 06 2016 04:26
I'm saying I know we cant use it, as this is not an array
Mahade Walid
@walidmahade
Jun 06 2016 04:26
hmmm, i found that earlier @AjSchaff
Xavier Velez
@JonSnow08
Jun 06 2016 04:26
@AjSchaff i know, but im trying to help you with the logic
Mahade Walid
@walidmahade
Jun 06 2016 04:26
Why do I need a loop @JonSnow08 ]
Xavier Velez
@JonSnow08
Jun 06 2016 04:26
@AjSchaff in what case would you even want to push something onto any value here
Mahade Walid
@walidmahade
Jun 06 2016 04:26
@JonSnow08
Xavier Velez
@JonSnow08
Jun 06 2016 04:27
@walidmahade to check through the different objects, rather than write the same code over and over again
Andrew
@AjSchaff
Jun 06 2016 04:27
anytime you would want something to be the last item in the array
Mahade Walid
@walidmahade
Jun 06 2016 04:27
This challenge is before the lessons of the loops @JonSnow08
So i think there is another way
Xavier Velez
@JonSnow08
Jun 06 2016 04:28
@AjSchaff andrew yes that is how an array works, but the instructions say nothing about changing the original object
Andrew
@AjSchaff
Jun 06 2016 04:28
this problem would be a great example if it were using arrays, because they are asking us to place the "value" at the last element
Mahade Walid
@walidmahade
Jun 06 2016 04:28
cant we just replace it ?
the value
?
no, that wast the first condition
LOL
Andrew
@AjSchaff
Jun 06 2016 04:29
@JonSnow08 I'm not sure I understand what ur asking
Xavier Velez
@JonSnow08
Jun 06 2016 04:30
@walidmahade loops is actually before Profile Lookup
thats what you're on correct?
Mahade Walid
@walidmahade
Jun 06 2016 04:30
no, me and @AjSchaff are trying the same problem
Andrew
@AjSchaff
Jun 06 2016 04:30
Record Collection
Mahade Walid
@walidmahade
Jun 06 2016 04:30
Hmmm
Xavier Velez
@JonSnow08
Jun 06 2016 04:31
@AjSchaff No, it's asking you to return the value
sorry one second
looking at the wrong challenge I think lol
let's start over I'm sorry I got you confused with someone else's code
Andrew
@AjSchaff
Jun 06 2016 04:32
@JonSnow08 no worries lord commander
Xavier Velez
@JonSnow08
Jun 06 2016 04:32
ok better now
this makes more sense
Mahade Walid
@walidmahade
Jun 06 2016 04:32
mu ha ha
@AjSchaff prop is an array
push() should work
!!!
Andrew
@AjSchaff
Jun 06 2016 04:33
maybe our syntax was wrong?
Xavier Velez
@JonSnow08
Jun 06 2016 04:33
@walidmahade your push statement is close but a bit off
Mahade Walid
@walidmahade
Jun 06 2016 04:34
okay, how ?
Xavier Velez
@JonSnow08
Jun 06 2016 04:34
you're both close and have the right logic, wrong syntax
function updateRecords(id, prop, value) {
  if (prop == "tracks" && value !== "") {
    collection[id].tracks.push(value);
  } else if (value !== "") {
collection[id][prop] = value;
  } else if (value === "") {
    delete collection[id][prop];
  }

  return collection;
Andrew
@AjSchaff
Jun 06 2016 04:34
ahhh...
if prop == "tracks"
then we know Tracks must exsist
so we don't need to target Prop
we need to target the array
Tracks
then push the value
Xavier Velez
@JonSnow08
Jun 06 2016 04:36
@AjSchaff there you go
Mahade Walid
@walidmahade
Jun 06 2016 04:36
I still did not get it
Xavier Velez
@JonSnow08
Jun 06 2016 04:36
you don't understand or it's not passing?
Andrew
@AjSchaff
Jun 06 2016 04:36
I understand, but it's not passing
updateRecords(5439, "tracks", "Addicted to love");
so for example @walidmahade
Xavier Velez
@JonSnow08
Jun 06 2016 04:37
oh add a }
at the end
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;




}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Mahade Walid
@walidmahade
Jun 06 2016 04:37
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {
     collection[id][prop] = value ;
  }else if( value !== "" && prop == "tracks" ) {
     collection[id][prop].push( value );
  }else {
    delete collection[id][prop] ;
  }

  return collection;
}
Andrew
@AjSchaff
Jun 06 2016 04:37
we are passing "tracks" as the prop here right?
Xavier Velez
@JonSnow08
Jun 06 2016 04:37
do this
go here
and copy and past my entire code box
and put it in there
that explains every single step for you
Michael
@Womper-Dev
Jun 06 2016 04:38
@ritvikraj14 did you ever finish the profile lookup Rit?
Xavier Velez
@JonSnow08
Jun 06 2016 04:38
and does a better job of it than I probably can
it even tells you which line just executed, and whats next to execute
if you still have questions
let me know and I'll do my best to explain
M
@raydiatur
Jun 06 2016 04:39
ive made some progress with the record collection, anyone able to assist a lil bit more?
Michael
@Womper-Dev
Jun 06 2016 04:40
i can help some i think @raydiatur
M
@raydiatur
Jun 06 2016 04:40
excellent, lemme post the code
Andrew
@AjSchaff
Jun 06 2016 04:40
@JonSnow08 I'm still getting Cannot read property 'push' of undefined
what if "tracks" didn't previously exist
like on 5439
Mahade Walid
@walidmahade
Jun 06 2016 04:40
@AjSchaff
M
@raydiatur
Jun 06 2016 04:41
function updateRecords(id, prop, value) {
  if (value !== "" && prop != "tracks"){
    collection[id][prop] = [value];
  } else if (prop == "tracks" && value !== "") {
    collection[id][prop] += [value];
  } else {
    delete collection[id][prop];
         }
  return collection;
}
ive gotten the 3rd and 5th checkmarks so far
Mahade Walid
@walidmahade
Jun 06 2016 04:41
I am not getting error messages
@AjSchaff
M
@raydiatur
Jun 06 2016 04:41
im understanding it more, just needing fresh eyes to gloss over it for me
Michael
@Womper-Dev
Jun 06 2016 04:41
lookin over it, one sec
Juan Cortes
@jcortes0309
Jun 06 2016 04:41
This message was deleted
Andrew
@AjSchaff
Jun 06 2016 04:42
5439: {
album: "ABBA Gold",
tracks: [ ]
}
};
Arpan
@sahooarpan
Jun 06 2016 04:42

function updateRecords(id, prop, value) {
if (value !== "" && prop != "tracks"){
collection[id][prop] = value;
} else if (value !== "" && prop == "tracks"){
collection[id][prop] += value;
} else {
delete collection.prop;
}

return collection;
}

Andrew
@AjSchaff
Jun 06 2016 04:42
I had to add tracks: []
Arpan
@sahooarpan
Jun 06 2016 04:42
please help me in this challenge
Mahade Walid
@walidmahade
Jun 06 2016 04:43
@AjSchaff how many green tick mark do you have ?
Michael
@Womper-Dev
Jun 06 2016 04:43
on the first if statement, for my solve i did not set collection[id][prop] = to an Array. I set it to just the value, because the if !== "tracks" means the value shouldnt be an array but a single item @raydiatur
Andrew
@AjSchaff
Jun 06 2016 04:43
@walidmahade all of them
M
@raydiatur
Jun 06 2016 04:43
@Womper-Dev im not following..
Mahade Walid
@walidmahade
Jun 06 2016 04:43
Lol,then help me,
Andrew
@AjSchaff
Jun 06 2016 04:43
@walidmahade , how about you, are you all set?
ok
Mahade Walid
@walidmahade
Jun 06 2016 04:44
// Only change code below this line
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {
     collection[id][prop] = value ;
  }else if( value !== "" && prop == "tracks" ) {
     collection[id][prop].push( value );
  }else {
    delete collection[id][prop] ;
  }

  return collection;
}
Michael
@Womper-Dev
Jun 06 2016 04:44
collection[id][prop] = value; instead of collection[id][prop] = [value];
M
@raydiatur
Jun 06 2016 04:44
ah
Andrew
@AjSchaff
Jun 06 2016 04:44
ok, if your 'else if' statement
Michael
@Womper-Dev
Jun 06 2016 04:44
[value] is an array, value is not
M
@raydiatur
Jun 06 2016 04:44
gotcha gotcha
Andrew
@AjSchaff
Jun 06 2016 04:44
you are checking to see if prop == "track"
M
@raydiatur
Jun 06 2016 04:44
the first check mark just ticker once i fixed that so theres already some progress!
Andrew
@AjSchaff
Jun 06 2016 04:44
that is the only way that block of code will execute
Michael
@Womper-Dev
Jun 06 2016 04:44
thought that might do it
Andrew
@AjSchaff
Jun 06 2016 04:44
is if prop == tracks
Mahade Walid
@walidmahade
Jun 06 2016 04:45
no quotes ?
Andrew
@AjSchaff
Jun 06 2016 04:45
no, u need quotes
sorry, just psudo typing to explain the logic
Michael
@Womper-Dev
Jun 06 2016 04:45
the if section where prop == "tracks" is a difficult one @raydiatur
Andrew
@AjSchaff
Jun 06 2016 04:45
but, if that block of code runs, you know "tracks" exsits, and you know it's an array
M
@raydiatur
Jun 06 2016 04:45
very much so
Andrew
@AjSchaff
Jun 06 2016 04:46
so you can target it directly like this
Mahade Walid
@walidmahade
Jun 06 2016 04:46
@AjSchaff where is the problem, I am so dumb ?
Andrew
@AjSchaff
Jun 06 2016 04:46
} else if (value !== "" && prop == "tracks"){
collection[id].tracks.push(value);
Xavier Velez
@JonSnow08
Jun 06 2016 04:46
I'm going to bed, sorry guys I work in the AM, I'm usually on every night and if you need some help feel free to ask and I will help where I can
Mahade Walid
@walidmahade
Jun 06 2016 04:46
else if( value !== "" && prop == "tracks" ) {
collection[id][prop].push( value );
}
Andrew
@AjSchaff
Jun 06 2016 04:47
see how I'm no longer targeting collection[id][prop]
Michael
@Womper-Dev
Jun 06 2016 04:47
@raydiatur I figured out what passes the tests but not 100% it is the best solution. I assume that when the prop == "tracks" the list is complete and it is ok to replace any tracks already in the code
Andrew
@AjSchaff
Jun 06 2016 04:47
im now targeting collection[id].tracks
Michael
@Womper-Dev
Jun 06 2016 04:47
@raydiatur what worked for me was doing collection[id][prop] = [value];
Mahade Walid
@walidmahade
Jun 06 2016 04:47
owwwww @AjSchaff
Andrew
@AjSchaff
Jun 06 2016 04:47
:)
:+1:
Xavier Velez
@JonSnow08
Jun 06 2016 04:47
My best advice. It can be easy to get caught up with trying to finish challenes as a fast as possible
M
@raydiatur
Jun 06 2016 04:47
@Womper-Dev alright i can see what you mean there
Mahade Walid
@walidmahade
Jun 06 2016 04:47
Thanks a lot @AjSchaff @JonSnow08
CamperBot
@camperbot
Jun 06 2016 04:47
walidmahade sends brownie points to @ajschaff and @jonsnow08 :sparkles: :thumbsup: :sparkles:
:warning: walidmahade already gave ajschaff points
:cookie: 273 | @jonsnow08 |http://www.freecodecamp.com/jonsnow08
Xavier Velez
@JonSnow08
Jun 06 2016 04:48
don't, before you move on make sure you understand the concept fully
Michael
@Womper-Dev
Jun 06 2016 04:48
converting the value to an array by putting it inside [value], this works for the test but I thought the best thing would be to use a .push()...i never got it to work @raydiatur
Andrew
@AjSchaff
Jun 06 2016 04:48
@JonSnow08 - how would the solution be possilbe however, without adding the array "Tracks" to 5439
thats the only part I'm still struggling with
Miguel López
@miguelopezv
Jun 06 2016 04:48
Hi everyone, I just solved Falsy Bouncer challenge using this function below, however first I tried to use return val != false but it didn't work but I can't comprehend why, any ideas?
function bouncer(arr) {
    function notNull(val) {
        if(val) {return val;}
    }
arr = arr.filter(notNull);
return arr;
}
Andrew
@AjSchaff
Jun 06 2016 04:48
I had to add tracks: [ ]
M
@raydiatur
Jun 06 2016 04:49
@Womper-Dev someone earlier mentioned above that i shouldnt be using that?
Xavier Velez
@JonSnow08
Jun 06 2016 04:49
@AjSchaff yeah, absolutely
Juan Cortes
@jcortes0309
Jun 06 2016 04:49
@Womper-Dev I think that if there's no array then you have to do the [value] to create the array, but afterwards you just .push(value)
Michael
@Womper-Dev
Jun 06 2016 04:49
They are probably correct.
Xavier Velez
@JonSnow08
Jun 06 2016 04:49
@AjSchaff I added nothing to the original code
only where it says to edit code
Mahade Walid
@walidmahade
Jun 06 2016 04:50
@AjSchaff please could you send me you whole code
Michael
@Womper-Dev
Jun 06 2016 04:50
can anyone post a working .push solve for the record collection?
Andrew
@AjSchaff
Jun 06 2016 04:50
@JonSnow08 , I don't get how you can .push on tracks of 5439 if tracks is not predefined
},
5439: {
  album: "ABBA Gold",
  tracks: [ ]
}
};
I added that
tracks: [ ]
Xavier Velez
@JonSnow08
Jun 06 2016 04:51
if (prop == "tracks" && value !== "") {
    collection[id].tracks.push(value);
M
@raydiatur
Jun 06 2016 04:51
i changed the values at the bottom and the changes came out weird so yeah, still got a lil more to go
Juan Cortes
@jcortes0309
Jun 06 2016 04:51
    if (collection[id][prop] === undefined) {

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

    } else {

      collection[id].tracks.push(value);

    }
Xavier Velez
@JonSnow08
Jun 06 2016 04:52
@AjSchaff because that statement is adding a tracks object
Juan Cortes
@jcortes0309
Jun 06 2016 04:52
@AjSchaff you need to check for undefined as shown in my code above
Michael
@Womper-Dev
Jun 06 2016 04:53
Juan Cortes code works perfectly. Thank you
Xavier Velez
@JonSnow08
Jun 06 2016 04:53
@AjSchaff if i just pushed the value, the value would be where tracks is
Andrew
@AjSchaff
Jun 06 2016 04:53

@JonSnow08
// 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",
tracks: [ ]
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Addicted to love");

@JonSnow08

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",
tracks: [ ]
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Addicted to love");

Juan Cortes
@jcortes0309
Jun 06 2016 04:53
@Womper-Dev you are welcome
Andrew
@AjSchaff
Jun 06 2016 04:53
idk why thats pasting so bad
Xavier Velez
@JonSnow08
Jun 06 2016 04:53
help format
CamperBot
@camperbot
Jun 06 2016 04:53

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Michael
@Womper-Dev
Jun 06 2016 04:54
its nearly 1 A.M. and I have to work in the morning. Goodnight ladies and gentlemen and good luck.
Zamua Nasrawt
@Zamua
Jun 06 2016 04:54
Does the FreeCodeCamp Curriculum ever teach us about angular.js?
M
@raydiatur
Jun 06 2016 04:54
only got the second check mark to clear it
Xavier Velez
@JonSnow08
Jun 06 2016 04:54
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;




}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Samuel Cupidon
@Zerazera
Jun 06 2016 04:54
@Zamua I think it used to. It doesn't now. You're on your own for Angular.
Sucks for me too
Xavier Velez
@JonSnow08
Jun 06 2016 04:55
@AjSchaff see how my 5439 has no track value in the original code
Mahade Walid
@walidmahade
Jun 06 2016 04:55
@raydiatur have you got hte second tik mark green ?
M
@raydiatur
Jun 06 2016 04:55
@walidmahade no
Andrew
@AjSchaff
Jun 06 2016 04:55
yeah I see
Zamua Nasrawt
@Zamua
Jun 06 2016 04:55
@Zerazera darn, thanks for the info! Any clue where I could learn it? I think codecademy is teaching it
CamperBot
@camperbot
Jun 06 2016 04:55
zamua sends brownie points to @zerazera :sparkles: :thumbsup: :sparkles:
:cookie: 458 | @zerazera |http://www.freecodecamp.com/zerazera
M
@raydiatur
Jun 06 2016 04:55
lemme post what i have now
Samuel Cupidon
@Zerazera
Jun 06 2016 04:55
@Zamua Codecademy has an angular tutorial. So does Codeschool.
M
@raydiatur
Jun 06 2016 04:55
function updateRecords(id, prop, value) {
  if (value !== "" && prop != "tracks"){
    collection[id][prop] = value;
  } else if (prop == "tracks" && value !== "") {
    collection[id].tracks.push(value);
  } else {
    delete collection[id][prop];
         }
  return collection;
}
Andrew
@AjSchaff
Jun 06 2016 04:55
@JonSnow08 isn't mine also checking value !== ""
?
Xavier Velez
@JonSnow08
Jun 06 2016 04:56
@AjSchaff it creates one when with if (prop == "tracks" && value !== "") { collection[id].tracks.push(value);
Samuel Cupidon
@Zerazera
Jun 06 2016 04:56
@Zamua I've also been working on the tutorials at thinkster, though those aren't interactive
@Zamua Tutorialspoint has a tutorial too
Mahade Walid
@walidmahade
Jun 06 2016 04:56
@JonSnow08 is there anything about the serial of the statements ?
Xavier Velez
@JonSnow08
Jun 06 2016 04:57
@AjSchaff I believe your issue is with that statement you're using. If i remember your code you aren't using .push
you're using =
Zamua Nasrawt
@Zamua
Jun 06 2016 04:57
@Zerazera would you recommend the thinkster and tutorialspoint ones?
Andrew
@AjSchaff
Jun 06 2016 04:57
@JonSnow08 If I paste your code in verbatim, it doesn't get a green check on the second item
@JonSnow08 After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Xavier Velez
@JonSnow08
Jun 06 2016 04:58
@AjSchaff hrmmm you're right
@AjSchaff let me have a look and see why that is and how I passed lol
Andrew
@AjSchaff
Jun 06 2016 04:58
@JonSnow08 if you add a empty array to 5439 it works
@JonSnow08 sounds good, I know my answer is not the correct approach to solving it....but it makes sense
@JonSnow08 I gotta head to bed, but if you figure it out I'll check Gitter in the morning, thanks for the help
CamperBot
@camperbot
Jun 06 2016 04:59
ajschaff sends brownie points to @jonsnow08 :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @jonsnow08 |http://www.freecodecamp.com/jonsnow08
Samuel Cupidon
@Zerazera
Jun 06 2016 04:59
@Zamua They both seem pretty decent. I've been going through thinkster over the last week. The official angular docs are also pretty good.
Xavier Velez
@JonSnow08
Jun 06 2016 04:59
@AjSchaff i'll PM you if I do
Andrew
@AjSchaff
Jun 06 2016 04:59
@JonSnow08 sounds good, later
Zamua Nasrawt
@Zamua
Jun 06 2016 05:00
@Zerazera Alright sweet, thanks! Yeah I've been reading the docs. They're surprisingly good haha.
CamperBot
@camperbot
Jun 06 2016 05:00
zamua sends brownie points to @zerazera :sparkles: :thumbsup: :sparkles:
:warning: zamua already gave zerazera points
Kenzo Mendoza
@KenzoM
Jun 06 2016 05:01

Hello all
I was able to solve one of JS challenge, "Where art thou".

However I am not satisfied with my solution, in terms of time complexity: I feel I have too much nested loops.

Here's my code:

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var keysSource = Object.keys(source);
  collection.forEach(function(obj){
    var alarm = 0;
    keysSource.forEach(function(key){

      if (obj.hasOwnProperty(key)){
        if (source[key] === obj[key]){
          alarm += 1;
        }
      }
      if (alarm === keysSource.length){
        arr.push(obj);
        return
      }
    })
  })
  console.log(arr)
  return arr;
}
Should I worry about time complexity at this point?
M
@raydiatur
Jun 06 2016 05:03
managed to get the second check mark but i lost the first one when i did that
Mahade Walid
@walidmahade
Jun 06 2016 05:06
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {
     collection[id][prop] = value ;
  }else if( value !== "" && prop == "tracks" ) {
     collection[id].tracks.push(value);
  }else {
    delete collection[id][prop] ;
  }

  return collection;
}
I have first, third and fourth tick marks
@raydiatur
M
@raydiatur
Jun 06 2016 05:07
i changed something but im going back to the code i originally posted
honestly dont feel like im actually learning anything, not that anyone is at fault, i just feel like im copying and pasting because its not clicking even though i can see what the code is trying to implement :(
Marcos Ostria
@compsci78
Jun 06 2016 05:08
Those code posts ... how did you do that? Screenshot images?
Mahade Walid
@walidmahade
Jun 06 2016 05:08

format help
help format
CamperBot
@camperbot
Jun 06 2016 05:08

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Mahade Walid
@walidmahade
Jun 06 2016 05:09
I felt the same @raydiatur
But I think, as you get more experienced, It will be okay, I mean learn by doing more
M
@raydiatur
Jun 06 2016 05:10
yeah, when i break it down and look at it in parts i get
its just when i try to look at it as a whole or in larger parts and i get lost, like a map
Mahade Walid
@walidmahade
Jun 06 2016 05:11
:smile:
M
@raydiatur
Jun 06 2016 05:11
can you help me finish this one?
Mahade Walid
@walidmahade
Jun 06 2016 05:11
I am stuck in the second state ment
other that that I have three green tick marks out of four
M
@raydiatur
Jun 06 2016 05:12
out of 5?
Mahade Walid
@walidmahade
Jun 06 2016 05:12
sorry, 4 out of five
LOL
:smile:
Marcos Ostria
@compsci78
Jun 06 2016 05:13
So I solved Caesars Cipher but wanting to know if there is a better solution or I did it correctly. What is the best way to get this feedback?
Samuel Cupidon
@Zerazera
Jun 06 2016 05:13
@compsci78 Post your solution
Mahade Walid
@walidmahade
Jun 06 2016 05:13
paste you code @compsci78
@raydiatur how may green marks have you reached ?
M
@raydiatur
Jun 06 2016 05:14
1st, 3rd, 4th, 5th

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.

this is the one im stuck on

Mahade Walid
@walidmahade
Jun 06 2016 05:14
yup me tooo
Arun Yadav
@ydarun
Jun 06 2016 05:15

Challange - "TRIBUTE WEB PAGE":

Is this correct way to build ??

Animation is not happenning on images .. How do i give animation better visual effects??

Here is the link https://codepen.io/ydarun/full/WxeBrp/

Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:16
@raydiatur .link?
M
@raydiatur
Jun 06 2016 05:16
@Alfarhanz i could post my code?
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:16
okay!
M
@raydiatur
Jun 06 2016 05:16
function updateRecords(id, prop, value) {
if ( value !== "" && prop !== "tracks" ) {
     collection[id][prop] = value ;
  } else if( value !== "" && prop == "tracks" ) {
     collection[id].tracks.push(value);
  } else {
    delete collection[id][prop] ;
  }

  return collection;
}
Samuel Cupidon
@Zerazera
Jun 06 2016 05:17
@compsci78 Here's mine if you want to compare yours
function rot13(str) { // LBH QVQ VG!
  const alphabet = Array.from(new Array(26), (x,i) => String.fromCharCode(i + 'A'.charCodeAt(0)));
  const rot13arr = alphabet.slice(13).concat(alphabet.slice(0, 13));
  return str.split('').map(x => (rot13arr.indexOf(x) !== -1) ? alphabet[rot13arr.indexOf(x)] : x).join('');
}
Mahade Walid
@walidmahade
Jun 06 2016 05:17
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {
     collection[id][prop] = value ;
  }else if(prop=="tracks" &&  value !=="") {
     collection[id][prop].push(value);
  }else {
    delete collection[id][prop] ;
  }

  return collection;
}
M
@raydiatur
Jun 06 2016 05:18
@walidmahade when i chagned it to that it took off the 4th tick mark
Mahade Walid
@walidmahade
Jun 06 2016 05:18
@Zerazera can you help us with the record collection js test
@raydiatur lol
what did you change ?
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:19

@walidmahade ..it would be

collection[id][prop]=value;

M
@raydiatur
Jun 06 2016 05:19
the [prop] before the .push
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:19

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

return collection;
}

Samuel Cupidon
@Zerazera
Jun 06 2016 05:19
@walidmahade What's the question?
Mahade Walid
@walidmahade
Jun 06 2016 05:19
in my case, both, [prop] and .tracks are working
@raydiatur
@Zerazera please check my second statement
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {
     collection[id][prop] = value ;
  }else if(prop=="tracks" &&  value !=="") {
     collection[id][prop].push(value);
  }else {
    delete collection[id][prop] ;
  }

  return collection;
}
the error message is " After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element."
M
@raydiatur
Jun 06 2016 05:21
@Alfarhanz that worked!
thanks @Alfarhanz
CamperBot
@camperbot
Jun 06 2016 05:21
raydiatur sends brownie points to @alfarhanz :sparkles: :thumbsup: :sparkles:
:cookie: 260 | @alfarhanz |http://www.freecodecamp.com/alfarhanz
M
@raydiatur
Jun 06 2016 05:21
so why is the first value not in brackets and the second is in brackets?
specifically:
collection[id][prop]=[value];
Mahade Walid
@walidmahade
Jun 06 2016 05:22
something to do with arrays
M
@raydiatur
Jun 06 2016 05:22
ah
Mahade Walid
@walidmahade
Jun 06 2016 05:23
Prop is an array
Yan Bin
@yanbin92
Jun 06 2016 05:23

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

if(value!==""){
if(prop!="tracks")
collection[id][prop]=value;//
else{ //==tracks
if(!collection[id].hasOwnProperty("tracks"))
collection[id].tracks=[];
collection[id].tracks.push(value);//If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.
}
}else//If value is blank, delete that prop.
delete collection[id][prop];

return collection;
}

Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:23
yup....
Mahade Walid
@walidmahade
Jun 06 2016 05:23
I guess adding a direct string would replace the previous value ?!!
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:24
We r pushing inside an array once....and den updating an object once..!!
M
@raydiatur
Jun 06 2016 05:24
alright, i hate to put it this way, i just want to someone to walk me through/spell out, why the statement i posted just now needs one but the first if statement doesnt require it?
ohhhhh
Paolo
@mav1283
Jun 06 2016 05:24
guys as suggested by michael earlier, you should replace push with just = [value]
M
@raydiatur
Jun 06 2016 05:24
so when we use brackets we are pushing that value into the object?
Marcos Ostria
@compsci78
Jun 06 2016 05:24
@ydarun What is the animation supposed to be and what is creating the animation?
Mahade Walid
@walidmahade
Jun 06 2016 05:25
so when we use brackets we are pushing that value into the object's tracks array
M
@raydiatur
Jun 06 2016 05:25
:+1:
Marcos Ostria
@compsci78
Jun 06 2016 05:25
yep
M
@raydiatur
Jun 06 2016 05:26
when we are not using brackets then we are..... assigning something, am i following correctly?
Mahade Walid
@walidmahade
Jun 06 2016 05:26
yup
M
@raydiatur
Jun 06 2016 05:26
awesome
Mahade Walid
@walidmahade
Jun 06 2016 05:26
hmm
I am also feeling awesome
:smile:
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:27
yup...in dis case we assigning a new value to a property of an object
M
@raydiatur
Jun 06 2016 05:27
i understand more about this assignment before i walked into it, still not 100% comprehended but hey theres some progress!
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:27
it takes time....
Mahade Walid
@walidmahade
Jun 06 2016 05:27
hmmm
M
@raydiatur
Jun 06 2016 05:27
alright, so the collection[id][prop] = value, thats whats getting me confused
the one without the brackets
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:28
here...prop is not an array!!..dats y only value and not [value]
M
@raydiatur
Jun 06 2016 05:28
okay
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:28
tracks is an array...so we r using [value[
M
@raydiatur
Jun 06 2016 05:28
so what exactly was that line of code doing?
Marcos Ostria
@compsci78
Jun 06 2016 05:29
@Zerazera Dang your solution looks so concise and using ES6 features
Taylor
@tfreeman17
Jun 06 2016 05:29
what is wrong with my code?
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:29
it was assigning the 'prop' of an object with value stored in'value'..
Marcos Ostria
@compsci78
Jun 06 2016 05:29
How long have you been developing?
M
@raydiatur
Jun 06 2016 05:30
okay....
Taylor
@tfreeman17
Jun 06 2016 05:30
Screen Shot 2016-06-05 at 11.28.02 PM.png
M
@raydiatur
Jun 06 2016 05:30
because we were accessing it with the bracket notation on collection[id][prop]?
Samuel Cupidon
@Zerazera
Jun 06 2016 05:30
@compsci78 I've been studying Javascript for probably four months now
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:31
@tfreeman17 ..ad more sub arrays to myList
Marcos Ostria
@compsci78
Jun 06 2016 05:31
@Zerazera programming in total?
or just JS for 4 months?
Taylor
@tfreeman17
Jun 06 2016 05:31
I have and I get errors ...
Screen Shot 2016-06-05 at 11.31.55 PM.png
Samuel Cupidon
@Zerazera
Jun 06 2016 05:32
@compsci78 Well, HTML/CSS/JS. In general I played around with it a bit as a kid, took a long stretch and looked at Python for about two months before deciding that it was better to start at the front end
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:32
which challenge...link would be great....so dat i can get a better understanding @tfreeman17
M
@raydiatur
Jun 06 2016 05:32
@tfreeman17 should have 5 things such as [milk, 1][eggs, 2][bread, 3][sugar, 4][grapes, 5]
Alfarhan Zahedi
@alfarhanz
Jun 06 2016 05:33
var myList = [["Chips",5],["Chocloate Bar",10],["Soda",5],["Biscuit",20],["Apples",10]];
@tfreeman17 ...u r missing commas in between
Samuel Cupidon
@Zerazera
Jun 06 2016 05:33
@compsci78 I did some Excel VBA stuff too at work, so that helps with understanding the programming language
Taylor
@tfreeman17
Jun 06 2016 05:33
@raydiatur ok thanks
CamperBot
@camperbot
Jun 06 2016 05:33
tfreeman17 sends brownie points to @raydiatur :sparkles: :thumbsup: :sparkles:
:cookie: 257 | @raydiatur |http://www.freecodecamp.com/raydiatur
Taylor
@tfreeman17
Jun 06 2016 05:33
got it thanks!
M
@raydiatur
Jun 06 2016 05:33
no prob
Nhat Khanh
@lednhatkhanh
Jun 06 2016 05:34
Somone please help me how to push an value into an array of a json?
Samuel Cupidon
@Zerazera
Jun 06 2016 05:34
@lednhatkhanh Access the array using dot or bracket notation and use the push method
Nhat Khanh
@lednhatkhanh
Jun 06 2016 05:37
Can't it says that can't read the prop 'push' of undefined! @Zerazera
Donovan
@dnvn999
Jun 06 2016 05:37
Hi all, I am stuck in challenge - Return Early Pattern for Functions. Below is my codes, is there any wrong with it?
js

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


  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Nhat Khanh
@lednhatkhanh
Jun 06 2016 05:38
@Zerazera it's in the Record Collection challenge, here's my code:
function updateRecords(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    collection[id][prop] = value;
  }
  else if (value !== "" && prop === "tracks"){
    collection[id][prop].push(value);
  }else if (value === ""){
    delete collection[id][prop];
  }
  return collection;
}
M
@raydiatur
Jun 06 2016 05:39
@lednhatkhanh cant use push on this one brother, just letting you know after having spending a while on it
stick to using brackets
Sanne
@sannek
Jun 06 2016 05:41
@dnvn999 You need to look at your if (a || b < 0) You're not checking if a <0, just if it is truthy.
Donovan
@dnvn999
Jun 06 2016 05:43
@sannek Thanks :D i fix it with ` a < 0 || b <0
CamperBot
@camperbot
Jun 06 2016 05:43
dnvn999 sends brownie points to @sannek :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @sannek |http://www.freecodecamp.com/sannek
Donovan
@dnvn999
Jun 06 2016 05:54
Hi all, I dont get what the question is asking for in challenge - Counting cards and my codes are,

var count = 0;

function cc(card) {
  // Only change code below this line
  if (card == 2, 3, 4, 5, 6) {
    return count += card + "Bet";

  } else if (card = 7, 8, 9){
    return count += card + "Hold";

  } else if (card = 10, 'J', 'Q', 'K', 'A'){
    return count += card + "Hold";
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Abhijit
@blackbirdabhi
Jun 06 2016 05:56
Hi all, I don't understand how to do Challenge: Stand in Line.
Mahade Walid
@walidmahade
Jun 06 2016 05:57
@dnvn999 does that code work ?
Donovan
@dnvn999
Jun 06 2016 05:58
@walidmahade nope
Jack Anderson
@JackAndersonLee
Jun 06 2016 06:00
@dnvn999 I don't think "," in between numbers count as an or
Donovan
@dnvn999
Jun 06 2016 06:00
@blackbirdabhi Something related to .shif() and .push() from previous exercise
Jack Anderson
@JackAndersonLee
Jun 06 2016 06:01
Might have to do if(card === 2 || card === 3 ||...)
Donovan
@dnvn999
Jun 06 2016 06:01
@blackbirdabhi But there is a catch, show us your code after you are done for now.
Jerry Bendy
@jerrybendy
Jun 06 2016 06:01
@dnvn999 use '&&'
Abhijit
@blackbirdabhi
Jun 06 2016 06:01
Ok @dnvn999
Jerry Bendy
@jerrybendy
Jun 06 2016 06:01
@dnvn999 sorry , it's '||'
Donovan
@dnvn999
Jun 06 2016 06:03
@JackAndersonLee @jerrybendy I will try it out first
Jerry Bendy
@jerrybendy
Jun 06 2016 06:03
@dnvn999 OK, if any questions, just ask for me
Abhijit
@blackbirdabhi
Jun 06 2016 06:04
@dnvn999 here's my code. It worked.
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removed=arr.shift();
return removed; // Change this line
}
Donovan
@dnvn999
Jun 06 2016 06:05
@blackbirdabhi gj :D
Abhijit
@blackbirdabhi
Jun 06 2016 06:05
:sweat_smile:
Jerry Bendy
@jerrybendy
Jun 06 2016 06:05
yes
Mahade Walid
@walidmahade
Jun 06 2016 06:07
@dnvn999
Donovan
@dnvn999
Jun 06 2016 06:07
@jerrybendy something like this?

var count = 0;

function cc(card) {
  // Only change code below this line
  if (card === 2 || card === 3 || card === 4 || card === 5 || card === 6) {
    return count += card + "Bet";

  } else if (card === 7 || card === 8 || card === 9){
    return count += card + "Hold";

  } else if (card === 10 || card === 'J' || card === 'Q' || card ==='K' || card === 'A'){
    return count += card + "Hold";
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:08
Need help in Seek and Destroy problem
Mahade Walid
@walidmahade
Jun 06 2016 06:08
You should use a switch statement
@dnvn999
Shusil Banjade
@shusil123
Jun 06 2016 06:08
@rabibsust , paste your code here
Donovan
@dnvn999
Jun 06 2016 06:08
@walidmahade okay, I will work on it now
Ivan Aganin
@criativ
Jun 06 2016 06:08
@rabibsust I solved only half of it by myself :(
Jerry Bendy
@jerrybendy
Jun 06 2016 06:08
@dnvn999 may count++
Mahade Walid
@walidmahade
Jun 06 2016 06:08
hmm
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:09
function remove(value) {
return value != value;
}
function destroyer(arr) {
// Remove all the values
var arglen = arguments.length;
for(i=1;i<arglen;i++){
arr = arr.filter(remove);
}
return arr;
}
Jerry Bendy
@jerrybendy
Jun 06 2016 06:09
@dnvn999 you can ignore 7, 8, 9, it do nothing
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:09
@criativ I can't understand how to pass argument value.
Shusil Banjade
@shusil123
Jun 06 2016 06:09
@rabibsust , in format help format
Donovan
@dnvn999
Jun 06 2016 06:10
@jerrybendy @walidmahade Can I still pass the test if I dont use switch statement ?
Jerry Bendy
@jerrybendy
Jun 06 2016 06:10
yes, you can
Ivan Aganin
@criativ
Jun 06 2016 06:10
@rabibsust I was struggling with arguments at first too
Shusil Banjade
@shusil123
Jun 06 2016 06:10
@rabibsust , arguments1, and arguments[2] are the values to be destroyed from arguments[0]
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:11
@shusil123 How can I do it from filter?
Mahade Walid
@walidmahade
Jun 06 2016 06:11
yes, but switch statement is clean @dnvn999
Seth
@xboudsady
Jun 06 2016 06:12
Hey guys, need help. The instructions isn't very clear on the Basic JavaScript Lesson: Escape Sequences in String
Jerry Bendy
@jerrybendy
Jun 06 2016 06:12

function cc(card) {
// Only change code below this line
if(card >= 2 && card <= 6){
count++;
} else if(card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
count--;
}

return count + " " + (count > 0 ? "Bet" : "Hold");

// Only change code above this line
}

Seth
@xboudsady
Jun 06 2016 06:12
Here's the instruction "Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr"
Donovan
@dnvn999
Jun 06 2016 06:12
@walidmahade I see, i will go with what I have done for now.
Jerry Bendy
@jerrybendy
Jun 06 2016 06:12
@dnvn999 How to send formated code like you send?
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:13
@criativ Can I pass arguments value?
Arpan
@sahooarpan
Jun 06 2016 06:13

var Bike = function() {

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

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

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

};

var myCar = new Car();

var myBike = new Bike();

where z wrong
Mahade Walid
@walidmahade
Jun 06 2016 06:13
sure
@dnvn999
Shusil Banjade
@shusil123
Jun 06 2016 06:13
@rabibsust , first create a function , which returns false when the values matches with arguments. And then filter the arr with that function..
Jerry Bendy
@jerrybendy
Jun 06 2016 06:13
function cc(card) {
  // Only change code below this line
  if(card >= 2 && card <= 6){
    count++;
  } else if(card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
    count--;
  }

  return count + " " + (count > 0 ? "Bet" : "Hold");

  // Only change code above this line
}
Ivan Aganin
@criativ
Jun 06 2016 06:13
@rabibsust Basicly I separater the array from the numbers I had to "destroy"
Julian Müller
@Julian24816
Jun 06 2016 06:13
@xboudsady try this: myStr = "\\ \t \t \r \n";
Ivan Aganin
@criativ
Jun 06 2016 06:13
it is done with a FOR loop
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:14
Ok I am working on it.
Ivan Aganin
@criativ
Jun 06 2016 06:14
arguments[0] - > [1, 2, 3, 1, 2, 3] ; arguments[1] - > 2 ; arguments[2] - > 3 and so on
Seth
@xboudsady
Jun 06 2016 06:14
@Julian24816 thanks, I just figured it out right before you sent that
CamperBot
@camperbot
Jun 06 2016 06:14
xboudsady sends brownie points to @julian24816 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @julian24816 |http://www.freecodecamp.com/julian24816
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:14
@criativ Thanks
CamperBot
@camperbot
Jun 06 2016 06:14
rabibsust sends brownie points to @criativ :sparkles: :thumbsup: :sparkles:
:cookie: 7 | @criativ |http://www.freecodecamp.com/criativ
Shusil Banjade
@shusil123
Jun 06 2016 06:15
function clean(val) {
  for (var j=0; j<aArr.length; j++) {
    if (aArr[j]==val) {
      return false;
    }
  }
something like this, here aArr is the array of arguments1 and 2
@rabibsust
Seth
@xboudsady
Jun 06 2016 06:15
oh, what's this brownie points thing?
Ahmad Jamaly Rabib
@rabibsust
Jun 06 2016 06:15
@shusil123 thanks
CamperBot
@camperbot
Jun 06 2016 06:15
rabibsust sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 344 | @shusil123 |http://www.freecodecamp.com/shusil123
Seth
@xboudsady
Jun 06 2016 06:15
ah, ok. keyword is "thanks"
Donovan
@dnvn999
Jun 06 2016 06:15
@jerrybendy Thanks, your code is cleaner and cool. :D
what does count++ , means again?
CamperBot
@camperbot
Jun 06 2016 06:15
dnvn999 sends brownie points to @jerrybendy :sparkles: :thumbsup: :sparkles:
:cookie: 3 | @jerrybendy |http://www.freecodecamp.com/jerrybendy
Ivan Aganin
@criativ
Jun 06 2016 06:15
I had such a headache yesterday - because i could not understand HOW to access those "toDestroy" numbers :(
Jerry Bendy
@jerrybendy
Jun 06 2016 06:16
@dnvn999 count++ means that made count plus 1
@dnvn999 equals count = count + 1
Donovan
@dnvn999
Jun 06 2016 06:17
@jerrybendy I see
Jerry Bendy
@jerrybendy
Jun 06 2016 06:18
👌
Ritvik Raj
@ritvikraj14
Jun 06 2016 06:18
https://www.freecodecamp.com/challenges/profile-lookup Can anyone give me code of this execise?
exercise*