These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Jul 2016
Moisés Man
@moigithub
Jul 19 2016 00:00
@usyyy return exit the function
soo.. as soon as ur code reach a return keyword.. it will ends
Gary Siu
@GarySiu
Jul 19 2016 00:00
Wrap it in a conditional (like if(…) )
Kevin Murphy
@kaym0
Jul 19 2016 00:02
Hey guys
eliza khachatryan
@Elijbet
Jul 19 2016 00:03
how to you pm someone here?
Kevin Murphy
@kaym0
Jul 19 2016 00:03
I got a question, if you would
Here is my code, but I know it's flawed despite passing the challenge.
Gary Siu
@GarySiu
Jul 19 2016 00:03
@Elijbet You can click on someone
Kevin Murphy
@kaym0
Jul 19 2016 00:03

function spinalCase(str) {
var regex = /\s+|_+/g;
var substr = '';
var finalstr = '';
var dup = /(-)\1/gi;

for (var i = 0; i < str.length; i++)
{
substr = str.charAt(i);
if (substr === substr.toLowerCase())
{
finalstr = finalstr.concat(substr);
}

if (substr === substr.toUpperCase())
{
substr = substr.toLowerCase();
var sub2 = substr;
sub2 = " " + sub2;
if (finalstr.charAt(0) === "")
{
finalstr = finalstr.concat(substr);
}
else{
finalstr = finalstr.concat(sub2);
}
}
}
finalstr = finalstr.replace(regex, "-");
finalstr = finalstr.replace(dup, "-");
finalstr = finalstr.replace(dup, "-");

return finalstr;
}

spinalCase('The_Andy_Grifith_Show')

Moisés Man
@moigithub
Jul 19 2016 00:03
@Elijbet click its icon
eliza khachatryan
@Elijbet
Jul 19 2016 00:03
@GarySiu thanks gary!
CamperBot
@camperbot
Jul 19 2016 00:03
elijbet sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
Kevin Murphy
@kaym0
Jul 19 2016 00:03
If you notice at the end I had to use the same command twice it halves the amount of -'s
CamperBot
@camperbot
Jul 19 2016 00:03
:cookie: 138 | @garysiu |http://www.freecodecamp.com/garysiu
Kevin Murphy
@kaym0
Jul 19 2016 00:04
Until 1, if it hits one. But if you use consecutive charactesr that create -'s, eventually it doesnt work
Usmaan Ali
@usyyy
Jul 19 2016 00:04
@GarySiu why is it failing
@moigithub why is it returning true?
Kevin Murphy
@kaym0
Jul 19 2016 00:04
Is there a better command for scannig for duplicates and replacing them
And how do I apply this to that? lol
Usmaan Ali
@usyyy
Jul 19 2016 00:05

function mutation(arr) {
  string1 = arr[0].toLowerCase();
  string2 = arr[1].toLowerCase().split("");
  new_arr = [string1, string2];

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

    if (string1.indexOf(string2[i]) !== - 1) {
      return true;  

  } 

  else return false;
  }
}

mutation(["hello", "hey"]);
Moisés Man
@moigithub
Jul 19 2016 00:05
@usyyy return string1.indexOf(string2[i]) !== - 1;
["hello", "hey"])
ur code doing
"hello".indexOf("h") !== -1
Usmaan Ali
@usyyy
Jul 19 2016 00:05
@GarySiu still not working
Kevin Murphy
@kaym0
Jul 19 2016 00:05
Can you link Usmaan?
Or tell me what it's called
The challenge,t hat is
Moisés Man
@moigithub
Jul 19 2016 00:06
"h" IS inside "hello".. so indexOf will return 0 (first index)
0 !== -1
0 is not equal to -1
soo.. its true
@usyyy
Gary Siu
@GarySiu
Jul 19 2016 00:06
@usyyy You’re still hitting return every loop
pahosler
@pahosler
Jul 19 2016 00:06
I'm seriously stuck on the argument optional challenge, this is what I have so far https://github.com/pahosler/freecodecamp/blob/master/argsoptional.js how far off am I, and can anyone point me to the rosette stone?
Kevin Murphy
@kaym0
Jul 19 2016 00:07
@usyyy Easy to do like function mutation(arr) {
var test = arr1.toLowerCase();
var target = arr[0].toLowerCase();
for (i=0;i<test.length;i++) {
if (target.indexOf(test[i]) < 0)
return false;
}
return true;
}
ds
<code> function mutation(arr) {
var test = arr1.toLowerCase();
var target = arr[0].toLowerCase();
for (i=0;i<test.length;i++) { if (target.indexOf(test[i]) < 0) return false; } return true; }</code>
Moisés Man
@moigithub
Jul 19 2016 00:08
help format
CamperBot
@camperbot
Jul 19 2016 00:08

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Gary Siu
@GarySiu
Jul 19 2016 00:08
@pahosler You’re immediately summing and returning
Moisés Man
@moigithub
Jul 19 2016 00:08
@kaym0 :point_up: July 18, 2016 7:08 PM
Usmaan Ali
@usyyy
Jul 19 2016 00:09
@GarySiu dont i need to hit return to iterate through the second array to check if the elements are located in the first string????
Gary Siu
@GarySiu
Jul 19 2016 00:09
@pahosler You need to check your arguments to see if the second argument is present before deciding what to do
Kevin Murphy
@kaym0
Jul 19 2016 00:10
<function mutation(arr) { var test = arr[1].toLowerCase(); var target = arr[0].toLowerCase(); for (i=0;i<test.length;i++) { if (target.indexOf(test[i]) < 0) return false; } return true; }>
Gary Siu
@GarySiu
Jul 19 2016 00:10
@usyyy Only use return when you are finished with your function
Kevin Murphy
@kaym0
Jul 19 2016 00:10
How do I post code properly onto here?
Gary Siu
@GarySiu
Jul 19 2016 00:10
help format
CamperBot
@camperbot
Jul 19 2016 00:10

: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

Kevin Murphy
@kaym0
Jul 19 2016 00:10
'''
function mutation(arr) {
var test = arr1.toLowerCase();
var target = arr[0].toLowerCase();
for (i=0;i<test.length;i++) {
if (target.indexOf(test[i]) < 0)
return false;
}
return true;
}'''
CamperBot
@camperbot
Jul 19 2016 00:10
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Jul 19 2016 00:10
using backticks...
and backticks MUST be on its own line
Kevin Murphy
@kaym0
Jul 19 2016 00:10
function mutation(arr) { var test = arr[1].toLowerCase(); var target = arr[0].toLowerCase(); for (i=0;i<test.length;i++) { if (target.indexOf(test[i]) < 0) return false; } return true; }
Gary Siu
@GarySiu
Jul 19 2016 00:11
3 backticks
Kevin Murphy
@kaym0
Jul 19 2016 00:11
function mutation(arr) {
  var test = arr[1].toLowerCase();
  var target = arr[0].toLowerCase();
  for (i=0;i<test.length;i++) {
    if (target.indexOf(test[i]) < 0)
      return false;
  }
  return true;
 }
pahosler
@pahosler
Jul 19 2016 00:11
@GarySiu yeah, kinda guess that's where I'm stuck, esp for the addTogether(2)(3), I can't figure it out or how to write the closure
Kevin Murphy
@kaym0
Jul 19 2016 00:11
Thank you.
pahosler
@pahosler
Jul 19 2016 00:11
going slowly insane(er)
Kevin Murphy
@kaym0
Jul 19 2016 00:11
Also, so could you guys help me with this? The problem I will post after
Moisés Man
@moigithub
Jul 19 2016 00:11
@pahosler read about currying too
Gary Siu
@GarySiu
Jul 19 2016 00:11
@pahosler Well start with detecting whether you have 2 arguments and go from there
Kevin Murphy
@kaym0
Jul 19 2016 00:12

function spinalCase(str) {
  var regex =  /\s+|_+/g;
  var substr = '';
  var finalstr = '';
  var dup = /(-)\1/gi;

  for (var i = 0; i < str.length; i++)
{  
   substr = str.charAt(i);
  if (substr === substr.toLowerCase())
    {
      finalstr = finalstr.concat(substr);
    }

if (substr === substr.toUpperCase()) 
     {
       substr = substr.toLowerCase();
       var sub2 = substr;
       sub2 = " " + sub2;
       if (finalstr.charAt(0) === "")
         {
           finalstr = finalstr.concat(substr);
         }
       else{
  finalstr = finalstr.concat(sub2);
       }
    }
}
  finalstr = finalstr.replace(regex, "-");
   finalstr = finalstr.replace(dup, "-");
   finalstr = finalstr.replace(dup, "-");

  return finalstr;
}

