These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jul 2016
colorpanda
@colorpanda2011
Jul 16 2016 00:00 UTC
@sjames1958gm cool, that works, any other?
Stephen James
@sjames1958gm
Jul 16 2016 00:00 UTC
@colorpanda2011 That is probably about it.
colorpanda
@colorpanda2011
Jul 16 2016 00:01 UTC
@sjames1958gm sorry, that doesn`t work.
Varun Sharma
@varun29
Jul 16 2016 00:01 UTC
you mean if i use a.num outside the object ,it won't work?? @jarenescueta731
colorpanda
@colorpanda2011
Jul 16 2016 00:01 UTC
@sjames1958gm have to put the else if in it.
Stephen James
@sjames1958gm
Jul 16 2016 00:01 UTC
@colorpanda2011 let me see?
@sjames1958gm what is the name again?
Chad Hurley
@ChadDean82
Jul 16 2016 00:02 UTC
thank Yall I have been hacking at this one most the day between wrestling with the Kid's & soothing the new Littlest one.
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:03 UTC
@varun29 sorry, i was talking about private variables but you asked about private properties. now i'm not sure if i'm confusing myself
Stephen James
@sjames1958gm
Jul 16 2016 00:03 UTC
@colorpanda2011
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
   arr.sort(function(a,b){ return a-b; });

  for (var i = 0; i < arr.length; i++) {
    if (num <= arr[i]) return i;
  }

  return i;
}
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:03 UTC
@varun29 gonna look at the challenge
Varun Sharma
@varun29
Jul 16 2016 00:05 UTC
so can you please nust have a look at the challenge??
@jarenescueta731
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:08 UTC
@varun29 ok so the point of private properties is so you have control over how the object's info is used in outside code
Aiden
@AidenMead
Jul 16 2016 00:09 UTC
Hey all, I am so lost on "Record Collection", I have no idea even where to start.
Varun Sharma
@varun29
Jul 16 2016 00:09 UTC
@jarenescueta731 how to use these function?
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:11 UTC
@varun29 for this challenge, your methods will be public, only the gear variable will be private
@varun29 it's just to show that you can't change the value of gear from outside the object
@varun29 it already gives you examples of public methods
@varun29 a private variable is simply declaring and assigning the variable inside the object
Varun Sharma
@varun29
Jul 16 2016 00:14 UTC
@jarenescue?
Alisdair Frost
@pacificfrost
Jul 16 2016 00:14 UTC
@ChadDean82 No worries man. I know the pain. It's always just that little bit that stumps you. Keep at it man! You'll be pro in no time
@AidenMead can you post the challenge? I'm assuming it is object properties?
Varun Sharma
@varun29
Jul 16 2016 00:15 UTC
we declare a variable inside the function in order to make it private.right?
Jamil Akhtar
@frontender007
Jul 16 2016 00:15 UTC

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if ( str.length > num ) {
     str = str.slice(-str.length, num);
     str +="...";
  }
  return str;
}
Can anybody help me with code please?
Varun Sharma
@varun29
Jul 16 2016 00:15 UTC
@jarenescueta731
Aiden
@AidenMead
Jul 16 2016 00:16 UTC
@pacificfrost it is, bear with me and I'll post it
Varun Sharma
@varun29
Jul 16 2016 00:17 UTC
@AidenMead "collection" is an object of objects
Chris
@ChrisGitter
Jul 16 2016 00:17 UTC
@frontender007 what are you trying to do?
str.slice(-str.length, num) that removes from the beginning, doesnt it?
Varun Sharma
@varun29
Jul 16 2016 00:18 UTC
@AidenMead you need to refer to all the objects using a for loop (by contacts[i])..and check for the properties.
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:18 UTC
hi guys, can you help me?
Promise Tochi
@Promhize
Jul 16 2016 00:19 UTC
Hello on the palindromes challenge, it says the argument should return false, im getting true, and all non-alphanumeric characters are supposed to be removed

function palindrome(str) {
// Good luck!
str = str.replace(/[^A-Za-z]/g, '');
str = str.toLowerCase();

var strArray = [];
for (var i = 0; i < str.length; i++) {
strArray.unshift(str[i]);
}
strArray = strArray.join('');

console.log(strArray === str);
if (strArray !== str) {
return false;
}

return true;

}

palindrome("1 eye for of 1 eye.");

Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:19 UTC
my js works until you loose on strict mode, do you know what is the problem?
http://codepen.io/Sperkajugglite/pen/JKyGJd?editors=0010
Jamil Akhtar
@frontender007
Jul 16 2016 00:20 UTC
@ChrisGitter I 'm at truncate a string challenge
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:21 UTC
you are removing alpha numeric chars, aren't you?
@Promhize
Promise Tochi
@Promhize
Jul 16 2016 00:21 UTC
yes
@Sperkajugglite yes
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:21 UTC
i mean, you are supposed to remove non-alpha, right?
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:21 UTC
@varun29 yes! you declare the variable inside the function to make it private. it's all about localization. sorry for the delay i had to be afk for a sec
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:22 UTC
@Promhize you are removing alphanumeric
Promise Tochi
@Promhize
Jul 16 2016 00:22 UTC
@Sperkajugglite yes i am removing non-alpha
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:22 UTC
your code is removing alphanumeric chars
try \W
and \D
Promise Tochi
@Promhize
Jul 16 2016 00:23 UTC
@Sperkajugglite okay, will try that out, thanks
CamperBot
@camperbot
Jul 16 2016 00:23 UTC
promhize sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:23 UTC
np :P
Varun Sharma
@varun29
Jul 16 2016 00:24 UTC
@jarenescueta731 so we cannot manipulate it from outside?
Rahin Ahmed
@rahin1122
Jul 16 2016 00:24 UTC

Hi Guys .I am not being able to make sense to make "result" below my codes even though after reading full instructions.My code is
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

Promise Tochi
@Promhize
Jul 16 2016 00:25 UTC
@Sperkajugglite i think /w doesnt remove - and _
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:25 UTC
@Promhize also check out regex101.com it's great for testing regular expressions str.match() replace() etc...
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:25 UTC
@Promhize, then use [-_ ]
Aiden
@AidenMead
Jul 16 2016 00:25 UTC
How do you post the code in here? I can't seem to figure it out
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:25 UTC
thatll do
Chris
@ChrisGitter
Jul 16 2016 00:25 UTC

@frontender007

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

inside your if statement

Jaren Escueta
@jarenescueta731
Jul 16 2016 00:25 UTC
@varun29 no you cannot from the outside, that's what makes it "private"
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:25 UTC
@AidenMead you use ```
then close with ```
Aiden
@AidenMead
Jul 16 2016 00:26 UTC

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

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

return collection;
}

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

Promise Tochi
@Promhize
Jul 16 2016 00:26 UTC
@Sperkajugglite hmm, will try that. @jarenescueta731 thanks
CamperBot
@camperbot
Jul 16 2016 00:26 UTC
:cookie: 321 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
:warning: promhize already gave sperkajugglite points
promhize sends brownie points to @sperkajugglite and @jarenescueta731 :sparkles: :thumbsup: :sparkles:
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:26 UTC
help format
CamperBot
@camperbot
Jul 16 2016 00:26 UTC

: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

Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:26 UTC
put ```at the end too
help simon? :laughing:
CamperBot
@camperbot
Jul 16 2016 00:26 UTC
no wiki entry for: simon laughing
Aiden
@AidenMead
Jul 16 2016 00:27 UTC
haha, I feel so silly right now, i can't seem to get it to work!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:27 UTC
@Promhize did it work?
@AidenMead "code here"
"" code here ""
fuck
don't know how to show you
Promise Tochi
@Promhize
Jul 16 2016 00:28 UTC
@Sperkajugglite :D it worked. Thanks
CamperBot
@camperbot
Jul 16 2016 00:28 UTC
promhize sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:warning: promhize already gave sperkajugglite points
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:28 UTC
@Promhize np
@AidenMead just put three before and threeafter!
atutus
oh
one woks too
didn't know that
Aiden
@AidenMead
Jul 16 2016 00:29 UTC

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

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

return collection;
}

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

'code'
code
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:30 UTC
autut
yes
las one you did worked
do the same
Aiden
@AidenMead
Jul 16 2016 00:30 UTC
hmmm, so it works if I type it out, but if I copy and paste code in between my "`" marks, it just prints it normal
Chad Hurley
@ChadDean82
Jul 16 2016 00:30 UTC
@pacificfrost should My 7-8 have the value of =0 or how would I write that to match?
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:31 UTC
@AidenMead idk i always paste
Aiden
@AidenMead
Jul 16 2016 00:31 UTC
One more try, I'm sorry if this doesn't work and I spam you all with the challenge one more time XD

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

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

return collection;
}

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

Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:31 UTC
dude, try with three
Aiden
@AidenMead
Jul 16 2016 00:31 UTC
Hmm, i give up, sorry all!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:31 UTC
@AidenMead last try?
Aiden
@AidenMead
Jul 16 2016 00:31 UTC
lol, ok

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

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

return collection;
}

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

Chad Hurley
@ChadDean82
Jul 16 2016 00:32 UTC
var count = 0;

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

      case 7:
      case 8:
      case 9:
      count =0 ;
     break;

      case 10:
      case 'J':
      case 'Q':
      case 'K':
      case 'A':
      count--;
      break;
  }

  if (count < +1) 

  {return  count + "Hold";}
  else if (count >1)
    {return count + "Bet";}





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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      count++;
      break;

      case 7:
      case 8:
      case 9:
      count =0 ;
     break;
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:34 UTC
@AidenMead i really don't know whats going on now, it should have worked this time
can you guys help me with the error?
http://codepen.io/Sperkajugglite/pen/JKyGJd?editors=0010
Aiden
@AidenMead
Jul 16 2016 00:36 UTC
Haha, I think it's somehow just me. Thanks for the help, though, @Sperkajugglite !
CamperBot
@camperbot
Jul 16 2016 00:36 UTC
aidenmead sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:36 UTC
@ChadDean82 i think in case 7... it should not equal 0
CamperBot
@camperbot
Jul 16 2016 00:36 UTC
:cookie: 306 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:36 UTC
@ChadDean82 maybe it shouldn't add anything
@ChadDean82 so, just don't do anything there
i don't remember the challenge rules
but try that
btw my simon doesn't look good on small screens yet
Chad Hurley
@ChadDean82
Jul 16 2016 00:37 UTC
@Sperkajugglite so take code 7-8 out completely?
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:37 UTC
@ChadDean82 if its 7 you shouldn't add, right?
@ChadDean82 if so, just delete it, right now you are assigning count to 0
Chad Hurley
@ChadDean82
Jul 16 2016 00:39 UTC
right on now My return on console is 0Hold guess there is something wrong with the if statement's?
llamatarianism
@llamatarianism
Jul 16 2016 00:43 UTC
you're setting count to 0
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:43 UTC
its equal to 0 (< 1), so it will return count (0) + "hold" (you should add one space before hold, like this " Hold")
llamatarianism
@llamatarianism
Jul 16 2016 00:43 UTC
that's different to adding 0
colorpanda
@colorpanda2011
Jul 16 2016 00:43 UTC
everyone have a good weekend!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:43 UTC
@llamatarianism @ChadDean82 thats what i said
Rahin Ahmed
@rahin1122
Jul 16 2016 00:44 UTC
Hi Guys , How can i create a "result " string inside the following function.

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

// Your code above this line
return result;
}

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

Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:47 UTC
format help
result = my noun + .... ?
amran16
@amran16
Jul 16 2016 00:48 UTC
does capitalize method work in JS, am working on Title Case a Sentence challenge?
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:48 UTC
i think it doesn't
try just toUpperCase with index 0
amran16
@amran16
Jul 16 2016 00:50 UTC
thanks @Sperkajugglite , how would I do it for each word though?
CamperBot
@camperbot
Jul 16 2016 00:50 UTC
amran16 sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Heather Kusmierz
@HKuz
Jul 16 2016 00:51 UTC
@rahin1122 you can have the result string say anything, then use concatenation (fancy word for combining strings with other strings or variables) of that string and the parameters.
Something like var result = "My " + my Adjective + myNoun + " would always " + myVerb + myAdverb;
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:52 UTC
@amran16 loop for word in string, word[first char].toUpperCase
?
is anyone alive?
does anyone have a problem, does anyone have a solution http://codepen.io/Sperkajugglite/pen/JKyGJd?editors=0010
:P?
amran16
@amran16
Jul 16 2016 00:55 UTC
thanks
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:56 UTC
np
Rahin Ahmed
@rahin1122
Jul 16 2016 00:56 UTC
@HKuz thank you
CamperBot
@camperbot
Jul 16 2016 00:56 UTC
rahin1122 sends brownie points to @hkuz :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @hkuz |http://www.freecodecamp.com/hkuz
Heather Kusmierz
@HKuz
Jul 16 2016 01:08 UTC
@rahin1122 no problem, cheers
Rahin Ahmed
@rahin1122
Jul 16 2016 01:10 UTC
@HKuz Its not working following your instructions .What is it basically i am not being able to understand logic .
labanch
@labanch
Jul 16 2016 01:16 UTC
Hello everyone! Can anyone explain to me what is test[i] in the following code? Is the if statement checking each letter in test?
function mutation(arr) {
  var target = arr[0].toLowerCase();
  var test = arr[1].toLowerCase();
  for(var i = 0; i<test.length; i++){
   if (target.indexOf(test[i]) < 0) 
      return false;
  }
  return true;
}

mutation(["Hello", "hey"]);
Heather Kusmierz
@HKuz
Jul 16 2016 01:18 UTC

@rahin1122 hmmmm, what about something like this:

// Your code below this line
var part1 = "My ";
var part2 = " would always ";
result = part1 + myAdjective + myNoun + part2 + myVerb + myAdverb;
// Your code above this line
return result;

I can't remember the exact instructions for that problem

