These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jul 2016
colorpanda
@colorpanda2011
Jul 16 2016 00:00
@sjames1958gm cool, that works, any other?
Stephen James
@sjames1958gm
Jul 16 2016 00:00
@colorpanda2011 That is probably about it.
colorpanda
@colorpanda2011
Jul 16 2016 00:01
@sjames1958gm sorry, that doesn`t work.
Varun Sharma
@varun29
Jul 16 2016 00:01
you mean if i use a.num outside the object ,it won't work?? @jarenescueta731
colorpanda
@colorpanda2011
Jul 16 2016 00:01
@sjames1958gm have to put the else if in it.
Stephen James
@sjames1958gm
Jul 16 2016 00:01
@colorpanda2011 let me see?
@sjames1958gm what is the name again?
Chad Hurley
@ChadDean82
Jul 16 2016 00:02
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
@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
@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
@varun29 gonna look at the challenge
Varun Sharma
@varun29
Jul 16 2016 00:05
so can you please nust have a look at the challenge??
@jarenescueta731
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:08
@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
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
@jarenescueta731 how to use these function?
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:11
@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
@jarenescue?
Alisdair Frost
@pacificfrost
Jul 16 2016 00:14
@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
we declare a variable inside the function in order to make it private.right?
Jamil Akhtar
@frontender007
Jul 16 2016 00:15

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
@jarenescueta731
Aiden
@AidenMead
Jul 16 2016 00:16
@pacificfrost it is, bear with me and I'll post it
Varun Sharma
@varun29
Jul 16 2016 00:17
@AidenMead "collection" is an object of objects
Chris
@ChrisGitter
Jul 16 2016 00:17
@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
@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
hi guys, can you help me?
Promise Tochi
@Promhize
Jul 16 2016 00:19
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
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
@ChrisGitter I 'm at truncate a string challenge
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:21
you are removing alpha numeric chars, aren't you?
@Promhize
Promise Tochi
@Promhize
Jul 16 2016 00:21
yes
@Sperkajugglite yes
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:21
i mean, you are supposed to remove non-alpha, right?
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:21
@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
@Promhize you are removing alphanumeric
Promise Tochi
@Promhize
Jul 16 2016 00:22
@Sperkajugglite yes i am removing non-alpha
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:22
your code is removing alphanumeric chars
try \W
and \D
Promise Tochi
@Promhize
Jul 16 2016 00:23
@Sperkajugglite okay, will try that out, thanks
CamperBot
@camperbot
Jul 16 2016 00:23
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
np :P
Varun Sharma
@varun29
Jul 16 2016 00:24
@jarenescueta731 so we cannot manipulate it from outside?
Rahin Ahmed
@rahin1122
Jul 16 2016 00:24

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
@Sperkajugglite i think /w doesnt remove - and _
Jaren Escueta
@jarenescueta731
Jul 16 2016 00:25
@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
@Promhize, then use [-_ ]
Aiden
@AidenMead
Jul 16 2016 00:25
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
thatll do
Chris
@ChrisGitter
Jul 16 2016 00:25

@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
@varun29 no you cannot from the outside, that's what makes it "private"
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:25
@AidenMead you use ```
then close with ```
Aiden
@AidenMead
Jul 16 2016 00:26

```// 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
@Sperkajugglite hmm, will try that. @jarenescueta731 thanks
CamperBot
@camperbot
Jul 16 2016 00:26
: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
help format
CamperBot
@camperbot
Jul 16 2016 00:26