spinalCase('The_Andy_Grifith_Show')
```
iratiwari
@iratiwari
Jul 19 2016 00:12

"Profile lookup challenge" - took me hours and hours. Then I looked up help and saw an if within an if, modified my code and submitted. I understand the if within if, but don't get why return "No such contact" works outside the if.function lookUpProfile(firstName, prop){
// Only change code below this line
for (i= 0; i< contacts.length; i++)
{
if (contacts[i].firstName===firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else
{
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line

}

Kevin Murphy
@kaym0
Jul 19 2016 00:12
In the 3rd last line of the program you will notice I use a command twice
Basically I've coded it to find any duplicate "-"'s and remove them
Kevin Murphy
@kaym0
Jul 19 2016 00:13
But for whatever reason the code only HALVES them. And I have tried swapping the "-" to "" and yeah
pahosler
@pahosler
Jul 19 2016 00:13
spinaltap
  function spinaltap(match) {
      (str.indexOf(match) === 0) ? match=match.toLowerCase() : match="-"+match.toLowerCase();
      match=match.split(/[_ ]/).join('');
            return match;

    }
    return str.replace(/^[A-Z]|\s[A-Z]|\W[A-Z]|\s([a-z])|([A_Z])\S|[A-Z]/g, spinaltap);
Gary Siu
@GarySiu
Jul 19 2016 00:13
Also quantifiers
Kevin Murphy
@kaym0
Jul 19 2016 00:13
Yes, I can find the answer online. Easy. I've written my own code and it does work
It's just I've tested it further (beyond the actual challenge) and it doesn't work
iratiwari
@iratiwari
Jul 19 2016 00:14
I was trying this earlier -

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

}

// Only change code above this line
for (i = 0 ; i < contacts.length ; i++)
{
if(contacts[i].hasOwnProperty("prop"))
{
return contacts[i].hasOwnProperty("prop");
}

}
}

Can someone help me understand?
Kevin Murphy
@kaym0
Jul 19 2016 00:14
Understand what?
Can you poist that link again
Stephen James
@sjames1958gm
Jul 19 2016 00:14
@iratiwari 1) no such property has to be only for the firstname that matches
Kevin Murphy
@kaym0
Jul 19 2016 00:15
Chat is super laggy + spam so it's in a impossible place to get to
iratiwari
@iratiwari
Jul 19 2016 00:15

@kaym0 "Profile lookup challenge" - took me hours and hours. Then I looked up help and saw an if within an if, modified my code and submitted. I understand the if within if, but don't get why return "No such contact" works outside the if.function lookUpProfile(firstName, prop){
// Only change code below this line
for (i= 0; i< contacts.length; i++)
{
if (contacts[i].firstName===firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else
{
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line

}

Gary Siu
@GarySiu
Jul 19 2016 00:15
@iratiwari What don’t you understand?
Usmaan Ali
@usyyy
Jul 19 2016 00:15
thanks @kaym0
CamperBot
@camperbot
Jul 19 2016 00:15
usyyy sends brownie points to @kaym0 :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @kaym0 |http://www.freecodecamp.com/kaym0
Kevin Murphy
@kaym0
Jul 19 2016 00:15
@GarySiu Please [post linkagain
Stephen James
@sjames1958gm
Jul 19 2016 00:16
@iratiwari When the loop ends you have checked all the contacts and if you didn't return because you matched first names you can return no such contact
iratiwari
@iratiwari
Jul 19 2016 00:16
I didn't understand the part where return "no such contact" is outside the for loop
doesn't it have to go through the entire array?
oh ok thanks @sjames1958gm
CamperBot
@camperbot
Jul 19 2016 00:17
iratiwari sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2003 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 19 2016 00:17
@iratiwari :+1:
Gary Siu
@GarySiu
Jul 19 2016 00:17
If your conditions in your for loop match, then they will exit before they ever hit that return
Think of it as a shorter way of writing an else clause
iratiwari
@iratiwari
Jul 19 2016 00:17
yes I guess that's what I was trying to do originally
Kevin Murphy
@kaym0
Jul 19 2016 00:18
I've already used regex, made the code. Like I said, I think it's a problem with something weird. If you run the code, it will halve the number of "-" instead of simply deleting duplicates
I want like, for example fa--fa---fa--fa-fa to say fa-fa-fa-fa
iratiwari
@iratiwari
Jul 19 2016 00:18
tried putting separate loops for everything @sjames1958gm @GarySiu so only 1-4 test cases were passing
Dan Couper
@DanCouper
Jul 19 2016 00:19
@pahosler you need to divide up the sequence of things to do for arguments optional:
  1. if either of the arguments aren’t a number, return undefined (in this case, addition is not possible, so you want to exit as fast as possible).
  2. else if both of the arguments are present, then add them together (you know at this point that they are numbers due to 1)
  3. else return a function that takes one argument - literally return function(arg) { /* do your stuff */ }. You already have the first argument, so this function should take an argument and add it to the one you already have. You aren’t trying to actually run the function, when the third condition is hit, the task is asking for the function itself
Gary Siu
@GarySiu
Jul 19 2016 00:19
@kaym0 So you want to match 1 or more occurance of - and to replace it with a single - ?
Kevin Murphy
@kaym0
Jul 19 2016 00:19
Yeah nevermind I can tell that you're swamped in here
Yes
I've beaten the challenge
SomeNeverLearn
@SomeNeverLearn
Jul 19 2016 00:20
Can anyone help me with code camp challenge 142, escaping sequences in strings?
Kevin Murphy
@kaym0
Jul 19 2016 00:20
It's just that I tested it further with more ----'s and all it does is halve them, and if there is too many -----'s and there isn't enough of the final lines, it won't half them enough lol
Gary Siu
@GarySiu
Jul 19 2016 00:20
@kaym0 So read up on quantifiers on that link. They let you specify how many times something occurs.
Also the global flag lets you match multiple times, not just the first time.
Kevin Murphy
@kaym0
Jul 19 2016 00:21
/(-)\1/gi;
The quantifier would be 1, correct?
Gary Siu
@GarySiu
Jul 19 2016 00:22
No?
x{n} Where n is a positive integer. Matches exactly n occurrences of the preceding item x.
scarejar
@scarejar
Jul 19 2016 00:24
jeeeez... finally done with the "record collection" ....
Gary Siu
@GarySiu
Jul 19 2016 00:24
@scarejar Congratulations! It will help you when you’re working with JSON
csdoty
@csdoty
Jul 19 2016 00:25
@scarejar Haha well done. I’m completely stuck.
Kevin Murphy
@kaym0
Jul 19 2016 00:25
So using var dup = /-{1}/gi;, it either shows 0 of the target or all of htem
Gary Siu
@GarySiu
Jul 19 2016 00:25
@kaym0 So -{3} would match 3 dashes
Kevin Murphy
@kaym0
Jul 19 2016 00:26
The problem is I'm just trying to scan for duplicate characters, for example Hello and if I was searching for l
It would find the duplicate l and delete it making the string Helo
pahosler
@pahosler
Jul 19 2016 00:26
@DanCouper thank you Dan, I think that's exactly how I needed to hear it :D
CamperBot
@camperbot
Jul 19 2016 00:26
pahosler sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 163 | @dancouper |http://www.freecodecamp.com/dancouper
Gary Siu
@GarySiu
Jul 19 2016 00:27
So if you were only trying to match 2 l’s you’d do l{2} or even just ll
pahosler
@pahosler
Jul 19 2016 00:27
@GarySiu thank you too!
CamperBot
@camperbot
Jul 19 2016 00:27
pahosler sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 139 | @garysiu |http://www.freecodecamp.com/garysiu
Gary Siu
@GarySiu
Jul 19 2016 00:27
But if you want to match any letter of the alphabet, you need to specify it as a range
Kevin Murphy
@kaym0
Jul 19 2016 00:27
So finding (1),(2),(3) isnt the problem, it's that I want to find all duplicates, so if there is helllo it would be helo
or hellllo be helo
Though it can only half them using that method, ?
Gary Siu
@GarySiu
Jul 19 2016 00:27
Ok, then you need a different quantifier
It will explain what your regex is matching as you experiment
pahosler
@pahosler
Jul 19 2016 00:30
piglatin was probably one of my fav challenges, figured it out quickly and my code is uber tight! hehe even had someone call it elegant, I've never had my code called elegant before LOL
Gary Siu
@GarySiu
Jul 19 2016 00:30
@kaym0 It also has a nice box in the bottom right that lets you choose from an explaination and it will tell you the regex you need
Kevin Murphy
@kaym0
Jul 19 2016 00:31
var dup = /-(?=-)/gi;
This is the correct code x(?=y)
For my example, if you used You're a dddickhead and wanted to fix it you would use /d(?=d)/gi to find it
Incase anybody asks
Pig Latin was a cool challenge
Dan Couper
@DanCouper
Jul 19 2016 00:34
@pahosler :) always best when you’re stuck to try to divide the challenge down into the smallest possible parts, just down to super-simple functions normally, and get those working individually. Sometimes it doesn’t work (you end up not being able to glue them all back together), but 90% of the time it does. eg What’s a sequence of simple tasks I need to do to complete? Have I made sure that I can catch problems as fast as possible so the program explodes/bails out or whatever? And once I can do each simple task, can it a. all be glued together, b. be simplified.
Kevin Murphy
@kaym0
Jul 19 2016 00:34
I'm really enjoying these advanced ones, trying to do them without the guides is a challenge. I usually check the guide after an the method of solving is so different
Thanks @GarySiu
CamperBot
@camperbot
Jul 19 2016 00:34
kaym0 sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 140 | @garysiu |http://www.freecodecamp.com/garysiu
Gary Siu
@GarySiu
Jul 19 2016 00:34
np
Kevin Murphy
@kaym0
Jul 19 2016 00:35
My favorite so far has actually been this one, and the challenge it was to find the proper regex to do my code differently than the guide. Also I really enjoyed the Roman Numerals one
scarejar
@scarejar
Jul 19 2016 00:35
What is the "basic algorithm scripting" ? Is it javascript or some other lang
Kevin Murphy
@kaym0
Jul 19 2016 00:35
Scarejar, it's Javascript
scarejar
@scarejar
Jul 19 2016 00:35
ahh
Kevin Murphy
@kaym0
Jul 19 2016 00:35
I've done all the stuff in chronological order so far
Though the logic behind the puzzles is sort of universal
At least, as far as the few languages I know go
I was viewing a webpage that used the roman numerals converted and the code on it was like 200 lines
And I managed to do the puzzle in like less than 20 lol
scarejar
@scarejar
Jul 19 2016 00:37
.. not sure if I should take algorithm scripting...
Kevin Murphy
@kaym0
Jul 19 2016 00:37
It's just interesting to look at how other people do things
pahosler
@pahosler
Jul 19 2016 00:37
@DanCouper I know, got too tired after pulling an all nighter and got overly confused. I did a flow chart for sorted union because I couldn't quite get it, as soon as the chart was done I had the code! Amazing what a little planning will do. and I usually do break them down quite a bit, but the arguments optional/closure thing just had me stummped to the point I just wasn't getting it.
Kevin Murphy
@kaym0
Jul 19 2016 00:37
Why?
Have you done the prerequisties?
scarejar
@scarejar
Jul 19 2016 00:38
me?
Kevin Murphy
@kaym0
Jul 19 2016 00:38
prerequisites
Yeah
scarejar
@scarejar
Jul 19 2016 00:38
Almost done with basic javascript, but I haven't done html nor css but I have some experience in how they work and how to use it generally
Kevin Murphy
@kaym0
Jul 19 2016 00:38
Well that's why they're basic lmao
You start at basic
They have nothing to do with HTML/CSS
Suren VB
@surenz298
Jul 19 2016 00:39

Hi
Looking for some help here with my span onclick function - I am not able to find out what is wrong here - appreciate some help

https://jsfiddle.net/#&togetherjs=h6RCrc50hP

pahosler
@pahosler
Jul 19 2016 00:39
@DanCouper still not 100% clear on closures but you got me a step closer
Kevin Murphy
@kaym0
Jul 19 2016 00:39
If you don't try things, especially challenging things, you won't ever get better
scarejar
@scarejar
Jul 19 2016 00:39
good point lol
Kevin Murphy
@kaym0
Jul 19 2016 00:39
You can also use the wikipedia to view the hints + answers.
scarejar
@scarejar
Jul 19 2016 00:40
but what will I learn from algorithm scripting?
Kevin Murphy
@kaym0
Jul 19 2016 00:40
If I can't figure it out, I'll refer to that and break it down and then try to rebuild it in my own way.
bitgrower
@bitgrower
Jul 19 2016 00:40
@pahosler One of the things that's important to learn is how to pace yourself ... when you get really tired and pull all-nighters, confusing is often the result. Neuroscientists will tell you how important getting good rest is for cognition ... and you have mental processes that work and benefit you when your conscious mind isn't around ... be sure to take advantage of this "benefit" ... and you won't have to work quite so hard ...
Rahin Ahmed
@rahin1122
Jul 19 2016 00:40

Hi Guys . Why I am not getting the right answer to go the next even after following all instructions.Can you guys have a quick look at my code .function myTest(num) {
// Only change code below this line
if (num < 5) {
return "Tiny";
} else if (num < 10) {
return "Small";
} else if (num < 15) {
return "Medium";
} else if (num < 20) {
return "Large";
} else {
return "Huge";
}
// Only change code above this line
}

// Change this value to test
myTest(25); I Guessed i could not fulfil conditions below. Instructions
Write chained if/else if statements to fulfill the following conditions:

num < 5 - return "Tiny"
num < 10 - return "Small"
num < 15 - return "Medium"
num < 20 - return "Large"
num >= 20 - return "Huge"

Kevin Murphy
@kaym0
Jul 19 2016 00:40
How to script algorithms lol
How to apply algorithms to solve problems and/or manipulate data more efficiently
Reduce your overall code quantity and maximize efficiency
scarejar
@scarejar
Jul 19 2016 00:41
lol, guess I do need that then
150 hours though x:
Edmund To
@edmundtfy
Jul 19 2016 00:41
Hello... stuck here! I don't understand why the code doesn't work:
function findUser(data) { .....; $getJSON (URL, findData()) ) // declared findUser, calling findData
function findData (data) { ... $getJSON (URL, pushHTML()) } // declared findData, calling pushHTML()
function pushHTML(data) { ... } // declared pushHTML()
$(document).ready $(document).ready(
  function(){ ... for(i=0;i<array;i++) { //the array contains different URL
    $getJSON(array[i], findUser())
  }
}
// what I expect: documentReady --> findUser --> findData --> pushHTML --> loop
// what happened: it loops, but all the content being pushed to the HTML is the same, data from the second last data I wanted to find in that array... why????
Kevin Murphy
@kaym0
Jul 19 2016 00:41
You've already learned some javascript. What's the point in knowing like 1/1000 of a language
scarejar
@scarejar
Jul 19 2016 00:42
the first line
pahosler
@pahosler
Jul 19 2016 00:42
@bitgrower Yeah, I know better, I'm old! But it's nothing new, working around the clock. I was just rying to get all the intermediate challenges out of the way, I spent WAY too long on them!
scarejar
@scarejar
Jul 19 2016 00:42
needs to end with a }
GG16
@GG16
Jul 19 2016 00:43
Hey, I'm confused. I don't see what's wrong with this function
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < i.length; j++) {
      product = product * arr[i][j];
    }
  }

  // Only change code above this line
  return product;
}
scarejar
@scarejar
Jul 19 2016 00:43
@kaym0 no lol, I wanted it to be js based, glad it is lol, I just needed to know if it will help me as a dev
Rose
@AIAGAX1
Jul 19 2016 00:43
Is someone able to help me with returning Boolean values from functions?? I've been stuck on this all day.
Stephen James
@sjames1958gm
Jul 19 2016 00:43
@GG16 Compare your second for loop to the example code - i is an integer and doesn't have length
Rose
@AIAGAX1
Jul 19 2016 00:44

function isLess(a, b) {
// Fix this code
(a < b) {
return true;
} {
return false;
}

// Change these values to test
isLess(10, 15);

GG16
@GG16
Jul 19 2016 00:44
Oh I see, thanks
Stephen James
@sjames1958gm
Jul 19 2016 00:45
@AIAGAX1 The if (condition) {return true} else {return false} can be replaced simply by return condition
John Alcher
@alchermd
Jul 19 2016 00:45
Hey mates. Let's say I have an array of [1,2,2,3,3,4,5,5,5] and I want to get the element 4 since it is the only element without a duplicate. How do I do that?
pahosler
@pahosler
Jul 19 2016 00:45
@alchermd try filter
scarejar
@scarejar
Jul 19 2016 00:45

function isLess(a, b) {
// Fix this code
if (a < b) {
return true;
} else{
return false;
}

// Change these values to test
isLess(10, 15);

Edmund To
@edmundtfy
Jul 19 2016 00:45
@alchermd both 1 and 4 both no duplicate?
John Alcher
@alchermd
Jul 19 2016 00:46
@edmundtfy oh LMAO you're right. In this case yes, I want to get 1 and 4 .
Stephen James
@sjames1958gm
Jul 19 2016 00:46
@alchermd You could compare indexOf and lastIndexOf and if equal then not duplicated
pahosler
@pahosler
Jul 19 2016 00:47
or use reduce...
Dennis Nguyen
@nguyendennist
Jul 19 2016 00:47
Hi I'm doing the Falsy Bouncer challenge under basic JS and I can't figure out what's wrong with my code.

``` (shift+enter for line break)
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var newArr = arr.filter(function(val) {
if(val === false || val === null || val === 0 || val === "" || val === undefined || isNaN(val)) {
return false;
}
return true;
});

return newArr;
}