llamatarianism
@llamatarianism
Jul 16 2016 01:19 UTC
you need spaces inbetween the words
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:19 UTC
@labanch have you tried logging indexOf(test[i]) to see what it outputs?
llamatarianism
@llamatarianism
Jul 16 2016 01:19 UTC
result = myAdjective + " " + myNoun + " " + ...
labanch
@labanch
Jul 16 2016 01:19 UTC
@no-stack-dub-sack good idea! I'll try that now
Heather Kusmierz
@HKuz
Jul 16 2016 01:20 UTC
@llamatarianism ah yes, good call
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:22 UTC
would any care to critique my wiki viewer? I programmed in an easter egg which was fun. All searches will look the same unless you enter "phish". Open to feedback on the code, design suggestions, constructive crit, etc. Thanks!
http://codepen.io/no_stack_dub_sack/full/akLkZP/
Seth
@rifen
Jul 16 2016 01:22 UTC
help Record Collection
CamperBot
@camperbot
Jul 16 2016 01:22 UTC

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

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

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

For the given id in collection:

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

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

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

labanch
@labanch
Jul 16 2016 01:22 UTC
@no-stack-dub-sack ok so it outputs each letter. I didn't know that you can access each letter in a string using bracket notation. I thought this was only used to access an element in an array or when accessing properties in objects
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:24 UTC
@labanch yup, works the same way
labanch
@labanch
Jul 16 2016 01:24 UTC
@no-stack-dub-sack cool! Learned something new. Thanks
CamperBot
@camperbot
Jul 16 2016 01:24 UTC
labanch sends brownie points to @no-stack-dub-sack :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @no-stack-dub-sack |http://www.freecodecamp.com/no-stack-dub-sack
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:25 UTC
@labanch no prob! That's what it's all about!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 01:27 UTC
@no-stack-dub-sack looks great!! :P
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:28 UTC
@Sperkajugglite Thanks! Let me know if you have any suggestions!
CamperBot
@camperbot
Jul 16 2016 01:28 UTC
no-stack-dub-sack sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Santiago Gómez
@Sperkajugglite
Jul 16 2016 01:28 UTC
doesn't load pages yet?
Rahin Ahmed
@rahin1122
Jul 16 2016 01:28 UTC
@HKuz I was forgetting to put ending curly braces .It has matched finally .Thank you very much.
Heather Kusmierz
@HKuz
Jul 16 2016 01:29 UTC
@rahin1122 sweet!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 01:30 UTC
http://codepen.io/Sperkajugglite/pen/JKyGJd?editors=0110 btw, guys I'm trying to figure out whats wrong with my simon, when you loose in strict mode it breaks :P
do you know what could be wrong? :innocent:
please, :cry: ?
Robinsond7691
@Robinsond7691
Jul 16 2016 01:38 UTC
Hey guys, quick question: Can i practice with javascript offline? Like, if I make an html page through notepad++ and incorporate some javascript in it, will it work?
Drez
@drez14
Jul 16 2016 01:39 UTC
@Robinsond7691 sure bro
Robinsond7691
@Robinsond7691
Jul 16 2016 01:39 UTC
@drez14 thanks man, sounds good.
CamperBot
@camperbot
Jul 16 2016 01:39 UTC
robinsond7691 sends brownie points to @drez14 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for drez14
willcodes
@willcodes
Jul 16 2016 01:41 UTC
hi guys, I know this isnt the most efficient way but could anyone help me add class on scroll? do I have to do .height or .top to my position vars?
$(document).ready(function(){



function scroller() {
  function aboutAdd() {
  var aboutActive = $("#nav-about").addClass(".nav-active");
  $("#nav-portfolio").removeClass(".nav-active");
  $("#nav-contact").removeClass(".nav-active")
};
function portfolioAdd() {
  var aboutActive = $("#nav-portfolio").addClass(".nav-active");
   $("#nav-about").removeClass(".nav-active");
  $("#nav-contact").removeClass(".nav-active")
};
function contactAdd() {
  var aboutActive = $("#nav-contact").addClass(".nav-active");
   $("#nav-about").removeClass(".nav-active");
  $("#nav-portfolio").removeClass(".nav-active")
};
var aboutPos = $("#about").offset();
var portfolioPos = $("#scroller").offset();
var contactPos = $("#contact").offset();

  $(window).on("scroll" , function() {
if (aboutPos > portfolioPos && aboutPos > contactPos {
 aboutAdd();
}
else if (portfolioPos > contactPos && portfolioPos < aboutPos){
  portfolioAdd();
}
else if(contactPos < portfolioPos && contactPos < aboutPos){
  contactAdd();
  }
  else{
  $("#nav-about"),removeClass(".nav-active") ;
  $("#nav-portfolio").removeClass(".nav-active");
  $("#nav-contact").removeClass(".nav-active");
  }
});




  };
});
Luke Bailey
@baileyl91
Jul 16 2016 01:49 UTC

Hi all,
I'm struggling to get 'Comparison with the Greater Than Operator' section to work.
Here my code:
function testGreaterThan(val) {
if (val > 15) { // Change this line
return "Over 100";
}

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

return "10 or Under";
}

// Change this value to test
testGreaterThan(200);

willcodes
@willcodes
Jul 16 2016 01:51 UTC
you can only have one if statement
@baileyl91
@baileyl91 you should have
if{
}
else if{
}
else{
if, else if, then finally else
JackeL
@jackel27
Jul 16 2016 01:54 UTC
going to stream a twitch overlay I started today on FCC twitch channel
Luke Bailey
@baileyl91
Jul 16 2016 01:58 UTC
@willcodes
I understand where you are coming from, but that the code they give on the topic section.
I have managed to get it work, did not need else for some reason.
It was to change the value of 'val' to match each testing statement.
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:11 UTC
hello all, help!!
Screen Shot 2016-07-15 at 9.11.20 PM.png
Silvano Rasta
@sirvanux
Jul 16 2016 02:15 UTC
Why Am I getting NaN here?

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var celcius;

fahrenheit = celcius * 1.8 + 32;

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

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

Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:16 UTC
@sirvanux use the fraction of 1.8
I'm not exactly sure why...posibly because it's a decimal number?
Silvano Rasta
@sirvanux
Jul 16 2016 02:17 UTC
i think its the same (9/5)
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:18 UTC
celcius is spelled celsius...
@sirvanux celcius is spelled celsius...
Silvano Rasta
@sirvanux
Jul 16 2016 02:18 UTC
thats it let me try
Ash
@Ash717
Jul 16 2016 02:18 UTC
hey guys i fixed my code but it seems it got stuck on one pic. Could you try this please and tell me if it works (http://codepen.io/Ash717/full/bZajEO/)
Silvano Rasta
@sirvanux
Jul 16 2016 02:19 UTC
@jesushilariohernandez thanks my friend i was getting crazy here
CamperBot
@camperbot
Jul 16 2016 02:19 UTC
sirvanux sends brownie points to @jesushilariohernandez :sparkles: :thumbsup: :sparkles:
:cookie: 175 | @jesushilariohernandez |http://www.freecodecamp.com/jesushilariohernandez
Diego Mayer
@Chrono79
Jul 16 2016 02:19 UTC
@sirvanux use the parameter, don't declare a var (celsius) inside your function
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:19 UTC
@sirvanux thanks man... I know the feeling!!! I'm stumped right now...too.
CamperBot
@camperbot
Jul 16 2016 02:19 UTC
jesushilariohernandez sends brownie points to @sirvanux :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for sirvanux
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:20 UTC
Screen Shot 2016-07-15 at 9.11.20 PM.png
Silvano Rasta
@sirvanux
Jul 16 2016 02:20 UTC
it was the typo
Ash
@Ash717
Jul 16 2016 02:20 UTC
anyone?
Silvano Rasta
@sirvanux
Jul 16 2016 02:20 UTC
celcius intead of celsius
Diego Mayer
@Chrono79
Jul 16 2016 02:21 UTC
@jesushilariohernandez review array manipulation methods: pop, push, shift and unshift, you need 2 of them
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:21 UTC
@Chrono79 Thank you sir...
CamperBot
@camperbot
Jul 16 2016 02:21 UTC
jesushilariohernandez sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1541 | @chrono79 |http://www.freecodecamp.com/chrono79
Ash
@Ash717
Jul 16 2016 02:22 UTC
>
Diego Mayer
@Chrono79
Jul 16 2016 02:24 UTC
@Ash717 you are using = instead of == or === in your if conditions
Ash
@Ash717
Jul 16 2016 02:24 UTC
alright
@Chrono79 thank you
CamperBot
@camperbot
Jul 16 2016 02:25 UTC
ash717 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1542 | @chrono79 |http://www.freecodecamp.com/chrono79
Ash
@Ash717
Jul 16 2016 02:26 UTC
@Chrono79 does it work now?
Diego Mayer
@Chrono79
Jul 16 2016 02:26 UTC
yes
abdoesam2011
@abdoesam2011
Jul 16 2016 02:26 UTC
hello guys i'm new here :smile:
Kent Saeteurn
@sansae
Jul 16 2016 02:26 UTC
Hi all, I'm trying to change the background color for my webpage but can't figure out why my code is not working. I've tried many different approaches found on stackoverflow (as recent as 2015), and have even tried doing it the way like W3Schools (http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp). This hasn't worked. Can anyone help look at my code and figure out what's wrong with it? My fiddle is here: https://jsfiddle.net/2aexjra5/
Pericles
@periman2
Jul 16 2016 02:26 UTC
getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
Ash
@Ash717
Jul 16 2016 02:27 UTC
@Chrono79 thank you!
CamperBot
@camperbot
Jul 16 2016 02:27 UTC
ash717 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: ash717 already gave chrono79 points
Pericles
@periman2
Jul 16 2016 02:27 UTC
why does the console says this when I try to access location data with naviagor.geolocation?
Diego Mayer
@Chrono79
Jul 16 2016 02:27 UTC
@periman2 you're using Chrome, don't you?
Pericles
@periman2
Jul 16 2016 02:28 UTC
yes I do
Diego Mayer
@Chrono79
Jul 16 2016 02:28 UTC
native browser geolocation in Chrome is restricted to https
Ash
@Ash717
Jul 16 2016 02:28 UTC
@Chrono79 thanks again!
CamperBot
@camperbot
Jul 16 2016 02:28 UTC
:warning: ash717 already gave chrono79 points
ash717 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jul 16 2016 02:28 UTC
@Ash717 no problem
Pericles
@periman2
Jul 16 2016 02:28 UTC
but other examples that use geolocation made in codepen work fine in chrome how is that possible?
what should I do? switch browsers?
Jonathan Leon
@Wo1v3r
Jul 16 2016 02:29 UTC
@periman2 I had that problem yesterday, be aware that you can access your codepen both in http and https
@periman2 I had that problem not only with the geolocation but also with loading external JS \ CSS over http and not https for example fontawesome
Kevin
@KevinBruland
Jul 16 2016 02:30 UTC
@periman2 yeah, link to the codepen through https, or you can use an https api call... I used weather underground for it personally
Jonathan Leon
@Wo1v3r
Jul 16 2016 02:30 UTC
@periman2 You can use geolocation if it runs on https and make a fallback to an api based on IP (which is over http)
Pericles
@periman2
Jul 16 2016 02:31 UTC
@Wo1v3r @Benalron how do I link the codepen through https I have no idea how to do that...
Chris
@KhriztianG
Jul 16 2016 02:31 UTC
need help on challenge "accessing objects properties with bracket notation" says i need to use bracket notation twice but i have the other answers just won't work with bracket notation any way i put them
Jonathan Leon
@Wo1v3r
Jul 16 2016 02:31 UTC
the ip api isn't accurate enough though as it seems to return the weather at my provider (150km from my city) so I'll do that fallback from geolocation l8r
@periman2 either open your codepen with https:// prefix
Pericles
@periman2
Jul 16 2016 02:32 UTC
and the exercise suggest opeweathermap api which is https as I just only now checked
Jonathan Leon
@Wo1v3r
Jul 16 2016 02:32 UTC
@periman2 or add another codepen with https:// prefix through the js menu (just add the link in the js settings -> external js)
that's what you would also do for a callback with jsonp (add another codepen as an extension)
so its good to get used to it
@periman2 you can make https requests over http but not the opposite
disregard what i just said in the last line im a bit confused, I need to go to bed XD
Pericles
@periman2
Jul 16 2016 02:35 UTC
@Wo1v3r haha don't worry about it thank you for your help I'll see what I can do right now
CamperBot
@camperbot
Jul 16 2016 02:35 UTC
periman2 sends brownie points to @wo1v3r :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @wo1v3r |http://www.freecodecamp.com/wo1v3r
Jonathan Leon
@Wo1v3r
Jul 16 2016 02:35 UTC
np goodluck you can pm me if you need help night :)
Pericles
@periman2
Jul 16 2016 02:36 UTC
night :)
Diego Mayer
@Chrono79
Jul 16 2016 02:37 UTC

@sansae

$(document).ready(function() {
  $("#getNewQuote").on("click", function(){    
    //on click, change background color
            $("body").css("background-color", "red");
  }); 
});

If you want to use jquery you have to add it, click on javascript panel top right and add it

Kevin
@KevinBruland
Jul 16 2016 02:38 UTC
@periman2 just add an S at the beginning of the codepen url
Pericles
@periman2
Jul 16 2016 02:41 UTC
@Benalron hmm I just did that and now it doesn't display the same error but it still doesn't work. probably some problem in my code
@Benalron thank you I'll try again now !
CamperBot
@camperbot
Jul 16 2016 02:41 UTC
periman2 sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 368 | @benalron |http://www.freecodecamp.com/benalron
Diego Mayer
@Chrono79
Jul 16 2016 02:41 UTC
@periman2 openweather works in http, not https, so you need some other service that let you load http content to your https site
labanch
@labanch
Jul 16 2016 02:41 UTC
help falsy bouncer
CamperBot
@camperbot
Jul 16 2016 02:41 UTC

:point_right: algorithm falsy bouncer [wiki]

Algorithm Falsy Bouncer

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

Remove all falsy values from an array.

Relevant Links

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

Pericles
@periman2
Jul 16 2016 02:42 UTC
@Chrono79 then I'll use a json api I found that works on chrome
Diego Mayer
@Chrono79
Jul 16 2016 02:42 UTC
@periman2 go for it
Pericles
@periman2
Jul 16 2016 02:42 UTC
@Chrono79 although openweather website is in https...
Diego Mayer
@Chrono79
Jul 16 2016 02:42 UTC
@periman2 the api works in http (last time I checked)
Pericles
@periman2
Jul 16 2016 02:43 UTC
@Chrono79 hm okay thank you
CamperBot
@camperbot
Jul 16 2016 02:43 UTC
periman2 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1543 | @chrono79 |http://www.freecodecamp.com/chrono79
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:45 UTC
ok...this is what I have so far...am I on right track...no clue were to go from here...??
Screen Shot 2016-07-15 at 9.45.03 PM.png
any study tips...
Pericles
@periman2
Jul 16 2016 02:47 UTC
@jesushilariohernandez you need to return only the element that was removed
@jesushilariohernandez and you should push the item not "1"
Norvin Burrus
@ndburrus
Jul 16 2016 02:49 UTC
@jesushilariohernandez here: return arr.shift(),arr.push(1); needs to be changed. in particular, the comma is an issue... what should we do? also, what needs to be pushed?
Pericles
@periman2
Jul 16 2016 02:50 UTC
@ndburrus @jesushilariohernandez it doesn't have to be a one liner ...
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:50 UTC
remove comma put semicolen
@ndburrus remove comma use semi
Norvin Burrus
@ndburrus
Jul 16 2016 02:51 UTC
@jesushilariohernandez ok, so let's see what the code looks like now..
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:52 UTC
Screen Shot 2016-07-15 at 9.52.08 PM.png
Pericles
@periman2
Jul 16 2016 02:52 UTC
@jesushilariohernandez why do you put everything on return?
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:53 UTC
@periman2 not sure! I'm stuck....
Pericles
@periman2
Jul 16 2016 02:53 UTC
do the push above the return and then return the item that was removed
one thing you need to return not two
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:53 UTC
@periman2 ah... i see
Screen Shot 2016-07-15 at 9.54.09 PM.png
@periman2 what do you mean by "it doesn't have to be a one liner?
Pericles
@periman2
Jul 16 2016 02:55 UTC
@jesushilariohernandez push the item....
inside the push put the item that's what you need to go in the list
other than that you're fine
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:56 UTC
@periman2 so weird!!! ...
Screen Shot 2016-07-15 at 9.56.06 PM.png
@periman2 @ndburrus Thanks for your help!
CamperBot
@camperbot
Jul 16 2016 02:56 UTC
jesushilariohernandez sends brownie points to @periman2 and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @periman2 |http://www.freecodecamp.com/periman2
:cookie: 980 | @ndburrus |http://www.freecodecamp.com/ndburrus
Pericles
@periman2
Jul 16 2016 02:57 UTC
no problem
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:58 UTC
@periman2 thanks again!
CamperBot
@camperbot
Jul 16 2016 02:58 UTC
jesushilariohernandez sends brownie points to @periman2 :sparkles: :thumbsup: :sparkles:
:warning: jesushilariohernandez already gave periman2 points
Pericles
@periman2
Jul 16 2016 02:58 UTC
@jesushilariohernandez I hope you understood why it worked this way
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 02:59 UTC
Yes sir I do know...I had to re-read this paragraph!!! several times...now that I've read it again after solving...It makes sense....
Screen Shot 2016-07-15 at 9.59.06 PM.png
@periman2 confusing...
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 03:00 UTC
does anyone know if there is something in my browser that could prevent twitch from loading streams and preventing a successful API call? Trying to load up the FCC stream that appears to be live but cannot see it - spinning wheel of death instead
Pericles
@periman2
Jul 16 2016 03:00 UTC
@jesushilariohernandez yes it's important to understand exactly the problem you want to solve
@no-stack-dub-sack what does the console say ?
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 03:02 UTC
@periman2 totally agree...since I've started...I has my text editor open and I work this problems on my own to se how they turn out...
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 03:02 UTC
@periman2 it just returns an empty object... maybe I have the call wrong, but what's troubling is that I haven't been able to load a single twitch stream for over an hour
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:05 UTC
Hello everyone.In the Caesar cipher challenge.I get the following output:THE-QUICK-BROWN-DOG-JUMPED-OVER-THE-LAZY-FOX; How do I tackle the problem of space and full stop.
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 03:07 UTC
@periman2 well I figured out the api call, but I still can't view any twitch streams
Pericles
@periman2
Jul 16 2016 03:07 UTC
@RajdeepRoy how do you use join ?
Emelin GUtierrez
@emelinpg
Jul 16 2016 03:07 UTC
Can someone help me with "escape sequences in strings" I dont understand it at all
Pericles
@periman2
Jul 16 2016 03:07 UTC
@no-stack-dub-sack are you sure the api functions currently ? Can you open it with your browser ?
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:09 UTC
@periman2 .I created a var a=' ' and then I just added the converted strings there.So how do we use join in this case?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 03:10 UTC
@periman2 well, I'm getting the json data in my log
Jesus Hilario Hernandez
@jesushilarioh
Jul 16 2016 03:10 UTC
@emelinpg what've you got so far?
Pericles
@periman2
Jul 16 2016 03:10 UTC
@no-stack-dub-sack hmm that's weird maybe as in helpfrontend for that matter
@RajdeepRoy can you show your code or pm it to me?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 03:11 UTC
but for some reason when I paste the call url into my browser I don't see the data...
yeah.. I could try. I always just come here for anything, seems to be the most active room overall
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:12 UTC

@periman2 function rot13(str) { // LBH QVQ VG!
var o='';
for (i=0;i<str.length;i++){ if (str.charCodeAt(i)>77){
o+= String.fromCharCode(str.charCodeAt(i)-13);
}
else {
o+= String.fromCharCode(str.charCodeAt(i)+13);
}
}
return o;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");

Chad Hurley
@ChadDean82
Jul 16 2016 03:12 UTC
@Chrono79 Hey Man for real I am triping out on this code been rewriting over & over for a day & a half this is what I have after the last reset I am oh so tired of rewriting this if/else please help
Joseph
@revisualize
Jul 16 2016 03:12 UTC
YO!
Chad Hurley
@ChadDean82
Jul 16 2016 03:13 UTC
var count = 0;

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


      case 10:
      case 'J':
      case 'Q':
      case 'K':
      case 'A':
      count--;
      break;
  }

  if (count<0) {
    return "Hold";
  } else if (count>0) {
    return "Bet";
  }
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 03:13 UTC
@periman2 oddly, I can view twitch streams in firefox but not chrome
Joseph
@revisualize
Jul 16 2016 03:14 UTC
@ChadDean82 You're not including the count with your return.
Pericles
@periman2
Jul 16 2016 03:15 UTC
@RajdeepRoy spaces have charcode 32 I think
@RajdeepRoy so when it finds a space it goes 32+13 that's why you se a - instead of a space
Chad Hurley
@ChadDean82
Jul 16 2016 03:17 UTC
@revisualize like this?
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:17 UTC
Thanks @periman2 .So should I have a code to filter codes greater than 65
CamperBot
@camperbot
Jul 16 2016 03:17 UTC
rajdeeproy sends brownie points to @periman2 :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @periman2 |http://www.freecodecamp.com/periman2
Chad Hurley
@ChadDean82
Jul 16 2016 03:17 UTC
if (count<0) {
    return count + "Hold";
  } else if (count>0) {
    return count + "Bet";
  }
Pericles
@periman2
Jul 16 2016 03:17 UTC
@RajdeepRoy and you're going to have problem with the dot "." too I think it's bigger than 90 or something
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:19 UTC
Thanks again @periman2 .U r of great help.
CamperBot
@camperbot
Jul 16 2016 03:19 UTC
rajdeeproy sends brownie points to @periman2 :sparkles: :thumbsup: :sparkles:
:warning: rajdeeproy already gave periman2 points
Vishal Bansal
@Vishal0024
Jul 16 2016 03:20 UTC
need hekp with Escape sequences
help
CamperBot
@camperbot
Jul 16 2016 03:20 UTC

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

Pericles
@periman2
Jul 16 2016 03:20 UTC
@RajdeepRoy just make sure that your if statements includes only the alphabet and in the "else" statement you include you include everything else (dots and spaces) and you just push them into your string without manipulating them
@RajdeepRoy no problem
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:21 UTC
ok @periman2
Vishal Bansal
@Vishal0024
Jul 16 2016 03:22 UTC
Can anybody help with Escape sequences?
Pericles
@periman2
Jul 16 2016 03:23 UTC
@Vishal0024 what do you need?
Vishal Bansal
@Vishal0024
Jul 16 2016 03:24 UTC
i need to print this --> FirstLine
\SecondLine\
ThirdLine
With the help of escape sequences
i did this---> 'FirstLine\n \ScondLine\ \rThirdLine'
what am i missing?
Pericles
@periman2
Jul 16 2016 03:25 UTC
you're extremely close
\SecondLine\ has \ left and right
you haven't included them
Vishal Bansal
@Vishal0024
Jul 16 2016 03:25 UTC
FirstLine\n \ScondLine\ \rThirdLine
FirstLine\n \ScondLine\ \rThirdLine
i included it
labanch
@labanch
Jul 16 2016 03:26 UTC
help seek and destroy
CamperBot
@camperbot
Jul 16 2016 03:26 UTC

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

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

Relevant Links

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

Pericles
@periman2
Jul 16 2016 03:26 UTC
no in order to display a backslash you need to have two one after the other
Chris
@Bitcross
Jul 16 2016 03:26 UTC
FirstLine\n\SecondLine\\
Pericles
@periman2
Jul 16 2016 03:26 UTC
\ this is how you display a backslash
Vishal Bansal
@Vishal0024
Jul 16 2016 03:26 UTC
here..when i am typing my message..it automatically removes that one \
Chris
@Bitcross
Jul 16 2016 03:26 UTC
\rThirdLine
Pericles
@periman2
Jul 16 2016 03:26 UTC
\ *
oh it takes it down
_\
I can't write it
Chris
@Bitcross
Jul 16 2016 03:27 UTC
@ChadDean82 Any luck on the card counting code?
Vishal Bansal
@Vishal0024
Jul 16 2016 03:27 UTC
yes
Pericles
@periman2
Jul 16 2016 03:27 UTC
"FirstLine\n\\SecondLine\\\rThirdLine"
it's this way
double \ left and right
Vishal Bansal
@Vishal0024
Jul 16 2016 03:27 UTC
yes..this is what i did..but it doesnt work
Chad Hurley
@ChadDean82
Jul 16 2016 03:28 UTC
@Bitcross no Sir still tinkering to try to crack the code
Pericles
@periman2
Jul 16 2016 03:28 UTC
@Vishal0024 this works for me how can it now work for you ?
check them again element by element
@emelinpg this is your question too
Vishal Bansal
@Vishal0024
Jul 16 2016 03:29 UTC
i did exactly what you mentioned
Chris
@Bitcross
Jul 16 2016 03:29 UTC

```
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
}

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

Vishal Bansal
@Vishal0024
Jul 16 2016 03:29 UTC
this is what i am getting as an error message
should have encoded text with the proper escape sequences and no spacing.
Pericles
@periman2
Jul 16 2016 03:30 UTC
paste your code here inside the ```
Vishal Bansal
@Vishal0024
Jul 16 2016 03:30 UTC
'var myStr="FirstLine\n\ScondLine\\rThirdLine";'
sorry about that \
Pericles
@periman2
Jul 16 2016 03:31 UTC
var myStr = "FirstLine\n\SecondLine\\rThirdLine"
yes it doens't show indeed
oooh
ScondLine...
should be SecondLine
Vishal Bansal
@Vishal0024
Jul 16 2016 03:32 UTC
o yes
what a silly mistake
Pericles
@periman2
Jul 16 2016 03:32 UTC
done an infinity of those myself xD
Vishal Bansal
@Vishal0024
Jul 16 2016 03:32 UTC
thank you so much..@periman2
Pericles
@periman2
Jul 16 2016 03:32 UTC
np :)
Vishal Bansal
@Vishal0024
Jul 16 2016 03:33 UTC
:-)
Chad Hurley
@ChadDean82
Jul 16 2016 03:35 UTC
@Bitcross word for word & still getting back console rturn of 0Hold. any idea's?
var count = 0;

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


      case 10:
      case 'J':
      case 'Q':
      case 'K':
      case 'A':
      count--;
      break;
  }

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





  return count;
