These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Apr 2016
Gwendolyn Faraday
@gwenf
Apr 25 2016 00:00
@allenhsieh I had the same problem when I first went through. I just went back months later and could understand a lot more. I wouldn't stay stuck on those because you don't need all of those to start the other projects
A H
@allenhsieh
Apr 25 2016 00:00
@gwenf Thank you so so much for saying that. That's what I needed to hear.
CamperBot
@camperbot
Apr 25 2016 00:00
allenhsieh sends brownie points to @gwenf :sparkles: :thumbsup: :sparkles:
:star: 707 | @gwenf | http://www.freecodecamp.com/gwenf
Gwendolyn Faraday
@gwenf
Apr 25 2016 00:00
@allenhsieh :+1:
A H
@allenhsieh
Apr 25 2016 00:01
@gwenf Does that go for front/back end as well?
Moisés Man
@moigithub
Apr 25 2016 00:01
ya first time is always hard, i redo the exercises too sometimes.. @allenhsieh
good as refresh/ self test
A H
@allenhsieh
Apr 25 2016 00:01
@gwenf like, I don't need to complete all of front end before starting the backend stuff?
Gwendolyn Faraday
@gwenf
Apr 25 2016 00:01
The backend is pretty hard if you don't understand most of the front end stuff
Andrew Schmidthuber
@calicode
Apr 25 2016 00:02
get through a few of the frontend projects. I'm working on the backend now after finishing the intermediate projects. The biggest hurdle you have coming is going from algo's to frontend projects. Building something from scratch for the first time can feel overwhelming.
A H
@allenhsieh
Apr 25 2016 00:03
thank you for the heads up @gwenf @calicode @moigithub
CamperBot
@camperbot
Apr 25 2016 00:03
allenhsieh sends brownie points to @gwenf and @calicode and @moigithub :sparkles: :thumbsup: :sparkles:
:warning: allenhsieh already gave gwenf points
:star: 1000 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 365 | @calicode | http://www.freecodecamp.com/calicode
bitgrower
@bitgrower
Apr 25 2016 00:23
oh dang, I missed out on giving moigithub his 1000th point .. :(

Building something from scratch for the first time can feel overwhelming.

...that's why I thought them moving the first front end projects ahead of doing any js was a good move ... people were getting far too stuck in doing js stuff ... not moving on to the web projects ...

Jaison D. Vieira
@jaisonv
Apr 25 2016 00:27
I'm stuck in the record collection task
they give me a json
and i have to push a value to a array in that json
but the console says "push property is undefined"
any ideas?
bitgrower
@bitgrower
Apr 25 2016 00:29
yep -- the variable you are trying to use isn't seen by the interpreter as an array ...
Stephen James
@sjames1958gm
Apr 25 2016 00:29
@jaisonv Show your code
bitgrower
@bitgrower
Apr 25 2016 00:29
^^^^ that too
A H
@allenhsieh
Apr 25 2016 00:30
thanks @bitgrower
CamperBot
@camperbot
Apr 25 2016 00:30
allenhsieh sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 1013 | @bitgrower | http://www.freecodecamp.com/bitgrower
Jaison D. Vieira
@jaisonv
Apr 25 2016 00:30

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

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

}

function updateRecords(id, prop, value) {

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

collection[id][prop] = value;

}

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

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

}

if (value === "") {

delete collection[id][prop];

}
return collection;
}

Stephen James
@sjames1958gm
Apr 25 2016 00:31
@jaisonv You don't need both [prop] and .tracks as they refer to the same thing
bitgrower
@bitgrower
Apr 25 2016 00:31
any time you get " < name of property > property is not defined, that means your variable is not seen by the interpreter as the type you think it is!
Jaison D. Vieira
@jaisonv
Apr 25 2016 00:32
@sjames1958gm aaaaaaaaaaahhhh
so true
it's not inside
dang i really didn't see it
Dustin
@Key-Banger
Apr 25 2016 00:39
@jaisonv prop is "tracks"
Ozan Araz
@haraldur12
Apr 25 2016 00:40
function confirmEnding(str, target) {
var firstArray = str.substr(-1);
var secondArray = target.substr(-1,2);
if (firstArray == secondArray){
return true ;
} else {
return false;
}
}
it solves all the problems except for
frozen / specification
gosh
Billy Ralph
@bralph20
Apr 25 2016 00:44
Screen Shot 2016-04-24 at 5.43.33 PM.png
Hey guys, can anyone help me out with this?
Dustin
@Key-Banger
Apr 25 2016 00:45
@haraldur12 You can use the length of target. str.substr(-target.length)
Frank XC
@tenkdayz
Apr 25 2016 00:46
@bralph20 what's the problem?
Billy Ralph
@bralph20
Apr 25 2016 00:47
@tenkdayz I'm stuck with this You should assign processArg to processed
Ozan Araz
@haraldur12
Apr 25 2016 00:48
try num inside the function
instead of processed
Moisés Man
@moigithub
Apr 25 2016 00:49
@bralph20 the funciton processed is already declared.. u need to use (call) it
u no need to re-declare
Ozan Araz
@haraldur12
Apr 25 2016 00:49
@Key-Banger on some instances i have to find two chars and on some others it is only one
progressArg();
Billy Ralph
@bralph20
Apr 25 2016 00:49
How do you call it?
Ozan Araz
@haraldur12
Apr 25 2016 00:49
functionname();
Frank XC
@tenkdayz
Apr 25 2016 00:50
@bralph20 you have to call the given function above
Moisés Man
@moigithub
Apr 25 2016 00:50
check the change function above
variable = myFunction ( somevalue )
Ozan Araz
@haraldur12
Apr 25 2016 00:51
how can I select either two or one items from each string ?
Moisés Man
@moigithub
Apr 25 2016 00:51
"call the processArg function with an argument of 7 and assign its returned value to the variable processed"
Ozan Araz
@haraldur12
Apr 25 2016 00:51
string[-1] ?
Dustin
@Key-Banger
Apr 25 2016 00:51
@haraldur12 target.length is a number. It changes as the target changes.
Ozan Araz
@haraldur12
Apr 25 2016 00:53
function confirmEnding(str, target) {
var firstArray = str.substr(-target.length);
if (firstArray == target){
return true ;
} else {
return false;
}
}
solved it like this
I am sure there is a simplified way of doing it
Moisés Man
@moigithub
Apr 25 2016 00:54
if (firstArray == target){ is evaluated to a boolean.. true or false
so u can just
return (firstArray == target)
Dustin
@Key-Banger
Apr 25 2016 00:55
@haraldur12 also str.substr(-target.length) is not an array. Its a string
Ozan Araz
@haraldur12
Apr 25 2016 00:56
@Key-Banger thanks Dustin I had doubts about it :)
but an array can consist of strings as well right=
Moisés Man
@moigithub
Apr 25 2016 00:57
[] !== ""
Dustin
@Key-Banger
Apr 25 2016 00:58
@haraldur12 Yea an array can have strings in it but they aren't the same. There is nothing really "wrong" with what you did, but if you name a variable "array" it should be an array.
Billy Ralph
@bralph20
Apr 25 2016 00:58
@tenkdayz @moigithub I got it, thank you!
CamperBot
@camperbot
Apr 25 2016 00:58
bralph20 sends brownie points to @tenkdayz and @moigithub :sparkles: :thumbsup: :sparkles:
:star: 1001 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 446 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Dustin
@Key-Banger
Apr 25 2016 00:58
@haraldur12 what @moigithub said.
Kevin
@KevinBruland
Apr 25 2016 01:04
I am having trouble getting an if statement to work if someone has a minute
Joseph
@revisualize
Apr 25 2016 01:04
@Benalron post your code
help format
CamperBot
@camperbot
Apr 25 2016 01:04

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Joseph
@revisualize
Apr 25 2016 01:04
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
Frank XC
@tenkdayz
Apr 25 2016 01:04
@Benalron go
Kevin
@KevinBruland
Apr 25 2016 01:05
  var paint = false;   // mouseDown value

  $(document).mousedown(function() {
    paint = true;      // when the mouse is pressed down, set paint to true
    console.log(paint);
  })
  .mouseup(function() {
    paint = false;    // When mouse is no longer held down, set paint to false
    console.log(paint);
  });