bouncer([7, "ate", "", false, 9]);
```

John Alcher
@alchermd
Jul 19 2016 00:48
@sjames1958gm Wow, I never heard of lastIndexOf. Looks perfect for my needs, I'll be back in a bit ...
Rahin Ahmed
@rahin1122
Jul 19 2016 00:48
@sjames1958gm Hi james .Could you please take a look at my code i just posted . I dont know why not being able to go next step .Basically stuck on If Else function chaining concept is not still clear .Thanks in advance.
kevinstonge
@kevinstonge
Jul 19 2016 00:48
before I go down a deep rabbit hole of if statements ... is there an EASY way to do the roman numeral converter that I'm not thinking of? Maybe a clue just to help me find the right path :)
Stephen James
@sjames1958gm
Jul 19 2016 00:48
Dan Couper
@DanCouper
Jul 19 2016 00:48
@Dotty7 what is it failing on?
also, follow the link to Boolean
that is on the challange page
you don’t need that list of tests
it’s fragile, and as you’ve seen, it breaks
Stephen James
@sjames1958gm
Jul 19 2016 00:49
@kevinstonge You don't have to do a lot of ifs if you create parallel arrays for decimal and roman
Dennis Nguyen
@nguyendennist
Jul 19 2016 00:49
alright thanks
kevinstonge
@kevinstonge
Jul 19 2016 00:50
{[1,"I"],[5,"V"] ... } ... like that?
Stephen James
@sjames1958gm
Jul 19 2016 00:51
@kevinstonge Yeah, and work from high to low
John
@tertiaryidentifier
Jul 19 2016 00:51
hey all -- how do I get accurate geolocation for weather app? trying to get user location via google API (https://developers.google.com/web/fundamentals/native-hardware/user-location/obtain-location?hl=en), but this doesn't work in non-secure sites like codepen.io ... any reccomendations for other editors?
or a fix to this bug?
I tried IP-address based javascript geolocation, and it was SUPER inaccurate
kevinstonge
@kevinstonge
Jul 19 2016 00:51
@sjames1958gm - thanks
CamperBot
@camperbot
Jul 19 2016 00:51
kevinstonge sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2004 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 19 2016 00:52
@rahin1122 It pasted that code into the challenge and it passed.
Pitmation
@Pitmation
Jul 19 2016 00:52
Can someone help me with the exercise Stand in line in .JS?
Stephen James
@sjames1958gm
Jul 19 2016 00:52
@rahin1122 Make sure the function name matches the tests sometime they change the tests, but the function in the editor is wrong.
@Pitmation What is your question?
Pitmation
@Pitmation
Jul 19 2016 00:53
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
John
@tertiaryidentifier
Jul 19 2016 00:53
anyone? :(
Rahin Ahmed
@rahin1122
Jul 19 2016 00:53
@sjames1958gm So whats gonna be the possible solution .thanks
Pitmation
@Pitmation
Jul 19 2016 00:53

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

return item1; // Change this line
}

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

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

Stephen James
@sjames1958gm
Jul 19 2016 00:53
@rahin1122 Copy the function name from the tests up to the editor
pahosler
@pahosler
Jul 19 2016 00:54
Pitmation
@Pitmation
Jul 19 2016 00:54
nextInLine([], 1) should return 1
nextInLine(2, 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
I don't understand what they mean
Stephen James
@sjames1958gm
Jul 19 2016 00:54
@Pitmation You need to use at least two of these > push, pop, shift, unshift to manipulate the array arr
Pitmation
@Pitmation
Jul 19 2016 00:54
@sjames1958gm thank you
CamperBot
@camperbot
Jul 19 2016 00:54
pitmation sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2005 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
pahosler
@pahosler
Jul 19 2016 00:55
@tertiaryidentifier and I used weather.gov to get my local weather :D
Pitmation
@Pitmation
Jul 19 2016 00:56
so if I recall var arr.shift; return item.pop;?
John
@tertiaryidentifier
Jul 19 2016 00:56
@pahosler , tips on how to easily integrate the zip locate into my codepen?
Rahin Ahmed
@rahin1122
Jul 19 2016 00:56
@sjames1958gm Thanks James It,s matched .
CamperBot
@camperbot
Jul 19 2016 00:56
rahin1122 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2006 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
pahosler
@pahosler
Jul 19 2016 00:58
@tertiaryidentifier this is still a WIP, I decided to skip around and do the coding challenges, but it should give you the basic idea http://codepen.io/pahosler/pen/PzKGOO?editors=1111
bitgrower
@bitgrower
Jul 19 2016 00:59
@pahosler no time is too long if it's spent profitably .. (and I am not exactly young...) I spent untold days on Seek and Destroy -- and I don't regret a minute of it ...
pahosler
@pahosler
Jul 19 2016 00:59
my version off codepen looks a little better and displays more info, haven't updated it yet though...
Rose
@AIAGAX1
Jul 19 2016 00:59
@ sjame1958gm I changed the if condition to return condition; in place of return true; return false; Is that correct?
Stephen James
@sjames1958gm
Jul 19 2016 01:00
@AIAGAX1 That sounds correct -
Rose
@AIAGAX1
Jul 19 2016 01:00

function isLess(a, b) {
// Fix this code
(10 < 15) {
return condition;
} {
return condition;
}

// Change these values to test
isLess(10, 15);

John
@tertiaryidentifier
Jul 19 2016 01:00
blergh!! thanks @pahosler .... apis and javascript are so confusing to me :(
CamperBot
@camperbot
Jul 19 2016 01:00
tertiaryidentifier sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @pahosler |http://www.freecodecamp.com/pahosler
John Alcher
@alchermd
Jul 19 2016 01:00
Who here has finished the Symmetric Difference challenge?
The challenge requires that [1, 2, 5], [2, 3, 5], [3, 4, 5]return [1,4,5]. Why does it require 5? Isn't 5 present in all of the arrays? I thought I should return the differences ...
https://www.freecodecamp.com/challenges/symmetric-difference
pahosler
@pahosler
Jul 19 2016 01:01
@bitgrower was that the one with "pink wool"?
Stephen James
@sjames1958gm
Jul 19 2016 01:01
@AIAGAX1 (10 < 15) is the condition so remove all the code replace with return 10 < 15
John
@tertiaryidentifier
Jul 19 2016 01:01
I miss the days when I just did simple algorithms. I don't get functions or jQuery or anything ... grrr
bitgrower
@bitgrower
Jul 19 2016 01:01
@pahosler that doesn't sound familiar ... :)
pahosler
@pahosler
Jul 19 2016 01:01
@tertiaryidentifier hope it helps
bitgrower
@bitgrower
Jul 19 2016 01:03
@alchermd -- it has to do with the order of operation ... in the first two, 5 is not unique, so it's removed ... then it's compared to the 3rd array, and since the 5 was removed, it's not present, and is unique ...
Pitmation
@Pitmation
Jul 19 2016 01:04
Still having some issues
bitgrower
@bitgrower
Jul 19 2016 01:04
@tertiaryidentifier practice ... just keep showing up and taking little nuggets as you can, each day ... some day you'll turn around and see that all those nuggets create a mountain of kowledge ... :)
John Alcher
@alchermd
Jul 19 2016 01:04
@bitgrower Now I see. Thanks!
CamperBot
@camperbot
Jul 19 2016 01:04
alchermd sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1143 | @bitgrower |http://www.freecodecamp.com/bitgrower
Darren Harrison
@dharrison2010
Jul 19 2016 01:06
So the JavaScript palindrome...is there a bug? "1 eye for of 1 eye." with numbers, spaces and period removed is the same forward or backward? Or am I missing something?
qeurago
@qeurago
Jul 19 2016 01:06
can someone help me make a button to convert the celsius temperature value pulled from the weather api to fahrenheit? i have tried a billion things and i can not get it to work
Stephen James
@sjames1958gm
Jul 19 2016 01:07
@dharrison2010 Who said to remove numbers?
@dharrison2010 You remove all but letters and numbers
Darren Harrison
@dharrison2010
Jul 19 2016 01:08
Yes...sorry...just went up to top and saw this! Thanks!
pahosler
@pahosler
Jul 19 2016 01:08
@qeurago you can look at mine... http://codepen.io/pahosler/pen/PzKGOO?editors=1111
Defeds
@defeds
Jul 19 2016 01:08
anybody see the issue with my code for Profile Lookup?
function lookUpProfile(firstName, prop){ // Only change code below this line if(firstName === contacts.firstName && prop === contacts.prop) { return contacts.prop; } else if(firstName !== contacts.firstName) { return "No such contact"; } else if(prop !== contacts.prop) { return "No such property"; } //

woah lemme reformat,

function lookUpProfile(firstName, prop){ // Only change code below this line if(firstName === contacts.firstName && prop === contacts.prop) { return contacts.prop; } else if(firstName !== contacts.firstName) { return "No such contact"; } else if(prop !== contacts.prop) { return "No such property"; } //

why isnt ``` working? lol
pahosler
@pahosler
Jul 19 2016 01:09
is it working
format help
help format
CamperBot
@camperbot
Jul 19 2016 01:09

: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

Stephen James
@sjames1958gm
Jul 19 2016 01:10
@defeds backquotes need to be on their own lines
Defeds
@defeds
Jul 19 2016 01:10
function lookUpProfile(firstName, prop){
// Only change code below this line
if(firstName === contacts.firstName && prop === contacts.prop) {
    return contacts.prop; 
  } else if(firstName !== contacts.firstName) {
    return "No such contact";
  } else if(prop !== contacts.prop) {
    return "No such property";
  }
//
@sjames1958gm @pahosler Thanks guys :)
CamperBot
@camperbot
Jul 19 2016 01:10
defeds sends brownie points to @sjames1958gm and @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @pahosler |http://www.freecodecamp.com/pahosler
:star2: 2007 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
pahosler
@pahosler
Jul 19 2016 01:10
unless they aren't
Stephen James
@sjames1958gm
Jul 19 2016 01:10
@defeds Let's with you need a loop to process all the contacts
Defeds
@defeds
Jul 19 2016 01:11
@sjames1958gm Ah! thanks again
CamperBot
@camperbot
Jul 19 2016 01:11
defeds sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: defeds already gave sjames1958gm points
pahosler
@pahosler
Jul 19 2016 01:14
@defeds have you tried contacts[prop] instead
or that LOL
JuanLrr
@JuanLrr
Jul 19 2016 01:14
if (prop === "tracks" && value !== "") {

    if (collection[id][prop]) {

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

    } else {

      collection[id][prop] = value;}

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

    collection[id][prop] = value;

  } else if ( value === "") {

    delete collection[id][prop];

  }
I need help with record collection
Stephen James
@sjames1958gm
Jul 19 2016 01:15
@JuanLrr What tests are not passing.
pahosler
@pahosler
Jul 19 2016 01:15
@JuanLrr don't forget to add an empty array back to the deleted prop or it won't pass
JuanLrr
@JuanLrr
Jul 19 2016 01:15
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Stephen James
@sjames1958gm
Jul 19 2016 01:15
collection[id][prop] = [value]
Joseph
@revisualize
Jul 19 2016 01:17
Hello.
Stephen James
@sjames1958gm
Jul 19 2016 01:17
@JuanLrr for the case where prop === "tracks" and value != "" and "tracks" is not set
Joseph
@revisualize
Jul 19 2016 01:17
I'm available to assist anyone that needs help on anything in the basic algorithms or below.
JuanLrr
@JuanLrr
Jul 19 2016 01:20
if (prop === "tracks" && value !== "") {

    if (collection[id][prop]) {

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

    } else {

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

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

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

  } else if ( value === "") {

    delete collection[id][prop];

  }
now it wont pass After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
Stephen James
@sjames1958gm
Jul 19 2016 01:21
@JuanLrr No, only change the first one
JuanLrr
@JuanLrr
Jul 19 2016 01:21
got it, thanks
Joseph
@revisualize
Jul 19 2016 01:22
@JuanLrr You need to use .hasOwnProperty.
Pitmation
@Pitmation
Jul 19 2016 01:22
can someone please help me with stand in line
Joseph
@revisualize
Jul 19 2016 01:22
@Pitmation Sure.

@Pitmation

// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // Add the number to the end of the array,

    // then remove the first element of array.
    // The nextInLine function should 
    // then return the element that was removed.
    return item; // Change this line
}

How do you add a number (item) to the end of an array (arr)?
How do you remove the first element from an array (arr)?

JuanLrr
@JuanLrr
Jul 19 2016 01:24
@sjames1958gm can you explain me why in the first one i need to write [value]? is it because tracks is an array?
Pitmation
@Pitmation
Jul 19 2016 01:24
arr.shift; item.pop;?
Stephen James
@sjames1958gm
Jul 19 2016 01:24
@JuanLrr Yes, you needed to make tracks an array
Joseph
@revisualize
Jul 19 2016 01:24
@Pitmation There were two questions and one answer?
Defeds
@defeds
Jul 19 2016 01:24

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

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

is that just essentially saying return the parameter "props" value?