Chris
@Bitcross
Jul 16 2016 03:41 UTC
@ChadDean82 you need a space in front of Hold and Bet. like this: " Hold" " Bet"
and you don't need that return at the end with just count.
Chad Hurley
@ChadDean82
Jul 16 2016 03:48 UTC
@Bitcross someone told Me that earlier but I could not for the life of Me figure out what they meant. should there be another else if for the return count + "Bet then a else for count+ "Bet" "Hold"; ?
Chris
@Bitcross
Jul 16 2016 03:49 UTC
@ChadDean82 Nope, all you need is the if statement you have set up, just with the spaces before the words at the beginning of the string.
Islam Ibakaev
@dagman
Jul 16 2016 03:50 UTC
@willcodes if i get you right this should work http://codepen.io/dagman/full/qNpJgN/
i believe you can prettify it a bit.
it took to me some time to figure this out to be honest :smile:
Chad Hurley
@ChadDean82
Jul 16 2016 03:58 UTC
I must not being understanding. But I am very passant if You are willing to be passant with Me. I have this now & still getting 0Hold;
if (count<=0) {
    return count + "Hold";
  } else {
    return count + "Bet";
  }
Chris
@Bitcross
Jul 16 2016 03:59 UTC
if (count<=0) {
    return count + " Hold";
  } else {
    return count + " Bet";
  }