: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
put ```at the end too
help simon? :laughing:
CamperBot
@camperbot
Jul 16 2016 00:26
no wiki entry for: simon laughing
Aiden
@AidenMead
Jul 16 2016 00:27
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
@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
@Sperkajugglite :D it worked. Thanks
CamperBot
@camperbot
Jul 16 2016 00:28
promhize sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:warning: promhize already gave sperkajugglite points
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:28
@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

`
// 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
autut
yes
las one you did worked
do the same
Aiden
@AidenMead
Jul 16 2016 00:30
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
@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
@AidenMead idk i always paste
Aiden
@AidenMead
Jul 16 2016 00:31
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
dude, try with three
Aiden
@AidenMead
Jul 16 2016 00:31
Hmm, i give up, sorry all!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:31
@AidenMead last try?
Aiden
@AidenMead
Jul 16 2016 00:31
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
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
@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
Haha, I think it's somehow just me. Thanks for the help, though, @Sperkajugglite !
CamperBot
@camperbot
Jul 16 2016 00:36
aidenmead sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:36
@ChadDean82 i think in case 7... it should not equal 0
CamperBot
@camperbot
Jul 16 2016 00:36
:cookie: 306 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:36
@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
@Sperkajugglite so take code 7-8 out completely?
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:37
@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
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
you're setting count to 0
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:43
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
that's different to adding 0
colorpanda
@colorpanda2011
Jul 16 2016 00:43
everyone have a good weekend!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:43
@llamatarianism @ChadDean82 thats what i said
Rahin Ahmed
@rahin1122
Jul 16 2016 00:44
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
format help
result = my noun + .... ?
amran16
@amran16
Jul 16 2016 00:48
does capitalize method work in JS, am working on Title Case a Sentence challenge?
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:48
i think it doesn't
try just toUpperCase with index 0
amran16
@amran16
Jul 16 2016 00:50
thanks @Sperkajugglite , how would I do it for each word though?
CamperBot
@camperbot
Jul 16 2016 00:50
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
@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
@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
thanks
Santiago Gómez
@Sperkajugglite
Jul 16 2016 00:56
np
Rahin Ahmed
@rahin1122
Jul 16 2016 00:56
@HKuz thank you
CamperBot
@camperbot
Jul 16 2016 00:56
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
@rahin1122 no problem, cheers
Rahin Ahmed
@rahin1122
Jul 16 2016 01:10
@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
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

@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
you need spaces inbetween the words
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:19
@labanch have you tried logging indexOf(test[i]) to see what it outputs?
llamatarianism
@llamatarianism
Jul 16 2016 01:19
result = myAdjective + " " + myNoun + " " + ...
labanch
@labanch
Jul 16 2016 01:19
@no-stack-dub-sack good idea! I'll try that now
Heather Kusmierz
@HKuz
Jul 16 2016 01:20
@llamatarianism ah yes, good call
Santiago Gómez
@Sperkajugglite
Jul 16 2016 01:21
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:22
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
help Record Collection
CamperBot
@camperbot
Jul 16 2016 01:22