if (paint){
  $(".full-grid").on("mouseover", "div", function() { // <--- set the background-color of an individual square on the grid to selectedColor.
    if ($(this).css("background-color") !== selectedColor){ // <--- If the selected color is different from the background color of box being clicked on
    $(this).css("background-color", selectedColor); // <--- change the color of the box to the selected color
    }
    else{ // <--- Otherwise, the selected color is the same as the box being clicked on.
       $(this).css("background-color", 'white'); // <--- turn the box white. 
    }
  });
}
the if statement is not executing while paint == true... I did a console.log("pain");, and paint is switching to true / false correctly
all of the code inside the if statement functions as intended
when the if statement is removed
Ozan Araz
@haraldur12
Apr 25 2016 01:08
but the global object var paint is false?
Frank XC
@tenkdayz
Apr 25 2016 01:08
@Benalron white needs double quotes ..
Ozan Araz
@haraldur12
Apr 25 2016 01:08
doesn't it effect the work flow?
Kevin
@KevinBruland
Apr 25 2016 01:09
@haraldur12 when I console.log paint inside of the mousedown function... its printing out true, is it possible thats a different paint variable than the global variable?
jadoo1989
@jadoo1989
Apr 25 2016 01:09
Hi guys, so doing the palindrome algorithm and I've got all of it done except for the last test, and I think it's because my regex is thrown off by the _. I've perused the regex pages and can't get anything to work with the more complicated written out versions.
/\W/g;
Frank XC
@tenkdayz
Apr 25 2016 01:09
@jadoo1989 that question is so common here.. /\W_/g add underscore
Hector Garcia
@augmt
Apr 25 2016 01:10
@Benalron why not just paste the code in the if block into the mousdown callback?
jadoo1989
@jadoo1989
Apr 25 2016 01:10
it's that simple? I could have sworn I did that.
Ekultek
@Ekultek
Apr 25 2016 01:10
Hey I'm on the profile lookup project in the basic javascript section and I'm confused as to what I'm doing wrong here:
//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
  if((firstName === contacts.firstName) && (prop === contacts['firstName'].prop)){
    return contacts.firstName.prop;
  }
  else if(firstName != contacts.firstName){
    return "No such contact";
  }
  else{
    return "No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Frank XC
@tenkdayz
Apr 25 2016 01:12
@jadoo1989 show your code maybe there something else messing with it
Greg Duncan
@GregatGit
Apr 25 2016 01:12
@Ekultek Shouldn't contacts have [i]
Kevin
@KevinBruland
Apr 25 2016 01:12
@augmt lol, I stared at this for like 45 minutes and didnt think of that
jadoo1989
@jadoo1989
Apr 25 2016 01:13
```js
Kevin
@KevinBruland
Apr 25 2016 01:13
@augmt ill give that a go
jadoo1989
@jadoo1989
Apr 25 2016 01:13
ooops
Ekultek
@Ekultek
Apr 25 2016 01:13
@GregatGit You know I was actually thinking it might be something like that
jadoo1989
@jadoo1989
Apr 25 2016 01:13
function palindrome(str) {
  var originalStr = [];
  var testStr;
  str = str.toLowerCase(); //convert string to lower case
  var re = /\W_/g; 
  str = str.replace(re, ""); //remove non letters/numbers with regex
  var strCopy = str; // make a copy of the formatted string
  originalStr = str.split(""); // put string into an array char by char
  testStr = originalStr.reverse(); // reverse the array
  testStr = testStr.join("");
  //logic
  if (strCopy == testStr)
    {
      return true;
    }
  else {
    return false;
  }
}



palindrome("eye b a l l ,");
it works this way with the regex \W but not \W_
because that was the first thing I tried
Greg Duncan
@GregatGit
Apr 25 2016 01:14
@Ekultek I would recommend looping through it
Frank XC
@tenkdayz
Apr 25 2016 01:15
@jadoo1989 originalStr is an array
Ekultek
@Ekultek
Apr 25 2016 01:15
So basically through a for loop in it and see what happens?
Dustin
@Key-Banger
Apr 25 2016 01:16
@jadoo1989 You might need gi. not just g. Also I use regex101.com to test regex
Greg Duncan
@GregatGit
Apr 25 2016 01:17
@Ekultek Yes - but make sure a return statement is not forced on it so it can check out contacts[i] all the way to contacts[lastone]
Kevin
@KevinBruland
Apr 25 2016 01:17
@augmt I am a little confused from trying that
Ozan Araz
@haraldur12
Apr 25 2016 01:18
function repeatStringNumTimes(str, num) {
  var newStr = str.repeat(num);
   if(num < 0){
     return "";
   } else{
     if (newStr){
       return newStr;
     }
   }
 }
why doesn't it return an empty string when num < 0 ?
Kevin
@KevinBruland
Apr 25 2016 01:18
@augmt and I think I remember why I created the variable paint now.... when I try to run it up there, each click basically toggles the code, rather than only executing while the mouse is held down
Frank XC
@tenkdayz
Apr 25 2016 01:19
@jadoo1989 try something like this
  str = str.toLowerCase(); //convert string to lower case
  var re = /\W_/g; 
  str1 = str.replace(re, ""); //remove non letters/numbers with regex
  forw = str1.split(""); // put string into an array char by char
  back = str1.reverse(); // reverse the array
@jadoo1989 you're adding unnecessary variables
Kevin
@KevinBruland
Apr 25 2016 01:21
@haraldur12 Sorry for the delay... aren't I changing the value of the global variable paint when I run the mousedown function?
Ekultek
@Ekultek
Apr 25 2016 01:22
@GregatGit can you give me an example please?
Ozan Araz
@haraldur12
Apr 25 2016 01:22
@Benalron I am not sure about it but I think it would be better to use inside the code block you are running
Kevin
@KevinBruland
Apr 25 2016 01:24
@haraldur12 thanks, I think you're right about the problem... when I switch it var paint = true, the code is always executing
CamperBot
@camperbot
Apr 25 2016 01:24
benalron sends brownie points to @haraldur12 :sparkles: :thumbsup: :sparkles:
:star: 268 | @haraldur12 | http://www.freecodecamp.com/haraldur12
Frank XC
@tenkdayz
Apr 25 2016 01:24
@Ekultek wrap the code inside a for loop and use it as such contacts[i]...
Kevin
@KevinBruland
Apr 25 2016 01:24
now I just need to find where to put it
Ekultek
@Ekultek
Apr 25 2016 01:26
I'm gonna go back through loops and such instead lol.
Greg Duncan
@GregatGit
Apr 25 2016 01:27
@Ekultek You want to loop through each of the contacts checking to see if they have a certain prop with a value - if they don't have the prop - you keep looping through -
Hector Garcia
@augmt
Apr 25 2016 01:28
@Benalron is this what you're trying to do? http://codepen.io/augmt/pen/reZNBV?editors=0010
Kevin
@KevinBruland
Apr 25 2016 01:30
@augmt no, I am trying to get it so I can hold down the mouse button, drag it across multiple squares and have them change
lizzieshipton
@lizzieshipton
Apr 25 2016 01:30
about to start the Wikipedia challenge and I'm not entirely sure how the "random" URL we are given works. can you just plug that URL into a JQuery request?
CamperBot
@camperbot
Apr 25 2016 01:30
you need to ask about @someone!
Moisés Man
@moigithub
Apr 25 2016 01:32
@Benalron probaly u wanna use mouseover event
Kevin
@KevinBruland
Apr 25 2016 01:32
@augmt on that, youl see that you click on one of the three colors at the of the grid, and then can drag and have the boxes change colors.... I want it to only change to the selected color when you are holding down the mouse button
@moigithub I have a mouseover event, but I want the event to only happen if the mouse is held down
Moisés Man
@moigithub
Apr 25 2016 01:32
in combination ith mousedown/mouseup to turn on/off a flag
Kevin
@KevinBruland
Apr 25 2016 01:32
@moigithub thats the part I cant figure out
Moisés Man
@moigithub
Apr 25 2016 01:32
when mousedown...paint=true
when mouseup paint = false
mouseover.. if paint change color...
Kevin
@KevinBruland
Apr 25 2016 01:33
@moigithub thats what I have with if statements, but its not working
Moisés Man
@moigithub
Apr 25 2016 01:33
if (paint) should be inside mouseover
Kevin
@KevinBruland
Apr 25 2016 01:35
@moigithub oh, that makes sense... I will try that
@moigithub thank you, thats exactly what I was looking for
CamperBot
@camperbot
Apr 25 2016 01:38
benalron sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 1002 | @moigithub | http://www.freecodecamp.com/moigithub
Kevin
@KevinBruland
Apr 25 2016 01:39
@moigithub just one other issue... sometimes when I am trying to drag, I am getting the circle with a line through it, which breaks the code
KimJongUno
@KimJongUno
Apr 25 2016 01:40
Hi guys, i was trying to get some help with the Plindrome challenge
Erik Maurer
@MauPow
Apr 25 2016 01:41
$(document).ready(function() {
  var go = document.getElementById("go");
  go.onclick = find;

  function find() {
    var searchTerm = document.getElementById("lookUp").value();
    console.log(searchTerm);
  };

});
What is wrong?
Just following the instructions on basic event handling
KimJongUno
@KimJongUno
Apr 25 2016 01:41
Moisés Man
@moigithub
Apr 25 2016 01:42
@Benalron sooo.. html thing u dragging some object to another place...
thats why the circle cursor thing
Kevin
@KevinBruland
Apr 25 2016 01:42
@moigithub thats kind of what I figured
KimJongUno
@KimJongUno
Apr 25 2016 01:42

function palindrome(str) {
// Good luck!
var reversedStr = str.replace(/[^A-Za-z0-9]/g, '').split('').reverse().join('').toLowerCase();

if(str == reversedStr) {
return true;
}else{
return false;
}
console.log(reversedStr);
}

palindrome("eye");

Moisés Man
@moigithub
Apr 25 2016 01:43
@Benalron should google something about "drag" + preventdefault
Kevin
@KevinBruland
Apr 25 2016 01:43
@moigithub sure, more than enough info... thanks again for all your help
CamperBot
@camperbot
Apr 25 2016 01:43
benalron sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: benalron already gave moigithub points
KimJongUno
@KimJongUno
Apr 25 2016 01:43

 function palindrome(str) {
// Good luck!
var reversedStr = str.replace(/[^A-Za-z0-9]/g, '').split('').reverse().join('').toLowerCase();

if(str == reversedStr) {
return true;
}else{
return false;
}
console.log(reversedStr);
}

palindrome("eye");
Sorry here it is
it doesn't return true in palindromes with white spaces
Luis
@zdrifted
Apr 25 2016 01:44
@KimJongUno You are comparing the reversed string to the original str with all it's blank spaces and such
Erik Maurer
@MauPow
Apr 25 2016 01:44
I am getting VM7538 pen.js:5 Uncaught TypeError: document.getElementById(...).value is not a function
But that is literally exactly what is written on the documentation
Kevin
@KevinBruland
Apr 25 2016 01:45
@moigithub thank you, I will read through that and other resources
CamperBot
@camperbot
Apr 25 2016 01:45
benalron sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: benalron already gave moigithub points
Erik Maurer
@MauPow
Apr 25 2016 01:45
I'm trying to make this as simple as possible but still failing, what gives
KimJongUno
@KimJongUno
Apr 25 2016 01:45
@Rushh lmao why didn't i see it, thanks a lot :p
CamperBot
@camperbot
Apr 25 2016 01:45
kimjonguno sends brownie points to @rushh :sparkles: :thumbsup: :sparkles:
:star: 250 | @rushh | http://www.freecodecamp.com/rushh
Moisés Man
@moigithub
Apr 25 2016 01:46
@MauPow whats ur code ?
probably the html is not ready yet ?
Luis
@zdrifted
Apr 25 2016 01:46
It happens lol @KimJongUno
Erik Maurer
@MauPow
Apr 25 2016 01:46
$(document).ready(function() {
  var go = document.getElementById("go");
  go.onclick = find;

  function find() {
    var searchTerm = document.getElementById("lookUp").value();
    console.log(searchTerm);
  };

});
in the HTML is just an input field with ID lookUp and a button with id go
<body class="container-fluid">

  <div>
    <input id= "lookUp" ></input>
  </div>

<button id="go" class="btn btn-primary">Search</button>
</body>
what the heck could possibly be wrong
Moisés Man
@moigithub
Apr 25 2016 01:48
This message was deleted
This message was deleted
Najma Aden
@najma103
Apr 25 2016 01:48
i am confused on the Golf Code assignment
i mean it's not hard but i can't figure out what it is asking me to do -- i guess i am not a golfer

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"

Erik Maurer
@MauPow
Apr 25 2016 01:50
I don't see how it is
Moisés Man
@moigithub
Apr 25 2016 01:50
sec.. googling :)
Erik Maurer
@MauPow
Apr 25 2016 01:50
every documentation I see says to do it (element).onclick = (function); with no parantheses
like wtf this is so simple
why is it so hard
there's a million ways to do it and none of them work
Jocelyn
@jocegonz
Apr 25 2016 01:52
@najma103 hey I finished that a bit ago, what are you having trouble with?
Najma Aden
@najma103
Apr 25 2016 01:53
@jocegonz i am not following this table --- for example the second data in the table <= par - 2
is that supposed to be if par is less than or equal to 2 and we ignore the stroke?
i guess my question is what is the relation of par to strokes
or maybe i am reading too much into
Jocelyn
@jocegonz
Apr 25 2016 01:55
so you have two parameters, right? strokes and pars. where strokes are the first set of data, so it would be "strokes <= par -2" for that particular case
I'm pulling it up right now
Erik Maurer
@MauPow
Apr 25 2016 01:57
Ok i seriously think javascript is broken
Najma Aden
@najma103
Apr 25 2016 01:57
oh i see @jocegonz if strokes === par -1 would be birdie
Erik Maurer
@MauPow
Apr 25 2016 01:57
$(document).ready(function() {

  function find() {
    alert("Hello");
  };


});
<button id="go" onclick = "find();" class="btn btn-primary">Search</button>
WHY does it not work?!@
Najma Aden
@najma103
Apr 25 2016 01:58
got it let me try to code that - thank you @jocegonz
CamperBot
@camperbot
Apr 25 2016 01:58
najma103 sends brownie points to @jocegonz :sparkles: :thumbsup: :sparkles:
Jocelyn
@jocegonz
Apr 25 2016 01:58
@najma103 that's it!
CamperBot
@camperbot
Apr 25 2016 01:58
:star: 217 | @jocegonz | http://www.freecodecamp.com/jocegonz
Moisés Man
@moigithub
Apr 25 2016 01:58

@MauPow

$(document).ready(function() {
  var go = document.getElementById("go");
go.onclick = find;

  function find() {
    var searchTerm = document.getElementById("lookUp").value;
    console.log(searchTerm);
  };

});

value is a property... so no () parentesis

Erik Maurer
@MauPow
Apr 25 2016 01:59
ok cool that works thanks @moigithub
CamperBot
@camperbot
Apr 25 2016 01:59
maupow sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 1003 | @moigithub | http://www.freecodecamp.com/moigithub
Erik Maurer
@MauPow
Apr 25 2016 01:59
Great job tutorial writers out there
so frustrating
Moisés Man
@moigithub
Apr 25 2016 01:59
but.. if u using jquery.. instead of using document.getElement.. etc
u can $("#go")
$("#go").click(find)
var searchTerm = $("#lookUp").val()
Erik Maurer
@MauPow
Apr 25 2016 02:00
see that one has ()
alright I got it thanks
Chase Webb
@jerrybaggin
Apr 25 2016 02:08

function reverseString(str) {
  return str.split('').reverse().join('');
}
var reverseString = ('hello');
id love some input, im having troubles with this bonfire reverse a string challenge. im not too sure what im missing here
DJ
@qualitymanifest
Apr 25 2016 02:10
function reverseString(str) {
  return str.split('').reverse().join('');
} // your function ends here
var reverseString = ('hello'); // not sure what you're trying to do with this. this is normally where FCC puts the function call
i think if you changed the last line to reverseString('hello'); it would pass
Chase Webb
@jerrybaggin
Apr 25 2016 02:14
@qualitymanifest bravo homes
@qualitymanifest brownie points! thank you
CamperBot
@camperbot
Apr 25 2016 02:14
jerrybaggin sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1143 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Apr 25 2016 02:15
yw :+1:
Erik Maurer
@MauPow
Apr 25 2016 02:36
I am trying to modify the example from the JSON API tutorial to pull a list of keys and values from the JSON file that wikipedia gives you. Any ideas on why this isn't doing anything?
var searchTerm;

$(document).ready(function() {
  var go = $("#go").click(find);

  //Get search value and wiki API
  function find() {
    searchTerm = $("#lookUp").val();

    var url = "http://en.wikipedia.org/w/api.php?format=json&action=query&titles=" + searchTerm + "&prop=revisions&rvprop=content&callback=?";

    $.getJSON(url, function(data) {
      var html = "";
      data.forEach(function(val) {
        var keys = Object.keys(val);
        html += "<div class = 'result'>";
        keys.forEach(function(key) {
          html += "<b>" + key + "</b>: " + val[key] + "<br>";
        });
        html += "</div><br>";
      });
      console.log(data);
      $(".message").html(html);
    });
  };
});
the JSON get function is exactly the same as in the tutorial https://www.freecodecamp.com/challenges/convert-json-data-to-html
shaunski11
@shaunski11
Apr 25 2016 02:38
I'm trying to complete the stand in line challenge however I can't complete the last requirement, "nextInLine([5,6,7,8,9], 1) should return 5". I get 5 as the returned value in the console but it's not letting me pass the challenge. Am I missing something?
function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  var removed = testArr.shift();
  return removed;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
CamperBot
@camperbot
Apr 25 2016 02:38
:bulb: to format code use backticks! ``` more info
Erik Maurer
@MauPow
Apr 25 2016 02:41
@shaunski11 I looked at mine, I believe you need to tell .shift what to do...
function nextInLine(arr, item) {
  // Your code here
  array = arr.push(item);
  first = arr.shift(array);

  return first;  // Change this line
This message was deleted
actually looking at that, i have no idea, sorry :(
shaunski11
@shaunski11
Apr 25 2016 02:44
@MauPow It's strange because the other three requirements passed.
Erik Maurer
@MauPow
Apr 25 2016 02:47
You need to push the array to a new function
```
testArray = arr.push(item);
from the function argument
that puts the item at the end of that new array
then first = arr.shift(); removes the first element
then you return first, which was removed
shaunski11
@shaunski11
Apr 25 2016 02:49
@MauPow I was using the testArr variable instead of arr. After the change it's working now. Thanks for your help!
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}
CamperBot
@camperbot
Apr 25 2016 02:50
shaunski11 sends brownie points to @maupow :sparkles: :thumbsup: :sparkles:
:star: 285 | @maupow | http://www.freecodecamp.com/maupow
Erik Maurer
@MauPow
Apr 25 2016 02:50
no problem :)
Tyler
@tylergross
Apr 25 2016 03:08
Is it possible to use setTimeout() with a function that you pass an argument? It doesn't seem to work for me IE. setTimeout(myFunc, 1000) will work but setTimeout(myFunc(50), 1000) does not work properly
Mevermind just realized you can pass parameters to the setTimeout
krisluu5695
@krisluu5695
Apr 25 2016 03:19
help Reverse a String
CamperBot
@camperbot
Apr 25 2016 03:19

:point_right: algorithm reverse a string [wiki]

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

:checkered_flag: Problem Explanation:

We need to take the string and reverse it, so if it originally reads 'hello', it will now read 'olleh'. We will need to split the string, and therefore we will be working with Arrays as well.

:pencil: read more about algorithm reverse a string on the FCC Wiki

Tyler
@tylergross
Apr 25 2016 03:20
@MauPow what info are you returning?
Wiki tic tac toe
CamperBot
@camperbot
Apr 25 2016 03:23
no wiki entry for: tic tac toe
Tyler
@tylergross
Apr 25 2016 03:23
Wiki tic-tac-toe
CamperBot
@camperbot
Apr 25 2016 03:23
no wiki entry for: tic-tac-toe
Tyler
@tylergross
Apr 25 2016 03:24
Wiki simon
CamperBot
@camperbot
Apr 25 2016 03:24
no wiki entry for: simon
Constantine Gauvoronsky
@ogkonstantin
Apr 25 2016 03:30

hey guys ! I'm just starting to learn freecodecamp's JS basics, and I have a problem with the first task ... Assign the value 7 to variable a.

Assign the contents of a to variable b.

var a = 7;
var b = 7;
a=b;
Eric Leung
@erictleung
Apr 25 2016 03:31
@ogkonstantin the assignment needs to be the other way. The b should be on the left side of the equals sign and the a is on the right.
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:31
help false bouncer
CamperBot
@camperbot
Apr 25 2016 03:31
no wiki entry for: false bouncer
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:32
help falsy bouncer
CamperBot
@camperbot
Apr 25 2016 03:32

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

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

Frank XC
@tenkdayz
Apr 25 2016 03:32
@ogkonstantin yeah you're putting the value of a in b so it should be b = a;
Constantine Gauvoronsky
@ogkonstantin
Apr 25 2016 03:32
@erictleung thanx !
CamperBot
@camperbot
Apr 25 2016 03:32
ogkonstantin sends brownie points to @erictleung :sparkles: :thumbsup: :sparkles:
:star: 335 | @erictleung | http://www.freecodecamp.com/erictleung
Norvin Burrus
@ndburrus
Apr 25 2016 03:34
@ogkonstantin ...hmmm... reverse the assignment.
@ogkonstantin you are making an assignment to b
@ogkonstantin the right side gets assigned to the left side
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:34
folks, any thoughts/comments on how to check for NaN condition
Constantine Gauvoronsky
@ogkonstantin
Apr 25 2016 03:35
Thanks, everybody ! such powerful feedback !
Norvin Burrus
@ndburrus
Apr 25 2016 03:36
@ogkonstantin does it make sense now?
Frank XC
@tenkdayz
Apr 25 2016 03:37
@SekharKolli are you doing the falsy challenge?
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:37
@tenkdayz , that is correct
Frank XC
@tenkdayz
Apr 25 2016 03:38
@SekharKolli use Boolean(yourValue)
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:38
so the function Boolean()
Frank XC
@tenkdayz
Apr 25 2016 03:38
@SekharKolli and filter() that returns if Boolean() true
Thomas McGuire
@mcguiretj
Apr 25 2016 03:39
trying to capitalize the first letter of each word with the string. Need help understanding this concept and why my output is only pushing out the first letters. Thanks
```js
krisluu5695
@krisluu5695
Apr 25 2016 03:39
help Check for Palindromes
CamperBot
@camperbot
Apr 25 2016 03:39

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Sekhar Kolli
@SekharKolli
Apr 25 2016 03:39
ok @tenkdayz. Thanks
CamperBot
@camperbot
Apr 25 2016 03:39
sekharkolli sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 449 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:40
Thanks @renelis @abhisekp @Rafase282 for your help with Algorithm: Falsy Bouncer
CamperBot
@camperbot
Apr 25 2016 03:40
sekharkolli sends brownie points to @renelis and @abhisekp and @rafase282 :sparkles: :thumbsup: :sparkles:
Thomas McGuire
@mcguiretj
Apr 25 2016 03:40

```
function titleCase(str) {
// split string into an array
var strArr = str.split(" ");
for(var i = 0 ; i < strArr.length ; i++){
strArr[i] = strArr[i].charAt(0).toUpperCase();
}
return strArr;
}

titleCase("I'm a little tea pot");

CamperBot
@camperbot
Apr 25 2016 03:40
:star: 390 | @renelis | http://www.freecodecamp.com/renelis
:star: 2471 | @abhisekp | http://www.freecodecamp.com/abhisekp
:star: 1180 | @rafase282 | http://www.freecodecamp.com/rafase282
Frank XC
@tenkdayz
Apr 25 2016 03:43
@mcguiretj what does that return?
Abhisek Pattnaik
@abhisekp
Apr 25 2016 03:44
@SekharKolli np! :+1:
did you enjoy? ;)
Thomas McGuire
@mcguiretj
Apr 25 2016 03:44
The output is the first letters capitalized but it also wants the full word. It's one of the basic algorithm problems.
Frank XC
@tenkdayz
Apr 25 2016 03:45
@mcguiretj youre not join() ing it
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:45
@mcguiretj, when you use the .split(“ “) function, you’ll receive an array of arrays.
@mcguiretj, add console.log(strArr); to your code after you use the split. You’ll be able to visualize it better.
Thomas McGuire
@mcguiretj
Apr 25 2016 03:47
ok
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:47
strArr[i] = strArr[i].charAt(0).toUpperCase(); using this line of code, you are overwriting the complete array with a single charater
*character
which is why you are seeing a single character output. @mcguiretj
JustinMartinIsHere
@JustinMartinIsHere
Apr 25 2016 03:49
havin some issues with the "convert Celcius to Fahrenheit" problem set. anyone able to help me.
Thomas McGuire
@mcguiretj
Apr 25 2016 03:49
Okay, I will check it out. Thanks for the help @SekharKolli
CamperBot
@camperbot
Apr 25 2016 03:49
mcguiretj sends brownie points to @sekharkolli :sparkles: :thumbsup: :sparkles:
:star: 279 | @sekharkolli | http://www.freecodecamp.com/sekharkolli
Frank XC
@tenkdayz
Apr 25 2016 03:49
@mcguiretj, when you use the .split(“ “) function, you’ll receive an array of arrays. not true
D.Mills
@millsdee74
Apr 25 2016 03:51

Challenge:Constructing Strings with Variables....keeps telling me Tim is not defined. This is what I have..... // Example
var ourName = "Free Code Camp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";

// Only change code below this line
var myName = "Tim";
myame = Time;
var myStr = "My name is " + Tim + "and I am swell!";

can anyone help
Kelvin-penang
@Kelvin-penang
Apr 25 2016 03:53
//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 validFirstName = false;
  var validProp = false;
  var answer;

  for (var i =0; i <contacts.length;i++){
    if (firstName == contacts[i].firstName){
      validFirstName = true;
     answer = contacts[i];
      break;
    }
  }

    if (contacts[0].hasOwnProperty(prop)){
      validProp=true;

    }
    if (! validFirstName){
      answer = "No such contact";
    }
    if (! validProp){
      answer = "No such property";
    }
    return answer[prop]  ;


}




// Only change code above this line
// Change these values to test your function
lookUpProfile("Akira", "likes");
Hi, can anybody help in detecting what went wrong here?
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:53
@mcguiretj , so changing your code to something like this should work
strArr[i] = strArr[i].charAt(0).toUpperCase() + strArr[i].substring(1); // adds the remaining part of string to the first  uppercase char
This message was deleted
Gary
@keengar
Apr 25 2016 03:57
@millsdee74 var Time; //define Tim as a var. The variable that contains "Tim" in your code is myName, so + myName + would add "Tim" to your string. Also, I think myame = Time; should be removed.
Michael Karpinski
@karpimpski
Apr 25 2016 03:58
http://codepen.io/karpimpski/pen/dMqygK I'm trying to get the background to become black when and then white again for the 3 values in my array, one at a time. can anybody tell me what I'm doing wrong?
Norvin Burrus
@ndburrus
Apr 25 2016 03:58
@millsdee74 can you see the comments - and suggestion?
Sekhar Kolli
@SekharKolli
Apr 25 2016 03:58

@tenkdayz , may be I worded it incorrectly, but what would you call the following output?

  console.log("This is a line".split(" "));
// ["This", "is", "a", "line"]

isn’t this an array of strings? (and string is a charater array right?)

Frank XC
@tenkdayz
Apr 25 2016 03:59
@SekharKolli it's an array of strings.
Norvin Burrus
@ndburrus
Apr 25 2016 03:59
@Kelvin-penang which challenge is that?
Frank XC
@tenkdayz
Apr 25 2016 03:59
@karpimpski are you using a loop to do it?
Michael Karpinski
@karpimpski
Apr 25 2016 03:59
@tenkdayz yeah
@tenkdayz I have a setInterval, and the loop calls another function
Sekhar Kolli
@SekharKolli
Apr 25 2016 04:00
@tenkdayz , and isn’t string an array of characters?
D.Mills
@millsdee74
Apr 25 2016 04:00
@ndburrus Yes, and I tried all I can think of
Norvin Burrus
@ndburrus
Apr 25 2016 04:00
@millsdee74 can you see the private chat?
D.Mills
@millsdee74
Apr 25 2016 04:01
@ndburrus ReferenceError: 'Tim' is undefined
Norvin Burrus
@ndburrus
Apr 25 2016 04:02
js
<// Example
var ourName = "Free Code Camp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";
// Only change code below this line
var myName = "Tim";
myame = Time;
var myStr = "My name is " + Tim + "and I am swell!";>
ok... use the variable name given in the challenge... (myName) - typo
Frank XC
@tenkdayz
Apr 25 2016 04:02
@SekharKolli youre right.. I was picturing this
[["This"], ["is"], ["a"], ["line"]]..
Norvin Burrus
@ndburrus
Apr 25 2016 04:03
js 
<// Example
var ourName = "Free Code Camp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";

// Only change code below this line
var myName = "Norvin Burrus";
var myStr = "My name is " + myName + " and I am swell!";


>
Frank XC
@tenkdayz
Apr 25 2016 04:04
@karpimpski so the colors should stay put or switch?
Norvin Burrus
@ndburrus
Apr 25 2016 04:05
@millsdee74 also, we are creating the variable for a reason - to use it!!
Michael Karpinski
@karpimpski
Apr 25 2016 04:05
@tenkdayz for now the background of my rows should become black for a short amount of time, then go back to white background, then the next row should do the same
OmMinky
@OmMinky
Apr 25 2016 04:05
Hi, have not clue on how to approach the 'nesting loop challenge', not sure how or what needs to be modified in the multiplyAll arrays also, help please
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<arr.length; j++);
 console.log(product[i][j]);
  }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);


var code = "formatted";
Sekhar Kolli
@SekharKolli
Apr 25 2016 04:06
:) that would be an array of array of strings. I’ll still call like what you call it. an array of strings @tenkdayz
Michael Karpinski
@karpimpski
Apr 25 2016 04:06
@tenkdayz I didn't have JQuery enabled
@tenkdayz I feel so stupid when this happens
Frank XC
@tenkdayz
Apr 25 2016 04:07
@karpimpski ok np ..
Michael Karpinski
@karpimpski
Apr 25 2016 04:07
@tenkdayz I'm sure I'll have more questions soon, so try to stay close if you can :P
Frank XC
@tenkdayz
Apr 25 2016 04:09
@karpimpski sure.. I
@karpimpski add detailed comments to your code if you want other people to review it.. it helps to know to see what is going on
Michael Karpinski
@karpimpski
Apr 25 2016 04:10
@tenkdayz I'll do that, thanks for the heads up
CamperBot
@camperbot
Apr 25 2016 04:10
karpimpski sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 450 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
D.Mills
@millsdee74
Apr 25 2016 04:10
@ndburrus none of your suggestions went through.
Norvin Burrus
@ndburrus
Apr 25 2016 04:11
@millsdee74 ok, can u post what you've got?
Frank XC
@tenkdayz
Apr 25 2016 04:12
@karpimpski is this the beginning of your simon project? I was trying to figure out.. "why would you want to do that?" hah
D.Mills
@millsdee74
Apr 25 2016 04:12
@ndburrus I got it. Thanks.
CamperBot
@camperbot
Apr 25 2016 04:12
millsdee74 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Michael Karpinski
@karpimpski
Apr 25 2016 04:12
@tenkdayz yeah, I'm trying very hard to wrap my head around this project. I'm having a really tough time, so I made this VERY rough prototype
CamperBot
@camperbot
Apr 25 2016 04:12
:star: 244 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 25 2016 04:13
@millsdee74 ok, great - kudos to you!! :clap:
Gary
@keengar
Apr 25 2016 04:14
@keengar @millsdee74 myName is the var that holds "Tim".
To add "Tim" to myStr you would use that var and not Tim. See below:
var myStr = "My name is " + myStr + "and I am swell!";
Frank XC
@tenkdayz
Apr 25 2016 04:14
@karpimpski I see. good to see someone not copying and pasting the example code.
Michael Karpinski
@karpimpski
Apr 25 2016 04:23
@tenkdayz http://codepen.io/karpimpski/pen/dMqygK I'm not sure how to move onto the next round (without user input yet)
@tenkdayz for now I just want it to automatically go to the next round
Frank XC
@tenkdayz
Apr 25 2016 04:26
@karpimpski the sequence array needs to be given another values somehow right..
Michael Karpinski
@karpimpski
Apr 25 2016 04:27
@tenkdayz yeah, I need to add my random number to the sequence
Frank XC
@tenkdayz
Apr 25 2016 04:29
@karpimpski when the user clicks on the right button it should run the newRound() .. I think you should make the sequence array global.
Michael Karpinski
@karpimpski
Apr 25 2016 04:30
@tenkdayz if you refresh I got it set up so that it does a new round every second, but it doesn't add a new value. I know that's because I empty it in the beginning, but making it global isn't working for me
@tenkdayz I tried making it global, but it won't run when I do and I'm not sure why
D.Mills
@millsdee74
Apr 25 2016 04:32
@keengar just saw this, good lookin' I got it though
Ben Steele
@doomcode
Apr 25 2016 04:33
This message was deleted
Frank XC
@tenkdayz
Apr 25 2016 04:39
@karpimpski I added a button to trigger the newRound()
@karpimpski I'm not familiar with codepen do you know how to make a fork to mess with it?
Michael Karpinski
@karpimpski
Apr 25 2016 04:41
@tenkdayz at the top there should be something that said fork
Ben Steele
@doomcode
Apr 25 2016 04:42

Hi all! I'm a FCC camper and I know this isn't exactly proper to post here, but I've just had an offer for a Junior developer if I could finish Codecademy's Blackjack game. I've got it all set up, but I keep getting an error. I know this isn't the best place to post, but codecademy's forums seem to be down and I have till tomorrow to get this up. I keep getting reference error. Any help would be super appreciated!

http://labs.codecademy.com/DTOh#:workspace

Michael Karpinski
@karpimpski
Apr 25 2016 04:42
@doomcode hey, can't promise I'll get back soon but once I'm done my project I'll do my best!
Frank XC
@tenkdayz
Apr 25 2016 04:43
@karpimpski then i just save it right
Michael Karpinski
@karpimpski
Apr 25 2016 04:43
@tenkdayz yes sir, it won't affect mine. it'll be your fork!
Shafeek B
@sbakhach
Apr 25 2016 04:43
hey guys I have a question around the blackjack game
Michael Karpinski
@karpimpski
Apr 25 2016 04:44
@tenkdayz I added the button, but it's the same thing as before
Shafeek B
@sbakhach
Apr 25 2016 04:44
how do you get a variable inside of a string?
Michael Karpinski
@karpimpski
Apr 25 2016 04:44
@sbakhach "blah blah blah " + var + "blah blah blah"
Frank XC
@tenkdayz
Apr 25 2016 04:44
@sbakhach "hello"+var+"world";
Michael Karpinski
@karpimpski
Apr 25 2016 04:45
@tenkdayz thanks for the fork! I'll check it out and get back to you
CamperBot
@camperbot
Apr 25 2016 04:45
karpimpski sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:warning: karpimpski already gave tenkdayz points
Chris Cullen
@123xylem
Apr 25 2016 04:46
Hi can someone advise me on this basic palindrome code?
Im going through a string and checking if it matches itself as a palindrome
for that Im looking at it with a for loop and removing white space
does this code work?
for(i=0;i<str.length;i++)
{if (str(i) == /\s+/g){str = str - [i];}
Michael Karpinski
@karpimpski
Apr 25 2016 04:46
@tenkdayz cool, it works! thank you!
CamperBot
@camperbot
Apr 25 2016 04:46
karpimpski sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:warning: karpimpski already gave tenkdayz points
Chris Cullen
@123xylem
Apr 25 2016 04:47
So im trying to remove white space (and eventually irregular chars)... Maybe I should just say if it = reg character keep it else remove it
Michael Karpinski
@karpimpski
Apr 25 2016 04:47
@tenkdayz again, I'm sure I'll have more questions soon but you've been so helpful so far!
Edward Cheadle
@echeadle
Apr 25 2016 04:48
@doomcode Is this the error? ReferenceError: deal is not defined
@doomcode you named the function Deal yet you call it in the code below as deal()
DJ
@qualitymanifest
Apr 25 2016 04:51
@123xylem you don't need to loop through it. just use str = str.replace(/regex for what to remove goes here/g, '');
Michael Karpinski
@karpimpski
Apr 25 2016 04:51
@tenkdayz got a restart button and a counter on-screen! http://codepen.io/karpimpski/pen/dMqygK
Chris Cullen
@123xylem
Apr 25 2016 04:51
@qualitymanifest so individually remove all instances of non regular characters with .replace?
Ive seen that done but its innefficient no?
feels like cheating
DJ
@qualitymanifest
Apr 25 2016 04:53
@123xylem no. do some reading on regex. the global flag will apply your regex replacement throughout the entire string
Frank XC
@tenkdayz
Apr 25 2016 04:53
@karpimpski the yellow div lights up but it doesnt look like it does
Michael Karpinski
@karpimpski
Apr 25 2016 04:54
@tenkdayz do you mean my code works but that one isn't visible enough?
Frank XC
@tenkdayz
Apr 25 2016 04:55
@karpimpski yea... that why I made it #000 just to make it more visible.. just for developing proposes
Michael Karpinski
@karpimpski
Apr 25 2016 04:55
@tenkdayz oh, I thought you just didn't get my updated code and that's why it was black. good thought, I'll make it black for now too
Chris Cullen
@123xylem
Apr 25 2016 04:55
@qualitymanifest But i need to replace - / , spaces etc
Ben Steele
@doomcode
Apr 25 2016 04:56
@echeadle ah, let me take a peek again...
Chris Cullen
@123xylem
Apr 25 2016 04:56
it will need many .replaces
DJ
@qualitymanifest
Apr 25 2016 04:56
@123xylem not if you use the global flag. i provided a link to that above
there's a regex metacharacter that finds all non-word characters (except for one...). you can find it in the other link above
Chris Cullen
@123xylem
Apr 25 2016 04:57
o ok
d wilder
@alhazen1
Apr 25 2016 04:57
@123xylem qm is right. With a regex all can be removed with one line of code. It will take some dense reading though
Chris Cullen
@123xylem
Apr 25 2016 04:57
@alhazen1 sounds fun :/
:)
DJ
@qualitymanifest
Apr 25 2016 04:59
@123xylem if you're new to regex there's some short tutorials that can help introduce you, rather than wading through documentation. http://regexone.com/ is pretty good
Chris Cullen
@123xylem
Apr 25 2016 04:59
@qualitymanifest @alhazen1 could i just use this: \W Find a non-word character
DJ
@qualitymanifest
Apr 25 2016 04:59
@123xylem yes, that was the one i was referring to. it will replace all non-alphanumerics except for one
Chris Cullen
@123xylem
Apr 25 2016 05:00
ah nice and easy
@qualitymanifest @alhazen1 thanks
CamperBot
@camperbot
Apr 25 2016 05:00
123xylem sends brownie points to @qualitymanifest and @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 350 | @alhazen1 | http://www.freecodecamp.com/alhazen1
:star: 1144 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Apr 25 2016 05:00
np
greg
@wearenotgroot
Apr 25 2016 05:00
@123xylem one thing to remember though. underscore is considered an alphanummeric. so you need to filter it out.
Chuck Adams
@chuckadams
Apr 25 2016 05:01
[^\W_]
DJ
@qualitymanifest
Apr 25 2016 05:02
@chuckadams pretty sure you don't want that ^
Chuck Adams
@chuckadams
Apr 25 2016 05:03
that basically matches \w except underscore
DJ
@qualitymanifest
Apr 25 2016 05:03
@chuckadams yeah but you're doing a replace and the ^ would invert it
i could be mistaken, i have been AFK for almost a month
Alex Rose
@thelyricalrose
Apr 25 2016 05:04
So I've spent a lot of time on my front end projects and now I'm a bit rusty with my JS, I'm having trouble getting the Diff two Arrays challenge down
Could anybody help me?
DJ
@qualitymanifest
Apr 25 2016 05:04
yeah, you don't want that ^, just tested it
Chuck Adams
@chuckadams
Apr 25 2016 05:05
@qualitymanifest ah i had the logic reversed in my brain
my iq drops about 1 point per line of scrollback i go back ;p
DJ
@qualitymanifest
Apr 25 2016 05:06
hah, yeah and it's late
greg
@wearenotgroot
Apr 25 2016 05:06
well you could use .match instead of replace :smile:
Alex Rose
@thelyricalrose
Apr 25 2016 05:07
function diffArray(arr1, arr2) {
  var newArr = [];
     for(var i = arr1.length; i > 0; i--){
       if (-1 == arr2.indexOf(arr1[i])){
           newArr.push(arr1[i]);
       }


    }
  // Same, same; but different.
  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Keeps returning null for newArr
I know what I have won't solve the whole problem, but I figure I need to get this step to work first
Frank XC
@tenkdayz
Apr 25 2016 05:09
@thelyricalrose all of the values on arr1 are in arr2 so it's not pushing anything
DJ
@qualitymanifest
Apr 25 2016 05:09
@thelyricalrose length starts at 1, array indexes start at 0
Frank XC
@tenkdayz
Apr 25 2016 05:10
@thelyricalrose so it's returning an empty array
Alex Rose
@thelyricalrose
Apr 25 2016 05:10
@tenkdayz I didn't even think of that!
DamianMitchell
@DamianMitchell
Apr 25 2016 05:10

Convert Celsius to Fahrenheit-function convertToF(celsius) {
// Only change code below this line
var fahrenheit;
// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code

Alex Rose
@thelyricalrose
Apr 25 2016 05:10
@tenkdayz I switched all cases of arr1 to arr2 and vice versa, now it is returning [null,4]
Chris Cullen
@123xylem
Apr 25 2016 05:10
for(i=0;i<str.length;i++)
{str=str.replace("\W", '');}
@qualitymanifest
any ideas how to use this expression? I think im mixing up reg exp and the other way of doing it
or a link that shows how to use reg exp
Alex Rose
@thelyricalrose
Apr 25 2016 05:11
@qualitymanifest I'm a little confused, so should it only be where i>1 for the for loop?
hmm, same thing, still getting a null in my array
DJ
@qualitymanifest
Apr 25 2016 05:12
the reason it's returning [undefined] is because length starts at 1 but array indexes start at 0. so you're starting the loop at 4 but arr1[4] doesn't exist. https://repl.it/CJNs
if you changed your loop to for(var i = arr1.length - 1; i > 0; i--){ you won't get that undefined
that's not how i would go about it, but that would fix your current issue
@123xylem don't use quotation marks around \W, use slashes / /
Alex Rose
@thelyricalrose
Apr 25 2016 05:13
@qualitymanifest @tenkdayz Thanks, I think I have a better grasp of arrays now!
CamperBot
@camperbot
Apr 25 2016 05:13
thelyricalrose sends brownie points to @qualitymanifest and @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 1145 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 451 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
d wilder
@alhazen1
Apr 25 2016 05:14
@123xylem No need to loop. replace will do that for the entire string.
Also the regex does not need quoting.
Frank XC
@tenkdayz
Apr 25 2016 05:14
@thelyricalrose can you post the new code
DJ
@qualitymanifest
Apr 25 2016 05:14
@123xylem and like i was saying you don't need a loop - if you use the global flag it will replace throughout the string
Alex Rose
@thelyricalrose
Apr 25 2016 05:14
@qualitymanifest out of curiosity, how would you do it?
Ben Steele
@doomcode
Apr 25 2016 05:14
@echeadle Thanks for taking a look! Haha, yeah when I fix the 'Deal()' issue, it brings up a reference error for 'hand'. I tried for a while to figure the hand reference out. It seems like I'm just not getting something.
CamperBot
@camperbot
Apr 25 2016 05:14
doomcode sends brownie points to @echeadle :sparkles: :thumbsup: :sparkles:
:star: 183 | @echeadle | http://www.freecodecamp.com/echeadle
Alex Rose
@thelyricalrose
Apr 25 2016 05:14
function diffArray(arr1, arr2) {
  var newArr = [];
     for(var i = arr2.length -1; i >= 0; i--){
       if (-1 == arr1.indexOf(arr2[i])){
           newArr.push(arr2[i]);
       }


    }
  // Same, same; but different.
  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Markus Kiili
@Masd925
Apr 25 2016 05:16
@thelyricalrose You could use .filter() method instead of loop.
DJ
@qualitymanifest
Apr 25 2016 05:16
@thelyricalrose i've actually been away from computers for about a month so i redid my solutions today to refresh myself. basically what i did for this one was concatenate the two arrays and then filter the new array, keeping the elements that existed in only one of the arrays
Chris Cullen
@123xylem
Apr 25 2016 05:16
@qualitymanifest str = str.replace(\W\, \''); this is not working either.. its saying unexpected \ if i use one or 2
DJ
@qualitymanifest
Apr 25 2016 05:17
@123xylem you really might want to try that regex tutorial and then dive into the docs
it's worth getting familiar with
Frank XC
@tenkdayz
Apr 25 2016 05:17
@123xylem youre regex should be something like this /\W_/g
DJ
@qualitymanifest
Apr 25 2016 05:18
not quite
needs to be in [] or have an or | pipeline...
Chris Cullen
@123xylem
Apr 25 2016 05:19
ok i look at a regex tutorial... it looks easy but I dont know the grammar
Alex Rose
@thelyricalrose
Apr 25 2016 05:21
@Masd925 I was avoiding that a little bit, but I guess it would probably be better to figure it out for further use
Michael Karpinski
@karpimpski
Apr 25 2016 05:22
does anybody know why I'm getting this bug on round 3? http://codepen.io/karpimpski/pen/dMqygK?editors=0011
@tenkdayz any ideas?
AndrewThM
@AndrewThM
Apr 25 2016 05:28

var count = 0;

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

return cc();
// Only change code above this line
}

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

This is what I've got for card counting challenge. Fairly stumped. Any help would be awesome.
Edward Cheadle
@echeadle
Apr 25 2016 05:28
@doomcode In the function playAsUser() you need to change hand.printHand() to userHand.printhand()
Michael Karpinski
@karpimpski
Apr 25 2016 05:30
@tenkdayz I think that, for some reason, my code always registers the third click of the third round as false
I mean the second click
Frank XC
@tenkdayz
Apr 25 2016 05:34
@karpimpski did you figure it out?
@karpimpski looks like it works again
greg
@wearenotgroot
Apr 25 2016 05:36
@AndrewThM you need to do an if test after the switch
Michael Karpinski
@karpimpski
Apr 25 2016 05:36
@tenkdayz it isn't working for me :/ I'm away from my computer for just 5 minutes, but keep trying to go through the rounds with clicking, I actually have that functioning a little. for me, the third round always messes up
greg
@wearenotgroot
Apr 25 2016 05:37
@AndrewThM review the lesson on switch statements
Frank XC
@tenkdayz
Apr 25 2016 05:38
@karpimpski strange.. it works fine when I run it
Michael Karpinski
@karpimpski
Apr 25 2016 05:41
@tenkdayz and you're clicking the boxes, not hitting next round?
Edward Cheadle
@echeadle
Apr 25 2016 05:41
@doomcode function playAsUser(){
var score = 0;
var userHand = new Hand();
var decision = confirm("Your hand is "+ userHand.printHand() + ": Hit OK to hit (take another card) or Cancel to stand");
while(decision){
userHand.hitMe();
decision = confirm("Your hand is now " + userHand.printHand() + ": Hit OK to hit (take another card) or Cancel to stand");
}
return userHand;
}
Michael Karpinski
@karpimpski
Apr 25 2016 05:41
@tenkdayz yeah, every third round bugs out on me when I click the boxes and not next round
Frank XC
@tenkdayz
Apr 25 2016 05:42
@karpimpski i wasnt .. i see the problem now
Edward Cheadle
@echeadle
Apr 25 2016 05:42
you need to return userHand, not userHand.score. You returned dealerHand and not dealerHand.score.
@doomcode Then it all works.
Chris Cullen
@123xylem
Apr 25 2016 05:44
I dont know why its telling me that this is not a function?
var safeStr = str.replaceAll(/W/,"");
I cant find how to use the /W regexp anywhere
Michael Karpinski
@karpimpski
Apr 25 2016 05:45
@123xylem try str.replace() instead of replaceAll()
@tenkdayz do you know why I'm getting this issue?
Chris Cullen
@123xylem
Apr 25 2016 05:47
@karpimpski that worked to let it become a function.. but the function didnt remove all non chars...
DJ
@qualitymanifest
Apr 25 2016 05:47
it's \W. the / / is what the pattern goes within
and you will still need to deal with underscores
Frank XC
@tenkdayz
Apr 25 2016 05:47
@karpimpski not sure what is going on anymore :neutral_face:
DJ
@qualitymanifest
Apr 25 2016 05:47
also i'm not aware of a replaceAll function... just replace
Michael Karpinski
@karpimpski
Apr 25 2016 05:47
@tenkdayz well do you understand my click() function? I think it's pretty straightforward
Chris Cullen
@123xylem
Apr 25 2016 05:48
var safeStr = str.replace(/\W,""/); this still leaves non word chars
DJ
@qualitymanifest
Apr 25 2016 05:49
ah i see there's a jQuery replaceAll. but FCC algorithms don't have jquery loaded in.
Chris Cullen
@123xylem
Apr 25 2016 05:49
^^
DJ
@qualitymanifest
Apr 25 2016 05:50
you're putting the slashes in the wrong place
Frank XC
@tenkdayz
Apr 25 2016 05:50
@karpimpski dont see why you would put a mousedown event inside a function..
DJ
@qualitymanifest
Apr 25 2016 05:50
they go around \W (and you will need to include the underscores......)
Michael Karpinski
@karpimpski
Apr 25 2016 05:51
@tenkdayz do you think that's my issue? the thinking behind that was so clicking before it generates the numbers wouldn't cause any problems
DJ
@qualitymanifest
Apr 25 2016 05:51
and youre not using the global flag, still

g

Frank XC
@tenkdayz
Apr 25 2016 05:52
@karpimpski I have never seen it used like that before..
Michael Karpinski
@karpimpski
Apr 25 2016 05:52
@tenkdayz oh, well putting mousedown in a function doesn't seem to cause any problems in my code
@tenkdayz do you think that would cause issues?
Frank XC
@tenkdayz
Apr 25 2016 05:53
@karpimpski you're calling that function inside animate()
Michael Karpinski
@karpimpski
Apr 25 2016 05:53
@tenkdayz yeah, so after it animates my buttons it checks my clicks
Chris Cullen
@123xylem
Apr 25 2016 05:53
supposedly it needs [] expression.. I have never seen this and not sure how im meant to know that
Frank XC
@tenkdayz
Apr 25 2016 05:53
@karpimpski that's what is confusing to me
Michael Karpinski
@karpimpski
Apr 25 2016 05:54
@tenkdayz well animate animates the buttons, and I want the user to click after the button animations
@tenkdayz should I put my clicks in a document ready, or no function at all?
Chris Cullen
@123xylem
Apr 25 2016 05:56
@qualitymanifest Ok ive got it now... but i had to cheat... I wish FreecodeCamp gave clearer resources for how to see what to do..
I basically Had to totally learn regexp to do this but how do I know how much im supposed to know or how long I should research for
str.replace(/[\W_]/g, '') is the correct code
Frank XC
@tenkdayz
Apr 25 2016 05:57
@karpimpski if it helps you sure..
Chris Cullen
@123xylem
Apr 25 2016 05:57
I dont know why it needs the [] and finding out why is very difficult
Frank XC
@tenkdayz
Apr 25 2016 05:57
@karpimpski is there an array for the player's clicks/sequence
Michael Karpinski
@karpimpski
Apr 25 2016 05:57
@tenkdayz it doesn't help me, that would only complicate things. I've tried, but my code wasn't written to accomodate that and I can't easily take the clicks out of the functions
V1ad1m1r
@V1ad1m1r
Apr 25 2016 05:57
js
$(document).ready(function() {

  if ("geolocation" in navigator) {
  navigator.xgeolocation.getCurrentPosition(function(position) {


    $(".tester").text("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);

    console.log(position.coords.longitude);     
  })};
ok guys, been trying to successfully call the coordinates for 2 days. what am I missing?
Michael Karpinski
@karpimpski
Apr 25 2016 05:57
@tenkdayz no, there isn't, but I thought that having the clicks variable and matching it up to the sequence array would work
V1ad1m1r
@V1ad1m1r
Apr 25 2016 05:58
btw. already fixed the xgeolocation issue
Frank XC
@tenkdayz
Apr 25 2016 05:58
@karpimpski oh ok that could work too
V1ad1m1r
@V1ad1m1r
Apr 25 2016 05:59
@123xylem you can always hype help, and the problem as well.
Michael Karpinski
@karpimpski
Apr 25 2016 05:59
@tenkdayz yeah, I don't see any issues with that. I start click at 0, and every time I click I check to see if that click is equal to the value at sequence[click] then increment my click value
V1ad1m1r
@V1ad1m1r
Apr 25 2016 05:59
@123xylem ie help cypher
Chris Cullen
@123xylem
Apr 25 2016 05:59
@V1ad1m1r help cypher?
this chat is very helpful... but I feel like a dummy always asking and not grasping the complicated answers..
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:00
type is in without my calltag and it will bring up a help sheet, with functional code for the cypher problem. there is a wiki sheet like this for pretty much each problem :)
Norvin Burrus
@ndburrus
Apr 25 2016 06:00
@AndrewThM have you been assisted?
Chris Cullen
@123xylem
Apr 25 2016 06:01
type what in?
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:01
help [problem name]
CamperBot
@camperbot
Apr 25 2016 06:01
no wiki entry for: problem name
Boyce
@Yijianc
Apr 25 2016 06:01
help Sum All Numbers in a Range
CamperBot
@camperbot
Apr 25 2016 06:01

:point_right: algorithm sum all numbers in a range [wiki]

Problem Explanation:

  • You need to create a program that will take an array of two numbers who are not necessarily in order, and then add not just those numbers but any numbers in between. For example, [3,1] will be the same as 1+2+3 and not just 3+1
:pencil: read more about algorithm sum all numbers in a range on the FCC Wiki
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:01
like that :)
Chris Cullen
@123xylem
Apr 25 2016 06:01
ahhhhhhhhhhhhhhhh
help Check for Palindromes
CamperBot
@camperbot
Apr 25 2016 06:01

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:02
@123xylem that way, if you are sure your code should be correct, this will break down what you should do, often in a few different methods, step by step :)
Edward Cheadle
@echeadle
Apr 25 2016 06:02
@doomcode The game works with those three changes.
AndrewThM
@AndrewThM
Apr 25 2016 06:03
@ndburrus yes. I figured it out.
Michael Karpinski
@karpimpski
Apr 25 2016 06:03
@tenkdayz it seems like I've made a BIT of progress on it
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:03
js
$(document).ready(function() {

  if ("geolocation" in navigator) {
  navigator.geolocation.getCurrentPosition(function(position) {


    $(".tester").text("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);

    console.log(position.coords.longitude);     
  })};
anyone got any ideas why this isnt pulling the geolocation data?
Norvin Burrus
@ndburrus
Apr 25 2016 06:04
@AndrewThM ok... :fire:
Frank XC
@tenkdayz
Apr 25 2016 06:05
@karpimpski you're not clearing the interval.. could that be it
Michael Karpinski
@karpimpski
Apr 25 2016 06:05
@tenkdayz nevermind, I didn't make progress :/ and I'm not sure what you mean by clear the interval
Chris Cullen
@123xylem
Apr 25 2016 06:05
@V1ad1m1r that help cypher is good... thanks
CamperBot
@camperbot
Apr 25 2016 06:05
123xylem sends brownie points to @v1ad1m1r :sparkles: :thumbsup: :sparkles:
:star: 287 | @v1ad1m1r | http://www.freecodecamp.com/v1ad1m1r
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:05
@123xylem your welcome:) its what we are all here for :)
Frank XC
@tenkdayz
Apr 25 2016 06:06
function animate(sequence) {
  var i = 0;
  //loop through sequence and run lightUp for each value
  var interval = setInterval(function() {
    lightUp(sequence[i]);

    i++;
    if (i >= sequence.length) {
      clearInterval(interval);//maybe here?
    }
  }, 1000);
  console.log(sequence);
  clicks();
}
@karpimpski if you setInterval.. shouldnt you clearInterval when the sequence is done
Michael Karpinski
@karpimpski
Apr 25 2016 06:07
@tenkdayz I'm sure you're right, I just don't know where I would put clearInterval or what the syntax is
Frank XC
@tenkdayz
Apr 25 2016 06:07
@karpimpski ^^
Michael Karpinski
@karpimpski
Apr 25 2016 06:08
@tenkdayz that doesn't change anything
Elbert Cortez
@trip16661
Apr 25 2016 06:10
help Symmetric Difference
CamperBot
@camperbot
Apr 25 2016 06:10

:point_right: algorithm symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about algorithm symmetric difference on the FCC Wiki

V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:10
help geolocation
CamperBot
@camperbot
Apr 25 2016 06:10
no wiki entry for: geolocation
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:11
help geo location
CamperBot
@camperbot
Apr 25 2016 06:11

:point_right: challenge get geo location data [wiki]

Get Geo-location Data

Every browser has a built in navigator that can give us this information.

The navigator will get our user's current longitude and latitude.

You will see a prompt to allow or block this site from knowing your current location. The challenge can be completed either way, as long as the code is correct.

By selecting allow you will see the text on the output phone change to your latitude and longitude

Here's some code that does this:

```js
if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(function(position) {

$("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);

});

:pencil: read more about challenge get geo location data on the FCC Wiki

Frank XC
@tenkdayz
Apr 25 2016 06:13
@karpimpski I think i fixed it
Michael Karpinski
@karpimpski
Apr 25 2016 06:13
@tenkdayz how?
Frank XC
@tenkdayz
Apr 25 2016 06:14
@karpimpski whats the purpose of click()
Michael Karpinski
@karpimpski
Apr 25 2016 06:14
@tenkdayz to analyze the user's clicks
Frank XC
@tenkdayz
Apr 25 2016 06:15
@karpimpski I remove it an it works fine now..
Michael Karpinski
@karpimpski
Apr 25 2016 06:15
@tenkdayz what do you mean? can you link me your fork?
Michael Karpinski
@karpimpski
Apr 25 2016 06:18
@tenkdayz that is so strange, but amazing! do you have any idea why this works?
Frank XC
@tenkdayz
Apr 25 2016 06:20
@karpimpski I didnt understand why you would call a function that doesnt do anything .. because everything inside had event listeners .. no idea why it fixed it though
Michael Karpinski
@karpimpski
Apr 25 2016 06:20
@tenkdayz yeah, I understand why that didn't make sense but I'm not sure why that would be the solution. anyway, thanks so much!
CamperBot
@camperbot
Apr 25 2016 06:20
karpimpski sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 452 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:22
js
$(document).ready(function() {

  if ("geolocation" in navigator) {
    navigator.geolocation.getCurrentPosition(function(position) {

      $(".tester").text("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);

      console.log(position.coords.longitude);
can anyone help with why this isnt pulling the geolocation data?
Frank XC
@tenkdayz
Apr 25 2016 06:22
@karpimpski np!
Michael Karpinski
@karpimpski
Apr 25 2016 06:24
@tenkdayz I think I'm gonna take a break for the night, it's late. there are some bugs already, gotta clean up my code, add a few features, and obviously make it look nicer, but most of the game functionality is down and that's great! couldn't have gotten this far without your help, so thank you again!
CamperBot
@camperbot
Apr 25 2016 06:24
karpimpski sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:warning: karpimpski already gave tenkdayz points
Elbert Cortez
@trip16661
Apr 25 2016 06:24
function sym(args) {
var argsArray = [].slice.call(arguments);
var filteredArray,a = 0;
argsArray = argsArray.reduce(function(prev,curr){
    return prev.concat(curr);
  });
filteredArray = argsArray.filter(function(element,i,arr){
  return arr.indexOf(element) !== i;
});
for (a; a < filteredArray.length;a++){
  argsArray.filter(function(elem){

    return elem === filteredArray[a];
  });
}
  return argsArray;
}

sym([1, 2, 3], [5, 2, 1, 4]);
is there any way to do this?
Frank XC
@tenkdayz
Apr 25 2016 06:24
@V1ad1m1r
  if(navigator.geolocation) {

    navigator.geolocation.getCurrentPosition(function(position) {
      lat = position.coords.latitude;
      long = position.coords.longitude;
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:25
@tenkdayz but im not assigning variables yet, im just trying to display a string with calls to the json. :/
Frank XC
@tenkdayz
Apr 25 2016 06:26
@karpimpski np man.. always looking to learn something new
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:26
im getting no response, not even from my console log.
Frank XC
@tenkdayz
Apr 25 2016 06:28

@V1ad1m1r

 if ("geolocation" in navigator) {

what is that for?

V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:29
@tenkdayz its a part of the example code. I assume it is to differentiate between blocked and allowed decisions by the user.
Frank XC
@tenkdayz
Apr 25 2016 06:31
@V1ad1m1r havent seen that before.. ok
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:31
i saw it here
help geo location
CamperBot
@camperbot
Apr 25 2016 06:31

:point_right: challenge get geo location data [wiki]

Get Geo-location Data

Every browser has a built in navigator that can give us this information.

The navigator will get our user's current longitude and latitude.

You will see a prompt to allow or block this site from knowing your current location. The challenge can be completed either way, as long as the code is correct.

By selecting allow you will see the text on the output phone change to your latitude and longitude

Here's some code that does this:

```js
if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(function(position) {

$("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);

});

:pencil: read more about challenge get geo location data on the FCC Wiki

Sheikh Osama
@osama212
Apr 25 2016 06:39
hi everyone :smile: , I'm on problem 189 and I have solved but it wont accept my solution. any ideas.
My topic is: Global vs Local Scope in Functions
My instructions are: Add a local variable to myOutfit to override the value of outerWear with "sweater".
my solution is

// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var outerWear = "sweater";

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

myOutfit();

V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:40
please format for forum
Sheikh Osama
@osama212
Apr 25 2016 06:40
oh sorry
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:40
js
also, try capitalizing Sweater
:)
@osama212 do you know how to format the code?
Jose Gonzalez
@sneezyxl
Apr 25 2016 06:43
I was just going to ask him that :p
V1ad1m1r
@V1ad1m1r
Apr 25 2016 06:44
:)
alright. well ill try to solve this again tomorrow.
Night all :)
Zach
@Moose1551
Apr 25 2016 06:48
I'm working on "confirm an ending" in the first set of bonfire challenges. Am I on the right track? Also, is it possible to nest an "if statement" in a "for loop?"
function confirmEnding(str, target) {
str = " ";
target = str.substr(str.length >= target);
 var fullString = "Bastian";
 var stringEnd = "n";
  var counter = 0;

  for (var i = 0; i < stringEnd.length - 1; i--) {
    //can I nest an if statement in a for loop?
  }


}
confirmEnding("Bastian", "n");
Frank XC
@tenkdayz
Apr 25 2016 06:50
@Moose1551 yes
Zach
@Moose1551
Apr 25 2016 06:52
@tenkdayz , yes to both questions?
Chuck Adams
@chuckadams
Apr 25 2016 06:52
really need to come up with tutorial material that explains the orthogonality of statements
Frank XC
@tenkdayz
Apr 25 2016 06:53
@Moose1551 no and yes..
Chuck Adams
@chuckadams
Apr 25 2016 06:53
yes, you can have if/then in a loop. you can have a loop in if/then
statements can be combined in pretty much any way
buiphuking
@buiphuking
Apr 25 2016 06:53
i'm doing No repeats please, advance algorithm , i', stuck , plz give me some advice , plzzzzzzzzzzzzzzz
Chuck Adams
@chuckadams
Apr 25 2016 06:54
actually i suppose an hour with Scratch would explain the concept better than anything
Frank XC
@tenkdayz
Apr 25 2016 06:54
@buiphuking that's the only algorithm I have left... it's a headache..
Samuel Cupidon
@Zerazera
Apr 25 2016 06:55
Look up Heap's algorithm
buiphuking
@buiphuking
Apr 25 2016 06:55
@tenkdayz i think there are a formula or something
Samuel Cupidon
@Zerazera
Apr 25 2016 06:55
for permutations
In Python there's a nice library that deals with permutations so you don't have to. Unfortunately, this is Javascript. :-)
Chuck Adams
@chuckadams
Apr 25 2016 06:56
there's oodles of JS libs for combinatorics too i imagine
buiphuking
@buiphuking
Apr 25 2016 06:56
how about ES6 or jquery ?
Chuck Adams
@chuckadams
Apr 25 2016 06:56
but yeah, JS is definitely not "batteries included"
Frank XC
@tenkdayz
Apr 25 2016 06:56
@buiphuking yes.. i think solving it with a formula is much easier than mutating thousands of pairs.. it too a look at one of the answers but it was all alien to me
Chuck Adams
@chuckadams
Apr 25 2016 06:57
ES6 doesn't have too much to add in that domain except a Set type
jquery isn't really for that, it's just DOM and AJAX
i'd say the top hit for "npm combinatorics" would be just right ;p
and lo and behold, it is
Samuel Cupidon
@Zerazera
Apr 25 2016 06:59
If you can't make heads or tails of Heap's algorithm (I couldn't) you can also try generating the lexicographic permutations in sequence. https://www.nayuki.io/page/next-lexicographical-permutation-algorithm But it's a lot less elegant than Heap.
buiphuking
@buiphuking
Apr 25 2016 07:18
@tenkdayz i found formula with aabb , but not yet with abcdefa
Marc Schöni
@marcschoeni
Apr 25 2016 07:20
why thats not ok?
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function myFunction() {

  // Only change code below this line.
  function myFunction() {
  return Math.floor(Math.random() * 10); 
  }
  // Only change code above this line.
}
kirbyedy
@kirbyedy
Apr 25 2016 07:22
no need for this line
function myFunction() {
1 is enough
Marc Schöni
@marcschoeni
Apr 25 2016 07:25
but i need var ?
kirbyedy
@kirbyedy
Apr 25 2016 07:25
not really
Marc Schöni
@marcschoeni
Apr 25 2016 07:25
is that right
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function myFunction() {

  // Only change code below this line.
  var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
  return Math.floor(Math.random() * 10);

  // Only change code above this line.
}
kirbyedy
@kirbyedy
Apr 25 2016 07:25
just that return line is fine
Ankit Panwar
@coderNoob
Apr 25 2016 07:25
In my Simon game, I've used a disableBoard() method but I'm still able to make clicks when the compTurn() is in execution. Why? It works just fine everyplace else.
http://codepen.io/coderNoob/pen/wGmbqZ?editors=1010
kirbyedy
@kirbyedy
Apr 25 2016 07:25
@marcschoeni return Math.floor(Math.random() * 10);
only this
Marc Schöni
@marcschoeni
Apr 25 2016 07:29
same issue fail on The result of randomWholeNum should be a whole number.
Coryphaeus
@cvdeby
Apr 25 2016 07:31
@marcschoeni Use exact number you need Math.floor(Math.random() * 19);
kirbyedy
@kirbyedy
Apr 25 2016 07:32
var result = Math.floor(Math.random() * 9);
return result;
Marc Schöni
@marcschoeni
Apr 25 2016 07:32
same i will look later
Coryphaeus
@cvdeby
Apr 25 2016 07:32
And you redeclared randomNumberBetween0and19, it's not wrong, but I think you don't need to redeclare it.
Dardan Demiri
@dardandemiri
Apr 25 2016 07:33
blob
blob
Is it possible to take this data from FreeCodeCamp
And put them in My website for example ?
Coryphaeus
@cvdeby
Apr 25 2016 07:35
This website make it automatically every day - http://fcctop100.herokuapp.com )
kirbyedy
@kirbyedy
Apr 25 2016 07:36
@cvdeby only 100 :(
Coryphaeus
@cvdeby
Apr 25 2016 07:36
@kirbyedy You can find yourself by search)
@kirbyedy If you logged in.
kirbyedy
@kirbyedy
Apr 25 2016 07:40
hmmm yea, strange I have pretty decent amount of points, and I am not listed
buiphuking
@buiphuking
Apr 25 2016 07:41
@tenkdayz i found formula for abcdef a
7! - 6.5!.2 = 3600
Marc Schöni
@marcschoeni
Apr 25 2016 07:48
@cvdeby same issue
Surbhi Oberoi
@surbhioberoi
Apr 25 2016 07:49
Hi, I had to write fizzbuzz function, i think it's ok, can someone check it for me? is there any way to improve it?
function fizzbuzz(num) {
    for (var i = 1; i <= 100; i++) {
        if (num % 3 === 0 && num % 5 === 0) {
            return 'fizzbuzz';
        }

        if (num % 3 === 0) {
            return 'fizz';
        }

        if (num % 5 === 0) {
            return 'buzz';
        }

        if (num === undefined || isNaN(num) === true) {
            return false;
        }
    }
        return num;
    }
Marc Schöni
@marcschoeni
Apr 25 2016 07:50
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function myFunction() {

  // Only change code below this line.
  var result = Math.floor(Math.random() * 9);
  return result;  
  // Only change code above this line.
}
Coryphaeus
@cvdeby
Apr 25 2016 07:50
@marcschoeni Are you working with 'Generate Random Whole Numbers within a Range' ?
Marc Schöni
@marcschoeni
Apr 25 2016 07:51
@cvdeby Generate Random Whole Numbers with JavaScript
Coryphaeus
@cvdeby
Apr 25 2016 07:53
@marcschoeni I'm sorry, you need to use 10 instead of 9. I thought, that you don't need that 9)
@marcschoeni 0.9999 * 10 = 9.999 and after floor, you'll get 9 as maximum
Constantine Gauvoronsky
@ogkonstantin
Apr 25 2016 07:54

Hey, guys, it's me again ! I'm sorry, but I really can't get this JS code ....

initialize the three variables a, b, and c with 5, 10, and "I am a" respectively so that they will not be undefined.

// Initialize these three variables
var a;
var b;
var c;

a = 6;
b = 15;
c="I am a";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

Here is the tips
a should be defined and have a value of 6
b should be defined and have a value of 15
c should not contain undefined and should have a value of "I am a String!"
Do not change code below the line
Coryphaeus
@cvdeby
Apr 25 2016 07:56
@surbhioberoi It'll be more clear, if you'll check num before loop called
Marc Schöni
@marcschoeni
Apr 25 2016 07:57
i can`t solve it thanks @cvdeby @kirbyedy for the idea with var result^^
CamperBot
@camperbot
Apr 25 2016 07:57
marcschoeni sends brownie points to @cvdeby and @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 917 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
:star: 375 | @cvdeby | http://www.freecodecamp.com/cvdeby
Coryphaeus
@cvdeby
Apr 25 2016 07:58
@marcschoeni return Math.floor(Math.random() * 10); It worked for me.
kirbyedy
@kirbyedy
Apr 25 2016 07:58
@ogkonstantin if you initialise a to 6 then the line below will give you a +1 which is 7
Marc Schöni
@marcschoeni
Apr 25 2016 07:58
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.

  var result = Math.floor(Math.random() *10);
  return result;  

}
Coryphaeus
@cvdeby
Apr 25 2016 07:59
@ogkonstantin In the end 'a' is equal to 7 and 'b' is equal to 20
Dustin Frank
@DustInCompetent
Apr 25 2016 08:01
@ogkonstantin You initialized a and b with 6 and 15 instead of 5 and 10.
Constantine Gauvoronsky
@ogkonstantin
Apr 25 2016 08:02
Thankx, everybody, I have to have a rest )
My brain doesn't work )
Punith K
@kpunith8
Apr 25 2016 08:05

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

// Only change code above this line
}

https://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20[%0A%20%20%20%20{%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20[%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22]%0A%20%20%20%20}%2C%0A%20%20%20%20{%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20[%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22]%0A%20%20%20%20}%2C%0A%20%20%20%20{%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20[%22Intriguing%20Cases%22%2C%20%22Violin%22]%0A%20%20%20%20}%2C%0A%20%20%20%20{%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20[%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22]%0A%20%20%20%20}%0A]%3B%0A%0A%0Afunction%20lookUpProfile%28firstName%2C%20prop%29{%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20if%28contacts.firstName%20!%3D%3D%20firstName%29{%0A%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20}%20else%20{%0A%20%20%20%20return%20contacts.prop%3B%0A%20%20}%20%0A%20%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A}%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile%28%22Akira%22%2C%20%22likes%22%29%3B%0A
Eldar Tinjić
@EldarT90
Apr 25 2016 08:08
i have few concerns with my JS calculator 1. square function isnt working properly 2. display windows is not properly fixed (you can notice it after the first input)
Brendon
@Balvamar
Apr 25 2016 08:09

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

for(var i=0;i<contacts.length;i++){
if(firstName!==contacts[i].firstName){
return "No such contact";
}else if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}

// Only change code above this line
}

I have run this code without the loop, changing the contact index manually from 0 to 1 to 2 etc, and it works for each case, but does not work in the loop. Anybody have any ideas?
Surbhi Oberoi
@surbhioberoi
Apr 25 2016 08:14
@cvdeby how?
Coryphaeus
@cvdeby
Apr 25 2016 08:17

@surbhioberoi Something like that:

if (num === undefined || isNaN(num)) {
  for(...)
}
return num;

Because of your num variable wasn't changed inside the loop, you can check it outside the loop, if num undefined, you got 1 empty loop on your code.

Surbhi Oberoi
@surbhioberoi
Apr 25 2016 08:19
okay! thank you @cvdeby
CamperBot
@camperbot
Apr 25 2016 08:19
surbhioberoi sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 376 | @cvdeby | http://www.freecodecamp.com/cvdeby
naassi
@naassi
Apr 25 2016 08:20
@Balvamar The loop is exiting the first time it hits a contact that does not have firstname prop
Semikin Nikita
@nightrunner91
Apr 25 2016 08:20
hey people. which one of you can help me with Javascript Lesson "Multiple Identical Options in Switch Statements"? I will be grateful <3
naassi
@naassi
Apr 25 2016 08:22
@Balvamar use the if statement to check if it does have it eg
for (var x = 0; x < contacts.length; x++){
    if (contacts[x].firstName === firstName) {
       //then if(????????) {
               //do this }
            return "No such property";
        }
    }
}
return "No such contact";
Brendon
@Balvamar
Apr 25 2016 08:23
@naassi could you please help me correct this, it is driving me crazy, and i have been working on it for 2 days.
naassi
@naassi
Apr 25 2016 08:25
@Balvamar You have the right idea you were just doing it the wrong way round and when the loop hit the return statement it stopped and did'nt check prop
Brendon
@Balvamar
Apr 25 2016 08:25
@naassi ok, i'll try it now, thankis
pompek
@pompek
Apr 25 2016 08:29
"Profile Lookup" doesn't accept my solution even tho it returns correctly. What's wrong with the 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 lookUp(firstName, prop){
// Only change code below this line
  for (var x = 0; x < contacts.length; x++){
      if (contacts[x].firstName === firstName) {
        return contacts[x][prop] ? contacts[x][prop] : "No such property";
      }
  }
  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");
Eldar Tinjić
@EldarT90
Apr 25 2016 08:33
need help with JS calculator bugs , tnx
pompek
@pompek
Apr 25 2016 08:34
nevermind. seems like I've changed function name...
naassi
@naassi
Apr 25 2016 08:34
@pompek Have you tried with a normal else statement?
Brendon
@Balvamar
Apr 25 2016 08:34
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var 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";
}
}else{
return "No such contact";
}
}
// Only change code above this line
}
Dardan Demiri
@dardandemiri
Apr 25 2016 08:35
@Balvamar
help format
Brendon
@Balvamar
Apr 25 2016 08:35
@dardandemiri what's that?
pompek
@pompek
Apr 25 2016 08:35
@naassi ya. problem was that it was expecting lookUpProfile and I had changed it to lookUp
Dardan Demiri
@dardandemiri
Apr 25 2016 08:36
var yourCode = "Is not looking good, so please paste it formated"
naassi
@naassi
Apr 25 2016 08:36
@pompek ah is that es6 syntax? the if/else with : ?
Brendon
@Balvamar
Apr 25 2016 08:37
@dardandemiri sorry, am pretty new, how do I do that?
pompek
@pompek
Apr 25 2016 08:37
@naassi not sure. just that I like to do it that way usually :)
naassi
@naassi
Apr 25 2016 08:37
@Balvamar is that not working now?
Brendon
@Balvamar
Apr 25 2016 08:37
@naassi no, only correct for the last 2
Rohit Kumar Jena
@rohitrango
Apr 25 2016 08:38
can anyone give me an approach as how to solve steamroller ?
Dustin Frank
@DustInCompetent
Apr 25 2016 08:41
wiki format
CamperBot
@camperbot
Apr 25 2016 08:41

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Dustin Frank
@DustInCompetent
Apr 25 2016 08:42
oh would you look at that, they rewrote it to include declaring the language.
Brendon
@Balvamar
Apr 25 2016 08:42
'''function lookUpProfile(firstName, prop){
// Only change code below this line
for (var 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";
}
}else{
return "No such contact";
}
}
// Only change code above this line
}
'''
CamperBot
@camperbot
Apr 25 2016 08:42
:bulb: to format code use backticks! ``` more info
Dustin Frank
@DustInCompetent
Apr 25 2016 08:42
wiki How to type backticks
CamperBot
@camperbot
Apr 25 2016 08:42
no wiki entry for: how to type backticks
Brendon
@Balvamar
Apr 25 2016 08:43
'''jsfunction lookUpProfile(firstName, prop){
// Only change code below this line
for (var 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";
}
}else{
return "No such contact";
}
}
// Only change code above this line
}
'''
CamperBot
@camperbot
Apr 25 2016 08:43
:bulb: to format code use backticks! ``` more info
Brendon
@Balvamar
Apr 25 2016 08:43
jsfunction lookUpProfile(firstName, prop){ // Only change code below this line for (var 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"; } }else{ return "No such contact"; } } // Only change code above this line }
Dustin Frank
@DustInCompetent
Apr 25 2016 08:43
Please listen to camperbot.
Brendon
@Balvamar
Apr 25 2016 08:44

```jsfunction lookUpProfile(firstName, prop){
// Only change code below this line
for (var 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";
}
}else{
return "No such contact";
}
}
// Only change code above this line
}

```

Dustin Frank
@DustInCompetent
Apr 25 2016 08:45
ffs
function lookUpProfile(firstName, prop){
  // Only change code below this line
  for (var 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";
      }
    }else{
      return "No such contact";
    }
  }
  // Only change code above this line
}
Coryphaeus
@cvdeby
Apr 25 2016 08:45
@Balvamar Shift+Enter after backstick
Rohit Kumar Jena
@rohitrango
Apr 25 2016 08:46
whats wrong in this ?
res = [];
var k;
function steamrollArray(arr) {
  // I'm a steamroller, baby
  if(arguments.length==1)
    k = 0;

  for(var i=0;i<arr.length;i++) {
    if(Array.isArray(arr[i])) {
      steamrollArray(arr[i],k+1);
    }
    else {
      res.push(arr[i]);
      console.log(arr[i] + " " + k);
    }
  }  //end of for loop

  if(k===0)
    return res;

}

steamrollArray([1, [2], [3, [[4]]]]);
Coryphaeus
@cvdeby
Apr 25 2016 08:46
@Balvamar Where is your object? And why are you using loop, if you have hasOwnProperty?
naassi
@naassi
Apr 25 2016 08:46
@Balvamar just copied your code into the challenge and it works on the first three its just not passing
Brendon
@Balvamar
Apr 25 2016 08:46
@DustInCompetent dude, I am learning, I pressed js - then pasted my code - thenthen Shift-Enter
pompek
@pompek
Apr 25 2016 08:47
@balvamar your 3rd return breaks the loop
Blauelf
@Blauelf
Apr 25 2016 08:47
@rohitrango You should not have "global" variables, as those initializations are done only once, not once per function call.
Rohit Kumar Jena
@rohitrango
Apr 25 2016 08:48
Then I think i must pass another argument (the result array)
Brendon
@Balvamar
Apr 25 2016 08:49
@DustInCompetent any suggestions as to why this does not work?
naassi
@naassi
Apr 25 2016 08:49
@Balvamar Yea just checked with my own code, it must be a bug on that challenge becouse the first three are returning the correct answer just not passing the challenge
Coryphaeus
@cvdeby
Apr 25 2016 08:49
@rohitrango Nice trick with arguments, but you could make it without runner. You're on the right way.
Blauelf
@Blauelf
Apr 25 2016 08:50
@rohitrango Either that, or put everything in another function that gets called instead. Or pass all information in your return value instead of having side-effects.
Rohit Kumar Jena
@rohitrango
Apr 25 2016 08:50
will try now @Blauelf @cvdeby
Ankit Panwar
@coderNoob
Apr 25 2016 08:51
In my Simon game, I've used a disableBoard() method but I'm still able to make clicks when the compTurn() is in execution. Why? It works just fine everyplace else.
http://codepen.io/coderNoob/pen/wGmbqZ?editors=1010
Dustin Frank
@DustInCompetent
Apr 25 2016 08:52
@Balvamar Would say the same as @pompek . a return breaks the loop so that the other contacts aren't looked at as soon as one of them does not have the given first name AND the property you're looking for
Brendon
@Balvamar
Apr 25 2016 08:57

@DustInCompetent @naassi

@Balvamar Yea just checked with my own code, it must be a bug on that challenge becouse the first three are returning the correct answer just not passing the challenge - so it's bugged?

Sheikh Osama
@osama212
Apr 25 2016 08:57
@V1ad1m1r sorry for the late reply... No, trying to figure how the format code :worried:
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 08:57
hello there can any one tell me what i'm doing wrong
Rohit Kumar Jena
@rohitrango
Apr 25 2016 08:58
@Blauelf did what u told ! Thanks :smile: , thanks to @cvdeby as well :)
CamperBot
@camperbot
Apr 25 2016 08:58
rohitrango sends brownie points to @blauelf and @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 1712 | @blauelf | http://www.freecodecamp.com/blauelf
api offline
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:00
how do i upload a pjoto here ?!!
Eldar Tinjić
@EldarT90
Apr 25 2016 09:00
i need help with my JS calculator, tnx
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:07
?????
Blauelf
@Blauelf
Apr 25 2016 09:09
@iskandar992 You can copy&paste photos here, but if you want to post code, copy&paste text instead.
help format
CamperBot
@camperbot
Apr 25 2016 09: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 the code.

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

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

Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:10

``` function updateRecords(id, prop, value) {

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

collection[id].prop = value;  

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

return collection;
}

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

```function updateRecords(id, prop, value) {

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

collection[id].prop = value;  

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

return collection;
}

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

Blauelf
@Blauelf
Apr 25 2016 09:11
Shift+Return to insert line breaks around the triple backticks
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:11
```
```
Blauelf
@Blauelf
Apr 25 2016 09:13
```js Shift+Return
return "Some String"; Shift+Return
```
becomes
return "Some String";
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:14
function updateRecords(id, prop, value) {

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

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



  return collection;
}
thank you so much
in the first if statement i'm supposed to update the property of a JSON object
Blauelf
@Blauelf
Apr 25 2016 09:15
collection[id].prop is same as collection[id]["prop"], which has nothing to do with variable prop.
And you could append to tracks array using collection[id].tracks.push(value), should not use collectionCopy anyway.
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:16
yeah i'm getting this
"prop" : "ABBA"
but i need the value of prop
Blauelf
@Blauelf
Apr 25 2016 09:17
Same for delete statement (both mistakes, dot instead of bracket notation, and collectionCopy instead of collection)
Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:18
for example
prop = artist
it should be
"artist" : "ABBA"
Blauelf
@Blauelf
Apr 25 2016 09:18
Then don't use "prop" but prop
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:18

Hi, i’m currently at the Seek and destroy bonfire, and i’m having some trouble with the .filter function.

because as i understand it, .filter loops through an array, and compares it to the callback function right? But how i target each «loop» or «key» in the .filter loop. Like we do in a for loop. (i=0;i<array.length;i++){ If (array[i] == something)} etc.

Abdulkarim Eskandar
@iskandar992
Apr 25 2016 09:19
why doesn't the dot notation work here :S i'm confused
Blauelf
@Blauelf
Apr 25 2016 09:20
@oisteinhaugland Inner function has its own arguments object, so you need to make that content from outer function's arguments accessible to inner function.
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:21
function destroyer(arr) {

    arr = arr.filter(function (value) {

      if ((value == arguments[1]  )){
         return false;   
      }  else {
        return true;
      } 
    });
  return arr;
}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Blauelf
@Blauelf
Apr 25 2016 09:21
@iskandar992 Dot notation is really static. As I said, collection[id].prop is same as collection[id]["prop"], it uses a static string "prop" instead of the value of variable prop.
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:21
this only checks the first argument ofcourse but i struggle with the value
because now, it checks the whole array, how do i get it to compare each individual key of it
Blauelf
@Blauelf
Apr 25 2016 09:22
You struggle with arguments. This is your inner function's arguments, not your outer function's.
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:23
so that would be something like value.arguments?
or is that comepletely off target?
Blauelf
@Blauelf
Apr 25 2016 09:23
Also, you can use indexOf to check whether an array contains an element, the return value is the index, or -1 if not found.
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:24
thanks @Blauelf . i’ll try it out
CamperBot
@camperbot
Apr 25 2016 09:24
oisteinhaugland sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1713 | @blauelf | http://www.freecodecamp.com/blauelf
Chris N
@lymeswold
Apr 25 2016 09:25
find random
Blauelf
@Blauelf
Apr 25 2016 09:25
You need some code that makes content available to your inner function, for example
  var targets = Array.prototype.slice.call(arguments, 1); // same as arguments.slice(1) if arguments were an array
  // now inside callback use targets as the list of all arguments but the first
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:32
i get a TypeError, i can’t slice undefined.
Blauelf
@Blauelf
Apr 25 2016 09:32
Sorry, typo in prototype
mnashrullah07
@mnashrullah07
Apr 25 2016 09:33
I got stuck on Accessing Nested Objects in JSON, is there anybody can help me?
Øistein Haugland
@oisteinhaugland
Apr 25 2016 09:34
still get the undefined error though. should the variable be outside the destroyer function?
Chiara
@chiara-f
Apr 25 2016 09:34
@mnashrullah07 hey! what seems to be the problem?
mnashrullah07
@mnashrullah07
Apr 25 2016 09:34
i wrote myStorage.car.inside["glove box"]; @chiara-f
is there anything wrong?
Chiara
@chiara-f
Apr 25 2016 09:36
@mnashrullah07 it should be working
var gloveBoxContents = myStorage.car.inside["glove box"];
is it something like this? @mnashrullah07
Boyce
@Yijianc
Apr 25 2016 09:38
help Roman Numeral Converter
CamperBot
@camperbot
Apr 25 2016 09:38

:point_right: algorithm roman numeral converter [wiki]

Problem Explanation:

  • You will create a program that converts an integer to a Roman Numeral.
:pencil: read more about algorithm roman numeral converter on the FCC Wiki
mnashrullah07
@mnashrullah07
Apr 25 2016 09:39
alright, let me try @chiara-f
Chiara
@chiara-f
Apr 25 2016 09:39
@mnashrullah07 :thumbsup:
Rohit Kumar Jena
@rohitrango
Apr 25 2016 09:39
can anyone tell me how sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) will return [1,4,5]
Symmetric difference problem
Coryphaeus
@cvdeby
Apr 25 2016 09:41
@rohitrango You should delete all the same values. For example [1,2,5] 'triangle sign' [2,3,5] will return [1,3]. triangle sign is symmetric difference's sign in math.
mnashrullah07
@mnashrullah07
Apr 25 2016 09:41
@chiara-f thank's buddy, it works. My bad, I forgot to write it after the variable declaration
CamperBot
@camperbot
Apr 25 2016 09:41
mnashrullah07 sends brownie points to @chiara-f :sparkles: :thumbsup: :sparkles:
:star: 310 | @chiara-f | http://www.freecodecamp.com/chiara-f
Chiara
@chiara-f
Apr 25 2016 09:42
@mnashrullah07 no problem! i'm glad we worked it out! :)
Rohit Kumar Jena
@rohitrango
Apr 25 2016 09:42
but 5 is present in all the 3 arrays, so how can it be present in the answer ?
check testcases
Sameer Shamsudeen
@sameershamsudheen
Apr 25 2016 09:43

hello I was doing Truncate a string, here is my code

function truncateString(str, num) {
  var result='';
  // Clear out that junk in your trunk
  if(str.length > num)
  {
    result = str.slice(0, num - 3) + '...';
  }
  else{

  }
    return result;
}
truncateString("Absolutely Longer", 2);

I get two correct answers, but i dont know how to do this, truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) can anyone help me please

Coryphaeus
@cvdeby
Apr 25 2016 09:43
you should compare two arrays step by step ([0]&[1])&[2]
the result of comparing first two sets, you should to compare with third set.
Rohit Kumar Jena
@rohitrango
Apr 25 2016 09:44
let me see
this is not the definiton of symmetric diff i guess
but will try anyway
Coryphaeus
@cvdeby
Apr 25 2016 09:45
@rohitrango In your case - [1,2,5]&[2,3,5] will return [1,3] and then [1,3]&[3,4,5] will return [1,4,5]
Armend
@ArmendBerisha
Apr 25 2016 09:47
@sameershamsudheen if the length of the second argument is major or equal to the length of the first
Coryphaeus
@cvdeby
Apr 25 2016 09:47
idea about arrays came from math.
Rohit Kumar Jena
@rohitrango
Apr 25 2016 09:47
obviously
Armend
@ArmendBerisha
Apr 25 2016 09:47
you have to return the str
Blauelf
@Blauelf
Apr 25 2016 09:49
@oisteinhaugland Are you sure you have no typo inside that line? If you put that inside a function, it should not throw an error.
Mohamed Ameen
@pmohdameen
Apr 25 2016 09:50

Basic Algorithm Scripting: Seek And Destroy

help me with my code. Its given below

function destroyer(arr) {
// Remove all the values

var filtered = arr.filter(function(val){
for (var i=1; i<arr.length; i++){
for (var j=0; j<arr0.length; j++){
return arr[0][j] !== arr[i];
}
}

});

return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

here is updated one
function destroyer(arr) {
  // Remove all the values

  var filtered = arr.filter(function(val){
    for (var i=1; i<arr.length; i++){
      for (var j=0; j<arr[0].length; j++){
        return arr[0][j] !== arr[i];
      }
    }


  });

  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Blauelf
@Blauelf
Apr 25 2016 09:55
@pmohdameen arr is [1, 2, 3, 1, 2, 3], arr[0] is 1. Use the arguments object, and keep in mind that the inner function has its own, so you need to make the content of outer function's arguments accessible to the inner function.
arguments is some array-like object (is no array, so does not inherit array methods) that gets all the arguments your function is called with, no matter how many you named.
Mohamed Ameen
@pmohdameen
Apr 25 2016 09:56
@Blauelf oh, so its not the whole ([1, 2, 3, 1, 2, 3], 2, 3) ?
naassi
@naassi
Apr 25 2016 09:58
Can anyone tell me why this isnt working?
Blauelf
@Blauelf
Apr 25 2016 09:58
Nope, arr gets first argument. Others have no name (as you don't know how many follow, even if the tests feature at most three)
Mohamed Ameen
@pmohdameen
Apr 25 2016 09:58
@Blauelf okay, great. thanks :)
CamperBot
@camperbot
Apr 25 2016 09:58
pmohdameen sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1714 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Apr 25 2016 09:59
@pmohdameen arguments is array-like, so you can use [] for accessing numeric properties and have a length property.
naassi
@naassi
Apr 25 2016 10:00
When I push the T/F values from the function i get true true false false but when i try to use them in if statement
its not working?
function dropElements(arr, func) {
  var newarr = [];
  for(var i = 0; i < arr.length; i ++) {
    if(func(arr[i])) {
     arr = arr.slice(arr[i]);
    }

   }
  return arr;
}

dropElements([1, 2, 3, 4], function(n) {return n >= 3;});
Mohamed Ameen
@pmohdameen
Apr 25 2016 10:00
@Blauelf okay, got it.
Blauelf
@Blauelf
Apr 25 2016 10:01
@naassi slice takes an index, not an element (and you don't stop your loop after that either by returning from function or by break). Also, what happens if none of the element has truthy return value of func?
You could return arr.slice(i) inside the loop and return [] after it, for example.
naassi
@naassi
Apr 25 2016 10:04
Ok @Blauelf I'll try that thanks
CamperBot
@camperbot
Apr 25 2016 10:04
naassi sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1715 | @blauelf | http://www.freecodecamp.com/blauelf
naassi
@naassi
Apr 25 2016 10:05
Got it thanks
Øistein Haugland
@oisteinhaugland
Apr 25 2016 10:07
@Blauelf the problem was that freecodecamp doesn’t like the .prototype. just had to remove it.
Ankit Panwar
@coderNoob
Apr 25 2016 10:13
@Blauelf In my Simon game, I've used a disableBoard() method but I'm still able to make clicks when the compTurn() is in execution. Why? It works just fine everyplace else.
http://codepen.io/coderNoob/pen/wGmbqZ?editors=1010
Coryphaeus
@cvdeby
Apr 25 2016 10:13
Ahah, Friendly Date Ranges is a second symmetric difference)
JaZy-K
@plavakutlaca
Apr 25 2016 10:16

Hi I am doing “Record Collection” challange right now .. Can some one help me unedstand logic and how to deal with "For the given id in collection

I got hang on the object staff add/ update/ delete … but this is some thing I cant figure it out.

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

  collection.id = true

  if (value !== "" || prop !== "tracks"){
    collection[prop] = value;
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Stephen James
@sjames1958gm
Apr 25 2016 10:22
@plavakutlaca collection.id = true is adding an id property to the collection, when using variables the [] are reuqired. When later accessing or updating the record you need collection[id]
Eldar Tinjić
@EldarT90
Apr 25 2016 10:22
@plavakutlaca nice nickname lol
@sjames1958gm morning ^^
JaZy-K
@plavakutlaca
Apr 25 2016 10:23
@EldarT90 hvala :)
Stephen James
@sjames1958gm
Apr 25 2016 10:23
@EldarT90 morning
jihad khorfan
@spyshow
Apr 25 2016 10:31

hi all i have a problem in challenge Arguments Optional ... my code is

function addTogether() {
  for(var i=0; i < arguments.length ; i++){
    if(typeof arguments[i] !== "number"){
      return undefined;
    }
  }
  if(arguments.length > 1){  
    for(i=0; i < arguments.length ; i++){
      return arguments[0]+arguments[1]; 
    }
  } else {
    var num = arguments[0] ;
    return function(){
        if(typeof a !== "number"){
        return undefined;
      } else {
        return num + a;
      } 
    };
  }


}

addTogether(2)(3);

but it give me no error just an empty output
it give me this error only for
addTogether(2)(3);
other test are OK

Boyce
@Yijianc
Apr 25 2016 10:31