Chad Hurley
@ChadDean82
Jul 16 2016 04:02 UTC
@Bitcross was that Your post or just a dup of mine?
Chris
@Bitcross
Jul 16 2016 04:06 UTC
that's mine. you're only missing a space after the opening " on both strings. so it prints the count, then a space before the word Hold and Bet.
wowcallmia
@wowcallmia
Jul 16 2016 04:06 UTC
i was told my output needs to be a single object not a bunch of strings can anyone help

var superCounter = function (x) {
var charCount = x.length;
var wordCount = x.split(" ").length;
var whiteSpace = wordCount - 1;
var letterCount = charCount - whiteSpace;
var wordArray = x.split(" ");
var avgLen = charCount / wordCount;

console.log(("Letters: " + letterCount), "Character count: " + charCount, "Word count: " + wordCount, "Whitespace count: " + whiteSpace, "Word length average: " + avgLen);

};

superCounter("word counter");

Chad Hurley
@ChadDean82
Jul 16 2016 04:10 UTC
@Bitcross K so probably a dumb ? but what would be My opening of the string?
wowcallmia
@wowcallmia
Jul 16 2016 04:10 UTC
need to turn console log into one object
Chris
@Bitcross
Jul 16 2016 04:12 UTC
@ChadDean82 right after the first " before Hold, you need a space. so instead of "Hold" it is " Hold". same goes for the else. "Bet" should be " Bet". they both need a space after the first double quote so that the count gets a space after it and it's separated from the strings.
Rahul Nayak
@pragyes31
Jul 16 2016 04:15 UTC
Hello Campers, I am trying to dynamically insert some values from json data to html but for some reason, it isn't happening. Can anybody point out the problem so that I can rectify it?
Chad Hurley
@ChadDean82
Jul 16 2016 04:16 UTC
@Bitcross Thank You
CamperBot
@camperbot
Jul 16 2016 04:16 UTC
chaddean82 sends brownie points to @bitcross :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @bitcross |http://www.freecodecamp.com/bitcross
Chris
@Bitcross
Jul 16 2016 04:18 UTC
@ChadDean82 You're welcome!
Chad Hurley
@ChadDean82
Jul 16 2016 04:25 UTC
@Bitcross always got to be something so simple. Just fyi I had to get My Wife to come look at everything to get a new set of eye's on it. That was the break thru. lol
Chris
@Bitcross
Jul 16 2016 04:28 UTC
@ChadDean82 It always helps to have someone who didn't write the code to look at it. I've had people point out spelling errors and missing semi-colon's before lol
Rahul Nayak
@pragyes31
Jul 16 2016 04:31 UTC
Anybody active right now?
Would like to have suggestions on the above codepen
martinronquillo
@martinronquillo
Jul 16 2016 04:33 UTC

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

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

Using Objects for Lookups
I dont know what is wrong with my code
Chris
@Bitcross
Jul 16 2016 04:35 UTC
 // Only change code below this line
  var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"
  };
  result = lookup[val];
martinronquillo
@martinronquillo
Jul 16 2016 04:37 UTC

@Bitcross when i run it, it says return not in function
// Setup
function phoneticLookup(val) {
var result = undefined;

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

}

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

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