: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
@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
@labanch yup, works the same way
labanch
@labanch
Jul 16 2016 01:24
@no-stack-dub-sack cool! Learned something new. Thanks
CamperBot
@camperbot
Jul 16 2016 01:24
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
@labanch no prob! That's what it's all about!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 01:27
@no-stack-dub-sack looks great!! :P
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 01:28
@Sperkajugglite Thanks! Let me know if you have any suggestions!
CamperBot
@camperbot
Jul 16 2016 01:28
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
doesn't load pages yet?
Rahin Ahmed
@rahin1122
Jul 16 2016 01:28
@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
@rahin1122 sweet!
Santiago Gómez
@Sperkajugglite
Jul 16 2016 01:30
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
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
@Robinsond7691 sure bro
Robinsond7691
@Robinsond7691
Jul 16 2016 01:39
@drez14 thanks man, sounds good.
CamperBot
@camperbot
Jul 16 2016 01:39
robinsond7691 sends brownie points to @drez14 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for drez14
willcodes
@willcodes
Jul 16 2016 01:41
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

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
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
going to stream a twitch overlay I started today on FCC twitch channel
Luke Bailey
@baileyl91
Jul 16 2016 01:58
@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 H.
@jesushilarioh
Jul 16 2016 02:11
hello all, help!!
Screen Shot 2016-07-15 at 9.11.20 PM.png
Silvano Rasta
@sirvanux
Jul 16 2016 02:15
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 H.
@jesushilarioh
Jul 16 2016 02:16
@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
i think its the same (9/5)
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:18
celcius is spelled celsius...
@sirvanux celcius is spelled celsius...
Silvano Rasta
@sirvanux
Jul 16 2016 02:18
thats it let me try
Ash
@Ash717
Jul 16 2016 02:18
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
@jesushilariohernandez thanks my friend i was getting crazy here
CamperBot
@camperbot
Jul 16 2016 02:19
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
@sirvanux use the parameter, don't declare a var (celsius) inside your function
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:19
@sirvanux thanks man... I know the feeling!!! I'm stumped right now...too.
CamperBot
@camperbot
Jul 16 2016 02:19
jesushilariohernandez sends brownie points to @sirvanux :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for sirvanux
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:20
Screen Shot 2016-07-15 at 9.11.20 PM.png
Silvano Rasta
@sirvanux
Jul 16 2016 02:20
it was the typo
Ash
@Ash717
Jul 16 2016 02:20
anyone?
Silvano Rasta
@sirvanux
Jul 16 2016 02:20
celcius intead of celsius
Diego Mayer
@Chrono79
Jul 16 2016 02:21
@jesushilariohernandez review array manipulation methods: pop, push, shift and unshift, you need 2 of them
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:21
@Chrono79 Thank you sir...
CamperBot
@camperbot
Jul 16 2016 02:21
jesushilariohernandez sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1541 | @chrono79 |http://www.freecodecamp.com/chrono79
Ash
@Ash717
Jul 16 2016 02:22
>
Diego Mayer
@Chrono79
Jul 16 2016 02:24
@Ash717 you are using = instead of == or === in your if conditions
Ash
@Ash717
Jul 16 2016 02:24
alright
@Chrono79 thank you
CamperBot
@camperbot
Jul 16 2016 02:25
ash717 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1542 | @chrono79 |http://www.freecodecamp.com/chrono79
Ash
@Ash717
Jul 16 2016 02:26
@Chrono79 does it work now?
Diego Mayer
@Chrono79
Jul 16 2016 02:26
yes
abdoesam2011
@abdoesam2011
Jul 16 2016 02:26
hello guys i'm new here :smile:
Kent Saeteurn
@sansae
Jul 16 2016 02:26
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
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
@Chrono79 thank you!
CamperBot
@camperbot
Jul 16 2016 02:27
ash717 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: ash717 already gave chrono79 points
Pericles
@periman2
Jul 16 2016 02:27
why does the console says this when I try to access location data with naviagor.geolocation?
Diego Mayer
@Chrono79
Jul 16 2016 02:27
@periman2 you're using Chrome, don't you?
Pericles
@periman2
Jul 16 2016 02:28
yes I do
Diego Mayer
@Chrono79
Jul 16 2016 02:28
native browser geolocation in Chrome is restricted to https
Ash
@Ash717
Jul 16 2016 02:28
@Chrono79 thanks again!
CamperBot
@camperbot
Jul 16 2016 02:28
:warning: ash717 already gave chrono79 points
ash717 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jul 16 2016 02:28
@Ash717 no problem
Pericles
@periman2
Jul 16 2016 02:28
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
@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
@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
@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
@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
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
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
and the exercise suggest opeweathermap api which is https as I just only now checked
Jonathan Leon
@Wo1v3r
Jul 16 2016 02:32
@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
@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
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
np goodluck you can pm me if you need help night :)
Pericles
@periman2
Jul 16 2016 02:36
night :)
Diego Mayer
@Chrono79
Jul 16 2016 02:37

@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
@periman2 just add an S at the beginning of the codepen url
Pericles
@periman2
Jul 16 2016 02:41
@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
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
@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
help falsy bouncer
CamperBot
@camperbot
Jul 16 2016 02:41

: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
@Chrono79 then I'll use a json api I found that works on chrome
Diego Mayer
@Chrono79
Jul 16 2016 02:42
@periman2 go for it
Pericles
@periman2
Jul 16 2016 02:42
@Chrono79 although openweather website is in https...
Diego Mayer
@Chrono79
Jul 16 2016 02:42
@periman2 the api works in http (last time I checked)
Pericles
@periman2
Jul 16 2016 02:43
@Chrono79 hm okay thank you
CamperBot
@camperbot
Jul 16 2016 02:43
periman2 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1543 | @chrono79 |http://www.freecodecamp.com/chrono79
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:45
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
@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
@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
@ndburrus @jesushilariohernandez it doesn't have to be a one liner ...
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:50
remove comma put semicolen
@ndburrus remove comma use semi
Norvin Burrus
@ndburrus
Jul 16 2016 02:51
@jesushilariohernandez ok, so let's see what the code looks like now..
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:52
Screen Shot 2016-07-15 at 9.52.08 PM.png
Pericles
@periman2
Jul 16 2016 02:52
@jesushilariohernandez why do you put everything on return?
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:53
@periman2 not sure! I'm stuck....
Pericles
@periman2
Jul 16 2016 02:53
do the push above the return and then return the item that was removed
one thing you need to return not two
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:53
@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
@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 H.
@jesushilarioh
Jul 16 2016 02:56
@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
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
no problem
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:58
@periman2 thanks again!
CamperBot
@camperbot
Jul 16 2016 02:58
jesushilariohernandez sends brownie points to @periman2 :sparkles: :thumbsup: :sparkles:
:warning: jesushilariohernandez already gave periman2 points
Pericles
@periman2
Jul 16 2016 02:58
@jesushilariohernandez I hope you understood why it worked this way
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 02:59
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
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
@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 H.
@jesushilarioh
Jul 16 2016 03:02
@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
@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
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
@periman2 well I figured out the api call, but I still can't view any twitch streams
Pericles
@periman2
Jul 16 2016 03:07
@RajdeepRoy how do you use join ?
Emelin GUtierrez
@emelinpg
Jul 16 2016 03:07
Can someone help me with "escape sequences in strings" I dont understand it at all
Pericles
@periman2
Jul 16 2016 03:07
@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
@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
@periman2 well, I'm getting the json data in my log
Jesus Hilario H.
@jesushilarioh
Jul 16 2016 03:10
@emelinpg what've you got so far?
Pericles
@periman2
Jul 16 2016 03:10
@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
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