Joseph
@revisualize
Jul 19 2016 01:25
@Pitmation One item on your list is correct to answer one of the questions.
JuanLrr
@JuanLrr
Jul 19 2016 01:25
@sjames1958gm thanks!
CamperBot
@camperbot
Jul 19 2016 01:25
juanlrr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2008 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Jul 19 2016 01:26
@defeds Are you still stuck?
Defeds
@defeds
Jul 19 2016 01:27
@revisualize Yeah, i guess just with that instruction
Stephen James
@sjames1958gm
Jul 19 2016 01:27
@defeds return the value of the property on the contact
Think of this challenge as going through a stack of business card looking for Bob's email. You look for Bob's card then look for his email address.
If you find his card and he has an email address return that, else return "no such property". If you do not find Bob's card return no such contact
Joseph
@revisualize
Jul 19 2016 01:27
@defeds Hint: You should return that there is NOT a contact in the contact list AFTER you've looped through all of the contacts.
Stephen James
@sjames1958gm
Jul 19 2016 01:27
@JuanLrr :+1:
Pitmation
@Pitmation
Jul 19 2016 01:29
you add a number by using push @sjames1958gm and then you remove an item by .push
Stephen James
@sjames1958gm
Jul 19 2016 01:29
@Pitmation push on and shift off?
Pitmation
@Pitmation
Jul 19 2016 01:30
@sjames1958gm shift off and push on
do I have to create a new variable to make this happen? @sjames1958gm
Stephen James
@sjames1958gm
Jul 19 2016 01:31
@Pitmation order is important, you have the value to push on item you can shift off into a variable and return that
Defeds
@defeds
Jul 19 2016 01:32
@revisualize Hmm, so that if statement would be outside the loop?
```
Joseph
@revisualize
Jul 19 2016 01:33
@defeds There is no if statement needed. (outside of the loop)
Defeds
@defeds
Jul 19 2016 01:34
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++) {
  if(firstName === contacts[i].firstName && prop === contacts[i].prop) {
    return contacts[i].prop;
  } else if(firstName !== contacts[i].firstName) {
    return "No such contact";
  } else if(prop !== contacts[i].prop) {
    return "No such property";
  }
}
so this is wrong? sorry for asking heaps, trying to understand :smile:
Pitmation
@Pitmation
Jul 19 2016 01:34
@sjames1958gm so can I do arr.push(item);
var first item = arr.shift(arr);
llamatarianism
@llamatarianism
Jul 19 2016 01:35
@defeds your function always returns something the first time it goes through the loop
so it only ever checks the 1st contact
Pitmation
@Pitmation
Jul 19 2016 01:35
return firstItem
llamatarianism
@llamatarianism
Jul 19 2016 01:35
@Pitmation shift doesn't take any arguments
so it's just arr.shift()
Stephen James
@sjames1958gm
Jul 19 2016 01:35
@Pitmation Yes you can. Bingo - (no space between first and item)
Joseph
@revisualize
Jul 19 2016 01:35
@defeds Does that code work?
llamatarianism
@llamatarianism
Jul 19 2016 01:35
but yes, you are right
Defeds
@defeds
Jul 19 2016 01:36

@revisualize it works for the last two, but it doesn't accept these:

Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]

Joseph
@revisualize
Jul 19 2016 01:36
@defeds Then the code doesn't work.
Pitmation
@Pitmation
Jul 19 2016 01:36
thank you @llamatarianism and @sjames1958gm
CamperBot
@camperbot
Jul 19 2016 01:36
pitmation sends brownie points to @llamatarianism and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: pitmation already gave sjames1958gm points
:star2: 1040 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Jul 19 2016 01:37
@defeds if you add in
console.log(i)
to your loop
you can see that it only ever logs 0
because your function returns on the first iteration, every time
Stephen James
@sjames1958gm
Jul 19 2016 01:38
@defeds If the first firstname doesn't match you will return no such contact and be done?
Also the last check for no such property should only be when firstname matches as well
Defeds
@defeds
Jul 19 2016 01:38
@llamatarianism Yeah thank you i'm starting to see that, so essentially because of the return it doesn't allow it to loop through all objects?
CamperBot
@camperbot
Jul 19 2016 01:38
defeds sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1041 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Jul 19 2016 01:38
return ends the execution of the function
so it also ends the execution of the loop
return is a bit like break, but for functions.
Stephen James
@sjames1958gm
Jul 19 2016 01:38
@defeds Remember the business card analogy
Defeds
@defeds
Jul 19 2016 01:39
@sjames1958gm @llamatarianism Thanks guys, i'll give it another shot :)
CamperBot
@camperbot
Jul 19 2016 01:39
defeds sends brownie points to @sjames1958gm and @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: defeds already gave llamatarianism points
:warning: defeds already gave sjames1958gm points
Stephen James
@sjames1958gm
Jul 19 2016 01:39
@defeds Try and take the input and the collection and be the computer and see where the code goes.
Keli Fine
@kelifine
Jul 19 2016 01:40
hey I've got the following code but it doesn't seem to be working for adding numbers to an array var array = [];
for (var i = 1; i == num; i++) {
array.push([i]);
}
can anyone help?
Diego Mayer
@Chrono79
Jul 19 2016 01:45
@kelifine why the [] around i? and i == num should be i <= num I guess
Maria Luciene
@lucienemlf
Jul 19 2016 01:45
Hi, I don't know why my tests are falling if the results are right. Can someone help me?
var array = [];

function reverseString(str) {
  for(var i = str.length; i >= 0; i--) {
    array.push(str[i]);
  }

  str = array.join('');
  return str;
}

reverseString("Greetings from Earth");
Diego Mayer
@Chrono79
Jul 19 2016 01:46
@lucienemlf your global var array keeps its value between tests, put it inside your function
Keli Fine
@kelifine
Jul 19 2016 01:46
@Chrono79 i've tried it with and without the [] and it didn't seem to help.. that fixed it though, thank you again!
CamperBot
@camperbot
Jul 19 2016 01:46
kelifine sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1569 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 19 2016 01:47
@kelifine with the [] you'll create an array of arrays like this: [[1],[2]...[n]]
Maria Luciene
@lucienemlf
Jul 19 2016 01:47
It worked. Thanks @Chrono79
CamperBot
@camperbot
Jul 19 2016 01:47
lucienemlf sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1570 | @chrono79 |http://www.freecodecamp.com/chrono79
Ralph Nahra
@Rallph
Jul 19 2016 01:52
Hey guys I'm back again but now I get TypeError: Cannot read property 'firstName' of undefined when I run this code

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];



function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
    return contacts[i][prop];
  }
}

  if (contacts[i].firstName !== firstName) {
    return "No such contact";
  }

  if (contacts[i].hasOwnProperty(prop) === false) {
    return "No such property";
  }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");
scarejar
@scarejar
Jul 19 2016 01:52
^ same problem rofl
well, stuck on the section
Ralph Nahra
@Rallph
Jul 19 2016 01:53
we can cry together
scarejar
@scarejar
Jul 19 2016 01:53
lol
been stuck on it for half an hour...
Joseph
@revisualize
Jul 19 2016 01:54
Let me look.
@scarejar What is your function?
scarejar
@scarejar
Jul 19 2016 01:54
pretty much the same as his really
Joseph
@revisualize
Jul 19 2016 01:54
TypeError: Cannot read property 'firstName' of undefined
Diego Mayer
@Chrono79
Jul 19 2016 01:55
@Rallph that's because you're using i outside the loop
Peter Weinberg
@no-stack-dub-sack
Jul 19 2016 01:55
Problem maybe someone can help me with, and I can post more code or the link to my pen if needed, but I have this jQuery hover effect that animates a div width on hover, then animates back to original state when mouse leaves the div. This part works fine, the thing is, I want the div to stay at the fully animated width (60px) ONLY if the div is clicked. Any idea how I might be able to accomplish this?
$("#streamingButton").hover(
  function(e){$(this).animate({width: "60px"})},
  function(e){$(this).animate({width: "20px"})}
);
Joseph
@revisualize
Jul 19 2016 01:56
@scarejar @Rallph Bob isn't the first person on the list.
scarejar
@scarejar
Jul 19 2016 01:56
Is the if (contacts[i].firstName === firstName) the right way to check if a property exist inside the array , inside that object?
Ralph Nahra
@Rallph
Jul 19 2016 01:56
ok so would this work?


//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];



function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
for (i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
    return contacts[i][prop];
  }
}

  if (contacts[i].firstName !== firstName) {
    return "No such contact";
  }

  if (contacts[i].hasOwnProperty(prop) === false) {
    return "No such property";
  }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");
scarejar
@scarejar
Jul 19 2016 01:57
no need to declare i twice
Diego Mayer
@Chrono79
Jul 19 2016 01:57
@Rallph no, because outside the loop i == contacts.length, so contacts[i] is undefined
Joseph
@revisualize
Jul 19 2016 01:57
@Rallph No.
Moisés Man
@moigithub
Jul 19 2016 01:57
@no-stack-dub-sack add a class on click.. with !important 60px width
Ralph Nahra
@Rallph
Jul 19 2016 01:57
@Chrono79 oh yeah, true
Joseph
@revisualize
Jul 19 2016 01:57
@Rallph contacts[i].firstName .. What is i outside of the loop?
scarejar
@scarejar
Jul 19 2016 01:57
double nest the if statements
Peter Weinberg
@no-stack-dub-sack
Jul 19 2016 01:57
@moigithub I will try that...
Joseph
@revisualize
Jul 19 2016 01:58
Also, you're not correctly creating a for loop.
scarejar
@scarejar
Jul 19 2016 01:58
wait lol, let me try it out P:
bcerney
@bcerney
Jul 19 2016 01:59
help markdown
CamperBot
@camperbot
Jul 19 2016 01:59
no wiki entry for: markdown
Ralph Nahra
@Rallph
Jul 19 2016 01:59
what's incorrect about the for loop?
Kun C
@KunFZ
Jul 19 2016 01:59
How can I post my code on here?
Diego Mayer
@Chrono79
Jul 19 2016 02:00
Read below @KunFZ
CamperBot
@camperbot
Jul 19 2016 02:00

: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

scarejar
@scarejar
Jul 19 2016 02:00
yeah, I'm stuck on returning the value of that property when both conditions are true
Kun C
@KunFZ
Jul 19 2016 02:00
@Chrono79 ok thx
CamperBot
@camperbot
Jul 19 2016 02:00
kunfz sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1571 | @chrono79 |http://www.freecodecamp.com/chrono79
Peter Weinberg
@no-stack-dub-sack
Jul 19 2016 02:01
@moigithub that worked and so simple. I was trying a couple of other similar solutions but my brain did not go there. Thanks much.
CamperBot
@camperbot
Jul 19 2016 02:01
no-stack-dub-sack sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1717 | @moigithub |http://www.freecodecamp.com/moigithub
scarejar
@scarejar
Jul 19 2016 02:02
nevermind.... so once the return line is hit, doesnt the for loop stop?
Kun C
@KunFZ
Jul 19 2016 02:02
function destroyer(arr) {
  var argumentLength = arguments.length;

  arr = arr.filter(function(currentValue){

    for(var i = 1; i < argumentLength; i++)
    {
      if(currentValue == arguments[i])
      {
        return false;
      }
    }
    return true;
  });

  return arr;
}

destroyer(["tree", "hamburger", 53], "tree", 53);
aye, so how come my filter doesn't work
scarejar
@scarejar
Jul 19 2016 02:03
@Rallph HALP
Diego Mayer
@Chrono79
Jul 19 2016 02:03
@KunFZ are you sure arguments inside your filter is the same arguments than the one outside?
Peter Weinberg
@no-stack-dub-sack
Jul 19 2016 02:04
@moigithub this is what I was trying, if your solution worked, why does this not?
$("#streamingButton").click(function(e) {
  $(this).css("width", "60px !important");
});
Kun C
@KunFZ
Jul 19 2016 02:04
@Chrono79 good point, I will try again
scarejar
@scarejar
Jul 19 2016 02:06
almost getting through P:
Ralph Nahra
@Rallph
Jul 19 2016 02:08
@scarejar sorry man I don't know anything lol
Moisés Man
@moigithub
Jul 19 2016 02:08
@no-stack-dub-sack css style will get overrided
class will remain on the html element...
scarejar
@scarejar
Jul 19 2016 02:08
@Rallph lol, I got the last 2 conditions done.... the first 3 though... I dont get why its not returning the prop
Peter Weinberg
@no-stack-dub-sack
Jul 19 2016 02:09
@moigithub ok, that makes sense... care to take a stab at the next problem which is very much related?
Stephen James
@sjames1958gm
Jul 19 2016 02:10
@scarejar @Rallph If you can learn any skill on these challenges that will surely help you long term, it is to be able to take the input to your code and run the code in your head or on paper and predict the path it will take. Practice this skill and the understanding of the code will follow.
Defeds
@defeds
Jul 19 2016 02:10
@scarejar it's opposite for me, the first 3 conditions go through, i'm just figuring out the last 3 haha, heres my code for the first though
Joseph
@revisualize
Jul 19 2016 02:10
Hint: You should return that there is NOT a contact in the contact list AFTER you've looped through all of the contacts.
CamperBot
@camperbot
Jul 19 2016 02:10
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Defeds
@defeds
Jul 19 2016 02:10
for(i = 0; i < contacts.length; i++) {
  if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
  } 
}
scarejar
@scarejar
Jul 19 2016 02:11
OHHH
, switch it around . prop !== stuff , not stuff !== prop
Stephen James
@sjames1958gm
Jul 19 2016 02:12
@defeds If you nest your ifs, then the code is much clearer.
if(firstName === contacts[i].firstName) {
  // do code for matching firstname
}
scarejar
@scarejar
Jul 19 2016 02:13
then again.. dont think its it... bu I swapped the two and it returned an error so I thought it was the way lol
Defeds
@defeds
Jul 19 2016 02:13
@sjames1958gm Thanks :)
CamperBot
@camperbot
Jul 19 2016 02:13
defeds sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2009 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
scarejar
@scarejar
Jul 19 2016 02:13
@defeds lol, thats exactly what I have...
Nick Irvine
@irvin3
Jul 19 2016 02:13
would anyone be able to help me get started on the Finders Keepers bonfire? I'm just not sure how to use a function as a parameter
CamperBot
@camperbot
Jul 19 2016 02:13
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Defeds
@defeds
Jul 19 2016 02:14
@scarejar but your first conditions arent working?
Nick Irvine
@irvin3
Jul 19 2016 02:14

function findElement(arr, func) {
  var num = 0;
  return num;
}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
scarejar
@scarejar
Jul 19 2016 02:14
nope
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++){
if(firstName == contacts[i].firstName && contacts[i].firstName.hasOwnProperty(prop)){
return contacts[i][prop];
}else if(firstName !== contacts[i].firstName){
return "No such contact";
}else if(prop !== contacts[i][prop]){
return "No such property";
}
}
// Only change code above this line
}
Stephen James
@sjames1958gm
Jul 19 2016 02:14
@irvin3 If the parameter name is func then simply func(value)
@scarejar Let's play a game. I have two contacts Susan and Bob in that order and I want Bob's email.
With your code I will see that the first contact doesnt match the firstname so the first if fails, then the second if passes and I return "No such contact"
But I never look at Bob's card :(
Remember return is the exit ramp for your function.
scarejar
@scarejar
Jul 19 2016 02:16
thought it would continue going because of the for loop lol
Kristo
@pathfinger
Jul 19 2016 02:16
Hi, I am stuck at Check for Palindromes challenge - https://www.freecodecamp.com/challenges/check-for-palindromes
I just don't get why every time I run the code, it says that lowerCase.split() is not a function.
Code that I have =

function palindrome(str) {
  // Good luck!
  var lowerCaseArray = [];
  var newText = "";
  var lowerCase = str.toLowerCase();
  lowerCase = /\W/gi;
  lowerCaseArray = lowerCase.split("");
  lowerCaseArray.reverse();
  newText = lowerCaseArray.join("");
  if (lowerCase === newText) {
    return true;
  } else {
    return false;
  }
}
palindrome("eye");
scarejar
@scarejar
Jul 19 2016 02:17
alright, I'll try switching the order , but the functions are called more than once
Stephen James
@sjames1958gm
Jul 19 2016 02:17
@pathfinger lowerCase is a RegExp object not a string
Schuyler Lewis
@spblewis
Jul 19 2016 02:17

Hello all, can anyone help me understand why my code won't work here? All I'm trying to do at the moment is return the raw data from the weather api. Any help would be appreciated.

https://codepen.io/spblewis/pen/MepbWm

Stephen James
@sjames1958gm
Jul 19 2016 02:17
@scarejar But for each test they are called only once.
Kristo
@pathfinger
Jul 19 2016 02:18
But how would I make it back into a string @sjames1958gm ?
Defeds
@defeds
Jul 19 2016 02:18
@sjames1958gm Just passed it! Thank you so so so much!
CamperBot
@camperbot
Jul 19 2016 02:18
defeds sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: defeds already gave sjames1958gm points
Kristo
@pathfinger
Jul 19 2016 02:18
Would I have to use replace? instead of just = /\W/gi?
Stephen James
@sjames1958gm
Jul 19 2016 02:18
@pathfinger You want to use .replace with the RegExp
@defeds Woot Woot now @scarejar is jealous
scarejar
@scarejar
Jul 19 2016 02:19
:
:<
Defeds
@defeds
Jul 19 2016 02:20
@sjames1958gm your way of explaining is a lot better, gave me a chance to actually figure it out myself instead of just getting the answer and learning nothing :)
Stephen James
@sjames1958gm
Jul 19 2016 02:20
@scarejar Try this analogy
Think of this challenge as going through a stack of business card looking for Bob's email. You look for Bob's card then look for his email address.
If you find his card and he has an email address return that, else return "no such property". If you do not find Bob's card return no such contact
The for loop is looking at each card in turn trying to find Bob's card
@defeds I try.
Defeds
@defeds
Jul 19 2016 02:21
Think of this challenge as going through a stack of business card looking for Bob's email. You look for Bob's card then look for his email address.
If you find his card and he has an email address return that, else return "no such property". If you do not find Bob's card return no such contact
@scarejar the bold part is where i figured it out
scarejar
@scarejar
Jul 19 2016 02:22
bob already has no such property lol, I have it working but the first 3 wont >_>
Ralph Nahra
@Rallph
Jul 19 2016 02:22
same
96street
@96street
Jul 19 2016 02:22
what does non-overlapping mean?
scarejar
@scarejar
Jul 19 2016 02:22
waittttt
Stephen James
@sjames1958gm
Jul 19 2016 02:23
@96street Not partially or fully on top of one another.
@96street What is the context
96street
@96street
Jul 19 2016 02:23
this is a function's documentation:
re.sub(pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl
not sure what it means there @sjames1958gm
Stephen James
@sjames1958gm
Jul 19 2016 02:25
@96street I think this means if you have a pattern like abcda and a string abdcabcdaabdca the second abdca overlaps the first because they share an a so there would only be two matches the first 5 and the last 5
Ralph Nahra
@Rallph
Jul 19 2016 02:27
I'm having the same propblem as scarejar but it's saying "No such contact". I have no idea what to do. If i put it in the for loop then it doesn't continue the loop, and if i put it outside the for loop i no longer means what it did.

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];



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

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




  if (firstName !== contacts[i].firstName) {
    return "No such contact";
  }

  if (contacts[i].hasOwnProperty(prop) === false) {
    return "No such property";
  }

}  
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");
Aaron Chiandet
@achiandet
Jul 19 2016 02:28
Good evening guys. I'm just now learning about the arguments object, which is totally new to me. It's not clicking so I'm seeking supplemental material to build and understanding, any suggestions?
I've read the MDN documentation.
Stephen James
@sjames1958gm
Jul 19 2016 02:29
@Rallph It cannot go inside the for loop because of the reason stated. If you get to the end of the for loop haven't you checked all the contacts, so you don't need a test, just return "no such contact"
scarejar
@scarejar
Jul 19 2016 02:29
lol, tried swapping the first two above and still no luck
Stephen James
@sjames1958gm
Jul 19 2016 02:30
also, no such property should be only checked if you are looking at the contact with the matching first name.
Ralph Nahra
@Rallph
Jul 19 2016 02:30
@sjames1958gm but what if the case is that it couldn't find the property?
Peter Weinberg
@no-stack-dub-sack
Jul 19 2016 02:31
Anyone feel like taking a look at my pen and guiding me through an issue I'm having, been stuck on it for a bit. @moigithub helped me solve it partially, but there is still some loose ends to tie up. There's some tricky circular logic I think I'm having trouble grasping. This part is not a requirement for the project, so I could just give it up, but boy, that would be no fun at all!
scarejar
@scarejar
Jul 19 2016 02:31
.-.
Defeds
@defeds
Jul 19 2016 02:32
@Rallph the if statements outside the loop have a contacts[i], but what is the [i] assigned to?
scarejar
@scarejar
Jul 19 2016 02:34
jeeezzus
y u no return :<
Ralph Nahra
@Rallph
Jul 19 2016 02:34
@defeds that's the problem. outside the loop it doesn't exists, but outside the loop i can't be used to keep track of the objects
Defeds
@defeds
Jul 19 2016 02:35
@Rallph well how are you getting the first name what are you doing to achieve that? don't you think you should do the same thing to the second if's?
ergooding
@ergooding
Jul 19 2016 02:36
does anybody have a good api that can be used with codepen? i've been trying to use quotesondesign.com, but my api calls keep getting blocked since they're being routed through a different origin
scarejar
@scarejar
Jul 19 2016 02:36
think i see the problem...
Ralph Nahra
@Rallph
Jul 19 2016 02:37
@defeds so i just put the others in their own for loop?
ergooding
@ergooding
Jul 19 2016 02:37
this quote generator is killing me :(
Defeds
@defeds
Jul 19 2016 02:37
@Rallph try it out, see if you're right
scarejar
@scarejar
Jul 19 2016 02:38
if the property firstname exists and it has its own property, it will return contact[i][prop]
but it doesnt check the others...
it returns the index of 1
of 0* when I need it to itterate through the rest
Defeds
@defeds
Jul 19 2016 02:40
@scarejar from what i've understood, it can't check the others because the return ends the loop
Stephen James
@sjames1958gm
Jul 19 2016 02:40
@scarejar - try this in your for loop
if(firstName === contacts[i].firstName) {
  // do code for matching firstname - test for property - return it or no such property
}
@scarejar If you don't match the first name, just go to the next contact.
Ralph Nahra
@Rallph
Jul 19 2016 02:43
well putting each if statement into a for loop didnt work
Stephen James
@sjames1958gm
Jul 19 2016 02:44
@Rallph Let's reword this.
For Each contact - if the contact has the matching first name then if it has a matching property return the property else return no such property. If after looking at all the contacts there is no matching first name return no such contact.
Ralph Nahra
@Rallph
Jul 19 2016 02:45
@sjames1958gm ohhh i think i get it now, thanks man
CamperBot
@camperbot
Jul 19 2016 02:45
rallph sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2010 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kun C
@KunFZ
Jul 19 2016 02:45
@Chrono79 thx it worked
CamperBot
@camperbot
Jul 19 2016 02:45
kunfz sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: kunfz already gave chrono79 points
Stephen James
@sjames1958gm
Jul 19 2016 02:46
@Rallph Good - cause I am heading to bed - good luck.
Ralph Nahra
@Rallph
Jul 19 2016 02:46
also to all the guys that hang out in the help channels, you da real MVPs
Defeds
@defeds
Jul 19 2016 02:54
@Rallph you added both into seperate for loops? for 3 total?
Ralph Nahra
@Rallph
Jul 19 2016 02:59
@defeds yes
Defeds
@defeds
Jul 19 2016 03:00
@Rallph why 3, try just the two in another
Aiden
@AidenMead
Jul 19 2016 03:01
Hey, can anyone help me out on the palindrome challenge?
fordj419
@fordj419
Jul 19 2016 03:05
hey can anyone help me please I'm stuck I'm on the escape Sequences in strings
here is my code
var myStr ="\FirstLine\nSecondLine\rThirdLine\";
KnoX
@knox97
Jul 19 2016 03:06
what are they asking you to do? @fordj419
scarejar
@scarejar
Jul 19 2016 03:07
still stuck rofl
so you need 2 for loops?
Norvin Burrus
@ndburrus
Jul 19 2016 03:07
@fordj419
ok, we need to take the given string, here:
"FirstLine newline backslash SecondLine backslash carriage-return ThirdLine" (ignore the spacing) and replace the appropriate text (bold words) with the escape coding (use the Code/Output chart)...
  • why is there a \ here: \FirstLine?
  • are we missing something, \n(here)SecondLine ?
  • also, missing something SecondLine(here)\r
  • why is there a \ here: ThirdLine\?
BarneyIX
@BarneyIX
Jul 19 2016 03:08
fordj419 you have to use \ to include \ in your sentence
Defeds
@defeds
Jul 19 2016 03:11
@scarejar :smile: if the if statements are outside the loop, how would they manage to go through the contacts array
BarneyIX
@BarneyIX
Jul 19 2016 03:11
it's to do with the number of \'s you use
scarejar
@scarejar
Jul 19 2016 03:11
lol, its going through the contacts >_> , just stuck on getting it to loop across all the props
gonna take a first* break and see if I can solve it lol
Defeds
@defeds
Jul 19 2016 03:11
@scarejar post code
BarneyIX
@BarneyIX
Jul 19 2016 03:12
"\SecondLine\" has to be like \SecondLine\\r
well it changed the formatting on me
scarejar
@scarejar
Jul 19 2016 03:12
how do I post it in code box?
Defeds
@defeds
Jul 19 2016 03:13
``` then shift enter and post code between it
scarejar
@scarejar
Jul 19 2016 03:13
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++){
   if(firstName !== contacts[i].firstName){
    return "No such contact";
   }
  else if(firstName == contacts[i].firstName){
    if(contacts[i].hasOwnProperty(prop)){
    return contacts[i][prop];
    }else if(prop !== contacts[i][prop]){
      return "No such property";
        }

  }
}
// Only change code above this line
}
Norvin Burrus
@ndburrus
Jul 19 2016 03:13
@fordj419 how are we doing?
review comment/s: :point_up: July 18, 2016 11:07 PM
Sara
@sarainshanghai
Jul 19 2016 03:14