Chris
@Bitcross
Jul 16 2016 04:38 UTC
// Setup
function phoneticLookup(val) {
  var result = "";

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

// Change this value to test
phoneticLookup("charlie");
that's the code that solved it for me
Shantanu Pramanik
@shantanu0323
Jul 16 2016 04:40 UTC
guyz please help me withthe 189th challenge
Chris
@Bitcross
Jul 16 2016 04:40 UTC
which one is that??
Shantanu Pramanik
@shantanu0323
Jul 16 2016 04:40 UTC
its local scope and functions
Chris
@Bitcross
Jul 16 2016 04:41 UTC
what's your code look like?
martinronquillo
@martinronquillo
Jul 16 2016 04:41 UTC
@Bitcross thanks i appreciate it. Oh and one more question how do people screenshot there code onto this chat
CamperBot
@camperbot
Jul 16 2016 04:41 UTC
martinronquillo sends brownie points to @bitcross :sparkles: :thumbsup: :sparkles:
:cookie: 213 | @bitcross |http://www.freecodecamp.com/bitcross
Chris
@Bitcross
Jul 16 2016 04:42 UTC
@martinronquillo type three ``` and then hit shift + Enter, paste your code
martinronquillo
@martinronquillo
Jul 16 2016 04:42 UTC
@Bitcross #3 or three?
Shantanu Pramanik
@shantanu0323
Jul 16 2016 04:43 UTC

function myLocalScope() {
'use strict';

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

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

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

Chris
@Bitcross
Jul 16 2016 04:43 UTC
three of the lowercase tilde key, the key beside the 1
Jerzz
@2cool4school
Jul 16 2016 04:43 UTC

// 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][prop] = value;
  } else if (prop=="tracks" && id.tracks===undefined) {
    collection[id].tracks = [];
    collection[id].tracks.push(value);
  } else if (prop=="tracks" && value!=="") {
    collection[id].tracks.push(value);
  } else if (value==="") {
    delete collection[id][prop];
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
can someone tell me why two of my ex. inputs wont work
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.
After updateRecords(2548, "tracks", ""), tracks should not be set
LordYamanouchi
@LordYamanouchi
Jul 16 2016 05:04 UTC
I don't really get how this works.
var expression = /\d+/g;
DJ
@qualitymanifest
Jul 16 2016 05:05 UTC
@LordYamanouchi regexone.com
LordYamanouchi
@LordYamanouchi
Jul 16 2016 05:05 UTC
@qualitymanifest Thanks !
CamperBot
@camperbot
Jul 16 2016 05:05 UTC
lordyamanouchi sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1278 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Vercaelus
@Vercaelus
Jul 16 2016 05:31 UTC
Has anyone here completed the "Seek and Destroy" bonfire? It's proving to be quite a problem for me
DJ
@qualitymanifest
Jul 16 2016 05:34 UTC
@Vercaelus plenty of people have... it's more helpful to ask a specific question. are you having problems with the arguments object or...?
basically all im saying is dont ask to ask, just ask, and be specific
Vercaelus
@Vercaelus
Jul 16 2016 05:36 UTC
Gotcha, I'll keep that in mind, thanks for the heads up. No, the arguments object is understandable (it was a hardcore curveball though). My issue is that I cant seem to figure out how to iterate the .filter() on the first array element
Kevin
@KevinBruland
Jul 16 2016 05:37 UTC
@Vercaelus filter is a bit confusing at first, I think when I did it I originally just used 2 for loops
DJ
@qualitymanifest
Jul 16 2016 05:37 UTC
@Vercaelus do you already have all the other arguments (besides the first one, which is arr), in a real array?
Vercaelus
@Vercaelus
Jul 16 2016 05:37 UTC
yes, I used Array.from();
Kevin
@KevinBruland
Jul 16 2016 05:38 UTC
@Vercaelus I would go through and read the entire .filter page at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter if you have not yet
Vercaelus
@Vercaelus
Jul 16 2016 05:39 UTC
@Benalron I actually already tried to use 2 for loops, to no avail. Most of these problems have been a non-issue, this is the only one that's caused me any grief
Kevin
@KevinBruland
Jul 16 2016 05:39 UTC
@Vercaelus sure, can I see your code?
Vercaelus
@Vercaelus
Jul 16 2016 05:40 UTC
Absolutely. Is there an easy way to share, or is it copy-paste?
DJ
@qualitymanifest
Jul 16 2016 05:40 UTC
@Vercaelus cool. so you want to run a filter on arr (arr.filter....) and return true if the additional arguments are not in arr, false otherwise. returning false removes the element
copy-paste is good, better if you format it
Vercaelus
@Vercaelus
Jul 16 2016 05:41 UTC
Got it
Kevin
@KevinBruland
Jul 16 2016 05:41 UTC
help format
CamperBot
@camperbot
Jul 16 2016 05:41 UTC

: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

Vercaelus
@Vercaelus
Jul 16 2016 05:43 UTC
function destroyer(arr) {
  // Remove all the values

  //var iterations = arr[0].length;
  var newArr = Array.from(arr);
  var finalArr = newArr[0].splice();

  function filter(a, b){
    return a !== b;
  }


  for(var i = 1;i<newArr.length;i++){

    //finalArr = finalArr.filter(fil(val, newArr[i]));
    finalArr.forEach
    /*
    for(var x = newArr[0].length-1;x >= 0;x--){
      if(newArr[x] === newArr[i]){
        newArr.splice(x,1);
        console.log(newArr);
      }
      */
    }


    /*
    for(var x = 0;x<iterations;x++){
      if(newArr[x] === arr[i]){
        newArr.splice(x,1);
      }
    }
    */
  }

  return newArr[0];
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Kevin
@KevinBruland
Jul 16 2016 05:43 UTC
there we go
Vercaelus
@Vercaelus
Jul 16 2016 05:43 UTC
I mutilated the code trying different solutions, by the way
DJ
@qualitymanifest
Jul 16 2016 05:44 UTC
@Vercaelus something to be aware of is that .filter runs a loop on the array it's called upon (in this case, arr) so no additional loops are needed.
Kevin
@KevinBruland
Jul 16 2016 05:44 UTC
the thing is there, youre not targeting the actual array in the arguments I believe
I could be wrong, I have not used array.from();
fauzankadri
@fauzankadri
Jul 16 2016 05:44 UTC
im doing the intermediate algorithm scripting challenge "Everything Be True". However Im not understanding the question. I thought it was asking to check if the key exists in each object but some cases have keys yet its suppose to return false. any help?
DJ
@qualitymanifest
Jul 16 2016 05:45 UTC
@Vercaelus here's an example. this filter function doesn't do anything, it just shows you that the parameter el represents each part of arr https://repl.it/Cc9i
Vercaelus
@Vercaelus
Jul 16 2016 05:45 UTC
@qualitymanifest yes, I thought that was the case :) However, I need to iterate over the initial array multiple times, in relation to how many numbers need "destroying"
@Benalron Array.from(); creates a real array from an argument object, so that it indexes all of its values like a normal array
Kevin
@KevinBruland
Jul 16 2016 05:48 UTC
ah OK, that makes sense
when I did it I just used arguments[0] to get the initial array, and then did a for loop with arguments.length to use the remaining individual numbers
with the for loop starting at 1 instead of 0, but if array from works like that... seems like its fine
DJ
@qualitymanifest
Jul 16 2016 05:50 UTC
@Vercaelus arr already is a proper array. arguments will give you an array-like object of all the arguments passed into your function. you're running Array.from() on the wrong thing
Jaren Escueta
@jarenescueta731
Jul 16 2016 05:50 UTC
@fauzankadri it's asking you to check the "truthy-ness" of the value. so not just checking for "false", but also values like NaN, undefined, 0, etc...
DJ
@qualitymanifest
Jul 16 2016 05:51 UTC
what i mean by "array-like" is that it looks like an array but you can't do much with it. so you want to convert arguments to a real array. hence the Array.from
Kevin
@KevinBruland
Jul 16 2016 05:51 UTC
@Vercaelus yeah... if you delete everything and just return arr... the only thing it returns is the array that is within the arguments
@Vercaelus as that is the one variable being taken in... I think you need to use "arguments" in order to target the remaining items being sent in
Vercaelus
@Vercaelus
Jul 16 2016 05:53 UTC
Let me try out y'alls suggestions, and see what I come up with
fauzankadri
@fauzankadri
Jul 16 2016 05:54 UTC
@jarenescueta731 thank you :)
CamperBot
@camperbot
Jul 16 2016 05:54 UTC
fauzankadri sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Vercaelus
@Vercaelus
Jul 16 2016 05:55 UTC
@Benalron @qualitymanifest This is what I have now, which is 40% correct;
function destroyer(arr) {
  // Remove all the values

  //var iterations = arr[0].length;
  var newArr = arr.slice();
  var destroyArr = Array.from(arguments);

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

    newArr = newArr.filter(function(val){
      return val !== newArr[i];
    });
  }

  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Woops, I fordot to change the comparison array to "destroyArr". After doing so, I completed the bonfire!
@Benalron thanks!
CamperBot
@camperbot
Jul 16 2016 05:57 UTC
vercaelus sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @benalron |http://www.freecodecamp.com/benalron
Kevin
@KevinBruland
Jul 16 2016 05:57 UTC
@Vercaelus NP, congratulations
Vercaelus
@Vercaelus
Jul 16 2016 05:57 UTC
@qualitymanifest thanks!
CamperBot
@camperbot
Jul 16 2016 05:57 UTC
vercaelus sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1279 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Kevin
@KevinBruland
Jul 16 2016 05:57 UTC
@Vercaelus ill show you mine for the sake of seeing arguments usage
it's not at all how I would do it now, but it works
Vercaelus
@Vercaelus
Jul 16 2016 05:58 UTC
I would enjoy seeing the comparison
Kevin
@KevinBruland
Jul 16 2016 05:58 UTC
function destroyer(arr) {
  for (x=0; x<arguments[0].length; x++){
    for (y=1; y<arguments.length; y++){
      if (arguments[0][x] === arguments[y]){
        delete arguments[0][x];
      }
    }
  }
  arr = arr.filter(Boolean);
  return arr;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
it was sloppy looking back at it
I just went through and deleted the item, which left a null in place which I filtered out later
Vercaelus
@Vercaelus
Jul 16 2016 05:59 UTC
To be honest, I cant even read it lol. But if it works, it works
Kevin
@KevinBruland
Jul 16 2016 05:59 UTC
but you can see how I used arguments[x] in the loop to check each individual argument
Vercaelus
@Vercaelus
Jul 16 2016 06:00 UTC
Ah, right
Kevin
@KevinBruland
Jul 16 2016 06:00 UTC
you can target them like elements in an array, so arguments [0] is the first argument, arguments1 is the second, etc
Vercaelus
@Vercaelus
Jul 16 2016 06:01 UTC
Do y'all know why it estimates a 50 hour completion time on the bonfires? I'm 2 away from being finished, and its taken me about 3 hours...
Markus Kiili
@Masd925
Jul 16 2016 06:01 UTC
@Vercaelus For a beginner it might take 50 hours or more.
Kevin
@KevinBruland
Jul 16 2016 06:01 UTC
it varies a LOT for people, I think 50 hours is a very conservative estimate to people do not feel like they are going too slow or rush through them
kind of lets people relax and take their time learning stuff instead of powering through them
Ayush Kenhi
@AyushKenhi
Jul 16 2016 06:02 UTC
How is my site looking - www.blahbah.hol.es
Vercaelus
@Vercaelus
Jul 16 2016 06:02 UTC
Ah, gotcha. I forget that some people actually have lives lol.
Markus Kiili
@Masd925
Jul 16 2016 06:02 UTC
@Benalron Your code has a problem if there are zeroes on arr.
Kevin
@KevinBruland
Jul 16 2016 06:04 UTC
@Masd925 would it?
@Masd925 oh right, because 0 is false with boolean, good point
Ayush Kenhi
@AyushKenhi
Jul 16 2016 06:12 UTC
Whats wrong here
why so inactive?
wowcallmia
@wowcallmia
Jul 16 2016 06:12 UTC
turning multiple variables into a return object help
Markus Kiili
@Masd925
Jul 16 2016 06:19 UTC
@AyushKenhi These hours are usually slow.
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:19 UTC
Need some expert review on the code for "Seek and Destroy" below. I've presented Option1 and Option2. Option1 eliminates the warning "Don't make function within loop" in Option2. Are there any other more elegant solutions?
function destroyer(arr) {
  // Remove all the values
  //alert (arguments[1]);
  var args = Array.prototype.slice.call(arguments);
  args.splice(0,1); 

  var isNotInList = function (list, val) {
    return list.indexOf(val) == -1; 
  };

  var result =[]; 

  /* OPTION 1 */
  result = arr.filter (function (elem) {
    return isNotInList (args, elem);
  });

  /* OPTION 2 */ 
  for (var x = 0; x < args.length; x++) {
    result = arr.filter (function (elem) { return elem != args[x]; });
    arr = result; 
  }


  return result; 

}
Markus Kiili
@Masd925
Jul 16 2016 06:21 UTC
This message was deleted
@kgashok You can tidy it up like this:
function destroyer(arr) {
  args = Array.prototype.slice.call(arguments,1);
  return arr.filter(function(val) {
    return args.indexOf(val)===-1;
  });
}
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:23 UTC
Thanks much @Masd925
CamperBot
@camperbot
Jul 16 2016 06:23 UTC
kgashok sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2128 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 16 2016 06:23 UTC
Your second solution is not that good because it filters arr many times.
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:24 UTC
@Masd925 if for some reason I needed to keep the for loop, how do I "move" the function out of the loop?
Markus Kiili
@Masd925
Jul 16 2016 06:24 UTC
@kgashok You can loop the arguments inside the filter callback.
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:25 UTC
@Masd925 I've tried that, but I don't seem to get it. Please provide the actual code...
Robert Currie Owusu Afari
@RC31
Jul 16 2016 06:28 UTC
Good morning
can someone help me out with this
Markus Kiili
@Masd925
Jul 16 2016 06:28 UTC
@kgashok
Robert Currie Owusu Afari
@RC31
Jul 16 2016 06:28 UTC

Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Markus Kiili
@Masd925
Jul 16 2016 06:28 UTC
Something like this would work:
function destroyer(arr) {
    return arr.filter(function(elem){
        for (var i=1;i<this.length;i++) {
            if (this[i]===elem) return false;
        }
        return true;
    },arguments);
}
Robert Currie Owusu Afari
@RC31
Jul 16 2016 06:29 UTC
this is my solution to the : var myStr= "\t \t \r \n \";
Markus Kiili
@Masd925
Jul 16 2016 06:29 UTC
Another way is to store arguments into a variable and use it inside the callback (filter callback has its own arguments object).
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:30 UTC
@Masd925 So, basically move the loop inside the function! Nice!
@Masd925 Please provide that code option as well (storing arguments into a variable).
Markus Kiili
@Masd925
Jul 16 2016 06:32 UTC
```
function destroyer(arr) {
    var args = arguments;
    return arr.filter(function(elem){
        for (var i=1;i<args.length;i++) {
            if (args[i]===elem) return false;
        }
        return true;
    });
}
llamatarianism
@llamatarianism
Jul 16 2016 06:33 UTC
well if we're just giving away solutions
may I offer my more ES6y version
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:33 UTC
@llamatarianism for the record, I did come up with "inelegant" solutions already. Yes, please the ES6y version!
llamatarianism
@llamatarianism
Jul 16 2016 06:33 UTC
function destroyer(arr, ...args) {
  return arr.filter(elem => !args.includes(elem))
}
ought to work
looks like it does
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:35 UTC
@llamatarianism that's the shortest solution for this I've seen if it does work
llamatarianism
@llamatarianism
Jul 16 2016 06:35 UTC
oh, I can golf it harder
just by messing up the names
d=(a,...r)=>a.filter(e=>!r.includes(e))
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:36 UTC
function destroyer(arr) {
    var args = Array.prototype.slice.call(arguments);
    return arr.filter(elem => args.indexOf(elem) === -1);

}
took me forever to understand this challenge
Markus Kiili
@Masd925
Jul 16 2016 06:37 UTC
@no-stack-dub-sack It can also be done without the array:
llamatarianism
@llamatarianism
Jul 16 2016 06:37 UTC
it's a shame there's no built-in inverse of filter
Markus Kiili
@Masd925
Jul 16 2016 06:37 UTC
function destroyer(arr) {
  return arr.filter(function(val) {
    return Array.prototype.indexOf.call(this,val,1)===-1;
  },arguments);
}
llamatarianism
@llamatarianism
Jul 16 2016 06:37 UTC
like reject
that'd save me a byte
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:38 UTC
@llamatarianism It works! But I get the warning "use esversion:6" - where do I specify that?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:38 UTC
@Masd925 so many solutions!
@kgashok if it works, don't worry about the warning. as long as it lets you pass
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:38 UTC
@no-stack-dub-sack just curious...
llamatarianism
@llamatarianism
Jul 16 2016 06:39 UTC
@kgashok in a comment
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:39 UTC
@no-stack-dub-sack it is the "warnings" that got me to ask on this gitter room...
llamatarianism
@llamatarianism
Jul 16 2016 06:39 UTC
// jshint esversion:6
don't worry, it's not a proper error
it's just the linter saying hey, you need to tell me if you're gonna use ES6 stuff.
because what if someone was using ES6 features by accident when they were developing for something that only has support for ES5?
the linter would have to tell them
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:40 UTC
@kgashok ES6 is essentially just the latest standard of javacript that hasn't quite been adopted ubiquitously yet if I understand correctly
has some new features that aren't yet supported by everything
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:41 UTC
Thanks much @no-stack-dub-sack @llamatarianism @Masd925
JS and its options are truly MIND BOGGLING!
CamperBot
@camperbot
Jul 16 2016 06:41 UTC
kgashok sends brownie points to @no-stack-dub-sack and @llamatarianism and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 996 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:cookie: 289 | @no-stack-dub-sack |http://www.freecodecamp.com/no-stack-dub-sack
:warning: kgashok already gave masd925 points
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:44 UTC
@llamatarianism There's a lot of merit to your suggestion for a reject function.
llamatarianism
@llamatarianism
Jul 16 2016 06:44 UTC
shrug. there's more important stuff they need to implement.
notably, there's no flatMap or xWhile functions (e.g. takeWhile, reduceWhile)
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:45 UTC
:smile:
wowcallmia
@wowcallmia
Jul 16 2016 06:45 UTC


    console.log(("Letters: " + letterCount), "Character count: " + charCount, "Word count: " + wordCount, "Whitespace count: " + whiteSpace, "Word length average: " + avgLen);
};
how can i put all those strings into one object output thank you
llamatarianism
@llamatarianism
Jul 16 2016 06:45 UTC
and none of the reducers are implemented on generators
which means you can't map or filter an unending sequence
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:46 UTC
has anyone in here right now built the twitch app? I'm having a little snafu that I could use a tip on...
llamatarianism
@llamatarianism
Jul 16 2016 06:47 UTC
@no-stack-dub-sack yes
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:48 UTC
@llamatarianism I'm having trouble iterating over the JSON data to get the information I need converted to html. I'm not having trouble accessing the info, but writing a forEach loop that won't cause the html to be written over by the previous piece of data
llamatarianism
@llamatarianism
Jul 16 2016 06:48 UTC
@no-stack-dub-sack show me what you got
Faisal Zulfiqar
@faisal-zulfiqar
Jul 16 2016 06:49 UTC
@Masd925 can you tell me how this code of yours work? The call function? :(
function destroyer(arr) {
  return arr.filter(function(val) {
    return Array.prototype.indexOf.call(this,val,1)===-1;
  },arguments);
llamatarianism
@llamatarianism
Jul 16 2016 06:49 UTC
@faisal1337 the array functions are pretty generic
they work on things that aren't arrays, but are similar to arrays
so you can do stuff like
Array.prototype.indexOf.call(arguments)
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:50 UTC
@llamatarianism it's in early stages and sort of a mess right now, I deleted the forEach because it wasn't working but see line 11, that's where I was trying to put it.
http://codepen.io/no_stack_dub_sack/pen/XKVxLJ?editors=0010
llamatarianism
@llamatarianism
Jul 16 2016 06:50 UTC
^ arguments isn't an array, but it's similar enough to one that you can use an array method on it
and in order to use an array method on it
you need to use .call
because that's just how you use methods of data structures on different data structures.
Faisal Zulfiqar
@faisal-zulfiqar
Jul 16 2016 06:51 UTC
Ahan
llamatarianism
@llamatarianism
Jul 16 2016 06:52 UTC
@no-stack-dub-sack why would you use a forEach?
none of the data returned is an array
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:52 UTC
@llamatarianism to get the data for each of the users?
llamatarianism
@llamatarianism
Jul 16 2016 06:52 UTC
that's what your for loop is doing
if you uncomment the console.log(data) bit
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:53 UTC
it's logging fine within the loop, but if I run that as is, the data gets written over by the next iteration
llamatarianism
@llamatarianism
Jul 16 2016 06:53 UTC
you'll see that it is getting data for each of the users
Faisal Zulfiqar
@faisal-zulfiqar
Jul 16 2016 06:53 UTC
@llamatarianism and what does 'this' 'val' and 1 are doing right here?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:53 UTC
@llamatarianism right, but now printing it into the document is what I'm having trouble with
Faisal Zulfiqar
@faisal-zulfiqar
Jul 16 2016 06:53 UTC
Actually I was working on my solution and I am using nested for loops but still I can't get it to work. Thought that it would be better to understand this .
llamatarianism
@llamatarianism
Jul 16 2016 06:54 UTC
@no-stack-dub-sack what's the issue? just use something like .append
@faisal1337 frankly I have no idea what the 1 is doing
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:54 UTC
I know the data is there though... I did this in a weird roundabout way with the wiki viewer, but that only worked because i knew the array has 10 indexes.
llamatarianism
@llamatarianism
Jul 16 2016 06:54 UTC
this is equal to arguments inside that filter function
cuz it got passed as the thisArg to filter -> documentation
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:55 UTC
I had 10 divs all set up to push into, but this one is unknown. ok, I will try that
llamatarianism
@llamatarianism
Jul 16 2016 06:55 UTC
and val is an item in the array
Robert Currie Owusu Afari
@RC31
Jul 16 2016 06:55 UTC
what does it mean to say a variable should have encoded text with the proper escape sequences and no spacing.
llamatarianism
@llamatarianism
Jul 16 2016 06:55 UTC
@no-stack-dub-sack what would be helpful is
if you actually showed me what you did that broke it
cuz I don't actually know what the problem is
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:56 UTC
@llamatarianism well nothing broke the fetching of the data, that's always been working fine. Hang tight, let me try this append thing. Nothing was breaking, i just couldn't get the forEach to work but apparently that's not what I need anyway
llamatarianism
@llamatarianism
Jul 16 2016 06:57 UTC
@no-stack-dub-sack a forEach of what?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:59 UTC
@llamatarianism never mind, I didn't know about append and that totally solved my problem. and now I feel silly, I should have asked for help earlier. I just spent an hour trying to work something out that didn't need working out. Thanks!
CamperBot
@camperbot
Jul 16 2016 06:59 UTC
no-stack-dub-sack sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 998 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:59 UTC
@llamatarianism I'm totally new to programming if you couldn't tell, every day learning a hundred new things
.append would probably have solved a bunch of problems in my last project too. Although it came out alright. You can see here though the silly way I got around it with the 10 already programmed in divs with unique ID's.
http://codepen.io/no_stack_dub_sack/full/akLkZP/
llamatarianism
@llamatarianism
Jul 16 2016 07:02 UTC
sweet baby jesus
welp
you can always go back and rewrite stuff
and inevitably cringe at your old code
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:12 UTC
@llamatarianism haha ok, I'll check it out. Yeah, I'll def go back and re-write this eventually, it's funny because on the surface I'm very happy with it, but as I go further along and look back at old code, I realize how many improvements can be made - but that won't change the appearance at all! What's underneath the hood is what really counts.
I like the look of the codepen one better, but yeah, doesn't seem to work
llamatarianism
@llamatarianism
Jul 16 2016 07:14 UTC
yeah I noticed I forgot to add the colours
just a second
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:15 UTC
how long have you been programming for? before FCC just with other languages I'm guessing?
llamatarianism
@llamatarianism
Jul 16 2016 07:15 UTC
@no-stack-dub-sack colours
not much
a few months
I just have absolutely nothing going on
afani martin
@whiz25
Jul 16 2016 07:15 UTC
Who can spot the prop with this /////
var checkObj = function(checkProp) {
// Your Code Here
checkProp = myObj;
var checkObj = myObj[checkProp];
return "Change Me!";
}; it is checking obj prop challenge.
llamatarianism
@llamatarianism
Jul 16 2016 07:15 UTC
I did all of the non-horrible language courses on codecademy before going to freecodecamp
so, not php or java
This message was deleted
This message was deleted
This message was deleted
actually nevermind every single line of that is kind of a problem.
1 sec
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:16 UTC
@llamatarianism gotcha, yeah, I have a full time job so trying to fit this in at least 4 hour a day but doesn't always work out.
You seem to be well on your way though
def looks nicer with the colors!
llamatarianism
@llamatarianism
Jul 16 2016 07:17 UTC
checkProp = myObj; // now you're going to be trying to find the property of `myObj` that is equal to itself, which is impossible.
var checkObj = myObj[checkProp] // this would work if you hadn't changed `checkProp`
return "Change Me!"; // you're supposed to change this. change it so it returns `myObj[checkProp]`.
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:17 UTC
im 3 months in about, zero prior experience
llamatarianism
@llamatarianism
Jul 16 2016 07:18 UTC
I'm probably about the same, but in terms of hours, I've probably had more experience
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:22 UTC
yup, and thats what counts. How far along in the fcc curriculum are you? do you intend to see it all the way through?
llamatarianism
@llamatarianism
Jul 16 2016 07:24 UTC
I've done the front end stuff and some of the back end stuff
though I half assed a lot of the front end projects
including full-assing them, then going back and finding neat ways to half-ass them
I don't really feel like finishing it though
I'd rather just make my own stuff when I feel like it
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:29 UTC
Hi
Anyone for help on this
var myStr; // Change this line
myStr = 'Firstline\n \SecondLine\ \rThirdline';
I cant seem to address what I am doing wrong
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:31 UTC
@llamatarianism fair enough... is the plan a coding job eventually or not really?
llamatarianism
@llamatarianism
Jul 16 2016 07:31 UTC
@no-stack-dub-sack probably
but I'm 15 so that's a while away
@DKSukhani
var myStr = 'Firstline\n \\SecondLine\ \rThirdline';
//                                   ^ you didn't escape this one
also
you're not supposed to have spaces between them
also
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:32 UTC
@llamatarianism cool, well good luck, I'm sure I'll see you around here - unless of course it day where you are and not 4 in the morning
llamatarianism
@llamatarianism
Jul 16 2016 07:32 UTC
it should be FirstLine and ThirdLine
@no-stack-dub-sack 8:32 am over here
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:33 UTC
ha! that explains why your handle doesnt seem familiar!
its 4am on friday night and I'm coding... .sheeesh. Anyway, thanks again for the help.
llamatarianism
@llamatarianism
Jul 16 2016 07:34 UTC
seeya
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:35 UTC
@llamatarianism Seems did not work
llamatarianism
@llamatarianism
Jul 16 2016 07:35 UTC
@DKSukhani if you followed all my advice it should work
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:36 UTC
myStr= "FirstLine\n\SecondLine\rThirdLine"
like this?
"FirstLine\n\SecondLine\rThirdLine"
double slash is disappearing
for some reason
llamatarianism
@llamatarianism
Jul 16 2016 07:37 UTC
`put your code between backticks when you post it in here`
then the backslashes will show up
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:37 UTC
'"FirstLine\n\SecondLine\rThirdLine"'
llamatarianism
@llamatarianism
Jul 16 2016 07:37 UTC
`\\` -> \\
no, backticks, not quotes
` != '
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:37 UTC
\ "FirstLine\n\SecondLine\rThirdLine" \
llamatarianism
@llamatarianism
Jul 16 2016 07:38 UTC
they're to the left of the 1 key
above tab
Cal-culator
@Cal-culator
Jul 16 2016 07:38 UTC

can anyone tell me what is wrong with this
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][prop]=value;
}
else if (prop ==="tracks" && id.tracks===undefined){
collection[id].tracks=[];
collection[id].tracks.push(value);
}
else if (prop==="tracks" && id.tracks!=="" && value!==""){
collection[id].tracks.push(value);
}
else if (value===""){
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
updateRecords(2548, "tracks", "Free");

Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:38 UTC
ya one seco
"FirstLine\n\SecondLine\\rThirdLine"
llamatarianism
@llamatarianism
Jul 16 2016 07:39 UTC
you still haven't escaped everything properly
afani martin
@whiz25
Jul 16 2016 07:39 UTC
That doesn't solve the prob @llamatarianism
llamatarianism
@llamatarianism
Jul 16 2016 07:39 UTC
you've got a newline, \S (which is invalid), a backslash, then an r
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:40 UTC
ok one sec - let me try
Jack Lyons
@JackEdwardLyons
Jul 16 2016 07:41 UTC
@JackEdwardLyons
hey guys, i have a question -- how do you split an array into arrays?
like this
 ['a', 'b', 'c']  convert to
[['a'],['b'],[c']]
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:41 UTC
"FirstLine\n\\SecondLine\rThirdLine"
llamatarianism
@llamatarianism
Jul 16 2016 07:42 UTC
you've escaped the first backslash correctly
but there needs to be a backslash before the carriage return (\r)
@JackEdwardLyons
const arr = [1, 2, 3];
arr.map(x => [x])
// -> [[1], [2], [3]]
though I'm not sure why you'd want to do that
Jack Lyons
@JackEdwardLyons
Jul 16 2016 07:43 UTC
ah cool
thanks @llamatarianism :)
CamperBot
@camperbot
Jul 16 2016 07:43 UTC
jackedwardlyons sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 999 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Cal-culator
@Cal-culator
Jul 16 2016 07:43 UTC
can anyone help me
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][prop]=value;
}
else if (prop ==="tracks" && id.tracks===undefined){
collection[id].tracks=[];
collection[id].tracks.push(value);
}
else if (prop==="tracks" && id.tracks!=="" && value!==""){
collection[id].tracks.push(value);
}
else if (value===""){
delete collection[id][prop];
}
return collection;
}
whats wrong with this
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:43 UTC
Got it @llamatarianism
Thanks for that hint that I was not escaping
llamatarianism
@llamatarianism
Jul 16 2016 07:44 UTC
@Cal-culator id.tracks is undefined
id is just a number
it has no "tracks" property
I think you want collection[id].tracks
Cal-culator
@Cal-culator
Jul 16 2016 07:44 UTC
ah ok
Robert Currie Owusu Afari
@RC31
Jul 16 2016 07:54 UTC
@DKSukhani can you explain it to me
this was my solution
myStr="\n\\r\"
Randy Goldsmith
@Dueldrawer8
Jul 16 2016 07:54 UTC
whenever you use blockquote tag.. is there anyway to change the color of the marking on the left hand side of text.. see my codepen to see what i mean
http://codepen.io/duel_drawer8/pen/WxdGzj/
Meet Mangukiya
@meetmangukiya
Jul 16 2016 07:59 UTC

for a json object

{
   "key": "value"
}

and

{
    key: "value"
}

produces same result

how do I use a variable's content as key then?
@meetmangukiya you parse it back into a js object, JSON.parse()
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:03 UTC
@hnry sorry I didn't get it
can you write the code and send?
Randy Goldsmith
@Dueldrawer8
Jul 16 2016 08:05 UTC
anyone?
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:05 UTC
do you mean
var a = JSON.parse({key: "value"});
@meetmangukiya is it actually json? because your example doesn't show that it is
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:06 UTC
@hnry it looks like the example one, and I think it is json
@meetmangukiya ok thats not json, that's just a regular object
@meetmangukiya
var a = {
  "key": "value"
}
console.log(a.key) // => "value"
@meetmangukiya makes no difference if it's "key" or key
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:07 UTC
yeah, thats the problem
The key is a variable
@meetmangukiya i don't get what you are asking
what is the actual problem? can you show a real example that shows the problem you are talking about?
llamatarianism
@llamatarianism
Jul 16 2016 08:08 UTC
{ key: "value" } and { "key": "value" } are 100% identical
the 1st one is just syntactic sugar for the 2nd one
it is not a variable
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:09 UTC
its like
var a = "foo";
var b = "bar";
var c = {a: b};
console.log(c) // => {a: bar} , I expect {foo: bar}
llamatarianism
@llamatarianism
Jul 16 2016 08:09 UTC
there's a way to do that
the ES5 version:
var c = {};
c[a] = b;
the ES6 version:
var c = { [a]: b };
Alexander Køpke
@alexanderkopke
Jul 16 2016 08:10 UTC
@Dueldrawer8 you can use css to change blockquote{border-left: 5px solid color;}
llamatarianism
@llamatarianism
Jul 16 2016 08:10 UTC
the [] makes it evaluate the variable
instead of treating it as a string
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:10 UTC
I tried () but not [], I thought () is used in evaluation
llamatarianism
@llamatarianism
Jul 16 2016 08:11 UTC
shrug.
javascript has a complicated syntax.
you want something that makes sense, go write lisp :P
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:11 UTC
I never tried lisp
anyways thanks @llamatarianism
CamperBot
@camperbot
Jul 16 2016 08:11 UTC
meetmangukiya sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1000 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Alexander Køpke
@alexanderkopke
Jul 16 2016 08:12 UTC
how is the market for lisp?
llamatarianism
@llamatarianism
Jul 16 2016 08:12 UTC
everything's really simple because everything is a lisp
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:12 UTC
come on lisp is supposed to one the harder languages to master @llamatarianism
llamatarianism
@llamatarianism
Jul 16 2016 08:12 UTC
@alexanderkopke clojure is actually quite popular nowadays
@Rud156 it really isn't
gimme a few seconds
Alexander Køpke
@alexanderkopke
Jul 16 2016 08:13 UTC
heard good things about clojure.. like that it makes you a better coder
llamatarianism
@llamatarianism
Jul 16 2016 08:13 UTC
(+ 1 2)
'(1 2)
'(1 . 2)
`(,@(list 1 2 3))
there, that's like, the entire syntax of most lisps.
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:13 UTC
can't understand a thing
first line probably adds the numbers
llamatarianism
@llamatarianism
Jul 16 2016 08:14 UTC
@Rud156 that's because a good 50% of that just consists of a DSL for macros
and 90% of lisp code just looks like the 1st line: (+ 1 2)
that first line accounts for most of the language's syntax.
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:14 UTC
Has anyone tried their hands on building a chrome extension?
Ghost
@ghost~56a80c91e610378809be5d28
Jul 16 2016 08:14 UTC
@llamatarianism go to bed that's an order sir llama :point_right:
llamatarianism
@llamatarianism
Jul 16 2016 08:14 UTC
clojure is more complex because it has a lot of data structure literals.
:keyword
["this" "is" "a" "vector"]
{:hash "map"}
#{:hash :set}
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:14 UTC
How do we store data using just js?
llamatarianism
@llamatarianism
Jul 16 2016 08:15 UTC
@evan153 :gun:
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:15 UTC
@meetmangukiya what do you mean by store??
llamatarianism
@llamatarianism
Jul 16 2016 08:15 UTC
but yeah, lisps are the definition of simple.
just lists.
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:15 UTC
@llamatarianism I'll be sure to check it out. Any specific resources I should see??
llamatarianism
@llamatarianism
Jul 16 2016 08:16 UTC
(define (map fun lst)
  (if (null? lst)
      '()
      (cons (fun (car lst)) (map fun (cdr lst)))))
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:16 UTC
@Rud156 you need to store user configs and all, right. In my case, am just making a simple app that is supposed to write the title and url of the current tab somewhere
llamatarianism
@llamatarianism
Jul 16 2016 08:16 UTC
@Rud156 the little schemer is good for learning scheme. practical common lisp is good for clisp. clojure for the brave and true is good for clojure.
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:17 UTC
@meetmangukiya you can use the local storage and store data
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:17 UTC
@Rud156 I just thought about using an array, but it is temperory, as long as the browser is not closed, then its all gone
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:17 UTC
using local storage will keep the data permanantly
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:18 UTC
@Rud156 yeah, the question is how?
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:18 UTC
just search for localStorage in javascript on google
llamatarianism
@llamatarianism
Jul 16 2016 08:19 UTC

that example above was in scheme. this is common lisp:

(defun map (fun lst)
  (if (null lst)
      nil
      (cons (funcall fun (first lst)) (map fun (rest lst)))))

this is clojure:

(defn map [fun lst]
  (if (empty? lst)
      '()
      (cons (fun (first lst)) (map fun (rest lst)))))
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:20 UTC
@llamatarianism scheme looks good
@meetmangukiya Here's the link: http://www.w3schools.com/html/html5_webstorage.asp
llamatarianism
@llamatarianism
Jul 16 2016 08:21 UTC
^ 99% of the above code is made out of data structure literals
just lists and stuff
the only thing you might not call a data structure literal is '
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:25 UTC
@Rud156 I dont understand how is this useful? There can be so many conflicts
It's like a program with lots of programmer working on the same program, setting various global variables unknown to each other
Cal-culator
@Cal-culator
Jul 16 2016 08:26 UTC

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

// Only change code above this line
}

why does this say TypeError: undefined is not an object
evaluating 'contacts[i]'
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:27 UTC
@Rud156 don't you think the same?
Jerzz
@2cool4school
Jul 16 2016 08:29 UTC
sup guys
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:29 UTC
the variables set in the localstorage are applicable to only one application so it will not conflict even if there are same variable in different webpages. Only your webapp needs to have non conflicting variables @meetmangukiya
Jerzz
@2cool4school
Jul 16 2016 08:30 UTC
i have a logical error that i can't put my finger on..
willfree108
@willfree108
Jul 16 2016 08:31 UTC
@llamatarianism Could you advice me ? I want to learn functionnal programming well and start a with a new language programming, wich one is best to learn the most possible about functionnal programming?
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:32 UTC
@Rud156 ohh.. very well... Is there any method I can loop over all the items in the local storage?
llamatarianism
@llamatarianism
Jul 16 2016 08:33 UTC
@willfree108 if you just wanna learn the most possible? haskell
Cal-culator
@Cal-culator
Jul 16 2016 08:33 UTC
what is it Jerzz
llamatarianism
@llamatarianism
Jul 16 2016 08:33 UTC
haskell is like, the definitive functional language
Cal-culator
@Cal-culator
Jul 16 2016 08:33 UTC
I will try to help if i can
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:34 UTC
@Cal-culator - the problem you have is in while statement
Jerzz
@2cool4school
Jul 16 2016 08:34 UTC

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Cal-culator
@Cal-culator
Jul 16 2016 08:35 UTC
@2cool4school oh. i did the same thing as you at first. id.tracks should be collection[id][tracks]
Jerzz
@2cool4school
Jul 16 2016 08:35 UTC
all the inputs work for my if/else if statements except, updateRecords(2468, "tracks", "Free")
willfree108
@willfree108
Jul 16 2016 08:35 UTC
@llamatarianism alright ty a lot, it's on my cursus too so it make more sense
CamperBot
@camperbot
Jul 16 2016 08:35 UTC
willfree108 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1001 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Jerzz
@2cool4school
Jul 16 2016 08:35 UTC
ive changed this
one minute ill be back
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:35 UTC
for(var i=0; i<localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage[key];
console.log(key + " => " + value);
}
@meetmangukiya
Cal-culator
@Cal-culator
Jul 16 2016 08:35 UTC
@dmitrij-schmidt How do i solve it?
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:36 UTC
@Cal-culator - .length starts always from 1, while indexes start from 0 ;) so in last iteration you are trying to reach non-existent item
simply i < contacts.length i think
Cal-culator
@Cal-culator
Jul 16 2016 08:36 UTC
@dmitrij-schmidt i changed that but the code still doesn't work.
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:36 UTC
alright, let me check it then :)
Jerzz
@2cool4school
Jul 16 2016 08:37 UTC
@Cal-culator I changed all instances to bracket and it gives the same results
Cal-culator
@Cal-culator
Jul 16 2016 08:37 UTC
@2cool4school
id.tracks===undefined should be collection[id][tracks]===undefined
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:37 UTC
@Rud156 How did you determine that localStorage is an array? Assuming I only know that length is a property of an array
Cal-culator
@Cal-culator
Jul 16 2016 08:38 UTC
id is just a number. You need an array for the code to know what exactly you want
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:38 UTC
typeof localStorage returns object
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:39 UTC
@meetmangukiya you can get the length of the items in localstorage. learn't it from a course by w3c on edx.org
Jerzz
@2cool4school
Jul 16 2016 08:39 UTC
@Cal-culator omg thank you i dont know how i didnt catch that inconsistency.. i knew there had to be one i looked at that for far too long to not catch that... thanks man.
CamperBot
@camperbot
Jul 16 2016 08:39 UTC
2cool4school sends brownie points to @cal-culator :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
Jerzz
@2cool4school
Jul 16 2016 08:39 UTC
@2cool4school its like reading your own essay you dont catch the word that you left out thats supposed to be in the sentence... derp
Cal-culator
@Cal-culator
Jul 16 2016 08:40 UTC
@2cool4school
don't thank me. thank llamatarianism. He helped me with that exact same essay.
CamperBot
@camperbot
Jul 16 2016 08:40 UTC
cal-culator sends brownie points to @2cool4school :sparkles: :thumbsup: :sparkles:
:cookie: 211 | @2cool4school |http://www.freecodecamp.com/2cool4school
Cal-culator
@Cal-culator
Jul 16 2016 08:40 UTC
code*
Jerzz
@2cool4school
Jul 16 2016 08:40 UTC
@Cal-culator haha, well it's like paying it forward lol
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:41 UTC
@Cal-culator - try to read about .hasOwnProperty()
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:41 UTC
ok @Rud156 thanks for all the help
CamperBot
@camperbot
Jul 16 2016 08:41 UTC
meetmangukiya sends brownie points to @rud156 :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @rud156 |http://www.freecodecamp.com/rud156
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:41 UTC
:D
Cal-culator
@Cal-culator
Jul 16 2016 08:41 UTC
@dmitrij-schmidt Ah ok. Thanks! I forgot about that. let me try taht
CamperBot
@camperbot
Jul 16 2016 08:41 UTC
cal-culator sends brownie points to @dmitrij-schmidt :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @dmitrij-schmidt |http://www.freecodecamp.com/dmitrij-schmidt
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:44 UTC