@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
@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
YO!
Chad Hurley
@ChadDean82
Jul 16 2016 03:13
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
@periman2 oddly, I can view twitch streams in firefox but not chrome
Joseph
@revisualize
Jul 16 2016 03:14
@ChadDean82 You're not including the count with your return.
Pericles
@periman2
Jul 16 2016 03:15
@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
@revisualize like this?
Rajdeep Roy
@RajdeepRoy
Jul 16 2016 03:17
Thanks @periman2 .So should I have a code to filter codes greater than 65
CamperBot
@camperbot
Jul 16 2016 03:17
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
if (count<0) {
    return count + "Hold";
  } else if (count>0) {
    return count + "Bet";
  }
Pericles
@periman2
Jul 16 2016 03:17
@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
Thanks again @periman2 .U r of great help.
CamperBot
@camperbot
Jul 16 2016 03:19
rajdeeproy sends brownie points to @periman2 :sparkles: :thumbsup: :sparkles:
:warning: rajdeeproy already gave periman2 points
Vishal Bansal
@Vishal0024
Jul 16 2016 03:20
need hekp with Escape sequences
help
CamperBot
@camperbot
Jul 16 2016 03:20

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
@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
ok @periman2
Vishal Bansal
@Vishal0024
Jul 16 2016 03:22
Can anybody help with Escape sequences?
Pericles
@periman2
Jul 16 2016 03:23
@Vishal0024 what do you need?
Vishal Bansal
@Vishal0024
Jul 16 2016 03:24
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
you're extremely close
\SecondLine\ has \ left and right
you haven't included them
Vishal Bansal
@Vishal0024
Jul 16 2016 03:25
FirstLine\n \ScondLine\ \rThirdLine
FirstLine\n \ScondLine\ \rThirdLine
i included it
labanch
@labanch
Jul 16 2016 03:26
help seek and destroy
CamperBot
@camperbot
Jul 16 2016 03:26

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

```
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
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
paste your code here inside the ```
Vishal Bansal
@Vishal0024
Jul 16 2016 03:30
'var myStr="FirstLine\n\ScondLine\\rThirdLine";'
sorry about that \
Pericles
@periman2
Jul 16 2016 03:31
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
o yes
what a silly mistake
Pericles
@periman2
Jul 16 2016 03:32
done an infinity of those myself xD
Vishal Bansal
@Vishal0024
Jul 16 2016 03:32
thank you so much..@periman2
Pericles
@periman2
Jul 16 2016 03:32
np :)
Vishal Bansal
@Vishal0024
Jul 16 2016 03:33
:-)
Chad Hurley
@ChadDean82
Jul 16 2016 03:35
@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
@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
@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
@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
@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
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
if (count<=0) {
    return count + " Hold";
  } else {
    return count + " Bet";
  }
Chad Hurley
@ChadDean82
Jul 16 2016 04:02
@Bitcross was that Your post or just a dup of mine?
Chris
@Bitcross
Jul 16 2016 04:06
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
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
@Bitcross K so probably a dumb ? but what would be My opening of the string?
wowcallmia
@wowcallmia
Jul 16 2016 04:10
need to turn console log into one object
Chris
@Bitcross
Jul 16 2016 04:12
@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
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
@Bitcross Thank You
CamperBot
@camperbot
Jul 16 2016 04:16
chaddean82 sends brownie points to @bitcross :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @bitcross |http://www.freecodecamp.com/bitcross
Chris
@Bitcross
Jul 16 2016 04:18
@ChadDean82 You're welcome!
Chad Hurley
@ChadDean82
Jul 16 2016 04:25
@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
@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
Anybody active right now?
Would like to have suggestions on the above codepen
martinronquillo
@martinronquillo
Jul 16 2016 04:33

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