Just finished the mutations bonfire but I'm still a little confused...

my code ends with an if statement. Without the curly braces, the entire code works and passes all the tests. With the curly braces, it only passes a portion of the tests. I understand that if statements don't always require braces but I don't understand why it changes some of the results when I add them?

function mutation(arr) {
var hello = arr[0].toLowerCase().split('');
var hey = arr1.toLowerCase().split('');
var diff = 0;

for (var i in hey) {
if (hello.indexOf(hey[i]) > -1) {
diff += 0;
} else {
diff += 1;
}
}
if (diff === 0)
return true;
else
return false;
}

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

fordj419
@fordj419
Jul 19 2016 03:14
@ndburrus thanks for helping but I'm still a little confused i met all the challenges it asked except this one.
CamperBot
@camperbot
Jul 19 2016 03:14
fordj419 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1029 | @ndburrus |http://www.freecodecamp.com/ndburrus
scarejar
@scarejar
Jul 19 2016 03:14
am I atleast close :< ?
fordj419
@fordj419
Jul 19 2016 03:15
myStr should have encoded text with the proper escape sequences and no spacing.
Norvin Burrus
@ndburrus
Jul 19 2016 03:15
help format @scarejar :sparkles:
for code posting - typing shift + enter provides additional line feeds (space for posting/pasting code).
you may also find the chat & compose buttons to the right of the chat text entry area useful. the backtick/s key is located to the left of the #1 (number one) key.
also, messages can be edited once they have been sent into the chat room. just hover to the right of the time stamp, and a button (three horizontal dots) will appear. click on that button and select edit. then, you can edit the previously entered text/message!
CamperBot
@camperbot
Jul 19 2016 03:15