@Cal-culator - also try to debug your code in https://repl.it/languages/javascript_web . it's more helpful because it allows to console.log things.

try console.log(contacts[i][j]) in your first if statement ;) it will give you a hint

Cal-culator
@Cal-culator
Jul 16 2016 08:46 UTC
@dmitrij-schmidt I will try that.
Kevin
@KevinBruland
Jul 16 2016 08:48 UTC
im pretty stuck trying to remove leading 0's in a string containing multiple numbers... about an hour in to trying to figure it out if anyone has any thoughts?
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:50 UTC
@Benalron - more info? some case maybe?
Kevin
@KevinBruland
Jul 16 2016 08:51 UTC
@dmitrij-schmidt I think I might have figured it out... general rule of thumb for me is to ask a question here, and I will figure it out 30 seconds later : ]\
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:52 UTC

@Benalron then small gift from me (of course if you don't know it already) - https://regex101.com/#javascript

right down in the middle there's 'substitution' section. really helpful tool

Kevin
@KevinBruland
Jul 16 2016 08:53 UTC
that's useful, thanks @dmitrij-schmidt
CamperBot
@camperbot
Jul 16 2016 08:53 UTC
benalron sends brownie points to @dmitrij-schmidt :sparkles: :thumbsup: :sparkles:
:cookie: 324 | @dmitrij-schmidt |http://www.freecodecamp.com/dmitrij-schmidt
Kevin
@KevinBruland
Jul 16 2016 08:53 UTC
its for the calculator... I noticed a "bug" in almost everyones calculator that is VERY minor, but I could not let slide
Cal-culator
@Cal-culator
Jul 16 2016 08:53 UTC
@dmitrij-schmidt Do i remove the while looping and do it some other way?
Because the loop still goes on even if the contact was found
Pablo
@Olbap14
Jul 16 2016 08:58 UTC

Hi, can someone help me?

This is my code:

 $(document).ready(function() {

   $("#randomBtn").on("click",function(){
     var answer="";
     var random= Math.floor(Math.random() * (3)+1);
     switch(random) {

       case 1:
         answer=['"La mujer es como la polvora, si no la tratas con cuidado, explota"', "Miguel Moyá"];
         break;
       case 2:
         answer= ['"Y los españoles, muy españoles y mucho españoles!!"', "Rajoy"];
         break;
       case 3:
         answer= ['"El mundo esta dividido en tres grandes grupos, el de los que sabe contar, y el de los que no."',"Homer J. Simpson"];}

     $(".message").html(answer[0]);
     $(".name").html(answer[1]);
     var tweet= "https://twitter.com/intent/tweet?text=+";
     answer=answer[0].split(" ");
     answer=answer[0].join("%20");
     tweet+= answer[0];
     tweet+= "%20"+ answer[1];
     console.log(answer);
     $("#tweetBtn").attr("href",tweet);
   });
});

My problem is that $("#tweetBtn").attr("href",tweet); don't work, also I write console.log(answer); for search problems, and console don't print anything

;_(
help please

Rudrangshu Nandi
@Rud156
Jul 16 2016 09:01 UTC
@Olbap14 you don't need to write %20 for each space. It's not necessary. Twitter will do that for you. try directly sending the text
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:01 UTC
it's more about the inside of the loop... read again the task description. inside the loop you have to:
check if firstName is an actual contact's firstName {
    check the given property (prop) is a property of that contact. {
        if so, return that prop
        if not, return 'no such prop'
    }
} if not {
    return 'no such contact'
}
@Cal-culator - sorry - forgot to mention. that part above is for you ;)
Cal-culator
@Cal-culator
Jul 16 2016 09:03 UTC
its ok. :)
i tried adding counterLoop and then entered it in the website you gave me. it works fine. i don't know why it won't work on this platform
@dmitrij-schmidt
Pablo
@Olbap14
Jul 16 2016 09:03 UTC
@Rud156 nice!!
Cal-culator
@Cal-culator
Jul 16 2016 09:04 UTC
Btw, how do you do that. I just copy and paste my code.
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:04 UTC
help format
CamperBot
@camperbot
Jul 16 2016 09:04 UTC