@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
// 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
guyz please help me withthe 189th challenge
Chris
@Bitcross
Jul 16 2016 04:40
which one is that??
Shantanu Pramanik
@shantanu0323
Jul 16 2016 04:40
its local scope and functions
Chris
@Bitcross
Jul 16 2016 04:41
what's your code look like?
martinronquillo
@martinronquillo
Jul 16 2016 04:41
@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
martinronquillo sends brownie points to @bitcross :sparkles: :thumbsup: :sparkles:
:cookie: 213 | @bitcross |http://www.freecodecamp.com/bitcross
Chris
@Bitcross
Jul 16 2016 04:42
@martinronquillo type three ``` and then hit shift + Enter, paste your code
martinronquillo
@martinronquillo
Jul 16 2016 04:42
@Bitcross #3 or three?
Shantanu Pramanik
@shantanu0323
Jul 16 2016 04:43

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
three of the lowercase tilde key, the key beside the 1
Jerzz
@2cool4school
Jul 16 2016 04:43

// 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
I don't really get how this works.
var expression = /\d+/g;
DJ
@qualitymanifest
Jul 16 2016 05:05
@LordYamanouchi regexone.com
LordYamanouchi
@LordYamanouchi
Jul 16 2016 05:05
@qualitymanifest Thanks !
CamperBot
@camperbot
Jul 16 2016 05:05
lordyamanouchi sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1278 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Vercaelus
@Vercaelus
Jul 16 2016 05:31
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
@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
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
@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
@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
yes, I used Array.from();
Kevin
@KevinBruland
Jul 16 2016 05:38
@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
@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
@Vercaelus sure, can I see your code?
Vercaelus
@Vercaelus
Jul 16 2016 05:40
Absolutely. Is there an easy way to share, or is it copy-paste?
DJ
@qualitymanifest
Jul 16 2016 05:40
@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
Got it
Kevin
@KevinBruland
Jul 16 2016 05:41
help format
CamperBot
@camperbot
Jul 16 2016 05:41

: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
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
there we go
Vercaelus
@Vercaelus
Jul 16 2016 05:43
I mutilated the code trying different solutions, by the way
DJ
@qualitymanifest
Jul 16 2016 05:44
@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
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
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
@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
@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
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
@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
@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
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
@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
Let me try out y'alls suggestions, and see what I come up with
fauzankadri
@fauzankadri
Jul 16 2016 05:54
@jarenescueta731 thank you :)
CamperBot
@camperbot
Jul 16 2016 05:54
fauzankadri sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Vercaelus
@Vercaelus
Jul 16 2016 05:55
@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
vercaelus sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @benalron |http://www.freecodecamp.com/benalron
Kevin
@KevinBruland
Jul 16 2016 05:57
@Vercaelus NP, congratulations
Vercaelus
@Vercaelus
Jul 16 2016 05:57
@qualitymanifest thanks!
CamperBot
@camperbot
Jul 16 2016 05:57
vercaelus sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1279 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Kevin
@KevinBruland
Jul 16 2016 05:57
@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
I would enjoy seeing the comparison
Kevin
@KevinBruland
Jul 16 2016 05:58
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
To be honest, I cant even read it lol. But if it works, it works
Kevin
@KevinBruland
Jul 16 2016 05:59
but you can see how I used arguments[x] in the loop to check each individual argument
Vercaelus
@Vercaelus
Jul 16 2016 06:00
Ah, right
Kevin
@KevinBruland
Jul 16 2016 06:00
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
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
@Vercaelus For a beginner it might take 50 hours or more.
Kevin
@KevinBruland
Jul 16 2016 06:01
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
How is my site looking - www.blahbah.hol.es
Vercaelus
@Vercaelus
Jul 16 2016 06:02
Ah, gotcha. I forget that some people actually have lives lol.
Markus Kiili
@Masd925
Jul 16 2016 06:02
@Benalron Your code has a problem if there are zeroes on arr.
Kevin
@KevinBruland
Jul 16 2016 06:04
@Masd925 would it?
@Masd925 oh right, because 0 is false with boolean, good point
Ayush Kenhi
@AyushKenhi
Jul 16 2016 06:12
Whats wrong here
why so inactive?
wowcallmia
@wowcallmia
Jul 16 2016 06:12
turning multiple variables into a return object help
Markus Kiili
@Masd925
Jul 16 2016 06:19
@AyushKenhi These hours are usually slow.
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:19
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
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
Thanks much @Masd925
CamperBot
@camperbot
Jul 16 2016 06:23
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
Your second solution is not that good because it filters arr many times.
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:24
@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
@kgashok You can loop the arguments inside the filter callback.
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:25
@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
Good morning
can someone help me out with this
Markus Kiili
@Masd925
Jul 16 2016 06:28
@kgashok
Robert Currie Owusu Afari
@RC31
Jul 16 2016 06:28

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
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
this is my solution to the : var myStr= "\t \t \r \n \";
Markus Kiili
@Masd925
Jul 16 2016 06:29
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
@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
```
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
well if we're just giving away solutions
may I offer my more ES6y version
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:33
@llamatarianism for the record, I did come up with "inelegant" solutions already. Yes, please the ES6y version!
llamatarianism
@llamatarianism
Jul 16 2016 06:33
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
@llamatarianism that's the shortest solution for this I've seen if it does work
llamatarianism
@llamatarianism
Jul 16 2016 06:35
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
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
@no-stack-dub-sack It can also be done without the array:
llamatarianism
@llamatarianism
Jul 16 2016 06:37
it's a shame there's no built-in inverse of filter
Markus Kiili
@Masd925
Jul 16 2016 06:37
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
like reject
that'd save me a byte
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:38
@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
@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
@no-stack-dub-sack just curious...
llamatarianism
@llamatarianism
Jul 16 2016 06:39
@kgashok in a comment
Ashok Bakthavathsalam
@kgashok
Jul 16 2016 06:39
@no-stack-dub-sack it is the "warnings" that got me to ask on this gitter room...
llamatarianism
@llamatarianism
Jul 16 2016 06:39
// 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
@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
Thanks much @no-stack-dub-sack @llamatarianism @Masd925
JS and its options are truly MIND BOGGLING!
CamperBot
@camperbot
Jul 16 2016 06:41
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
@llamatarianism There's a lot of merit to your suggestion for a reject function.
llamatarianism
@llamatarianism
Jul 16 2016 06:44
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
:smile:
wowcallmia
@wowcallmia
Jul 16 2016 06:45


    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
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
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
@no-stack-dub-sack yes
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:48
@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
@no-stack-dub-sack show me what you got
Faisal Zulfiqar
@faisal1337
Jul 16 2016 06:49
@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
@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
@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
^ 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
@faisal1337
Jul 16 2016 06:51
Ahan
llamatarianism
@llamatarianism
Jul 16 2016 06:52
@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
@llamatarianism to get the data for each of the users?
llamatarianism
@llamatarianism
Jul 16 2016 06:52
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
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
you'll see that it is getting data for each of the users
Faisal Zulfiqar
@faisal1337
Jul 16 2016 06:53
@llamatarianism and what does 'this' 'val' and 1 are doing right here?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:53
@llamatarianism right, but now printing it into the document is what I'm having trouble with
Faisal Zulfiqar
@faisal1337
Jul 16 2016 06:53
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
@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
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
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
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
and val is an item in the array
Robert Currie Owusu Afari
@RC31
Jul 16 2016 06:55
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
@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
@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
@no-stack-dub-sack a forEach of what?
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 06:59
@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
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
@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
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
@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
yeah I noticed I forgot to add the colours
just a second
Peter Weinberg
@no-stack-dub-sack
Jul 16 2016 07:15
how long have you been programming for? before FCC just with other languages I'm guessing?
llamatarianism
@llamatarianism
Jul 16 2016 07:15
@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
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
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
@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
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
im 3 months in about, zero prior experience
llamatarianism
@llamatarianism
Jul 16 2016 07:18
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
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
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
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
@llamatarianism fair enough... is the plan a coding job eventually or not really?
llamatarianism
@llamatarianism
Jul 16 2016 07:31
@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
@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
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
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
seeya
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:35
@llamatarianism Seems did not work
llamatarianism
@llamatarianism
Jul 16 2016 07:35
@DKSukhani if you followed all my advice it should work
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:36
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
`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
'"FirstLine\n\SecondLine\rThirdLine"'
llamatarianism
@llamatarianism
Jul 16 2016 07:37
`\\` -> \\
no, backticks, not quotes
` != '
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:37
\ "FirstLine\n\SecondLine\rThirdLine" \
llamatarianism
@llamatarianism
Jul 16 2016 07:38
they're to the left of the 1 key
above tab
Cal-culator
@Cal-culator
Jul 16 2016 07:38

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
ya one seco
"FirstLine\n\SecondLine\\rThirdLine"
llamatarianism
@llamatarianism
Jul 16 2016 07:39
you still haven't escaped everything properly
afani martin
@whiz25
Jul 16 2016 07:39
That doesn't solve the prob @llamatarianism
llamatarianism
@llamatarianism
Jul 16 2016 07:39
you've got a newline, \S (which is invalid), a backslash, then an r
Dipesh Sukhani
@DKSukhani
Jul 16 2016 07:40
ok one sec - let me try
Jack Lyons
@JackEdwardLyons
Jul 16 2016 07:41
@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
"FirstLine\n\\SecondLine\rThirdLine"
llamatarianism
@llamatarianism
Jul 16 2016 07:42
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
ah cool
thanks @llamatarianism :)
CamperBot
@camperbot
Jul 16 2016 07:43
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
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
Got it @llamatarianism
Thanks for that hint that I was not escaping
llamatarianism
@llamatarianism
Jul 16 2016 07:44
@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
ah ok
Robert Currie Owusu Afari
@RC31
Jul 16 2016 07:54
@DKSukhani can you explain it to me
this was my solution
myStr="\n\\r\"
Randy Goldsmith
@Dueldrawer8
Jul 16 2016 07:54
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