: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

Defeds
@defeds
Jul 19 2016 03:15
@scarejar if firstname !== ?

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

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

scarejar
@scarejar
Jul 19 2016 03:16
so I should use the && ?
BarneyIX
@BarneyIX
Jul 19 2016 03:16
fordj419 it should look something like this '''//SecondLine///rThirdLine"
Norvin Burrus
@ndburrus
Jul 19 2016 03:16
@fordj419 is this the lesson? :point_up: July 18, 2016 11:07 PM
CamperBot
@camperbot
Jul 19 2016 03:16
:bulb: to format code use backticks! ``` more info
Defeds
@defeds
Jul 19 2016 03:16
@scarejar Yeah, i remember before you had it fine
BarneyIX
@BarneyIX
Jul 19 2016 03:16
the/'s are the escape characters you need to use
Why do they have yourname@yourname?
Aiden
@AidenMead
Jul 19 2016 03:18
I can't figure out why this code isn't working out, it should be working.
function palindrome(str) {

  var newString = str.toLowerCase('');
  var justLetters = newString.replace(/[^a-zA-Z0-9S]+/g);
  var backwards = justLetters.split('').reverse('').join('');
  if (str === backwards){
    return true;
  } else {
    return false;
  }
}



palindrome("eye");
It won't remove any of the characters I'm asking it to remove with 'var justLetters'
fordj419
@fordj419
Jul 19 2016 03:20
thanks @BarneyIX trying it now
CamperBot
@camperbot
Jul 19 2016 03:20
fordj419 sends brownie points to @barneyix :sparkles: :thumbsup: :sparkles:
:cookie: 176 | @barneyix |http://www.freecodecamp.com/barneyix
BarneyIX
@BarneyIX
Jul 19 2016 03:23
hey don't include the quotes in my previous suggestion btw Ford
I had to use that to get the /'s to show up
Norvin Burrus
@ndburrus
Jul 19 2016 03:31
@fordj419 were the comments helpful?
fordj419
@fordj419
Jul 19 2016 03:33
@ndburrus still trying it
Chris Katzmann
@cwkatzmann
Jul 19 2016 03:34
@AidenMead your if statement is incorrect
@AidenMead you are comparing the original string to the manipulated backwards string that is missing some characters and is lowercased
qeurago
@qeurago
Jul 19 2016 03:35
hey guys, i have a number that i got from an api, just wondering how can i code it so pressing a button changes that number? i tried a few things but i cant work it out
for ex. the number is 29 and i want to apply a mathematical equation to that number
Joseph
@revisualize
Jul 19 2016 03:40
@AidenMead You're doing your comparison incorrectly.
@scarejar YOu need to return No such contact AFTER you go through the whole list.
function lookUpProfile(firstName, prop){           // Basic function with two params
   for (var i = 0; i < contacts.length; i++) {     // you know a basic for loop through the contacts array.
        if (firstName === contacts[i].firstName) { // if the contact i has a firstName that matches my firstName param
            return contacts[i].hasOwnProperty(prop) ? contacts[i][prop] : "No such property"; // true
        }  // Ternary: if (contacts[i].hasOwnProperty(prop)) { return that contacts prop value } 
    }      // else ... return that it doesn't have the property
    return "No such contact"; // after the loop is completed. That means the contact wasn't found. 
}                             // because the function would have *HALTED* with the first return statement.
Norvin Burrus
@ndburrus
Jul 19 2016 03:42
@fordj419 can you post your code so far?
scarejar
@scarejar
Jul 19 2016 03:44
:O
GOT THE FIRST 3
Joseph
@revisualize
Jul 19 2016 03:46
I said...
Hint: You should return that there is NOT a contact in the contact list AFTER you've looped through all of the contacts.
5 times in this chat across the last two hours. And no one seemed to listen.
Alisdair Frost
@pacificfrost
Jul 19 2016 03:48
Hey guys, I'm a little stumped with record collection. Mind if I get some help?
scarejar
@scarejar
Jul 19 2016 03:49
@revisualize tried that but still stuck lol
@pacificfrost what are you stuck on?
kevinstonge
@kevinstonge
Jul 19 2016 03:50
I can't believe I figured out "Wherefore art thou" ... it was so damn confusing! How horrible is my solution?
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  arr = collection;
  arr = arr.filter(function(val) {
    j=0;
    for (i=0;i<Object.keys(source).length;i++) {
      if (arr[arr.indexOf(val)].hasOwnProperty(Object.keys(source)[i]) && arr[arr.indexOf(val)][Object.keys(source)[i]] == source[Object.keys(source)[i]]) { j++; }
    }
    return (j==Object.keys(source).length);
  });

  // Only change code above this line
  return arr;
}
Alisdair Frost
@pacificfrost
Jul 19 2016 03:50

I want to figure out the pseudocode, then I'll try and figure out the rest, buuut:

```function updateRecords(id, prop, value) {
/ pseudocode
variables
i: id, prop, value,
o: collection
/
if (collection[[hasOwnProperty(prop)]] === false)
console.log("added prop successfully");

if (collection.id[prop[0]] === 0)
collection = collection.id[prop[push(value)]];
console.log("pushed value");

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

return collection;
}```

scarejar
@scarejar
Jul 19 2016 03:51
o:
Alisdair Frost
@pacificfrost
Jul 19 2016 03:52
@revisualize Thanks. I'll take a look!
CamperBot
@camperbot
Jul 19 2016 03:52
pacificfrost sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1430 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 19 2016 03:53
@pacificfrost You're trying to use dot notation for variables. That doesn't work. Dot Notation is a string literal. Example: myObj.name; is the same as myObj["name"]; if you want to access the var name; you need to use bracket notation without "s because "s signify strings. myObj[name];
@pacificfrost This: collection[[hasOwnProperty(prop)]] is also not correct.

@pacificfrost Doing this:

if (collection.id[prop[0]] === 0)
collection = collection.id[prop[push(value)]];

Overrides the whole var collection.

Doing collection.id[prop[push(value)]] isn't the correct way to push to an array.
Alisdair Frost
@pacificfrost
Jul 19 2016 03:55
@revisualize Right. I'll take another look based on what you've told me and see what I can do.
Joseph
@revisualize
Jul 19 2016 03:56
@pacificfrost if (value === 0){ isn't the same as "If value is blank, " That code you have reads.. "If value is 0, "
Ye
@qzmly100
Jul 19 2016 03:56

现在我们将使用字符串的相关知识,建立一个填字风格的文字游戏。

通过使用提供的变量:名词myNoun、形容词myAdjective、动词myVerb、副词myAdverb,来创建一个新的字符串 result。

此外,除了所提供的词之外,你还需要添加额外的连接字符串。

我们提供了多种测试,该测试将用多个不同的输入来运行你的函数,以确保所有提供的单词和你额外添加的连接字符串能够准确输出。

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");
wordBlanks("cat", "little", "hit", "slowly");

please how doing?
Ye
@qzmly100
Jul 19 2016 04:01
Thanks you
edmond
@aqkfps
Jul 19 2016 04:09
blob
Alisdair Frost
@pacificfrost
Jul 19 2016 04:09
@revisualize , it seems to print, so it hasn't crashed, but it's not printing anything to the console so far.
  if (collection[id.hasOwnProperty(prop)] === "")
    collection[id[0]] = prop;
I'm not sure how to check if the array has the property. I think is basically what has me stumped
Joseph
@revisualize
Jul 19 2016 04:11
@pacificfrost May I suggest reviewing that link?
Alisdair Frost
@pacificfrost
Jul 19 2016 04:12
@revisualize Sure, sorry. I guess I'm just being impatient. I'll try again! Thanks for the hint.
CamperBot
@camperbot
Jul 19 2016 04:12
pacificfrost sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: pacificfrost already gave revisualize points
Joseph
@revisualize
Jul 19 2016 04:12
@aqkfps (firstName === contacts[i]["firstName"])
edmond
@aqkfps
Jul 19 2016 04:15
blob
Emelin GUtierrez
@emelinpg
Jul 19 2016 04:17
Can somene help me with the "passing values to functions with arguments" section plz
Jerzz
@2cool4school
Jul 19 2016 04:17
Hey does anyone have a second?
Taylor
@admiraltaylor
Jul 19 2016 04:17
Yeah sure dude
Jerzz
@2cool4school
Jul 19 2016 04:18
how is the factorial of 0 supposed to be 1? factorial(0) = 1????
Taylor
@admiraltaylor
Jul 19 2016 04:18
@emelinpg What is your question?
Jerzz
@2cool4school
Jul 19 2016 04:18
am i missing something
Taylor
@admiraltaylor
Jul 19 2016 04:18
hmmm
Jerzz
@2cool4school
Jul 19 2016 04:18
all factorials work except the case of the zero
Emelin GUtierrez
@emelinpg
Jul 19 2016 04:19
@admiraltaylor I dont understand the section at all! i made ductionWithArgs a function but after that i'm lost
David Di Feo
@ddifeo
Jul 19 2016 04:19
@2cool4school its just defined that way by mathematicians
Taylor
@admiraltaylor
Jul 19 2016 04:19
@2cool4school what Dave just said.
Emelin GUtierrez
@emelinpg
Jul 19 2016 04:21
@admiraltaylor nvm I just figured it out!ty you tho
Taylor
@admiraltaylor
Jul 19 2016 04:22
haha no worries
Jerzz
@2cool4school
Jul 19 2016 04:22
@realxtensive @admiraltaylor
I was just making sure I wasn't erring in some way... Doesn't make sense but that's not my profession of choice. Throw in an if num = 0 return 1 and bam
thanks guys
Taylor
@admiraltaylor
Jul 19 2016 04:26
I, too need help if someone know's what's up. I'm stuck on the "Seek and Destroy". Basked on what I understand from the Arguments and filter documentation, this should work, but... apparently the array I created isn't real?

function destroyer(arr)
{
// Remove all the values
var args = Array.prototype.slice.call(arguments);
var missiles = args.slice(1, args.length);
var victims = args.slice(0,1);

for (var i=0; i<missiles.length; i++)
{
victims.filter(missiles[i]);
}

return victims;
}

destroyer([1, 2, 3, 4, 5, 6], 7, 8);

quicksilver774
@quicksilver774
Jul 19 2016 04:27
Hi guys, i need some help. Ive been stuck on this counting cards excercise for a whole day
vkrish83
@vkrish83
Jul 19 2016 04:27
could anyone help me to complete switch statement exercise
Emelin GUtierrez
@emelinpg
Jul 19 2016 04:28
Can someone help me with "Global Scope and Functions" I am completley lost in this section
Taylor
@admiraltaylor
Jul 19 2016 04:28
do any of you have specific questions?
quicksilver774
@quicksilver774
Jul 19 2016 04:28
Ive almost got it complete but the code wont resolve for Cards Sequence 10, J, Q, K, A should return "-5 Hold"

here is my codevar answer = "";

switch (card){   
  case card = 2, 3, 4, 5, 6:   
  answer = "5 Bet";
  break;


  case card = 2, 'J', 9, 2, 7:
  answer = "1 Bet";
  break;


  case card = 2, 2, 10:
  answer = "1 Bet";
  break;


  case card = 7, 8, 9:
  answer = "0 Hold";
  break;


  case card = 3, 7,'Q', 8, 'A':
  answer = "-1 Hold";
  break;


  case card = 3, 2, 'A', 10, 'K':
  answer = "-1 Hold";
  break;

  case card = 10, 'J', 'Q', 'K', 'A':
  answer = "-5 Hold";
      }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');

Emelin GUtierrez
@emelinpg
Jul 19 2016 04:29
I dont understand the section at all :(
Jerzz
@2cool4school
Jul 19 2016 04:29
@emelinpg what do you not understand?
quicksilver774
@quicksilver774
Jul 19 2016 04:29

var count = 0;

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

switch (card){   
  case card = 2, 3, 4, 5, 6:   
  answer = "5 Bet";
  break;


  case card = 2, 'J', 9, 2, 7:
  answer = "1 Bet";
  break;


  case card = 2, 2, 10:
  answer = "1 Bet";
  break;


  case card = 7, 8, 9:
  answer = "0 Hold";
  break;


  case card = 3, 7,'Q', 8, 'A':
  answer = "-1 Hold";
  break;


  case card = 3, 2, 'A', 10, 'K':
  answer = "-1 Hold";
  break;

  case card = 10, 'J', 'Q', 'K', 'A':
  answer = "-5 Hold";
      }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');

Carlos Zavaleta
@nerdyamigo
Jul 19 2016 04:29
@emelinpg what section u stuck on?
edmond
@aqkfps
Jul 19 2016 04:30
case :2
Carlos Zavaleta
@nerdyamigo
Jul 19 2016 04:30
@emelinpg Global scope can be accessed throughout everywhere in your code so if you declare a global variable you can use that variable in any function you have
Coy Sanders
@coymeetsworld
Jul 19 2016 04:30
@quicksilver774 that doesn't look right
Emelin GUtierrez
@emelinpg
Jul 19 2016 04:31
@2cool4school @cyberamigo I'm stuck in the "global scope and fuctions". I dont understand how to declare a global variable though
Carlos Zavaleta
@nerdyamigo
Jul 19 2016 04:31
@emelinpg but if you have local scope meaning you declare a varibale inside a function you can only access that value inside that function
Coy Sanders
@coymeetsworld
Jul 19 2016 04:31
the case should only be one card value each, and you need each card type
2-A
Taylor
@admiraltaylor
Jul 19 2016 04:31
@quicksilver774 I think you're taking the wrong approach.
Carlos Zavaleta
@nerdyamigo
Jul 19 2016 04:32
@emelinpg you declare a global scope outside of a function
//this is a global variable
var a = 'I am global' 

function globalvar() { 
console.log(a)
}
quicksilver774
@quicksilver774
Jul 19 2016 04:32
it meets all the instructions but 1
and idk why
Coy Sanders
@coymeetsworld
Jul 19 2016 04:32
but its not the right way to do it
Taylor
@admiraltaylor
Jul 19 2016 04:32
@quicksilver774 instead of making a switch statement for the specific answers that it will test for, you should make switch statements that add or subtract from the "count" variable which was declared for you at the top of the code
quicksilver774
@quicksilver774
Jul 19 2016 04:33
What approach should i take?
Coy Sanders
@coymeetsworld
Jul 19 2016 04:33
the count changes after each card, so after cc(10); cc('J'); cc('Q'); cc('K'); cc('A'); it should print out -5 Hold, but if it was just cc(10); it would be -1 Hold, then when you call cc('J'); it would be -2 Hold;
pahosler
@pahosler
Jul 19 2016 04:33
sorta brute forcing it
edmond
@aqkfps
Jul 19 2016 04:33
This message was deleted
scarejar
@scarejar
Jul 19 2016 04:33
will "Math.random()" ever generate a 1? Or is 1 excluded?
pahosler
@pahosler
Jul 19 2016 04:33
intersting to see all the different coding styles and approaches here
Coy Sanders
@coymeetsworld
Jul 19 2016 04:33
@aqkfps please remove that
don't give the answers out please
Carlos Zavaleta
@nerdyamigo
Jul 19 2016 04:33
@emelinpg that a variable is global because it was declared on the global scope so it can be used inside my function
edmond
@aqkfps
Jul 19 2016 04:33
sorry
Carlos Zavaleta
@nerdyamigo
Jul 19 2016 04:34
@emelinpg i sent you a pm if u need more help
Taylor
@admiraltaylor
Jul 19 2016 04:34
@coymeetsworld have you already completed the "seek and destroy" algorithm?
pahosler
@pahosler
Jul 19 2016 04:34
javascript is certainly versatile :D
Coy Sanders
@coymeetsworld
Jul 19 2016 04:34
yes @admiraltaylor
quicksilver774
@quicksilver774
Jul 19 2016 04:34
the code examples havent taught me that method above
so i couldnt understand it,
Coy Sanders
@coymeetsworld
Jul 19 2016 04:34
@quicksilver774 do you know how case/switch works? incrementing/decrementing a variable? That's pretty much all you need
Taylor
@admiraltaylor
Jul 19 2016 04:34
@coymeetsworld do you mind helping me out? I'm stuck but I thought I was following the documentation properly
quicksilver774
@quicksilver774
Jul 19 2016 04:34
i tried nesting an if statement inside a switch statement to account for the count but it didnt seem to work
pahosler
@pahosler
Jul 19 2016 04:35
@quicksilver774 use if/else this is one of those cases where it's a much easier approach
Taylor
@admiraltaylor
Jul 19 2016 04:35
@quicksilver774 you don't need to account for the count. You need to add to it or subtract from it depending on what card is added
Coy Sanders
@coymeetsworld
Jul 19 2016 04:35
@quicksilver774 you could use a series of if/elseif/else statements, but case/switch is much simpler
i would go with case/switch, but each case should represent an individual card, not a sequence of cards
the idea is every time you call cc() the count gets modified based on the card that is shown
so when you call cc() 5 times and each is a high card the count is -5
but if you called cc() only 3 times with high cards its -3
Vishal Bansal
@Vishal0024
Jul 19 2016 04:36
help?
CamperBot
@camperbot
Jul 19 2016 04:36

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

Coy Sanders
@coymeetsworld
Jul 19 2016 04:36
or say you called it 4 times, 2 times its a low card and 2 times its high, the count would be 0, does that make sense?
pahosler
@pahosler
Jul 19 2016 04:37
it's only 12 lines of code with if/else not sure how many with switch/case
Coy Sanders
@coymeetsworld
Jul 19 2016 04:37
maybe less lines @pahosler, but less text overall
you can actually put multiple cases on same line too so code can be even more succinct
Vishal Bansal
@Vishal0024
Jul 19 2016 04:38
help?
CamperBot
@camperbot
Jul 19 2016 04:38

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

Taylor
@admiraltaylor
Jul 19 2016 04:38
thanks @camperbot
CamperBot
@camperbot
Jul 19 2016 04:38
admiraltaylor sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 2073 | @camperbot |http://www.freecodecamp.com/camperbot
Taylor
@admiraltaylor
Jul 19 2016 04:38
geez
quicksilver774
@quicksilver774
Jul 19 2016 04:39
@coymeetsworld it makes sense what you say!
Thanks, ill give it a try
Coy Sanders
@coymeetsworld
Jul 19 2016 04:40
ok good, i'll be around
Taylor
@admiraltaylor
Jul 19 2016 04:40
blob
@coymeetsworld this is my code for seek and destroy. .. any insights?
when I run it, the output is "7 is not a function"
er: "TypeError: 7 is not a function"
pahosler
@pahosler
Jul 19 2016 04:42

@coymeetsworld nah, not for this one...

if (card >=2 && card <=6) {
    count++;
  } else if (card >=7 && card <=9) {
    count=count;
  } else {
    count--;
  }

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

don't cheat y'all!!!

Coy Sanders
@coymeetsworld
Jul 19 2016 04:43
@pahosler how do you count for face cards?
or I see
John Yoo
@goonboy
Jul 19 2016 04:43
Can anyone help me with the "Escape Sequences in Strings" exercise for Javascript?
Coy Sanders
@coymeetsworld
Jul 19 2016 04:43
@admiraltaylor I think thats coming from your filter function
filter takes in a function, not a value
Taylor
@admiraltaylor
Jul 19 2016 04:44
correct
hahaha
that would explain a lot
Coy Sanders
@coymeetsworld
Jul 19 2016 04:44
the MDN article has pretty good example of how filter works
Taylor
@admiraltaylor
Jul 19 2016 04:44
gracias
John Yoo
@goonboy
Jul 19 2016 04:44
anyone see a problem with this code?
var myStr = 'FirstLine \n \SecondLine\ \r Thirdline';
I can't get by this JS exercise in freeCodeCamp
It gives me this error - "myStr should have encoded text with the proper escape sequences and no spacing."
Coy Sanders
@coymeetsworld
Jul 19 2016 04:46
yeah theres some problems with it @goonboy
This message was deleted
yeah there shouldn't be any spaces
try removing them and see what happens
John Yoo
@goonboy
Jul 19 2016 04:47
but I tried this var myStr = 'FirstLine\n\SecondLine\\rThirdline';
and I still got the same error
pahosler
@pahosler
Jul 19 2016 04:47
@coymeetsworld see the else count-- at the end of my if/else :D
you oughta see how short my piglatin code is :D :D
John Yoo
@goonboy
Jul 19 2016 04:49
this is what the code should be based on - FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Coy Sanders
@coymeetsworld
Jul 19 2016 04:50
you have a typo in your answer @goonboy, look at it closer
fix it and i think you're ok
Joseph
@revisualize
Jul 19 2016 04:50
@goonboy How do you escape a new line?
How do you escape a backslash?
How do you escape a carriage-return?
Coy Sanders
@coymeetsworld
Jul 19 2016 04:50
he got all that @revisualize, he just has a typo
Joseph
@revisualize
Jul 19 2016 04:51
\n \\ \r
Oh!
Thirdline.
LOL!
Coy Sanders
@coymeetsworld
Jul 19 2016 04:51
yeah
John Yoo
@goonboy
Jul 19 2016 04:52
var myStr = 'FirstLine\n\SecondLine\\rThirdline';
ohhh
you guys are the best!
Code long and prosper.×
Coy Sanders
@coymeetsworld
Jul 19 2016 04:53
:thumbsup:
96street
@96street
Jul 19 2016 04:53
Any idea why this isn't working? (Python)
Define a function called purify that takes in a list of numbers, removes all odd numbers in the list, and returns the result.
def purify(numbers):
    ans = []
    for num in numbers:
        if num % 2 == 0:
            ans += num
    return ans

print purify([1, 2, 3, 4])
John Yoo
@goonboy
Jul 19 2016 04:53
merci beaucoup! sorry, it's been a long day of of coding bootcamp...my brain is friend
my brain is fried I mean.
David Shin
@datadaveshin
Jul 19 2016 04:54
@96street - you have to append to the ans list
ans.append(num)
96street
@96street
Jul 19 2016 04:55
Thanks that works @datadaveshin
CamperBot
@camperbot
Jul 19 2016 04:55
96street sends brownie points to @datadaveshin :sparkles: :thumbsup: :sparkles:
:cookie: 9 | @datadaveshin |http://www.freecodecamp.com/datadaveshin
David Shin
@datadaveshin
Jul 19 2016 04:55
you were trying to add a list to a number
Joseph
@revisualize
Jul 19 2016 04:55
Help JavaScript ... Help JavaScript ... Help JavaScript
CamperBot
@camperbot
Jul 19 2016 04:55
no wiki entry for: javascript help javascript helpjavascript
96street
@96street
Jul 19 2016 04:55
Whoops thought I was in Help
David Shin
@datadaveshin
Jul 19 2016 04:55
or rather vice versa….
Nick Irvine
@irvin3
Jul 19 2016 04:55
hey peeps, Im working on the steamroller bonfire and think i may need a little assistance in simplifying a multidimensional array
Joseph
@revisualize
Jul 19 2016 04:56
@96street https://gitter.im/FreeCodeCamp/Help is just for HTML/CSS & jQuery.
Nick Irvine
@irvin3
Jul 19 2016 04:56

function steamrollArray(arr) {
  // I'm a steamroller, baby
  var newArr = [];
  for(var x = 0; x < arr.length; x++){
    if(Array.isArray(arr[x])){
      for(var i = 0; i < arr[x].length; i++){
        newArr.push(arr[x][i]);
      }
    }
    else{
      newArr.push(arr[x]);
    }
  }
  //return in fcc
  console.log(newArr);

}

steamrollArray([1, [2], [3, [[4]]]]);
steamrollArray([1, {}, [3, [[4]]]]);
96street
@96street
Jul 19 2016 04:56
@revisualize Thought it was for anything
because there is no other room to ask this
There isn't?
help chat
CamperBot
@camperbot
Jul 19 2016 04:56

:point_right: official free code camp chat rooms [wiki]

The following are our official chat rooms.

Please note that all chat rooms listed here are publicly accessible and indexed by search engines, so only share email addresses or other sensitive information in private messages.

Chat Room Description
FreeCodeCamp our main chat room - hang out and chat about life and learning to code
Help get help with our HTML, CSS and jQuery challenges from your fellow campers
HelpJavaScript get help with our JavaScript and algorithm challenges from your fellow campers
HelpFrontEnd get help with our front end projects from your fellow campers
HelpDataViz get help with our data visualization projects from your fellow campers
HelpBackEnd get help with our back end projects from your fellow campers
Git get help with using Git, from your fellow campers
Linux get help with using Linux, from your fellow campers
SQL get help on relational databases and SQL, from your fellow campers
Python get help doing our back end projects in Python, from your fellow campers
Java get help doing our back end projects in Java, from your fellow campers
Ruby get help doing our back end projects in Ruby, from your fellow campers
PHP get help doing our back end projects in PHP, from your fellow campers
Go get help doing our back end projects in Go, from your fellow campers

:pencil: read more about official free code camp chat rooms on the FCC Wiki

pahosler
@pahosler
Jul 19 2016 04:56
@irvin3 MDN actually has the answer for that
96street
@96street
Jul 19 2016 04:56
not active @revisualize
Joseph
@revisualize
Jul 19 2016 04:57
@96street Then I'd suggest going to the main chat room.
Nick Irvine
@irvin3
Jul 19 2016 04:57
@pahosler is that the mozilla site?
pahosler
@pahosler
Jul 19 2016 04:57
yup
search flatten
IIRC
not the name a a js prototype, but a code example
Nick Irvine
@irvin3
Jul 19 2016 04:58
@pahosler are you talking about the reduce()?
pahosler
@pahosler
Jul 19 2016 04:58
indeed
Joseph
@revisualize
Jul 19 2016 04:59
@96street You're also not doing your code correctly.
Nick Irvine
@irvin3
Jul 19 2016 04:59
@pahosler yea i think i will run into a problem with that maybe, since the array is multidimensional , right?
96street
@96street
Jul 19 2016 04:59
how so? @revisualize
pahosler
@pahosler
Jul 19 2016 04:59
nope
@irvin3 always try the stuff, see if it works, tweak if needed
@irvin3 I think the only code change I had to make was exchanging my array name
Nick Irvine
@irvin3
Jul 19 2016 05:02
Yea i was just thinking i couldnt go that route because it sugests using Array.isArray()
Joseph
@revisualize
Jul 19 2016 05:02
@96street Let me write this in JS for you:
Define a function called purify that takes in a list of numbers, removes all odd numbers in the list, and returns the result.
function purify (arr) {
   var result = [];
   for (var i = 0; i < arr.length; i++) {
      if ((arr[i] % 2) === 0) {
          result.push(arr[i]);
      }
   }
   return result; // returning an array of results.
}
OR!
Joseph
@revisualize
Jul 19 2016 05:03
function purify (arr) {
   return arr.filter(x => (arr[x] % 2) === 0);
}
pahosler
@pahosler
Jul 19 2016 05:04
nice @revisualize !
Joseph
@revisualize
Jul 19 2016 05:04
OR!
pahosler
@pahosler
Jul 19 2016 05:04
uh oh
Joseph
@revisualize
Jul 19 2016 05:04
var purify = (arr) => arr.filter(x => (arr[x] % 2) === 0);
Nick Irvine
@irvin3
Jul 19 2016 05:04
@pahosler yea that example that they give produced the same result that i was getting with the code i wrote, i still have trouble with reducing a multidimensional array within a multdimensional array
96street
@96street
Jul 19 2016 05:06
that looks good, what is 'x =>' though? @revisualize
David Shin
@datadaveshin
Jul 19 2016 05:06
I wouldn’t say the first way was wrong, in fact, I think the first way is better for a beginner, then work up to using things like map/filter/reduce, etc.
pahosler
@pahosler
Jul 19 2016 05:06
@irvin3 you have something similar to this?
return arr.reduce(function (flat, toFlatten) {
      return flat.concat(Array.isArray(toFlatten) ? steamrollArray(toFlatten) : toFlatten);
    }, []);
Joseph
@revisualize
Jul 19 2016 05:06
@96street ES6 Arrow Function.
@96street All 3 code blocks should do the same thing.
Manisha
@manisha9735
Jul 19 2016 05:07
please take a look my code. why isn't it giving the correct results?
https://www.freecodecamp.com/challenges/counting-cards#
Joseph
@revisualize
Jul 19 2016 05:07
@manisha9735 "Talk is cheap. Show me the code." - Linux
Nick Irvine
@irvin3
Jul 19 2016 05:08
@pahosler not exactly, I dont quite understand your code after flat.concat
pahosler
@pahosler
Jul 19 2016 05:08
look up turnary
Manisha
@manisha9735
Jul 19 2016 05:09

function cc(card) {
// Only change code below this line

var count =0;
switch (card){

case 2:
   count++;
case 3:
  count++;
case 4:
  count++;
case 5:
  count++;
case 6:
  count++;
 case 7:
  count=count;
   case 8:
  count=count;
   case 9:
  count=count;
   case 10:
  count--;
   case "J":
  count--;
   case "K":
  count--;
   case "Q":
  count--;
   case "A":
  count--;
   if(count>=1){
     return (count+" Bet");
   }
     else{
       return (count+" Hold");
     }

   break;

}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Archangelpak
@Archangelpak
Jul 19 2016 05:09
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = "maps"; // Change this line
can someone pls help me with this task?
David Shin
@datadaveshin
Jul 19 2016 05:09
@96street @revisualize in python, probably the more “pythonic” way of doing it would have been
<code>def purify(numbers):
return [num for num in numbers if num % 2 == 0]</code>
Nick Irvine
@irvin3
Jul 19 2016 05:10
@pahosler okay I understand your code now, I would have never gotten that with what has been provided so far in FCC tho
David Shin
@datadaveshin
Jul 19 2016 05:10
how do you make a code block, lol
Joseph
@revisualize
Jul 19 2016 05:10
@manisha9735 You're not breaking.
@manisha9735
// Here is a pseudocode example:

switch (num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  case valueN:
    statementN;
    break;
}
pahosler
@pahosler
Jul 19 2016 05:11
weird los real time connection, never happened to me b4 :O
David Shin
@datadaveshin
Jul 19 2016 05:12
def purify(numbers):
    return [num for num in numbers if num % 2 == 0]

print purify([1, 2, 3, 4])
pahosler
@pahosler
Jul 19 2016 05:12
phew, think I'm back now...
Archangelpak
@Archangelpak
Jul 19 2016 05:12
anyone?
96street
@96street
Jul 19 2016 05:12
@datadaveshin yeah that seems better just dont think ive come across it yet
Manisha
@manisha9735
Jul 19 2016 05:12
@revisualize If i use break, it will not count for the other values. how do i mke it count for the other values as well?
Markus Kiili
@Masd925
Jul 19 2016 05:12
@Archangelpak Access the object with bracket or dot notation.
David Shin
@datadaveshin
Jul 19 2016 05:13
@96street - that’s an example of “list comprehension”… it’s a little advanced, but if you say it out loud it will make sense… “return num for each num in numbers if blah blah"
pahosler
@pahosler
Jul 19 2016 05:13
@irvin3 don't rely on just what you get here, read research, and watch some of the other people get help
Archangelpak
@Archangelpak
Jul 19 2016 05:13
@Masd925 as far as I know I can read
David Shin
@datadaveshin
Jul 19 2016 05:14
@96street - you need the brackets to make it a list though, without , you end up in the weird realm of generators
pahosler
@pahosler
Jul 19 2016 05:14
@irvin3 if you use it the challenge will show errors in the code box but it'll still run, it's weird like that
Alisdair Frost
@pacificfrost
Jul 19 2016 05:14

Hey guys, I'm still having trouble with record collection....

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

I've even pulled this ^ solution from codepen, and it still says this task is incorrect? is there a bug?

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Ye
@qzmly100
Jul 19 2016 05:14

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "myNoun"+"myAdjective"+"myVerb"+"myAdverb";
// 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");
//wordBlanks("cat", "little", "hit", "slowly");

help me?
CamperBot
@camperbot
Jul 19 2016 05:14

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

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

Via Command Line

Refer to this answer on Super User.

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

Markus Kiili
@Masd925
Jul 19 2016 05:15
@Archangelpak There is only one property key inside myStorage, so use it as a key when you access the object. Then look what is the property value of that key.
Nick Irvine
@irvin3
Jul 19 2016 05:15
@pahosler yea I mean obviously i look up stuff that i know that im not familiar with, but would have never been able to know that i didnt know the part that I was referring to
pahosler
@pahosler
Jul 19 2016 05:16
@irvin3 yup
@irvin3 saw the turnary thing being used here in chat, checked it out, use it a LOT
Alisdair Frost
@pacificfrost
Jul 19 2016 05:17
Anyone able to help?
pahosler
@pahosler
Jul 19 2016 05:18

like with this...

var pig = str;
  (str = str.split(/(\b)([^aeiou]+)/).reverse().join('')) === pig ? str += "way" : str += "ay";
  return str;

I love that bit of code LOL

96street
@96street
Jul 19 2016 05:18
@datadaveshin yeah i did it seems logical
ty
Manish Giri
@Manish-Giri
Jul 19 2016 05:20
@pacificfrost with?
Alisdair Frost
@pacificfrost
Jul 19 2016 05:20

Hey guys, I'm still having trouble with record collection....

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

I've even pulled this ^ solution from codepen, and it still says this task is incorrect? is there a bug?

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
that lol........... I am so lost right now :worried:
Archangelpak
@Archangelpak
Jul 19 2016 05:20
@Masd925 I dont get it
Manish Giri
@Manish-Giri
Jul 19 2016 05:21
@pacificfrost post the challenge URL from your browser
Alisdair Frost
@pacificfrost
Jul 19 2016 05:21
@Manish-Giri https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%0A%20%20%20%20%2F%2F%20If%20prop%20isn't%20%22tracks%22%20and%20value%20isn't%20blank%2C%20%0A%20%20%20%20%2F%2F%20update%20or%20set%20the%20value%20for%20that%20record%20album's%20property.%0A%20%20%20%20if%20(prop%20!%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22)%0A%20%20%20%20%20%20collection%5Bid%5D%5Bprop%5D%20%3D%20value%3B%0A%0A%20%20%20%20%2F%2F%20If%20prop%20is%20%22tracks%22%20and%20value%20isn't%20blank%2C%20%0A%20%20%20%20%2F%2F%20push%20the%20value%20onto%20the%20end%20of%20the%20album's%20existing%20tracks%20array.%0A%20%20%20%20%2F%2F%20If%20prop%20is%20%22tracks%22%20but%20the%20album%20doesn't%20have%20a%20%22tracks%22%20property%2C%20%0A%20%20%20%20%2F%2F%20create%20an%20empty%20array%20before%20adding%20the%20new%20value%20to%20the%20album's%20%0A%20%20%20%20%2F%2F%20corresponding%20property.%0A%20%20%20%20%2F%2F%20Your%20code%20here%0A%0A%2F%2F%20If%20value%20is%20blank%2C%20%0A%2F%2F%20delete%20that%20property%20from%20the%20album.%0A%20%20%20%20%2F%2F%20Your%20code%20here%0A%20%20%20%20%0A%20%20%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
Olly Sholotan
@Ollysho
Jul 19 2016 05:22
Hey guys! could anyone tell me why my code is giving me back an empty array?

function bouncer(arr) {
  var falsy = Boolean;

  function rFalsy() {
    return !Boolean;
  }

  var newArr = arr.filter(rFalsy);
  return newArr;
}

bouncer([7, "ate", "", false, 9]);
Manish Giri
@Manish-Giri
Jul 19 2016 05:22
@pacificfrost your link doesn’t have most of the code in it, is it the latest version
Manisha
@manisha9735
Jul 19 2016 05:22
@qzmly100
you have to provide spaces in between. try this:
var result = " "+myNoun+" "+myAdjective+" "+myVerb+" "+myAdverb;
Jerzz
@2cool4school
Jul 19 2016 05:22
If someone has a minute I could use a little help.
Alisdair Frost
@pacificfrost
Jul 19 2016 05:23
@Manish-Giri Didn
Manisha
@manisha9735
Jul 19 2016 05:23
Alisdair Frost
@pacificfrost
Jul 19 2016 05:23
@Manish-Giri didn't realize it posted what I was working on... Sorry, gimme a sec.
Manish Giri
@Manish-Giri
Jul 19 2016 05:24
@manisha9735 did you have a question with that challenge?
Olly Sholotan
@Ollysho
Jul 19 2016 05:24
@revisualize Ahh, let me look at that
Markus Kiili
@Masd925
Jul 19 2016 05:24
@Archangelpak
Alex T.
@lx-t
Jul 19 2016 05:24
This message was deleted
Markus Kiili
@Masd925
Jul 19 2016 05:24
In the Object

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

there is only one property key "car"  and the property value is 

{
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
}

If you access the object with myStorage["car"] or myStorage.car, you will get that value. Then you need to access that value (an object).
Manisha
@manisha9735
Jul 19 2016 05:25
@Manish-Giri Yes the switch case isn't giveing me the correct results
Manish Giri
@Manish-Giri
Jul 19 2016 05:25
@pacificfrost no prob!
@manisha9735 can you post your code please
Manisha
@manisha9735
Jul 19 2016 05:25

@Manish-Giri
function cc(card) {
// Only change code below this line

var count =0;
switch (card){

case 2:
   count++;
case 3:
  count++;
case 4:
  count++;
case 5:
  count++;
case 6:
  count++;
 case 7:
  count=count;
   case 8:
  count=count;
   case 9:
  count=count;
   case 10:
  count--;
   case "J":
  count--;
   case "K":
  count--;
   case "Q":
  count--;
   case "A":
  count--;
   if(count>=1){
     return (count+" Bet");
   }
     else{
       return (count+" Hold");
     }

   break;

}

}
cc(2); cc(3); cc(4); cc(5); cc(6);

Joseph
@revisualize
Jul 19 2016 05:26
@Ollysho I don't understand your filter or the function that you're calling to do the filter.
Olly Sholotan
@Ollysho
Jul 19 2016 05:26
@lx-t Thanks for that! I didn't realize Boolean itself was a function
CamperBot
@camperbot
Jul 19 2016 05:26
ollysho sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @lx-t |http://www.freecodecamp.com/lx-t
Olly Sholotan
@Ollysho
Jul 19 2016 05:26
@revisualize I was trying to filter out all boolean attributes but I was over complicating it
Markus Kiili
@Masd925
Jul 19 2016 05:26
@Ollysho You are very close to the solution.
Joseph
@revisualize
Jul 19 2016 05:26
<