: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

Cal-culator
@Cal-culator
Jul 16 2016 09:06 UTC
@dmitrij-schmidt where is that
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:08 UTC

@Cal-culator - in your case contacts[i] is an object, and seems like it's properties are not enumerated - that way unreachable by contacts[i][j] where j is a number

try to run in repl.it that code below and read logs

var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    }
];

console.log(contacts[0]);
console.log(contacts[0][0]);
console.log(contacts[1]);
console.log(contacts[1][1]);

@Cal-culator as for backticks: you have to put it in chat window like

'''
code
code
code
'''

just replace apostrophes with backticks - the ` marks ;)

CamperBot
@camperbot
Jul 16 2016 09:09 UTC
:bulb: to format code use backticks! ``` more info
Cal-culator
@Cal-culator
Jul 16 2016 09:09 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
var i=0;
  CounterLoop:
while (i<=contacts.length-1){
    if (contacts[i].hasOwnProperty(prop)===false){
      console.log("No such property");
      break CounterLoop;
    }
    else if (contacts[i].hasOwnProperty(prop)===true && contacts[i].firstName===firstName){
      console.log(contacts[i][prop]);
      break CounterLoop;
    }
   else if (firstName===contacts[i][firstName]){
      console.log(contacts[i][firstName]);
      break CounterLoop;
    }
    else if (firstName!==contacts[i][firstName]){
      console.log("No such contact");
      break CounterLoop;
  }
  i++;
}
i changed it to this
@dmitrij-schmidt
it seemed to work in repl.it but not here
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:13 UTC
@Cal-culator am i wrong to see, that it makes only one run of the loop?
Cal-culator
@Cal-culator
Jul 16 2016 09:15 UTC
@dmitrij-schmidt what do you mean?
it is supposed to loop until it finds the contact and firstName
llamatarianism
@llamatarianism
Jul 16 2016 09:15 UTC
@dmitrij-schmidt you are correct
also, there's no reason to use a loop label in this case
you can just use break;
reminder that every time you use a goto, dijkstra kills a puppy
FM
@mafelix
Jul 16 2016 09:16 UTC
hurrrrrrr
Hashir Ahmad
@hash-14
Jul 16 2016 09:17 UTC

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

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

What is the problem in this?

FM
@mafelix
Jul 16 2016 09:17 UTC
ouch
record collection
help record collection
CamperBot
@camperbot
Jul 16 2016 09:17 UTC

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

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

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

For the given id in collection:

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

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

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

FM
@mafelix
Jul 16 2016 09:17 UTC
there you go
Hashir Ahmad
@hash-14
Jul 16 2016 09:17 UTC
Thanks!
Cal-culator
@Cal-culator
Jul 16 2016 09:18 UTC
@dmitrij-schmidt The code works in repl.it
FM
@mafelix
Jul 16 2016 09:18 UTC
@Cal-culator read up on if else statements and breaks
@Cal-culator and see if in what condition/if you need to use break statements to finish this problem
Cal-culator
@Cal-culator
Jul 16 2016 09:18 UTC
@mafelix will do
FM
@mafelix
Jul 16 2016 09:19 UTC
you're breaking after every if else if else statement
now see if your logic works for what the problem is asking for
@Cal-culator and
while(i<=collection.length-1){
can be rewritten to this:
Cal-culator
@Cal-culator
Jul 16 2016 09:20 UTC
@mafelix I did it this way because of my while looping
FM
@mafelix
Jul 16 2016 09:20 UTC
while(i<collection.length){
don't you need to iterate over all the records?
to pass some tests?
you're saying for some of your tests
check if you find ONE thing and break
I don't recall if it's just one thing or not
but I do remember I did not do it this way
you're saying
basket = [apple,orange,baby,zucchini]

if(basket has apple)
#do something
break;
is that what you want?
or do you have to make sure all the items are apples?
Cal-culator
@Cal-culator
Jul 16 2016 09:22 UTC
@mafelix dont i have to do the former?
FM
@mafelix
Jul 16 2016 09:22 UTC
I don't know
you tell me
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:23 UTC
@mafelix, @Cal-culator - there are three possible return points and the logic is like this:
check if firstName is an actual contact's firstName {
    check the given property (prop) is a property of that contact. {
        if so, return that prop
        if not, return 'no such prop'
    }
} if not {
    return 'no such contact'
}
FM
@mafelix
Jul 16 2016 09:23 UTC
is there more than one record in record collection?
Cal-culator
@Cal-culator
Jul 16 2016 09:23 UTC
@dmitrij-schmidt I will comment my current code and try that
FM
@mafelix
Jul 16 2016 09:24 UTC
pseudo code is precious
talk outloud to yourself
and explain your code to yourself
and the problem
don't do it in public places though
because people will think you're crazy
Cal-culator
@Cal-culator
Jul 16 2016 09:25 UTC
@mafelix :)
@dmitrij-schmidt Do I have to loop to check?
FM
@mafelix
Jul 16 2016 09:26 UTC
help record collection
CamperBot
@camperbot
Jul 16 2016 09:26 UTC

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

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

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

For the given id in collection:

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

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

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

Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:26 UTC
@Cal-culator you can make a test on one chosen element from array, or put it inside a loop from the beginning :)
and remember to console.log things inside those ifs, to see what they actually produce
FM
@mafelix
Jul 16 2016 09:28 UTC
If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.
Meet Mangukiya
@meetmangukiya
Jul 16 2016 09:32 UTC
var a = 'https://youtube.com';
a.split(/(\/)|(\.)/); // => ["https:", "/", undefined, "", "/", undefined, "youtube", undefined, ".", "com"]
Can someone explain, why the undefined?
Cal-culator
@Cal-culator
Jul 16 2016 09:33 UTC
if (contacts.hasOwnProperty("firstName")===firstName){
    console.log(firstName);
    if (contacts.hasOwnProperty(prop)===true){
      console.log(prop);
    }
    else if (contacts.hasOwnProperty(prop)===false){
      console.log("No such Property");
    }
  }
  else if (contacts.hasOwnProperty("firstName")!==firstName){
    console.log("No such contact");
  }