for a json object

{
   "key": "value"
}

and

{
    key: "value"
}

produces same result

how do I use a variable's content as key then?
hnry
@hnry
Jul 16 2016 08:01
@meetmangukiya you parse it back into a js object, JSON.parse()
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:03
@hnry sorry I didn't get it
can you write the code and send?
Randy Goldsmith
@Dueldrawer8
Jul 16 2016 08:05
anyone?
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:05
do you mean
var a = JSON.parse({key: "value"});
hnry
@hnry
Jul 16 2016 08:05
@meetmangukiya is it actually json? because your example doesn't show that it is
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:06
@hnry it looks like the example one, and I think it is json
hnry
@hnry
Jul 16 2016 08:06
@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
yeah, thats the problem
The key is a variable
hnry
@hnry
Jul 16 2016 08:08
@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
{ 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
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
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
@Dueldrawer8 you can use css to change blockquote{border-left: 5px solid color;}
llamatarianism
@llamatarianism
Jul 16 2016 08:10
the [] makes it evaluate the variable
instead of treating it as a string
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:10
I tried () but not [], I thought () is used in evaluation
llamatarianism
@llamatarianism
Jul 16 2016 08:11
shrug.
javascript has a complicated syntax.
you want something that makes sense, go write lisp :P
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:11
I never tried lisp
anyways thanks @llamatarianism
CamperBot
@camperbot
Jul 16 2016 08:11
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
how is the market for lisp?
llamatarianism
@llamatarianism
Jul 16 2016 08:12
everything's really simple because everything is a lisp
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:12
come on lisp is supposed to one the harder languages to master @llamatarianism
llamatarianism
@llamatarianism
Jul 16 2016 08:12
@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
heard good things about clojure.. like that it makes you a better coder
llamatarianism
@llamatarianism
Jul 16 2016 08:13
(+ 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
can't understand a thing
first line probably adds the numbers
llamatarianism
@llamatarianism
Jul 16 2016 08:14
@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
Has anyone tried their hands on building a chrome extension?
Evan
@CodeDraken
Jul 16 2016 08:14
@llamatarianism go to bed that's an order sir llama :point_right:
llamatarianism
@llamatarianism
Jul 16 2016 08:14
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
How do we store data using just js?
llamatarianism
@llamatarianism
Jul 16 2016 08:15
@evan153 :gun:
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:15
@meetmangukiya what do you mean by store??
llamatarianism
@llamatarianism
Jul 16 2016 08:15
but yeah, lisps are the definition of simple.
just lists.
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:15
@llamatarianism I'll be sure to check it out. Any specific resources I should see??
llamatarianism
@llamatarianism
Jul 16 2016 08:16
(define (map fun lst)
  (if (null? lst)
      '()
      (cons (fun (car lst)) (map fun (cdr lst)))))
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:16
@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
@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
@meetmangukiya you can use the local storage and store data
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:17
@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
using local storage will keep the data permanantly
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:18
@Rud156 yeah, the question is how?
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:18
just search for localStorage in javascript on google
llamatarianism
@llamatarianism
Jul 16 2016 08:19

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
@llamatarianism scheme looks good
@meetmangukiya Here's the link: http://www.w3schools.com/html/html5_webstorage.asp
llamatarianism
@llamatarianism
Jul 16 2016 08:21
^ 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
@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

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
@Rud156 don't you think the same?
Jerzz
@2cool4school
Jul 16 2016 08:29
sup guys
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:29
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
i have a logical error that i can't put my finger on..
willfree108
@willfree108
Jul 16 2016 08:31
@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
@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
@willfree108 if you just wanna learn the most possible? haskell
Cal-culator
@Cal-culator
Jul 16 2016 08:33
what is it Jerzz
llamatarianism
@llamatarianism
Jul 16 2016 08:33
haskell is like, the definitive functional language
Cal-culator
@Cal-culator
Jul 16 2016 08:33
I will try to help if i can
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:34
@Cal-culator - the problem you have is in while statement
Jerzz
@2cool4school
Jul 16 2016 08:34

// 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
@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
all the inputs work for my if/else if statements except, updateRecords(2468, "tracks", "Free")
willfree108
@willfree108
Jul 16 2016 08:35
@llamatarianism alright ty a lot, it's on my cursus too so it make more sense
CamperBot
@camperbot
Jul 16 2016 08:35
willfree108 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1001 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Jerzz
@2cool4school
Jul 16 2016 08:35
ive changed this
one minute ill be back
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:35
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
@dmitrij-schmidt How do i solve it?
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:36
@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
@dmitrij-schmidt i changed that but the code still doesn't work.
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:36
alright, let me check it then :)
Jerzz
@2cool4school
Jul 16 2016 08:37
@Cal-culator I changed all instances to bracket and it gives the same results
Cal-culator
@Cal-culator
Jul 16 2016 08:37
@2cool4school
id.tracks===undefined should be collection[id][tracks]===undefined
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:37
@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
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
typeof localStorage returns object
Rudrangshu Nandi
@Rud156
Jul 16 2016 08:39
@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
@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
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
@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
@2cool4school
don't thank me. thank llamatarianism. He helped me with that exact same essay.
CamperBot
@camperbot
Jul 16 2016 08:40
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
code*
Jerzz
@2cool4school
Jul 16 2016 08:40
@Cal-culator haha, well it's like paying it forward lol
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 08:41
@Cal-culator - try to read about .hasOwnProperty()
Meet Mangukiya
@meetmangukiya
Jul 16 2016 08:41
ok @Rud156 thanks for all the help
CamperBot
@camperbot
Jul 16 2016 08:41
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
:D
Cal-culator
@Cal-culator
Jul 16 2016 08:41
@dmitrij-schmidt Ah ok. Thanks! I forgot about that. let me try taht
CamperBot
@camperbot
Jul 16 2016 08:41
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

@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
@dmitrij-schmidt I will try that.
Kevin
@KevinBruland
Jul 16 2016 08:48
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
@Benalron - more info? some case maybe?
Kevin
@KevinBruland
Jul 16 2016 08:51
@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

@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
that's useful, thanks @dmitrij-schmidt
CamperBot
@camperbot
Jul 16 2016 08:53
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
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
@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

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
@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
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
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
@Rud156 nice!!
Cal-culator
@Cal-culator
Jul 16 2016 09:04
Btw, how do you do that. I just copy and paste my code.
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:04
help format
CamperBot
@camperbot
Jul 16 2016 09:04

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around 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
@dmitrij-schmidt where is that
Dmitrij Schmidt
@dmitrij-schmidt
Jul 16 2016 09:08

@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
:bulb: to format code use backticks! ``` more info
Cal-culator
@Cal-culator
Jul 16 2016 09:09
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
@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
@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
@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
hurrrrrrr
Hashir Ahmad
@hash-14
Jul 16 2016 09:17

// 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
ouch
record collection
help record collection
CamperBot
@camperbot
Jul 16 2016 09:17

: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
there you go
Hashir Ahmad
@hash-14
Jul 16 2016 09:17
Thanks!
Cal-culator
@Cal-culator
Jul 16 2016 09:18
@dmitrij-schmidt The code works in repl.it
FM
@mafelix
Jul 16 2016 09:18
@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
@mafelix will do
FM
@mafelix
Jul 16 2016 09:19
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
@mafelix I did it this way because of my while looping
FM
@mafelix
Jul 16 2016 09:20
while(i<collection.length)