doesn't output anything
Tom Cake
@TomCake15
Jul 16 2016 09:34 UTC
Hi, what am I doing wrong in the function?
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
function checkObj(checkProp) {
  if (myObj.hasOwnProperty("checkProp")) {
    return myObj[checkProp_var]; 
  }  
  return  "Not Found";
}
checkObj("gift");
Cal-culator
@Cal-culator
Jul 16 2016 09:35 UTC
@TomCake15 i don't think its checkProp_var
try just
return myObj[checkProp];
Tom Cake
@TomCake15
Jul 16 2016 09:37 UTC
@Cal-culator
thx but still not working. It will not find the properties
CamperBot
@camperbot
Jul 16 2016 09:37 UTC
tomcake15 sends brownie points to @cal-culator :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
Cal-culator
@Cal-culator
Jul 16 2016 09:37 UTC
How about if (myObj.hasOwnProperty(checkProp)===true)
You quoted checkProp but checkProp is not a property
checkProp is a variable in which you assign the actual property
@TomCake15
Tom Cake
@TomCake15
Jul 16 2016 09:39 UTC
@Cal-culator ahah . thank you :) :sparkles:
CamperBot
@camperbot
Jul 16 2016 09:39 UTC
tomcake15 sends brownie points to @cal-culator :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:41 UTC
@Cal-culator - what type of value does .hasOwnProperty() return?
Varun Sharma
@varun29
Jul 16 2016 09:43 UTC

hello everyone....
function reverseString(str) {
var j=0;

for(var i=(str.length)-1 ;i>0;i--){

str[j]=str[(str.length)-1];
j++;

}
return str;
}

reverseString("hello");
can anyone please help me out ..
i want to reverse a given string

Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:43 UTC

@Cal-culator - so far i know it's a boolean, so...

if (contacts.hasOwnProperty("firstName") ===firstName){

in case of success is evaluated as

if (true ===firstName){

which is false :)

Varun Sharma
@varun29
Jul 16 2016 09:45 UTC
can i accept some answer??
expect*
Yan Savidan
@yannniii
Jul 16 2016 09:46 UTC
Hello
can someone help me with the counting cards challenge pls? I can't get it to print the result with the 'if' statement after a "return"
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:48 UTC
@varun29 - you don't need any loop here. please, read those links provided in task description. you have to use .split(), .reverse() and .join() in the right order, that's all ;)
@yannniii - we can try, can you paste code here? formatted with backticks please :)
Varun Sharma
@varun29
Jul 16 2016 09:49 UTC
what if I don't want to use methods and do it all on my own manually ,sir @dmitrij-schmidt
Yan Savidan
@yannniii
Jul 16 2016 09:51 UTC
I don't know how to post code here.... lol such a newbee
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:51 UTC
help format
CamperBot
@camperbot
Jul 16 2016 09:51 UTC

: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

Yan Savidan
@yannniii
Jul 16 2016 09:52 UTC
what is this backticks sign?? can't see it clearly on my screen
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:53 UTC
@yannniii depends on the keyboard you have. probably that mark above Tab button in upper left corner of keyboard
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 09:54 UTC
@varun29
function reverseString(str) {
var str1='';
for(var i=(str.length)-1 ;i>-1;i--){
str1+=str[i];
}
return str1;
}
reverseString("hello");
Yan Savidan
@yannniii
Jul 16 2016 09:54 UTC
using a Macbook air french keyboard
Robert Currie Owusu Afari
@RC31
Jul 16 2016 09:55 UTC
hello
can someone please help me out with this
i am stuck
myStr should have encoded text with the proper escape sequences and no spacing.
var myStr = "\ \t \t \r \n\";\
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:56 UTC
@yannniii check that sign below quote mark
Yan Savidan
@yannniii
Jul 16 2016 09:56 UTC
«««
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:56 UTC
nope :D
Robert Currie Owusu Afari
@RC31
Jul 16 2016 09:56 UTC
this is what i did
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 09:57 UTC
@RC31 read the instructions .I think they have also added some text.
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:58 UTC
@RC31 you have only some marks, but no words in it :)
Varun Sharma
@varun29
Jul 16 2016 09:58 UTC
@UtkarshShukla7 you didn't declare str1 to be an array..
why?
Robert Currie Owusu Afari
@RC31
Jul 16 2016 09:58 UTC
@dmitrij-schmidt

Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

@dmitrij-schmidt
vivek sharma
@Vsharma254
Jul 16 2016 09:59 UTC
hello
Robert Currie Owusu Afari
@RC31
Jul 16 2016 09:59 UTC
and then these are the questions
vivek sharma
@Vsharma254
Jul 16 2016 09:59 UTC
anyone know java script
Robert Currie Owusu Afari
@RC31
Jul 16 2016 09:59 UTC
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
the last 3 has ticked green
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:00 UTC
@varun29 I am just concating the string characters.
vivek sharma
@Vsharma254
Jul 16 2016 10:00 UTC
actually i have worked on the angular js and jquery now i am going mto learn node js
Robert Currie Owusu Afari
@RC31
Jul 16 2016 10:00 UTC
but i have been at the first one for sometime now
@dmitrij-schmidt
vivek sharma
@Vsharma254
Jul 16 2016 10:00 UTC
so i would to know that what topic i should cover to learn node js
Rafael De La Cruz
@leafarafael
Jul 16 2016 10:00 UTC
hey guys I need help for this :D

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

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

// Test Setup
var testArr = [1,2,3,4,5];
nextInLine([5,6,7,8,9],1);

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

Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:01 UTC
@yannniii look for something that looks like an apostrophe on your keyboard, and test them
Rafael De La Cruz
@leafarafael
Jul 16 2016 10:01 UTC
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
the result I get is.....
nextInLine([], 1) should return 1
nextInLine(2, 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr4 should be 10
Before: [2,3,4,5]
2
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:01 UTC
@RC31 but it also says that:
Assign the following three lines of text into the single variable myStr using escape sequences.
FirstLine
\SecondLine\
ThirdLine
Rafael De La Cruz
@leafarafael
Jul 16 2016 10:01 UTC
After:[3,4,5
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:02 UTC
@leafarafael you also have to push the item in the arr
Yan Savidan
@yannniii
Jul 16 2016 10:02 UTC
```this?
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:03 UTC
@RC31 but the ther sequences like this first one
FirstLine\nSecondLine...
Robert Currie Owusu Afari
@RC31
Jul 16 2016 10:04 UTC
@dmitrij-schmidt i tried it too
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:04 UTC
@yannniii yes! put three of them above code, and three below
Varun Sharma
@varun29
Jul 16 2016 10:04 UTC
@UtkarshShukla7 can we just concatenate using + sign
Robert Currie Owusu Afari
@RC31
Jul 16 2016 10:04 UTC
"FirstLine\n\SecondLine\rThirdLine"
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:04 UTC
@varun29 yes
Varun Sharma
@varun29
Jul 16 2016 10:05 UTC
can this be done using array also??
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:05 UTC
@RC31 almost there! just add two escaped backslashes where they are supposed to be
Robert Currie Owusu Afari
@RC31
Jul 16 2016 10:05 UTC
@dmitrij-schmidt ok
Varun Sharma
@varun29
Jul 16 2016 10:05 UTC
can we just take another array and store the reverse of the original one into our new array? @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:05 UTC
@varun29 yes store in it and then join it (but you have to use array method)
Yan Savidan
@yannniii
Jul 16 2016 10:06 UTC
var count = 0;

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

 return count;

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

  }
  else {
    return count + " " + "Bet";
  }
 //Add/remove calls to test your function.
// Note: Only the last will display
}// Note: Only the last will display

  cc(2); cc('J'); cc(9); cc(2); cc(7);
Iuli
@IulianChirvasa
Jul 16 2016 10:06 UTC
what is wrong with my code? it works fine. i don;t understand why isn't accepted

var contor = 1;
var factorial =0;
function factorialize(num) {
for(var i=1;i<=num;i++)
factorial = contor*=i;
if(num === 0){
factorial = 1;
}
return factorial;
}

factorialize(5);

Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:07 UTC
@yannniii - test it here, and try to fix bugs that are shown ;) https://repl.it/languages/javascript_web
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:07 UTC
@yannniii remove return count;
Robert Currie Owusu Afari
@RC31
Jul 16 2016 10:07 UTC
@dmitrij-schmidt \FirstLine\n\SecondLine\rThirdLine\
??
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:08 UTC
@IulianChirvasa don't use global variables .
Iuli
@IulianChirvasa
Jul 16 2016 10:09 UTC
i use global because i can't declare local
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:09 UTC

@RC31 nope.
1)backslashes are escaped by \ - one for escaping, one for backslash
2) try to get output like

FirstLine
\SecondLine\
ThirdLine

see that backslashes are before and after SecondLine?

Robert Currie Owusu Afari
@RC31
Jul 16 2016 10:10 UTC
@dmitrij-schmidt ok
Yan Savidan
@yannniii
Jul 16 2016 10:10 UTC
thx guys, it is always these little quotation marks or extra words that I implement which fxxk up the program
UtkarshShukla7
@UtkarshShukla7
Jul 16 2016 10:10 UTC
@IulianChirvasa but FCC performs many tests on the same function so your global variables values are passed to the next test too
Iuli
@IulianChirvasa
Jul 16 2016 10:11 UTC
@UtkarshShukla7 understand..
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:11 UTC
@yannniii get yourself some code editor with linter. or at least run it trough repl.it or something that will show you some hints ;)
Iuli
@IulianChirvasa
Jul 16 2016 10:15 UTC

function palindrome(str) {
// Good luck!
var splitToString = str.split('');
var reverseString = splitToString.reverse();
if(str === reverseString){
return true;
}
else{
return false;
}
}

palindrome("eye");

tthe problem is when the given string is indeed a palindrome
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:15 UTC
@IulianChirvasa please, format code with backticks, it's easier to read ;)
Iuli
@IulianChirvasa
Jul 16 2016 10:16 UTC
@dmitrij-schmidt how?
Keone Martin
@Athaman
Jul 16 2016 10:16 UTC
help format
CamperBot
@camperbot
Jul 16 2016 10:16 UTC

: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

Keone Martin
@Athaman
Jul 16 2016 10:17 UTC
@IulianChirvasa you need to filter out non letter/number characters and also make the whole string lowercase before comparison
Iuli
@IulianChirvasa
Jul 16 2016 10:18 UTC
@Athaman thanks
CamperBot
@camperbot
Jul 16 2016 10:18 UTC
iulianchirvasa sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 584 | @athaman |http://www.freecodecamp.com/athaman
Keone Martin
@Athaman
Jul 16 2016 10:18 UTC
no problem :)
Varun Sharma
@varun29
Jul 16 2016 10:25 UTC
if i just declare an array like this var a[]; and just input values in it using a for loop. is it right ??
can i do this in java script?
Keone Martin
@Athaman
Jul 16 2016 10:26 UTC
you want var a = [];
Indhu
@Indhusethu
Jul 16 2016 10:30 UTC
do we hav to complete basic algorithm scripting to code a pen??
anyone??
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:32 UTC
@Indhusethu no.
Indhu
@Indhusethu
Jul 16 2016 10:32 UTC
ok @dmitrij-schmidt
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:33 UTC
but what do you want to code? algorithms help you better understand theory. coding those projects help you practice it
Indhu
@Indhusethu
Jul 16 2016 10:33 UTC
oh well thanks!!! @dmitrij-schmidt
CamperBot
@camperbot
Jul 16 2016 10:33 UTC
indhusethu sends brownie points to @dmitrij-schmidt :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @dmitrij-schmidt |http://www.freecodecamp.com/dmitrij-schmidt
Keone Martin
@Athaman
Jul 16 2016 10:33 UTC
algorithms are good for you ;)
Indhu
@Indhusethu
Jul 16 2016 10:34 UTC
whom are yu saying @Athaman
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:34 UTC
@Athaman :+1: yust like mayonaise!
*just
Keone Martin
@Athaman
Jul 16 2016 10:35 UTC
i... don't know if mayonaise is actually 'good' for you. but it is pretty enjoyable so that's nice.
Promise Tochi
@Promhize
Jul 16 2016 10:35 UTC
This message was deleted
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:38 UTC
@Athaman well, if i'm to judge from those 'swedish mealtime' videos, it's really good :D
Keone Martin
@Athaman
Jul 16 2016 10:38 UTC
seems like a reliable source of information.
Promise Tochi
@Promhize
Jul 16 2016 10:39 UTC

Hello i have this code for the truncate string challenge:
'''
function truncateString(str, num) {
// Clear out that junk in your trunk
//var newstrlength;
if (str > 3 || num > 3) {
var newstrlength = num - 3;
str = str.substring(0, newstrlength || num);
str = str.concat('...');
}
else if (num < 3) {
str = str.substring(0, num);
str = str.concat('...');
}
return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
'''

but it cannot work with this function call:

'''
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)
'''

is the argument syntax correct, because im getting syntax errors when i try to use function call to debug

how do i paste code
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 10:39 UTC
@Promhize backticks, not apostrophes
Promise Tochi
@Promhize
Jul 16 2016 10:39 UTC
,,, this?
Keone Martin
@Athaman
Jul 16 2016 10:39 UTC
located next to the 1 on a US keyboard
nope, `
Promise Tochi
@Promhize
Jul 16 2016 10:40 UTC
okay found it thanks
Keone Martin
@Athaman
Jul 16 2016 10:40 UTC
welcome
Promise Tochi
@Promhize
Jul 16 2016 10:40 UTC
three backticks right?
Keone Martin
@Athaman
Jul 16 2016 10:40 UTC
yup, on a line above then 3 on a line below the code chunk
Promise Tochi
@Promhize
Jul 16 2016 10:41 UTC
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)
is this argument in this function correct, thats what's on the truncate string challenge
Keone Martin
@Athaman
Jul 16 2016 10:42 UTC
why are you calling .length on the argument being passed in?