These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Jun 2016
David Halls
@DavidHalls
Jun 21 2016 00:00
@96street this is not getting the lat and lon, but i think i have it fixed for ya
Greg Duncan
@GregatGit
Jun 21 2016 00:02
@96street are you using chrome?
anacou
@anacou
Jun 21 2016 00:02
can someone help me with the Generate Random Whole Numbers with Javascript challenge?
96street
@96street
Jun 21 2016 00:02
both chrome & firefox
@GregatGit
David Halls
@DavidHalls
Jun 21 2016 00:02
@anacou yes
96street
@96street
Jun 21 2016 00:02
someone here said it doesn't work on chrome
anacou
@anacou
Jun 21 2016 00:03
here's my code

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.
Math.floor(Math.random() * 10);
  return Math.random();
}
Greg Duncan
@GregatGit
Jun 21 2016 00:03
@96street you have a few key problems with your code
Eden Coleman
@nede36
Jun 21 2016 00:03

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

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

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

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

Stephen James
@sjames1958gm
Jun 21 2016 00:04
@anacou Your code is returning simply Math.random();
96street
@96street
Jun 21 2016 00:04
@Byzgig did you manage to fix it?
Tyler Moeller
@TylerMoeller
Jun 21 2016 00:04
@96street navigator.geolocation will only work in chrome when your weather app is served over HTTPS. https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only?hl=en
David Halls
@DavidHalls
Jun 21 2016 00:04
@96street yes
Stephen James
@sjames1958gm
Jun 21 2016 00:04
Eden Coleman
@nede36
Jun 21 2016 00:04
I'm stuck here, I needed to convert the switch statement into a lookup table called "lookup". Then use it to lookup "val" and assign the associated string to the "result" variable
Stephen James
@sjames1958gm
Jun 21 2016 00:05
@nede36 You need result = ?
David Halls
@DavidHalls
Jun 21 2016 00:05
@anacou just return what you wrote
Greg Duncan
@GregatGit
Jun 21 2016 00:05
@96street chrome is blocking (navigator.geoLocation) if your are using http - but if you you use https it wont work for the free regisgtration of openweather which needs to be http
David Halls
@DavidHalls
Jun 21 2016 00:05
This message was deleted
96street
@96street
Jun 21 2016 00:06
right
i'm just gonna do it on firefox then
Greg Duncan
@GregatGit
Jun 21 2016 00:06
@96street you can use http://ip-api.com/json to get lat and long
David Halls
@DavidHalls
Jun 21 2016 00:06
```
$(document).ready(function() {
var lat = "";
var lon = "";
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("geolocation not eneabled");
}
});
function showPosition(pos) {
var lat = pos.coords.latitude;
var lon = pos.coords.longitude;
console.log( lat + " : " + lon);
}
console.log(lat);
console.log(lon);
```
@96street that should get you the lat and lon
anacou
@anacou
Jun 21 2016 00:07
thanks @Byzgig truly appreciate it!
CamperBot
@camperbot
Jun 21 2016 00:07
:cookie: 344 | @byzgig |http://www.freecodecamp.com/byzgig
anacou sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
Greg Duncan
@GregatGit
Jun 21 2016 00:07
@96street but the other issue is your second getJSON call - it needs to be inside the first or it won't have the lat and long yet
Stephen James
@sjames1958gm
Jun 21 2016 00:08
@Byzgig The last two console.log will output empty strings.
David Halls
@DavidHalls
Jun 21 2016 00:09
@GregatGit not from what i am seeing
96street
@96street
Jun 21 2016 00:09
yeah disregard that it was just from anothe method
@Byzgig can you explain what you changed from my code and why?
that looks good tho
David Halls
@DavidHalls
Jun 21 2016 00:10
@GregatGit wait you were right, i had em printing somehwere up top too
Greg Duncan
@GregatGit
Jun 21 2016 00:10
@96street the api must have http:// at the front of it
David Halls
@DavidHalls
Jun 21 2016 00:11
@96street i removed that first function and had it just in the document.ready and then you also had geolocation spelled wrong
Greg Duncan
@GregatGit
Jun 21 2016 00:11
@96street have you registered at openweather
96street
@96street
Jun 21 2016 00:11
no do i have to?
Greg Duncan
@GregatGit
Jun 21 2016 00:12
@96street yes - but its free
anacou
@anacou
Jun 21 2016 00:12
what's wrong with this code and why

// Example
function ourFunction(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

  return Math.floor(Math.random() * (myMax - myMin + 1)) + min; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
Stephen James
@sjames1958gm
Jun 21 2016 00:13
@anacou check your all variable names
96street
@96street
Jun 21 2016 00:14
@GregatGit what do I get if I sign up?
anacou
@anacou
Jun 21 2016 00:14
@sjames1958gm not sure I understand
Stephen James
@sjames1958gm
Jun 21 2016 00:15
@anacou Look at that line of code and make sure all your variables have the correct names.
Greg Duncan
@GregatGit
Jun 21 2016 00:15
@96street just google openweather register and you should get a link - it only take 3 or 4 mins
Stephen James
@sjames1958gm
Jun 21 2016 00:15
@sjames1958gm myMax, myMin and ?? min ??
Greg Duncan
@GregatGit
Jun 21 2016 00:15
@96street Good luck - I have to go
anacou
@anacou
Jun 21 2016 00:16
got it thanks @sjames1958gm
CamperBot
@camperbot
Jun 21 2016 00:16
anacou sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1607 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Finesse Rucker
@Finesse315
Jun 21 2016 00:16
how do i show my code?
Stephen James
@sjames1958gm
Jun 21 2016 00:16
help format
CamperBot
@camperbot
Jun 21 2016 00:16

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

96street
@96street
Jun 21 2016 00:17
ty @GregatGit
CamperBot
@camperbot
Jun 21 2016 00:17
96street sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 611 | @gregatgit |http://www.freecodecamp.com/gregatgit
Stephen James
@sjames1958gm
Jun 21 2016 00:17
@anacou :+1:
@Finesse315 Basically - three backticks (next to one key), shift-enter, paste, shift-enter, three backticks, enter
Brendan Kinahan
@BKinahan
Jun 21 2016 00:18
```js
like this :D
```
96street
@96street
Jun 21 2016 00:18
i've used your code but not working http://codepen.io/kingdezz/pen/RRROEr?editors=0011 @Byzgig
Finesse Rucker
@Finesse315
Jun 21 2016 00:19

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



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

// Change this value to test
caseInSwitch(1);
David Halls
@DavidHalls
Jun 21 2016 00:19
@96street delete the very last occurrence of });
Ken Haduch
@khaduch
Jun 21 2016 00:20
@96street - if you look in the JS panel of the CodePen editor view, you have a syntax error - an extra (or what looks like an extra });
Finesse Rucker
@Finesse315
Jun 21 2016 00:20
im geting unreachable break after return
Osman Zakir
@DragonOsman
Jun 21 2016 00:20
how do I get this requirement: ""Sherlock", "likes" should return ["Intriguing Cases", "Violin"]" to check out? My current code is: function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (firstName == "Akira") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Laine"; } else if (prop == "number") { return "0543236543"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == "Harry") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Potter"; } else if (prop == "number") { return "0994372684"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == "Sherlock") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Holmes"; } else if (prop == "number") { return "0487345643"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } if (firstName == "Kristian") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Vos"; } else if (prop == "number") { return "unknown"; } else if (prop == "likes") { return ['Intriguing Cases', 'Violin']; } } else { return "No such property"; } } else { return "No such contact"; } } // Only change code above this line }
All of the requirements check out except for that aforementioned one
Stephen James
@sjames1958gm
Jun 21 2016 00:21
@Finesse315 You'll want to switch on the input value val - switch (val) {}
ranter than return alpha - set answer to "alpha" (answer = "alpha")
Ken Haduch
@khaduch
Jun 21 2016 00:21
@DragonOsman - can you post your code with the formatting syntax as shown below:
help format
CamperBot
@camperbot
Jun 21 2016 00:21

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

96street
@96street
Jun 21 2016 00:21
sweet it's working @Byzgig
so i just accepted the browser to take my location, now it's stored in lat and lon?
Where to now?
Osman Zakir
@DragonOsman
Jun 21 2016 00:22
@khaduch: That's what I did, though. I'll try it again.
Finesse Rucker
@Finesse315
Jun 21 2016 00:22
@sjames1958gm thx
CamperBot
@camperbot
Jun 21 2016 00:22
finesse315 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1608 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Osman Zakir
@DragonOsman
Jun 21 2016 00:22
function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (firstName == "Akira") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Laine"; } else if (prop == "number") { return "0543236543"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == "Harry") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Potter"; } else if (prop == "number") { return "0994372684"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == "Sherlock") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Holmes"; } else if (prop == "number") { return "0487345643"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } if (firstName == "Kristian") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Vos"; } else if (prop == "number") { return "unknown"; } else if (prop == "likes") { return ['Intriguing Cases', 'Violin']; } } else { return "No such property"; } } else { return "No such contact"; } } // Only change code above this line }
Ken Haduch
@khaduch
Jun 21 2016 00:22
@DragonOsman - you should not have hardcoded names within your test conditions - that' much I can see from the code.
llamatarianism
@llamatarianism
Jun 21 2016 00:22
help format
CamperBot
@camperbot
Jun 21 2016 00:22

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Stephen James
@sjames1958gm
Jun 21 2016 00:22
@DragonOsman You should not be referring to all the values in the contacts objects, but use the variables.
Ken Haduch
@khaduch
Jun 21 2016 00:22
use the "multiline code @DragonOsman format
David Halls
@DavidHalls
Jun 21 2016 00:22
@96street now you need to build your json call
Stephen James
@sjames1958gm
Jun 21 2016 00:22
help format
CamperBot
@camperbot
Jun 21 2016 00:22

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

96street
@96street
Jun 21 2016 00:23
@Byzgig gotcha
Osman Zakir
@DragonOsman
Jun 21 2016 00:23
function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (firstName == "Akira") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Laine"; } else if (prop == "number") { return "0543236543"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == "Harry") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Potter"; } else if (prop == "number") { return "0994372684"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == "Sherlock") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Holmes"; } else if (prop == "number") { return "0487345643"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } if (firstName == "Kristian") { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Vos"; } else if (prop == "number") { return "unknown"; } else if (prop == "likes") { return ['Intriguing Cases', 'Violin']; } } else { return "No such property"; } } else { return "No such contact"; } } // Only change code above this line }
Stephen James
@sjames1958gm
Jun 21 2016 00:23
@DragonOsman Assume you cannot see the contact information above.
andreyorlov33
@andreyorlov33
Jun 21 2016 00:24

Hello! :)
I am finishing up my Twitch API project and I would really appreciate some constructive criticism on my code.
I also have a question with regards to my apps functionality.
It is possible to check a Twitch channel status by utilizing search in my app.
The search will send a JSON request to the Twitch server and then create an element and append it to the DOM.
The element is being created with an ID tag.
However after the element is appended into the DOM, the $() selector does not bind to the element and I cannot figure out why.
The element is being created in the userStatus() function on line 97.
The .click function which I am attempting to bind to the element is on line 142 .
Please advice on why the element is not binding to the selector.
If you know of any Youtube links that can be beneficial to me please feel free to send me the links!
Thank you for your time !

HERE IS THE CODEPEN:
Codepen

Osman Zakir
@DragonOsman
Jun 21 2016 00:25
How do I get it to return the "likes" for Sherlock Holmes? And I can't tell which element would be accessed by what index because the arrangement of this type of array is too confusing for me.
Finesse Rucker
@Finesse315
Jun 21 2016 00:26

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch ("val") {
    case 1:
      answer = "alpha";
      break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
      break;
  }



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

// Change this value to test
caseInSwitch(2);
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:29
Hello everybody
Stephen James
@sjames1958gm
Jun 21 2016 00:29
@Finesse315 You want to test the variable val - you are testing the string "val"
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:30
I got stuck on the "Escape Sequences in Strings"
Ken Haduch
@khaduch
Jun 21 2016 00:30
@james-freitas - hello
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:30
var myStr = "Here is a backslash: \.\n\t\t Here is a newline with two tabs.";
FM
@mafelix
Jun 21 2016 00:30
@james-freitas you have a period there
@james-freitas that's not needed
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:30
In the middle ?
FM
@mafelix
Jun 21 2016 00:30
yes
Finesse Rucker
@Finesse315
Jun 21 2016 00:30
knew it was sething simple.. thx removed the quotes and it worked
Ken Haduch
@khaduch
Jun 21 2016 00:31
@james-freitas - you do not need the extra verbiage in there, only the character sequence that they give, using the escape codes, separated by spaces.
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:32
Ok, gonna try it
Osman Zakir
@DragonOsman
Jun 21 2016 00:34
@sjames1958gm: How do I access each of the names, though? I'm hard-coding the names because I can't tell which index corresponds with what in this kind of array. And how do I make it correctly written the "likes" for Sherlock Holmes?
Ian
@IMLaing
Jun 21 2016 00:35
I added in a function to replicate the initial submit function on.('click', 'li', function(){.... which then made the item add with all the original buttons.
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:35
Sorry by the noobyness
var myStr = "Here is a backslash: \ \n \t \t Here is a new line with two tabs.";
It should be like this above?
Stephen James
@sjames1958gm
Jun 21 2016 00:36
contacts[id][prop] @DragonOsman
bitgrower
@bitgrower
Jun 21 2016 00:39

today's drop of coding wisdom ... don't beat yourself up because your coding mistake was something simple, or something dumb ... it happens frequently, and to all programmers ... it has more to do with the human condition than your competence...so do not let it get you down, and do not beat yourself up about it ...

However, you can use it constructively by keeping a log of the types of coding errors you make commonly ... that way, you have a checklist you can refer to when facing a seemingly intractable (or at least frustrating) challenge ... (both here in FCC, and beyond...)

The number of bugs I've tracked down and thought ... man, this is gonna be really interesting when I figure it out ... and then were extremely mundane is rather legion ... (and since I've worked on a lot of code written by others, those were errors introduced by others. It's actually a bit awe-inspiring to come across a bug which has been in the code for YEARS and had not previously been found & fixed ...

Osman Zakir
@DragonOsman
Jun 21 2016 00:40
@sjames1958gm: What's that for? It's not doing anything when I put it in as the return value of Sherlock's "likes".
Ken Haduch
@khaduch
Jun 21 2016 00:40
@james-freitas - I think that you just need to (and maybe only need to) do this: var myStr = "\\ \t \r \n"; or whatever the character sequence is. No extra words in there? I haven't looked back to review what they challenge is asking for.
Osman Zakir
@DragonOsman
Jun 21 2016 00:41
@sjames1958gm: Wait, never mind
yeah, didn't work
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:42
@khaduch - Here is the challenge

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

Here is a backslash: .
Here is a new line with two tabs.

Alex Harshaw
@aharshaw
Jun 21 2016 00:42
Hi Everyone. This should be a quick one.
Accessing Nested Objects
Stephen James
@sjames1958gm
Jun 21 2016 00:42
@DragonOsman You have a loop and you are supposed to check if firstName === contacts[id].firstName then you know that you can do the other requirements
Alex Harshaw
@aharshaw
Jun 21 2016 00:42

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

// Only change code below this line

var gloveBoxContents = myStorage.car.inside.glove_box; // Change this line
FM
@mafelix
Jun 21 2016 00:42
@aharshaw what is confusing you?
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 00:42

You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above with no additional spaces between each escape sequence.

Here is the text with the escape sequences written out.

Here is a backslash: backslash.newline tab tab Here is a new line with two tabs.

Alex Harshaw
@aharshaw
Jun 21 2016 00:43
It won't accept my input
var gloveBoxContents = myStorage.car.inside.glove_box;
Osman Zakir
@DragonOsman
Jun 21 2016 00:43
@sjames1958gm : There's no variable id anywhere in my code, though, so it won't recognize it
Alex Harshaw
@aharshaw
Jun 21 2016 00:43
I'm beginning to think it has something to do with how I'm writing glove_box @mafelix
Stephen James
@sjames1958gm
Jun 21 2016 00:44
@DragonOsman id was supposed to be i my bad.
FM
@mafelix
Jun 21 2016 00:44
@james-freitas it's a very simple exercise you're tackling. you should read up on what it means so you actually understand it
@aharshaw what do you mean?
Alex Harshaw
@aharshaw
Jun 21 2016 00:44
i changed the key to glove then called it as "glove" instead of "glove_box" and I got "maps"
FM
@mafelix
Jun 21 2016 00:44
@aharshaw pm me
Alex Harshaw
@aharshaw
Jun 21 2016 00:44
As it is now, I'm getting undefined results
FM
@mafelix
Jun 21 2016 00:44
@aharshaw pm your code and stuff so we don't flood the channel
Alex Harshaw
@aharshaw
Jun 21 2016 00:45
... I don't know how :( @mafelix
FM
@mafelix
Jun 21 2016 00:45
click on my picture
and click on private message
chat privately
w/e we can skip that
you're getting undefined results
Alex Harshaw
@aharshaw
Jun 21 2016 00:46
I don't have the option. It just has your followers, repos, following...
FM
@mafelix
Jun 21 2016 00:46
kk that's fine
so you're getting undefined results because you're calling a property that's not actually tthere
so post your code again
Alex Harshaw
@aharshaw
Jun 21 2016 00:47

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

// Only change code below this line

var gloveBoxContents = myStorage.car.inside.glove_box; // Change this line
I'm following you on Github now btw
FM
@mafelix
Jun 21 2016 00:47
the mistake is very simple
Alex Harshaw
@aharshaw
Jun 21 2016 00:47
but yea, is "glove_box" the wrong way to write it?
FM
@mafelix
Jun 21 2016 00:47
yes
Alex Harshaw
@aharshaw
Jun 21 2016 00:47
That's what I was thinking
FM
@mafelix
Jun 21 2016 00:47
you need bracket notation
myStorage.car.inside["glove box"]
Alex Harshaw
@aharshaw
Jun 21 2016 00:48
Boom
Perfect, thanks @mafelix
CamperBot
@camperbot
Jun 21 2016 00:48
aharshaw sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @mafelix |http://www.freecodecamp.com/mafelix
Osman Zakir
@DragonOsman
Jun 21 2016 00:49
@sjames1958gm: I've got it like this now: function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Laine"; } else if (prop == "number") { return "0543236543"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Potter"; } else if (prop == "number") { return "0994372684"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Holmes"; } else if (prop == "number") { return "0487345643"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Vos"; } else if (prop == "number") { return "unknown"; } else if (prop == "likes") { return ["Intriguing Cases", "Violin"]; } } else { return "No such property"; } } else { return "No such contact"; } } an it's still not working. What am I doing wrong?
What was working before also isn't working now
FM
@mafelix
Jun 21 2016 00:50
no one is gonna read your code like that man
lol
nest your code between ```
Osman Zakir
@DragonOsman
Jun 21 2016 00:50
that's what I'm doing
FM
@mafelix
Jun 21 2016 00:50
var test = "oaiefjoaiwjfoiajwefoiaj";
Osman Zakir
@DragonOsman
Jun 21 2016 00:50
I guess it's not working for me, @mafelix
FM
@mafelix
Jun 21 2016 00:50
' aoiejfoiawejfiewa'
code
Stephen James
@sjames1958gm
Jun 21 2016 00:51
@DragonOsman Basically - three backticks (next to one key), shift-enter, paste, shift-enter, three backticks, enter
Alex Harshaw
@aharshaw
Jun 21 2016 00:51
function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Laine"; } else if (prop == "number") { return "0543236543"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Potter"; } else if (prop == "number") { return "0994372684"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } else if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Holmes"; } else if (prop == "number") { return "0487345643"; } else if (prop == "likes") { return contacts[i][prop]; } } else { return "No such property"; } } if (firstName == contacts[i].firstName) { if (prop == "lastName" || prop == "number" || prop == "likes") { if (prop == "lastName") { return "Vos"; } else if (prop == "number") { return "unknown"; } else if (prop == "likes") { return ["Intriguing Cases", "Violin"]; } } else { return "No such property"; } } else { return "No such contact"; } } a
Stephen James
@sjames1958gm
Jun 21 2016 00:51
backticks on their own line
FM
@mafelix
Jun 21 2016 00:52
function test(){
   console.log('this is a test');
}
Osman Zakir
@DragonOsman
Jun 21 2016 00:52
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++)
  {
    if (firstName == contacts[i].firstName)
    {
      if (prop == "lastName" || prop == "number" || prop == "likes")
      {
        if (prop == "lastName")
        {
          return "Laine";
        }
        else if (prop == "number")
        {
          return "0543236543";
        }
        else if (prop == "likes")
        {
          return contacts[i][prop];
        }
      }
      else
      {
        return "No such property";
      }
    }
    else if (firstName == contacts[i].firstName)
    {
      if (prop == "lastName" || prop == "number" || prop == "likes")
      {
        if (prop == "lastName")
        {
          return "Potter";
        }
        else if (prop == "number")
        {
          return "0994372684";
        }
        else if (prop == "likes")
        {
          return contacts[i][prop];
        }
      }
      else
      {
        return "No such property";
      }
    }
    else if (firstName == contacts[i].firstName)
    {
      if (prop == "lastName" || prop == "number" || prop == "likes")
      {
        if (prop == "lastName")
        {
          return "Holmes";
        }
        else if (prop == "number")
        {
          return "0487345643";
        }
        else if (prop == "likes")
        {
          return contacts[i][prop];
        }
      }
      else
      {
        return "No such property";
      }
    }
    if (firstName == contacts[i].firstName)
    {
      if (prop == "lastName" || prop == "number" || prop == "likes")
      {
        if (prop == "lastName")
        {
          return "Vos";
        }
        else if (prop == "number")
        {
          return "unknown";
        }
        else if (prop == "likes")
        {
          return ["Intriguing Cases", "Violin"];
        }
      }
      else
      {
        return "No such property";
      }
    }
    else
    {
      return "No such contact";
    }
  }
```
FM
@mafelix
Jun 21 2016 00:52
so what are you having problems with?
that's a lot of if conditionals, you probably don't need that many to complete the exercise I think you are doing.
but tell me what makes you think your code is wrong?
Osman Zakir
@DragonOsman
Jun 21 2016 00:54
@mafelix: I've got all of the requirements still with a red cross on them except for the last two
meaning that only the last two check out
FM
@mafelix
Jun 21 2016 00:54
and what are the last two tests?
ok so you're passing only the last two
then let's work from there and try to past the tests one by one
whats a test that you don't pass?
Osman Zakir
@DragonOsman
Jun 21 2016 00:55
@mafelix: the first of the two is ""Bob", "number" should return "No such contact"" and the second is ""Akira", "address" should return "No such property""
and the ones I don't pass are the rest of them
Stephen James
@sjames1958gm
Jun 21 2016 00:56
@DragonOsman Your code should not have any of the values hardcoded from the contacts array. It should all be done only with variables.
FM
@mafelix
Jun 21 2016 00:56
so... give me a test that does not pass
and we'll modify your code to work for that test
and we'll do it for the next test and so on and so forth
Osman Zakir
@DragonOsman
Jun 21 2016 00:57
@mafelix: ""Kristian", "lastName" should return "Vos"
That's one
FM
@mafelix
Jun 21 2016 00:57
and stephen is right that your code is hardcoding values
paste the object
then we'll work through it
Osman Zakir
@DragonOsman
Jun 21 2016 00:57
how do I paste the object?
Finesse Rucker
@Finesse315
Jun 21 2016 00:57
function chainToSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {

  case "bob": 
    answer = "Marley";
      break;
    case 42: 
    answer = "The Answer";
      break;
    case 1: 
    answer = "There is no #1";
      break;
    case 99: 
    answer = "Missed me by this much!";
      break;
    case 7:
    answer = "Ate Nine";
      break;
    default:
      answer = "";

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

// Change this value to test
chainToSwitch(7);
Rickey Olsen
@rickeyolsen
Jun 21 2016 00:58
I'm learning escapes in javascript but am having an issue putting multiple ones together. Can anyone tell me what I'm doing wrong?var myStr= "Here is a backslash: \.\n\t\t
Here is a new line with two tabs."; // Change this line
FM
@mafelix
Jun 21 2016 00:58
what I am referring to is the javascript object you're looking through
Finesse Rucker
@Finesse315
Jun 21 2016 00:58
whats wrong with this
Osman Zakir
@DragonOsman
Jun 21 2016 00:58
@mafelix : how do I paste the object
FM
@mafelix
Jun 21 2016 00:58
same way you pasted your code
Osman Zakir
@DragonOsman
Jun 21 2016 00:58
?
Jonathan Mitchell
@Vanhealen
Jun 21 2016 00:58
is there a way to sort an array within a map function and retain the original order outside of the map function's scope because JS is functionaly scoped?
Stephen James
@sjames1958gm
Jun 21 2016 00:58
@Finesse315 looks like you are missing a }
@DragonOsman The only property name you should have in your code is firstName
Marcusisgreat
@Marcusisgreat
Jun 21 2016 00:59
I'm having trouble with the switch statements can someone tell me what I'm doing wrong
FM
@mafelix
Jun 21 2016 00:59
copy and paste the object you're iterating through
Marcusisgreat
@Marcusisgreat
Jun 21 2016 00:59
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
case '1':
console.log("alpha");
break;
case '2':
console.log( "beta");
break;
case '3':
console.log("gamma");
break;
case '4':
console.log("delta");
break;
}
// Only change code above this line
return answer;
}
Finesse Rucker
@Finesse315
Jun 21 2016 00:59
@sjames1958gm thx again
CamperBot
@camperbot
Jun 21 2016 00:59
finesse315 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: finesse315 already gave sjames1958gm points
Rickey Olsen
@rickeyolsen
Jun 21 2016 00:59
This is also my first q and havent figured out putting in code yet...
FM
@mafelix
Jun 21 2016 00:59
there's a M+ button in the chat bar
Ken Haduch
@khaduch
Jun 21 2016 01:00
@james-freitas - I apologize for my previous post about the escape sequences. I didn't know that they completely changed the code requirements, so there is extra stuff in there. My previously passing test also does not pass now...
FM
@mafelix
Jun 21 2016 01:00
click on that sh1t and look at the markdowns
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:01
Anyone got any ideas?
FM
@mafelix
Jun 21 2016 01:01
whats the name of the exercise
Osman Zakir
@DragonOsman
Jun 21 2016 01:01
@sjames1958gm: You mean the only property that should be hardcoded in there is that one? I'm not sure how to get to them by array index, though. And by pasting the object, do they mean this? { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] }
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:02
Selecting from many options with Switch Statements
FM
@mafelix
Jun 21 2016 01:02
@DragonOsman whats the name of the exercise?
Rickey Olsen
@rickeyolsen
Jun 21 2016 01:03
'''
var myStr= "Here is a backslash: \.\n\t\t
Here is a new line with two tabs."; // Change this line
'''
CamperBot
@camperbot
Jun 21 2016 01:03
:bulb: to format code use backticks! ``` more info
FM
@mafelix
Jun 21 2016 01:03
find object property
CamperBot
@camperbot
Jun 21 2016 01:03
find object property
nothing found
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:03
@khaduch - thanks for your help
CamperBot
@camperbot
Jun 21 2016 01:03
james-freitas sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1353 | @khaduch |http://www.freecodecamp.com/khaduch
here is the exercise
J.S. Toy
@toymechqm
Jun 21 2016 01:03
what is wrong with this ?
var myStr = "Here is a backslash: \\.\n\t\t Here is a new line with two tabs.";
find contact
CamperBot
@camperbot
Jun 21 2016 01:04
find contact
nothing found
FM
@mafelix
Jun 21 2016 01:04
find contact list
CamperBot
@camperbot
Jun 21 2016 01:04
find contact list
nothing found
Rickey Olsen
@rickeyolsen
Jun 21 2016 01:04
I also need help with this
var myStr= "Here is a backslash: \\.\n\t\t
        Here is a new line with two tabs."; // Change this line
J.S. Toy
@toymechqm
Jun 21 2016 01:04
@mafelix yes? My escaping seems proper, no?
FM
@mafelix
Jun 21 2016 01:04
alright let me know when you figure out the name of the exercise so I can look through the object you're looking through.
@toymechqm are you sure?
Ken Haduch
@khaduch
Jun 21 2016 01:04
@james-freitas - did you get it to pass? I think that the new string that you are supposed to encode, and the requirements, are really poorly set up!
Osman Zakir
@DragonOsman
Jun 21 2016 01:05
{
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
```
J.S. Toy
@toymechqm
Jun 21 2016 01:05
look at it, Im pretty sure im getting stuck on some silly spacing thing according to their tests
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:05
@khaduch - no, I am stuck yet
Osman Zakir
@DragonOsman
Jun 21 2016 01:05
@mafelix: It's Profile Lookup
Ken Haduch
@khaduch
Jun 21 2016 01:05
@toymechqm - I just had to fix mine to meet the new requirements - there should be no space bettween the \t and the Here is a new line
Rickey Olsen
@rickeyolsen
Jun 21 2016 01:05
@toymechqm Im thinking the same thing. I've been stuck on it for half an hour...
FM
@mafelix
Jun 21 2016 01:05
@toymechqm in your repl you linked what is the output?
Ken Haduch
@khaduch
Jun 21 2016 01:06
@james-freitas - I just got mine to work again - can you please re-post what you have now?
FM
@mafelix
Jun 21 2016 01:06
and is it the output the exercise is looking for?
J.S. Toy
@toymechqm
Jun 21 2016 01:06
@khaduch thanks, that was ridicuoulous
CamperBot
@camperbot
Jun 21 2016 01:06
toymechqm sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1354 | @khaduch |http://www.freecodecamp.com/khaduch
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:06
@khaduch - here it is: '''
CamperBot
@camperbot
Jun 21 2016 01:06
:bulb: to format code use backticks! ``` more info
FM
@mafelix
Jun 21 2016 01:06
Here is a backslash: \.
         Here is a new line with two tabs.
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:06
''' var myStr = "Here is a backslash: \. \n\r\t\tHere is a new line with two tabs.";
'''
CamperBot
@camperbot
Jun 21 2016 01:06
:bulb: to format code use backticks! ``` more info
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:07
thanks @camperbot
CamperBot
@camperbot
Jun 21 2016 01:07
james-freitas sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1918 | @camperbot |http://www.freecodecamp.com/camperbot
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:07
var myStr = "Here is a backslash: \\. \n\r\t\tHere is a new line with two tabs.";
Ken Haduch
@khaduch
Jun 21 2016 01:07
@mafelix you have an errant \r in there, I think that's the problem. Oh, and your backslash should be \\
Rickey Olsen
@rickeyolsen
Jun 21 2016 01:07
thanks @khaduch
CamperBot
@camperbot
Jun 21 2016 01:07
rickeyolsen sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1355 | @khaduch |http://www.freecodecamp.com/khaduch
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:08
Can anyone help me with selecting from many options with switch statements?
Ken Haduch
@khaduch
Jun 21 2016 01:08
@Marcusisgreat - sure, we could... please post your code...
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:09

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
case '1':
console.log("alpha");
break;
case '2':
console.log( "beta");
break;
case '3':
console.log("gamma");
break;
case '4':
console.log("delta");
break;
}
// Only change code above this line
return answer;
}

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

Side note, how do you post the code like @mafelix did a little bit up?
J.S. Toy
@toymechqm
Jun 21 2016 01:10
@Marcusisgreat
function caseInSwitch(val) {
var answer = val;
// Only change code below this line
switch (answer) {
case '1':
console.log("alpha");
break;
case '2':
console.log( "beta");
break;
case '3':
console.log("gamma");
break;
case '4':
console.log("delta");
break;
}
// Only change code above this line
return answer;
}
// Change this value to test
caseInSwitch("1");
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:10
@toymechqm Thank you
op1346
@op1346
Jun 21 2016 01:10
Can anyone help me with the Stand in Line challenge?
CamperBot
@camperbot
Jun 21 2016 01:10
marcusisgreat sends brownie points to @toymechqm :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @toymechqm |http://www.freecodecamp.com/toymechqm
J.S. Toy
@toymechqm
Jun 21 2016 01:10
1 !== "1" 1 is an integer whereas "1" is a string
FM
@mafelix
Jun 21 2016 01:10
@Marcusisgreat nest your code between 3 backticks "```"
James Daniel Correia de Freitas
@james-freitas
Jun 21 2016 01:11
@khaduch - I will try again tomorrow. Thanks for your help.
CamperBot
@camperbot
Jun 21 2016 01:11
james-freitas sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jonathan Mitchell
@Vanhealen
Jun 21 2016 01:11
function sortAndRetain(arr) {
  // var array = Array.from(arguments);
  var array = [1,2,3,76,6,5]
  return function sortSecret() {
    return array.sort(function(a,b) {
    return a - b;
    });
  }
  console.log(arr)  
}


var sortedd = sortAndRetain([1,2,7,6,3,4,5])
sortedd(array)
//Doesn't array get saved to the variable sortedd? in its closed over environment?
CamperBot
@camperbot
Jun 21 2016 01:11
:warning: james-freitas already gave khaduch points
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:11
@toymechqm Nice catch!
@mafelix Ok I will try that now
@mafelix Hmmm it still doesn't seem to be working
FM
@mafelix
Jun 21 2016 01:14
" var works=true"
type in three back ticks, hit cmd+enter for a new line and format
```
shift+enter*
aoiefjoaiewjfoiajewofiajweiofjawoe
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:15
``` var works
var works=true
Ahh ok, great at first I thought you meant in my code for my challenge
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:18
So I am doing Seek and Destroy in Basic Algorithmic Scripting, and it reads destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1], and destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1]. But when I write console.logstatements to figure out why my algorithm isn't working, I get that the filters for the first array are 2, 3, 5, and the second are 2, 3.
J.S. Toy
@toymechqm
Jun 21 2016 01:19
@kimberlythegeek lets see the code
FM
@mafelix
Jun 21 2016 01:19
@kimberlythegeek do you understand how arguments work in javascript?
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:19
@toymechqm could you check my code one more time from before? I got rid of the quotes but it still doesn't seem to work
J.S. Toy
@toymechqm
Jun 21 2016 01:20
@Marcusisgreat post it
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:21
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
     case 1:
      console.log("alpha");
      break;
     case 2:
      console.log( "beta");
      break;
     case 3:
      console.log("gamma");
      break;
     case 4:
      console.log("delta");
      break;
  }
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
J.S. Toy
@toymechqm
Jun 21 2016 01:21
look at your var declaration
Ian Arsenault
@ianarsenault
Jun 21 2016 01:21

Not sure if anyone can help me with Find the Longest Word in a String
I'm getting a few right, but it's got to be just by luck. My guess here is to sort the array by length of each string, but .sort() doesn't work at all.


function findLongestWord(str) {
  var foo = str.split(" ");

  for (var i = 0; i < foo.length; i++) {
    if (foo[i].length > foo[i + 1].length) {
        return foo[i].length;
    }
  } 
}

findLongestWord("The quick brown fox jumped over the lazy dog");

I'm getting 5 back

CamperBot
@camperbot
Jun 21 2016 01:21
find the longest word in a stringim getting a few right but its got to be just by luck my guess here is to sort the array by length of each string but sort doesnt work at allfunction findlongestwordstr var foo strsplit return foosort for var i 0 i foolength i if fooilength fooi 1length return fooilength findlongestwordthe quick brown fox jumped over the lazy dog
nothing found
J.S. Toy
@toymechqm
Jun 21 2016 01:21
@Marcusisgreat what is wrong with this line?:
  var answer = "";
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:22
@toymechqm It's blank but I thought it was part of the code I oculdn't change
J.S. Toy
@toymechqm
Jun 21 2016 01:22
or a better question: you have a function argument that str. How are you using str in your function?
@Marcusisgreat do you see what I am getting at ?
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:23
As a variable?
I think so, but I'm not sure what should be inside my switch statement
J.S. Toy
@toymechqm
Jun 21 2016 01:24

you have this line:

function caseInSwitch(val) {

however 'val' isn't being used in your function it just exists. so you should use it to change the switch case

your code is fine. you have just given answer an empty string though.
so what happens if you had this?

var answer = 3;

instead of this:

var answer = "";
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:26
Let me see what happens
Rémi Fortier
@mizujin
Jun 21 2016 01:26
@GorgonsMaze Your code is a good start, but in your loop, you're only comparing a word with the following one
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:26
hey guys, just starting my weather app and having problems getting the geolocation feature to work in code pen. Here's my code... any suggestions?
<!-- OpenWeather API Key: 41dc7e43be316a1e39f32a94b9008abe
-->
<p><button onclick="geoLocate()">Show my location</button></p>
<div id="coords"></div>

<script>
  function geoLocate() {
  var output = document.getElementById('coords')

  if (!navigator.geolocation) {
    output.innerHTML = '<p>Geolocation Feature Unavailable</p>';
    return;
  };

  function success(position) {
    var lat = position.coords.latitude;
    var long = position.coords.longitude;
    output.innerHTML = '<p>Latitude is ' + lat + '° <br>Longitude is ' + long + '°</p>';

  };

  function error() {
    output.innerHTML = '<p>Error...</p>';
  };

  output.innerHTML = "<p>Locating...</p>";

  navigator.geolocation.getCurrentPosition(success, error);
  }
</script>
ignore API key
Ian Arsenault
@ianarsenault
Jun 21 2016 01:26
@mizujin Yeah I'm looking at it and I know it's just comparing the first one with the second one, and stopping.
J.S. Toy
@toymechqm
Jun 21 2016 01:26
so you need ti figure this out:
var answer =  "how can I make this a dynamic VALue based on what the function argument is?" ;
Ian Arsenault
@ianarsenault
Jun 21 2016 01:27
I've been looking at bubble sort but thats confusing to me, not sure how to store the one with the greater length, and then compare to the next index in the array
Rémi Fortier
@mizujin
Jun 21 2016 01:27
@GorgonsMaze Say you have a variable length = 0, and you are assigning it with each word length, if it's bigger than it's current value, you might get something out of it
Marcusisgreat
@Marcusisgreat
Jun 21 2016 01:27
@toymechqm Ok I see what you are saying. If I still have trouble I'll come back to this
Ian Arsenault
@ianarsenault
Jun 21 2016 01:27
I'm sure there's an easier/simpler way to do this. I've just been trying to hack something together to figure it out
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:28
this keeps returning error, but the pen from MDN has virtually the same code (what I modeled it after) and there's works fine. Is there some sort of special permission to use geolocating in CodePen or something?
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:28
@mafelix yes
Ian Arsenault
@ianarsenault
Jun 21 2016 01:28
@mizujin Ok I think I get what you're saying.
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:28
@mafelix i'm actually on intermediate algorithmic scripting, but this is one that i skipped over and came back to
FM
@mafelix
Jun 21 2016 01:28
find seek and destroy
CamperBot
@camperbot
Jun 21 2016 01:28

find seek and destroy

:zero: algorithm seek and destroy

FM
@mafelix
Jun 21 2016 01:29
@kimberlythegeek so if you know how arguments work in js
@kimberlythegeek what do you think the problem is in your code? can you paste it agin?
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:29
I'm not sure you understand the problem I'm having...
J.S. Toy
@toymechqm
Jun 21 2016 01:29
@Marcusisgreat you get it?
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:29
What it's telling me should be the input is not the actual input
Rémi Fortier
@mizujin
Jun 21 2016 01:29
@GorgonsMaze Post your code if you need any other input
Carissa Thomas
@CarissaThomas
Jun 21 2016 01:30
hey guys im trying to create this complex data structure (Manipulating Complex Objects exercise), why cant I combine theses two objects? Youll see red Xs on lines 13/14
Screen Shot 2016-06-20 at 6.28.17 PM.png
J.S. Toy
@toymechqm
Jun 21 2016 01:30
comma?
FM
@mafelix
Jun 21 2016 01:30
@kimberlythegeek what do you mean by that?
@kimberlythegeek that's why I asked if you know how arguments worked in js
Carissa Thomas
@CarissaThomas
Jun 21 2016 01:31
@toymechqm Lol yup, THANK U
CamperBot
@camperbot
Jun 21 2016 01:31
carissailly sends brownie points to @toymechqm :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @toymechqm |http://www.freecodecamp.com/toymechqm
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:31
destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].
destroyer([2, 3, 2, 3], 2, 3) should return []
J.S. Toy
@toymechqm
Jun 21 2016 01:31
@carissailly haha yeah i hate that
FM
@mafelix
Jun 21 2016 01:31
so whats your output you're getting for your code?
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:32
but instead of 2, 3, 5 for the first, it's giving me 2,3, and instead of 2,3 for the second, it gives me 2,3,5
FM
@mafelix
Jun 21 2016 01:32
@kimberlythegeek are you accounting for the fact that you don't know how many arguments are going be passed?
@kimberlythegeek can you show your code?
Ken Haduch
@khaduch
Jun 21 2016 01:33
@GorgonsMaze - what you can do is to keep track of the length of the longest word in a separate variable, and test the length of each new word against the stored value for the longest one, which will be the longest one up to point where you've checked. If the new length is greater, store that, otherwise just move to the next word until complete.
@no-stack-dub-sack - if you are using http: to access the page, then the Chrome browser will no longer support the geolocation. And if you use https://, geolocation will work, but then the openweather site (free edition) will not work. People have been using http://ip-api.com/ for location info.
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:37
ahhh! I knew I wasn't crazy.
Ken Haduch
@khaduch
Jun 21 2016 01:37
@kimberlythegeek - please post the actual code that you've written, not the test results that are expected.
FM
@mafelix
Jun 21 2016 01:37
@kimberlythegeek here's what I think is wrong
@kimberlythegeek your first parameter is always going to be an array
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:38
I eventually just tried pasting the exact code from MDN's pen into mine and it didn't work, I knew something was up. When using https it works now. @khaduch
FM
@mafelix
Jun 21 2016 01:38
@kimberlythegeek then you will get an undetermined about of values to compare
Sam Nave
@shrapnel2012
Jun 21 2016 01:38
Hey guys. I had a question...having an issue with the javascript assignment: local scope and function. I have my local var variable but I can't seem to past the rest of the test. I attempted to mimic the test example and I have been googling for the last hour.
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:38
yes.
I know.
FM
@mafelix
Jun 21 2016 01:38
@kimberlythegeek you must code for the unknown amount of arguments
Kimberly Pennington
@kimberlythegeek
Jun 21 2016 01:38
I have.
FM
@mafelix
Jun 21 2016 01:38
@kimberlythegeek then the input should be correct?
Ken Haduch
@khaduch
Jun 21 2016 01:39
@no-stack-dub-sack - yes, it will work with https:// to get the geolocation, but you will not be able to access openweather. that will only work with http://
3jM310
@3jM310
Jun 21 2016 01:39
hey guys whats wrong with this code? var myStr = "Here is a backslash: \.\n\t\t Here is a new line with two tabs";
FM
@mafelix
Jun 21 2016 01:40
@kimberlythegeek if you still think the input is funny then it has to be something wrong with how you're handling the arguments. the input should be correct if you handled it correctly.
J.S. Toy
@toymechqm
Jun 21 2016 01:40
haha @3jM310 this one is dumb, we just were talking about it. they want a very specific string value here. there is not supposed to be a space between your last tab and "here".
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:40
@khaduch so in other words, I have to call the ip-api to get the lat and long instead of using the built in JS geolocation object? bummer...
Ken Haduch
@khaduch
Jun 21 2016 01:40
@3jM310 - I think that it is the space between the \t and the Here is a new line with two tabs - I think that this new test is rather confusing
FM
@mafelix
Jun 21 2016 01:41
@kimberlythegeek take a look at the code again that you use to handle the arguments. you're not pasting your code so I can't really do anything but guess from what you're telling me.
Ken Haduch
@khaduch
Jun 21 2016 01:41
@no-stack-dub-sack - yes, at least if you are using Chrome. Firefox still supports it, as far as I know. I've seen people suggest to try the geolocation and if it doesn't work (since you don't know which browser people will be using) fall back to ip-api.com
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:42
@khaduch ip-api.com seems like the safer and less complicated bet then. Should cover all browsers with less code.
Ken Haduch
@khaduch
Jun 21 2016 01:43
@no-stack-dub-sack - I think that it is less accurate (I'm guessing) but I would say that for the purposes of this exercise, it should be sufficient?
Frank
@Frankbono
Jun 21 2016 01:44
I am currently working on the "Record Collection" exercise in the JavaScript section. The instructions make absolutely no sense to me. I really don't know what is being asked of me. In the hints section, it tells me to refer back to a previous exercise, yet when I click the link, the exercise is completely gone from the curriculum. Can someone help me out here
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 01:44
@khaduch works for me. thanks for the clarification. I knew something was up but couldn't figure it out. Kudos.
CamperBot
@camperbot
Jun 21 2016 01:44
no-stack-dub-sack sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1356 | @khaduch |http://www.freecodecamp.com/khaduch
3jM310
@3jM310
Jun 21 2016 01:45
thanks @khaduch and @toymechqm but nothing i tried deleting the space and changing "H" for "h"
CamperBot
@camperbot
Jun 21 2016 01:45
3jm310 sends brownie points to @khaduch and @toymechqm :sparkles: :thumbsup: :sparkles:
:cookie: 260 | @toymechqm |http://www.freecodecamp.com/toymechqm
:star2: 1357 | @khaduch |http://www.freecodecamp.com/khaduch
J.S. Toy
@toymechqm
Jun 21 2016 01:46
@3jM310 lets see it again
your string value i mean
3jM310
@3jM310
Jun 21 2016 01:47
i got this know var myStr = "Here is a backslash: \.\n\t\there is a new line with two tabs";
@toymechqm
Chad H
@chadg1980
Jun 21 2016 01:47
I am having trouble with Javascript queue. I am getting 3/4 green checks. Can anyone help me with the queue function?
nexitInLine(arr, item)
Ken Haduch
@khaduch
Jun 21 2016 01:48
@3jM310 - there should be a period at the end of the sentence, and the "here" should be "Here"
@chadg1980 - sure, post your code...
J.S. Toy
@toymechqm
Jun 21 2016 01:49
@3jM310 console.log("Here is a backslash: \.\n\t\there is a new line with two tabs")
and that too
3jM310
@3jM310
Jun 21 2016 01:52
well i tried that code and nothing its missing this myStr should have encoded text with the proper escape sequences and spacing. and this one too myStr should not have any spaces in between consecutive escape sequences. @toymechqm
Chad H
@chadg1980
Jun 21 2016 01:52

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

arr.unshift(item);
return arr.pop(); // Change this line
}

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

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

Ken Haduch
@khaduch
Jun 21 2016 01:54
@3jM310 - can you post your code one more time? Please?
MyNameIsKayJay
@MyNameIsKayJay
Jun 21 2016 01:54
I think I'm having the same issue as @3jM310 . And my code: var myStr = "Here is a backslash:\.\n\t\t Here is a new line with two tabs.";
var myStr = "Here is a backslash:\.\n\t\t Here is a new line with two tabs.";
except it's missing a backslash
Ken Haduch
@khaduch
Jun 21 2016 01:55
@MyNameIsKayJay you should have \\ for the backslash, and I think a space between the backslash: and \\. And no space after the second \t
3jM310
@3jM310
Jun 21 2016 01:56
var myStr = "Here is a backslash: .\n\t\there is a new line with two tabs"; @khaduch
MyNameIsKayJay
@MyNameIsKayJay
Jun 21 2016 01:56
Thanks @khaduch that worked for me
CamperBot
@camperbot
Jun 21 2016 01:56
mynameiskayjay sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1358 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 21 2016 01:57
@MyNameIsKayJay - you're welcome... this new version of that lesson has not improved the situation - it is rather confusing!
Chad H
@chadg1980
Jun 21 2016 01:58
I got it, thanks for your help.
Ken Haduch
@khaduch
Jun 21 2016 02:02
@3jM310 - okay - it looks like you are missing the backslash escape character: \\, the here should be Here, and there should be a period after "two tabs" as in two tabs. The test is looking for very specific contents in the final string, so you have to match it exactly as they want it.
beidao
@MAXAmbitious
Jun 21 2016 02:02
hello world
CamperBot
@camperbot
Jun 21 2016 02:02

welcome to FreeCodeCamp @MAXAmbitious!

gamerilla
@gamerilla
Jun 21 2016 02:02

Hey guys I'm doing the Global vs Local Scope in Functions challenge. My code output is showing correctly yet it tells me it isn't correct. Could someone tell me if my code is wrong?
```// 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();

beidao
@MAXAmbitious
Jun 21 2016 02:03
I am searching for help to pass the chapter 212th
Ian Arsenault
@ianarsenault
Jun 21 2016 02:03
This message was deleted
3jM310
@3jM310
Jun 21 2016 02:03
now i tried like this var myStr = "Here is a backslash:\.\n \t\t Here is a new line with two tabs."; and nothing @khaduch
beidao
@MAXAmbitious
Jun 21 2016 02:03
Is there any lovely people to help me ?
perossing
@perossing
Jun 21 2016 02:04
@Frankbono I'm stuck on this one, too . The instructions specifically say to deal with id that does not contain the key "tracks, but it seems like what we really need to do is deal with any id that is missing any one of the keys. I started out by testing to see if the id has the property 'tracks', but from what I'm getting when I run tests, I think we need to check for any missing property and be able to assign values to that property. "Tracks" happens to be an array, so needs some extra attention. I'm calling it quits for the moment, but maybe that helps explain the directions? (or it might just show how confused I am).
Ken Haduch
@khaduch
Jun 21 2016 02:05
@3jM310 - your backslash should be written as \\, as the table shows. There should be a space after the backslash: and before the \\ and there should be no spaces between consecutive escape sequences, in other words: \n \t should be \n\t. There should be no space after the \t between it and the Here - in other words \t\tHere
bitgrower
@bitgrower
Jun 21 2016 02:09
@perossing - yes, you do -- although this is a change that was made in that challenge in the last few months (I am not sure exactly when) ... and I don't feel like the instructions (usually excellent) help you to program for that case ...
3jM310
@3jM310
Jun 21 2016 02:11
Finally thanks your are the best men @khaduch
CamperBot
@camperbot
Jun 21 2016 02:11
3jm310 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: 3jm310 already gave khaduch points
bitgrower
@bitgrower
Jun 21 2016 02:11
in any case, if you check for .hasOwnProperty for the property, and if not found, create it, in this case, with the value of [], because the value must be of type arrray ... then you will be on your way to solving this little gotcha in the problem ...
Ken Haduch
@khaduch
Jun 21 2016 02:11
@gamerilla - @gamerilla - it looks like your code is correct. Can you try to reload the browser and see if it works, or clear the temporary files if reloading doesn't work?
@3jM310 - I think that that new example for that lesson is really difficult, I wonder who changed it? I'll have to try and look that one up.
gamerilla
@gamerilla
Jun 21 2016 02:12
Thanks @khaduch , It's actually my mistake. I wrote "sweater" as "Sweater". I'm half asleep and didn't notice it wasn't a capitalized in the error.
CamperBot
@camperbot
Jun 21 2016 02:12
gamerilla sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1359 | @khaduch |http://www.freecodecamp.com/khaduch
linx97
@linx97
Jun 21 2016 02:13

Hi I'm trying to do the Mad Libs challenge and I don't really get it... this is what I have: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
"Once upon a time, a super " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + " at me.";

// Your code above this line
return result;
}

Ken Haduch
@khaduch
Jun 21 2016 02:13
@gamerilla - haha, I missed that, too, in my bouncing back and forth between windows... good work!
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 02:13
@khaduch any idea why this doesn't work?
<p><button id="geoLocate">Show my location</button></p>
<div id="out"></div>

<script>
  $(document).ready(function() {
  $("#geoLocate").on('click', function() {
    $.getJSON('http://ip-api.com/json', function(json) {
      $("#out").html(JSON.stringify(json.value.lat))
    });
  });
})
</script>
Ken Haduch
@khaduch
Jun 21 2016 02:14
@no-stack-dub-sack - I don't think there is a value property in the json string? Try json.lat
Stephen James
@sjames1958gm
Jun 21 2016 02:15
@linx97 You are not setting your constructed string to the result variable.
Peter Weinberg
@no-stack-dub-sack
Jun 21 2016 02:16
@khaduch yup. that's it. I was basing that off a previous example, thought that applied to all JSON but must've been only for that API, makes sense now
Robert
@Brayn7
Jun 21 2016 02:16
can anyone help me figure out how to make this js cleaner. I have two getJson calls that are really similar and dont want to repeat myself so... basically i want to make a function and call it later inside this autocomplete function i have. here take a look someone please. http://codepen.io/Brayn/pen/VaJBog?editors=0010
message me for more info if needed
Ian Arsenault
@ianarsenault
Jun 21 2016 02:17
Still stuck on how to have it go past the first two words.

function findLongestWord(str) {
  // split string into array of strings
  var foo = str.split(" ");
  // Loop through the array 
  for (var i = 0; i < foo.length; i++) {
    var a = 0;
    a = foo[i].length;
    if (a > foo[i+1].length) {
      a = a;
    } else {
      a = foo[i+1].length;
    }

    //return a;
  } 
}

findLongestWord("The quick brown fox jumped over the lazy dog");
linx97
@linx97
Jun 21 2016 02:17
shouldn't it be var result = ""; and then my code would go in the quotations? but it tells me that my code should go below that line..
Stephen James
@sjames1958gm
Jun 21 2016 02:17
@linx97 You can then result = "your string";
Ken Haduch
@khaduch
Jun 21 2016 02:18
@linx97 result = "Once upon a time, a super " + myAdjective + etc.
Stephen James
@sjames1958gm
Jun 21 2016 02:20
@GorgonsMaze you will reset a to zero on each loop move var a = 0 before your loop, then you can compare foo[i].length to a
then you won't have foo[i+1] which will run past the end of the array. Return a after your loop.
Ken Haduch
@khaduch
Jun 21 2016 02:20

@GorgonsMaze - keep a separate variable, something like var longest = 0; at the beginning of your function. As you check the length of each word, as in

if ( foo[i].length > longest) longest = foo[i].length;

That way you are comparing each word's length to the longest one that you have seen up to this point.

Ian Arsenault
@ianarsenault
Jun 21 2016 02:22
@sjames1958gm do I not assign a = foo[i].length ? Once I take it outside the loop I get TypeError: undefined is not an object (evaluating 'foo[i+1].length')
Stephen James
@sjames1958gm
Jun 21 2016 02:24
@GorgonsMaze If you start a = 0 then you can do what @khaduch said above if (foo[i].length > a) a = foo[i].length
the problem with foo[i+1] is your i goes to foo.length - 1 and foo[foo.length - 1 + 1] is past the end of foo.
bitgrower
@bitgrower
Jun 21 2016 02:25
@GorgonsMaze the way your loop is written as well, it -will evaluate to look at something past the end of the array ... when i = foo.length -1 (the last value in your loop) a looks at foo[length].length which is undefined...
beat me to it, @sjames1958gm
Stephen James
@sjames1958gm
Jun 21 2016 02:26
@bitgrower :)
Ian Arsenault
@ianarsenault
Jun 21 2016 02:27
@sjames1958gm @bitgrower Ok that makes sense
MrBurks
@mrburks
Jun 21 2016 02:27

var myTotal = 0;

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

myTotal += myArr[i];

}

there's gotta be a typo somewhere...

Stephen James
@sjames1958gm
Jun 21 2016 02:28
@GorgonsMaze generally best to only operate on the current value [i] in a for loop
@mrburks Is this a challenge
MrBurks
@mrburks
Jun 21 2016 02:29
how exactly do you mean? @sjames1958gm
Stephen James
@sjames1958gm
Jun 21 2016 02:29
@mrburks Which challenge is this -
MrBurks
@mrburks
Jun 21 2016 02:30
@sjames1958gm Iterate Through an Array with a For Loop
Stephen James
@sjames1958gm
Jun 21 2016 02:30
@mrburks Declare and initialize a variable total to 0.
@mrburks The challenge is looking for total not myTotal
MrBurks
@mrburks
Jun 21 2016 02:31
yes i know what its looking for just not clear how to get there
Stephen James
@sjames1958gm
Jun 21 2016 02:31
@mrburks I mean you need to use the variable name total not myTotal
MrBurks
@mrburks
Jun 21 2016 02:32
it still doesn't add the values of the array
Stephen James
@sjames1958gm
Jun 21 2016 02:32
var total = 0;
for(var i = 0; i < myArr.length; i++){
   total += myArr[i];
}
MrBurks
@mrburks
Jun 21 2016 02:32
oh lol
forgot to edit the 2nd one
Stephen James
@sjames1958gm
Jun 21 2016 02:33
@mrburks facepalm?
MrBurks
@mrburks
Jun 21 2016 02:34
got it...wierd I did "total" first. Oh well. I got it now. thanks @sjames1958gm Yes, I facepalm myself too.
CamperBot
@camperbot
Jun 21 2016 02:34
mrburks sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1609 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 21 2016 02:35
@mrburks I don't know if you did this, but if you are debugging your code, only make one change at a time and retest, Because if you make two, one of them might be correct, but the other my break the code in a different way, but you might not know that.
Chris Cuevo
@ccuevo
Jun 21 2016 02:40
hi all! i'm having issues with the first part of the "Record Collection" challenge:

If prop does not contain the key "tracks", then update or set the value for that incomplete prop.

If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.

my code so far looks like this
function updateRecords(id, prop, value) {
  if (prop !== "tracks") {
    collection[id][prop] = value;
  } else if (prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  } else if (value === "") {
    delete collection[id][prop];
  }
Stephen James
@sjames1958gm
Jun 21 2016 02:41
@ccuevo Inside your second else if you will need to check if the property tracks exists in collection[id] (recall hasOwnProperty)
@ccuevo I think your third sentence above the code should be if prop does contain the key "tracks" . . .
Rodney Guillen
@infrony
Jun 21 2016 02:43
hello help please
Stephen James
@sjames1958gm
Jun 21 2016 02:43
@infrony What up?
Rodney Guillen
@infrony
Jun 21 2016 02:43
with nextInLine(arr, item)
Kevin Schwert
@kevinpschwert
Jun 21 2016 02:43

I'm having trouble with the Profile Lookup. I am able to get the first three conditions met if I just leave the first if statement in but when I add the else if statement it doesn't count the first three but it counts the fourth one and I am not understanding why. Here is my code://Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

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

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

Rodney Guillen
@infrony
Jun 21 2016 02:43
when return values
Drew Stonebraker
@drstonebraker
Jun 21 2016 02:44
is there a room I can go to get help with a git problem?
Stephen James
@sjames1958gm
Jun 21 2016 02:44
@kevinpschwert If you were going through a stack of business cards looking for Bob's email and the first card was Carol's would you quit saying "no such contact" that is what your code is doing.
@Stoney229 back end I think is good for that kind of question
Drew Stonebraker
@drstonebraker
Jun 21 2016 02:45
@sjames1958gm ty
CamperBot
@camperbot
Jun 21 2016 02:45
stoney229 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1610 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 21 2016 02:46
@infrony What code do you have so far?
help format
CamperBot
@camperbot
Jun 21 2016 02:46

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Chris Cuevo
@ccuevo
Jun 21 2016 02:46
thanks @sjames1958gm !
CamperBot
@camperbot
Jun 21 2016 02:46
ccuevo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1611 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 21 2016 02:47
@ccuevo :+1: FYI, you are going to have trouble with the value === "" tests when the property is not tracks.
Rodney Guillen
@infrony
Jun 21 2016 02:48
This message was deleted
Kevin Schwert
@kevinpschwert
Jun 21 2016 02:49
@sjames1958gm But my first condition is if the name and property are met it should return that. If I delete the other if else and the else statement it works but once I add those in there it doesn't and that's what I am confused about
Ian Arsenault
@ianarsenault
Jun 21 2016 02:49

Any pointers as to how I keep looping through it until the end? For some reason it goes through once, and stops.

function findLongestWord(str) {
  var foo = str.split(" "); //foo length = 9
  var longest = 0;

  // Loop through the array 
  for (var i = 0; i < foo.length; i++) {
    if (foo[i].length > longest) {
       longest = foo[i].length;
    } 
    return longest;
  }
}

findLongestWord("The quick brown fox jumped over the lazy dog");

This returns 3

Rodney Guillen
@infrony
Jun 21 2016 02:49
function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
kencalf
@kencalf
Jun 21 2016 02:50
There is a setTimeOut function I believe
look online for how to recall a function
Ian Arsenault
@ianarsenault
Jun 21 2016 02:50
Ok Thanks @kencalf
CamperBot
@camperbot
Jun 21 2016 02:50
gorgonsmaze sends brownie points to @kencalf :sparkles: :thumbsup: :sparkles:
:cookie: 4 | @kencalf |http://www.freecodecamp.com/kencalf
Dylan
@dhcodes
Jun 21 2016 02:51
@infrony you need to use .shift() and .push() methods
you add the item to the arr
and then shift off the first item and return it
Lynne Dixon
@LynneDixon
Jun 21 2016 02:51
Struggling with Javascript #147 "Escape Sequences in Strings. Keeps telling me "myStr should have encoded text with the proper escape sequences and spacing" and "myStr should not have any spaces in between consecutive escape sequences." Here's my code: var myStr = "Here is a backslash: \. \n\t\t Here is a new line with two tabs"; // Change this line
Rodney Guillen
@infrony
Jun 21 2016 02:52
you have a example, please
in thi camp not have one
Ian Arsenault
@ianarsenault
Jun 21 2016 02:52
@kencalf Can you explain how my for loop doesn't run though? Not sure why I need to recall the function if the for loop itself is supposed to run 9 times
Stephen James
@sjames1958gm
Jun 21 2016 02:54
@kevinpschwert You cannot return no such contact until after checking all contacts. You will also need to make sure that the firstName matches when testing for no such property.
@GorgonsMaze If you have return in your loop it will only execute loop once and return. You can have code after the loop still inside the function
kencalf
@kencalf
Jun 21 2016 02:55
@GorgonsMaze although I'm not familiar with the for loop, I understand what your trying to do, and I would do it a different way I think.
Ian Arsenault
@ianarsenault
Jun 21 2016 02:55
Ah ok yeah. @sjames1958gm thanks
CamperBot
@camperbot
Jun 21 2016 02:55
gorgonsmaze sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1612 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
kencalf
@kencalf
Jun 21 2016 02:55
@GorgonsMaze what happens when you run that anyway
your just trying to filter out the longest word right
Ian Arsenault
@ianarsenault
Jun 21 2016 02:55
@kencalf It only runs once, It returns 3
yeah I need the length longest word out of the array. but I think @sjames1958gm game me my mistake
kencalf
@kencalf
Jun 21 2016 02:56
Ok @GorgonsMaze so the function works, it's just only being Called Once
correct?
I think I may be able to dig up code I wrote that calls a function repeatedly
Ian Arsenault
@ianarsenault
Jun 21 2016 02:58
No worries @kencalf I figured it out. Thank you guys @sjames1958gm @bitgrower @khaduch
CamperBot
@camperbot
Jun 21 2016 02:59
gorgonsmaze sends brownie points to @kencalf and @sjames1958gm and @bitgrower and @khaduch :sparkles: :thumbsup: :sparkles:
:warning: gorgonsmaze already gave sjames1958gm points
:warning: gorgonsmaze already gave kencalf points
:star2: 1360 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 1108 | @bitgrower |http://www.freecodecamp.com/bitgrower
Dylan
@dhcodes
Jun 21 2016 02:59
@LynneDixon that's weird. i can't get it either
kencalf
@kencalf
Jun 21 2016 02:59
Anybody wanna see code for a game I made in JS? Might give you ideas for future projects
Ian Arsenault
@ianarsenault
Jun 21 2016 03:00
Sure
Kevin Schwert
@kevinpschwert
Jun 21 2016 03:01
@sjames1958gm I got this to work. Is there a more efficient and better way that you think to write it though?function lookUpProfile(firstName, prop){
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";
}
}
}
return "No such contact";
}
96street
@96street
Jun 21 2016 03:01
i just signed up to an account on http://openweathermap.org/api , how do I get the API now?
David Halls
@DavidHalls
Jun 21 2016 03:02
@96street go to keys or something like that
Dylan
@dhcodes
Jun 21 2016 03:02
@96street they will give you a key
you then put your key in the api address
96street
@96street
Jun 21 2016 03:02
what do I do with the key?
ok
read that
Dylan
@dhcodes
Jun 21 2016 03:03
@96street i think it goes at the end, but read the link i sent
96street
@96street
Jun 21 2016 03:03
ah k
NagarajuGunda
@NagarajuGunda
Jun 21 2016 03:03
Hi Guys, i am getting ReferenceError: stringify is not defined in one of the javvascript challenges
David Halls
@DavidHalls
Jun 21 2016 03:04
@NagarajuGunda try resetting it
Lynne Dixon
@LynneDixon
Jun 21 2016 03:05
Struggling with Javascript #147 "Escape Sequences in Strings. Keeps telling me "myStr should have encoded text with the proper escape sequences and spacing" and "myStr should not have any spaces in between consecutive escape sequences." Here's my code: var myStr = "Here is a backslash: \. \n\t\t Here is a new line with two tabs";
NagarajuGunda
@NagarajuGunda
Jun 21 2016 03:05
still same David
why there is backslash before . @LynneDixon
David Halls
@DavidHalls
Jun 21 2016 03:06
@NagarajuGunda post your code
NagarajuGunda
@NagarajuGunda
Jun 21 2016 03:06

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

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

return collection;
}

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

Greg Duncan
@GregatGit
Jun 21 2016 03:07
@96street var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&appid=" + yourAppid;
96street
@96street
Jun 21 2016 03:07
sweet
Dylan
@dhcodes
Jun 21 2016 03:08
@LynneDixon you do need two backslashes "Here is a backslash \. ...
NagarajuGunda
@NagarajuGunda
Jun 21 2016 03:08
yeah @LynneDixon
96street
@96street
Jun 21 2016 03:08
where did you get this link from: http://api.openweathermap.org/data/2.5/weather?lat= @GregatGit
Dylan
@dhcodes
Jun 21 2016 03:09
@96street it's in the documentation
click API at the top and then choose what type of weather you want to get
ex. current
and you'll see "API doc"
96street
@96street
Jun 21 2016 03:10
got it
NagarajuGunda
@NagarajuGunda
Jun 21 2016 03:10
anyone pls help about stringify error
David Halls
@DavidHalls
Jun 21 2016 03:11
@NagarajuGunda change this var collectionCopy = JSON.parse(stringify(collection)); to this var collectionCopy = JSON.parse(JSON.stringify(collection));
Norvin Burrus
@ndburrus
Jun 21 2016 03:11
This message was deleted
CamperBot
@camperbot
Jun 21 2016 03:11
no wiki entry for: format @lynnedixon
Norvin Burrus
@ndburrus
Jun 21 2016 03:11
help format @LynneDixon
CamperBot
@camperbot
Jun 21 2016 03:11

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

NagarajuGunda
@NagarajuGunda
Jun 21 2016 03:12
now error gone, thanks @Byzgig
CamperBot
@camperbot
Jun 21 2016 03:12
:cookie: 345 | @byzgig |http://www.freecodecamp.com/byzgig
nagarajugunda sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
Garrett
@grrttmrtn
Jun 21 2016 03:12
Anyone know what's wrong with slasher flick?
```
function slasher(arr, howMany) {
  // it doesn't always pay to be first
  var remove = howMany - 1;
  var end = arr.length +1;
for (var i =0; i <= howMany; i++)  {
  arr = arr.slice(i);
  }  return arr;
}


slasher([1, 2, 3], 2);
Norvin Burrus
@ndburrus
Jun 21 2016 03:13
@LynneDixon carefully map the words given to the code equivalent characters in the chart/table. also, pay attention to the spacing and punctuation.... :sparkles:
David Halls
@DavidHalls
Jun 21 2016 03:13
@grrttmrtn why howmany - 1??
Garrett
@grrttmrtn
Jun 21 2016 03:13
ahh I was messing around before
It's not being ussed
used*
Only using the for loop at the moment
Jonathan Carroll
@gkcodeman
Jun 21 2016 03:14

Would someone mind taking a look at my code and telling me why these portions of the code aren't pulling in the data..

elText.textContent = firstGirl.name; <-- it will pull in the data if I use this.name but i have more than one object there and all the objects pull in the same data if I use this.name for example.

page is here http://codepen.io/jonathanlcarroll/pen/vKXbWX?editors=1010

I'm working on constructor functions for the first time today and I thought I had it but kinda stumped as to why it's not pulling in data when their are multiple objects
Rashad
@RashadGHub
Jun 21 2016 03:16

JavaScript code for this Assign the value 7 to variable a.

Assign the contents of a to variable b.

?
Stefan Bekirov
@bekir0v
Jun 21 2016 03:16
hey I would like to ask what is wrong in this code :
var myStr = "I am a ,\"double quoted\"string inside,\"double quotes\","; // Change this line
it's about Escaping Literal Quotes in Strings
Dylan
@dhcodes
Jun 21 2016 03:18
@bekir0v i don't think you need the commas?
@gkcodeman do you mean you want to write one function that pulls in the info for each?
Jonathan Carroll
@gkcodeman
Jun 21 2016 03:18
yes I have written one constructor function on that code pen
and yes you are correct I want to pass in different arguments and be able to pull back out and .textContent that data into my html id's
Dylan
@dhcodes
Jun 21 2016 03:21
@gkcodeman well one reason is because you need to add new to your object
i think
var = new Dating(params)
otherwise it's undefined
Jonathan Carroll
@gkcodeman
Jun 21 2016 03:21
ugh
@dhcodes you are so right
dangit
Dylan
@dhcodes
Jun 21 2016 03:21
np, it took me a second to figure it out too
Jonathan Carroll
@gkcodeman
Jun 21 2016 03:22
@dhcodes totally fixed it all
@dhcodes thanks man
CamperBot
@camperbot
Jun 21 2016 03:22
gkcodeman sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1080 | @dhcodes |http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Jun 21 2016 03:23
np. Happy coding
Stefan Bekirov
@bekir0v
Jun 21 2016 03:23
@dhcodes I did this one var myStr = "I am a \"double quoted\"string inside\"double quotes\"." and it still wrong
Dylan
@dhcodes
Jun 21 2016 03:23
@bekir0v think about what the sentence is trying to say
you need to escape the first and last quotes i believe
@bekir0v nvm
i'm looking at teh challenge now
Stefan Bekirov
@bekir0v
Jun 21 2016 03:26
Everythig is right by the console
Dylan
@dhcodes
Jun 21 2016 03:26
@bekir0v looks like you are missing a space before string and after inside
Stefan Bekirov
@bekir0v
Jun 21 2016 03:26
I don't get id
Jonathan Carroll
@gkcodeman
Jun 21 2016 03:27
@dhcodes while i got you here..I was noticing how I had to write a ton of elText var's in that codepen to get access to all of the html <li>'s for all that data. Is there a more DRY way to go about doing that?
Dylan
@dhcodes
Jun 21 2016 03:27
i just passed it with var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
Stefan Bekirov
@bekir0v
Jun 21 2016 03:27
yyes
you right
the space is problem
i did it
thank you sir
Dylan
@dhcodes
Jun 21 2016 03:28
@gkcodeman you could make them a class instead of ids
and then use document.getElementsByClassName('class')
to get an array
then loop through it and assign this to the divs
this.name
for each
i supposed
suppose
idk that's a good question
Jonathan Carroll
@gkcodeman
Jun 21 2016 03:29
copy'ing and pasting that to mull over when I get a chance. I think you may be onto something there :)
preciate it bro. taking a mental break now!
Dylan
@dhcodes
Jun 21 2016 03:30
or a forEach might work
yes, i need sleep
good luck
m0sagal
@m0sagal
Jun 21 2016 03:30
Good Morning
Rodney Guillen
@infrony
Jun 21 2016 03:31
@dhcodes thanks!
CamperBot
@camperbot
Jun 21 2016 03:31
infrony sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1081 | @dhcodes |http://www.freecodecamp.com/dhcodes
darsparx
@darsparx
Jun 21 2016 03:34
@m0sagal good evening
trần nguyễn minh anh
@Anntran2222
Jun 21 2016 03:36
can someone help me with the stand in line challenge please I cannot get it
David Halls
@DavidHalls
Jun 21 2016 03:36
@Anntran2222 will do
Arjun
@arjunsingh81989
Jun 21 2016 03:37
Does anyone know what is the "Brackets" equivalent command for: git config --global core.editor “subs -n -w" <-- This command is for Sublime but I want an equivalent command for Brackets. Basically configuring Git to open Brackets in a new window and waiting until the file is closed before continuing.
Norvin Burrus
@ndburrus
Jun 21 2016 03:38
@bekir0v it looks like commas are an issue... :sparkles:
trần nguyễn minh anh
@Anntran2222
Jun 21 2016 03:39

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

return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@Byzgig it said i need to Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Stefan Bekirov
@bekir0v
Jun 21 2016 03:39
i did it sir
@ndburrus thank you
CamperBot
@camperbot
Jun 21 2016 03:39
bekir0v sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 663 | @ndburrus |http://www.freecodecamp.com/ndburrus
m0sagal
@m0sagal
Jun 21 2016 03:39
i'm stuck at Escape Sequences in Strings challenge
Jmyers6093
@Jmyers6093
Jun 21 2016 03:39
hello
David Halls
@DavidHalls
Jun 21 2016 03:39
@Anntran2222 sweet, how do you add something to an array?
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:40
@m0sagal ME TOO!
Jmyers6093
@Jmyers6093
Jun 21 2016 03:40
Wow
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:40
for 40 min now
Jmyers6093
@Jmyers6093
Jun 21 2016 03:40
Watch the video i posted
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:40
@Jmyers6093 begone troll
CamperBot
@camperbot
Jun 21 2016 03:40
:trollface: troll problems? notify admins here
m0sagal
@m0sagal
Jun 21 2016 03:40
:D
Jmyers6093
@Jmyers6093
Jun 21 2016 03:40
My profile pic will soon be hitler
trần nguyễn minh anh
@Anntran2222
Jun 21 2016 03:41
use push? @Byzgig
David Halls
@DavidHalls
Jun 21 2016 03:41
good
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:41
@Jmyers6093 Bro, you're not funny by any means. People are actually here to learn and here you are fucking off and making the process longer.
David Halls
@DavidHalls
Jun 21 2016 03:41
@Anntran2222 now how do you remove the first element in an array
trần nguyễn minh anh
@Anntran2222
Jun 21 2016 03:41
shift?
m0sagal
@m0sagal
Jun 21 2016 03:41
@tlloyd1990 i can't solve the first and last one
Norvin Burrus
@ndburrus
Jun 21 2016 03:41
@Anntran2222 this may be useful Javascript Array Methods: Unshift(), Shift(), Push(), And Pop() :sparkles:
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:42
@m0sagal looks like we are in the same boat
Norvin Burrus
@ndburrus
Jun 21 2016 03:42
@bekir0v excellent! nice work :sparkles:
m0sagal
@m0sagal
Jun 21 2016 03:42
LOL
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:42
@m0sagal this is what I have var myStr = "Here is a backslash: \.\n\t\t \"Here is a new line with two tabs\".";
m0sagal
@m0sagal
Jun 21 2016 03:43
This message was deleted
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:43
note: one there is a backslash next to the first that is not showing up
m0sagal
@m0sagal
Jun 21 2016 03:44
This message was deleted
David Halls
@DavidHalls
Jun 21 2016 03:44
@Anntran2222 nailed it, you use those two functions to complete that challenge
m0sagal
@m0sagal
Jun 21 2016 03:44
var myStr = "\tab\tab\newline \.\. \backslash";
@tlloyd1990 check that out var myStr = "Here is a backslash: \.\n\t\tHere is a new line with two tabs.";
rphares
@rphares
Jun 21 2016 03:50
@tlloyd1990 , @m0sagal , you dont need any text in that,
just literally write each of those using that chart,
for example, the first part was backslash,
William Cabell
@wbac88
Jun 21 2016 03:51
Hi guys, I'm working on the Profile lookup challenge, and I'm having trouble figuring out how to get started writing a "for" loop that would compare first names entered into a function to the first names that are in the array.
rphares
@rphares
Jun 21 2016 03:51
so the start should be var myStr = "\\ @m0sagal , @tlloyd1990
no text, just the code versions of those special characters, in order, with a space between each one.
Norvin Burrus
@ndburrus
Jun 21 2016 03:51
@bekir0v type help format
help format @bekir0v
CamperBot
@camperbot
Jun 21 2016 03:52

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:52
@rphares thanks!
CamperBot
@camperbot
Jun 21 2016 03:52
tlloyd1990 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 5232 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
Jun 21 2016 03:52
sure thing! Happy coding!
Matt
@TheeMattOliver
Jun 21 2016 03:52
@wbac88 any code to share so far?
Thomas Lloyd
@tlloyd1990
Jun 21 2016 03:52
@m0sagal Thanks for your help too!
CamperBot
@camperbot
Jun 21 2016 03:52
tlloyd1990 sends brownie points to @m0sagal :sparkles: :thumbsup: :sparkles:
:cookie: 159 | @m0sagal |http://www.freecodecamp.com/m0sagal
William Cabell
@wbac88
Jun 21 2016 03:52
@tlloyd1990 You know, I can't even think through the logic of it to get started.
Matt
@TheeMattOliver
Jun 21 2016 03:53
@wbac88 ok cool. so what you're trying to do is loop through the entire object.
so the first thing you gotta do in a for loop
is set up the variable you're gonna be calling "index"
Ken Haduch
@khaduch
Jun 21 2016 03:53
@LynneDixon - did you get that "Escape Sequences" problem figured out?
Matt
@TheeMattOliver
Jun 21 2016 03:53
most people use the letter "i" for that
so that's the first part of the for loop
Stefan Bekirov
@bekir0v
Jun 21 2016 03:53
@ndburrus
Matt
@TheeMattOliver
Jun 21 2016 03:54
for (var i = 0;.....
Norvin Burrus
@ndburrus
Jun 21 2016 03:54
@bekir0v yes?
Matt
@TheeMattOliver
Jun 21 2016 03:54
(ignore the dot dot dot)
William Cabell
@wbac88
Jun 21 2016 03:54
@TheeMattOliver That makes sense, I'm having trouble with the next part , where I need to compare the strings.
Stefan Bekirov
@bekir0v
Jun 21 2016 03:54
@ndburrus what do you mean help format
Matt
@TheeMattOliver
Jun 21 2016 03:54
gotcha
William Cabell
@wbac88
Jun 21 2016 03:55
@TheeMattOliver So, I get comparing numbers, it's how to do it with strings, without typing out each one individually.
Norvin Burrus
@ndburrus
Jun 21 2016 03:55
help format whenyou need assistance, you can type "help (subject)", and campervbot will assist, if possible...
Stefan Bekirov
@bekir0v
Jun 21 2016 03:55
@ndburrus I would like to show my code like matt did it now
CamperBot
@camperbot
Jun 21 2016 03:55

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

William Cabell
@wbac88
Jun 21 2016 03:55
I feel like I'm missing a key piece of information to get started!
Matt
@TheeMattOliver
Jun 21 2016 03:55
hm
I see what you mean
remember
Ken Haduch
@khaduch
Jun 21 2016 03:55
@LynneDixon :point_up: June 20, 2016 11:05 PM - that was the last entry I found with your code, and you posted var myStr = "Here is a backslash: \\. \n\t\t Here is a new line with two tabs";
Since I am signing off, you want to remove the spaces between all of the escape characters, and after the final \t. And the sentence should end with a period. I hope that helps, if you still need help.
Matt
@TheeMattOliver
Jun 21 2016 03:55
you're talking about an object here
so you are going to need to access the "key" first
Norvin Burrus
@ndburrus
Jun 21 2016 03:56
@bekir0v see the Code information?
Matt
@TheeMattOliver
Jun 21 2016 03:56
e.g. the index
William Cabell
@wbac88
Jun 21 2016 03:56
I need to compare i to a string to check it, right?
or some character of that string?
David Halls
@DavidHalls
Jun 21 2016 03:57
@wbac88 first do this: The function should check if firstName is an actual contact's firstName then do this: the given property (prop) is a property of that contact. then do this: If both are true, then return the "value" of that property.
William Cabell
@wbac88
Jun 21 2016 03:58
@Byzgig Yes, it's that first thing that I'm trying to figure out.
Stefan Bekirov
@bekir0v
Jun 21 2016 03:58
@ndburrus where can I find code information
David Halls
@DavidHalls
Jun 21 2016 04:00
@wbac88 you good with for loops
Matt
@TheeMattOliver
Jun 21 2016 04:00
so the firstName needs to be compared to the index in the Contacts object; if they are equal you keep moving through the logic like @byzgig points out and say, ok, i know that evaluates to true, so now I can check if the object has the property prop
William Cabell
@wbac88
Jun 21 2016 04:00
I always think I'm ok with whatever the subject is until I get to these challenges, then I realize I don't know anything! @Byzgig
Matt
@TheeMattOliver
Jun 21 2016 04:01
I will be the first to admit that this one wasn't easy for me at all
David Halls
@DavidHalls
Jun 21 2016 04:01
@wbac88 k buddy, you need a for loop to start this off, write that out
William Cabell
@wbac88
Jun 21 2016 04:01
OK, so this is what I started with just to type something out: for (var i = 0; i < contacts.firstName; i++)
Matt
@TheeMattOliver
Jun 21 2016 04:02
@bekir0v you have to type three hashes like this: ```
then you type Shift + enter, and type another three ```
William Cabell
@wbac88
Jun 21 2016 04:02
I assume it's the middle section that makes no sesne.
Matt
@TheeMattOliver
Jun 21 2016 04:02
put your code in between the two
@wbac88 that's a great start!
David Halls
@DavidHalls
Jun 21 2016 04:03
@wbac88 change contacts.firstName to something that would be representative of the length of contacts
Matt
@TheeMattOliver
Jun 21 2016 04:03
you initialize the index to 0, bc you're starting at the 0th index
i < contacts.length is how I would set it up, because you're looping to the end of the object
and i++ works bc you're going one by one
DavidR
@davidrinconv
Jun 21 2016 04:04
Finally I finished my weather app... let me know what you think :)
William Cabell
@wbac88
Jun 21 2016 04:04
OK, so contact.length is talking about the number of characters within the string right?
Matt
@TheeMattOliver
Jun 21 2016 04:05
@wbac88 not quite.
you should use contacts.length (note the 's')
William Cabell
@wbac88
Jun 21 2016 04:06
@TheeMattOliver So then what is the contacts.length accessing?
Matt
@TheeMattOliver
Jun 21 2016 04:06
because we are looping through the object itself
MrBurks
@mrburks
Jun 21 2016 04:06
Not getting it. because I don't understand what I'm supposed to do.

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

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

Matt
@TheeMattOliver
Jun 21 2016 04:06
var contacts = { / key: value /}
by looping through contacts.length we can access things inside of the object called contacts
m0sagal
@m0sagal
Jun 21 2016 04:07
@davidrinconv Congratulations
William Cabell
@wbac88
Jun 21 2016 04:07
@TheeMattOliver Ahhh, ok, I never totally understood that!
colin aulds
@auldsyababua
Jun 21 2016 04:09
I have a question about the .hasOwnProperty method
i have this function:
function checkObj(checkProp) {
  myObj.hasOwnProperty(checkProp);

}
Matt
@TheeMattOliver
Jun 21 2016 04:10
right, so your loop exists to start going through that object, and saying, "Does firstName = (whatever the firstName is at a certain index)"?
Luneyandminions
@Luneyandminions
Jun 21 2016 04:10
@davidrinconv it looks great! Well done! :D
Norvin Burrus
@ndburrus
Jun 21 2016 04:10
@bekir0v ok, just type: help format
Matt
@TheeMattOliver
Jun 21 2016 04:11
@auldsy-ababua and what are you hoping your function returns?
Stefan Bekirov
@bekir0v
Jun 21 2016 04:11
help format
CamperBot
@camperbot
Jun 21 2016 04:11

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

William Cabell
@wbac88
Jun 21 2016 04:11
@TheeMattOliver Awesome, so then with the if statement within the for loop, do I need to write out each of the possible names, or is there a way to simply say "if this input matches any of the strings..."
colin aulds
@auldsyababua
Jun 21 2016 04:11
@TheeMattOliver well if the property is found, i need it to return one thing and if not another
Matt
@TheeMattOliver
Jun 21 2016 04:12
@wbac88 there definitely is
colin aulds
@auldsyababua
Jun 21 2016 04:12
so i assume i need to create and if/else statement in the funciton
DavidR
@davidrinconv
Jun 21 2016 04:12
@m0sagal Thank you
CamperBot
@camperbot
Jun 21 2016 04:12
davidrinconv sends brownie points to @m0sagal :sparkles: :thumbsup: :sparkles:
:cookie: 165 | @m0sagal |http://www.freecodecamp.com/m0sagal
colin aulds
@auldsyababua
Jun 21 2016 04:12
but i dont really understand how to reference the boolean that gets returned by the .hasOwProperty
Matt
@TheeMattOliver
Jun 21 2016 04:13
@auldsy-ababua the way I understand it, it will only return true or false depending on whether it satisfies....so couldn't we just set up a conditional that says if (true) { do something};
?
colin aulds
@auldsyababua
Jun 21 2016 04:13
right
thats what i was thinking
but what do I set equal to true?
Matt
@TheeMattOliver
Jun 21 2016 04:14
@wbac88 youre going to be using bracket notation to access the index you're referencing in your loop, and setting that equal to the firstName variable
colin aulds
@auldsyababua
Jun 21 2016 04:14
meaning if (x = true) { do this}
else if (x = false) { do that}
William Cabell
@wbac88
Jun 21 2016 04:15
@TheeMattOliver OK, let me give that a shot, brb.
colin aulds
@auldsyababua
Jun 21 2016 04:15
what is the "x" in this case?
Matt
@TheeMattOliver
Jun 21 2016 04:15
@auldsy-ababua hmm
Chris Cuevo
@ccuevo
Jun 21 2016 04:16

i'm trying to complete this part of "Record Collection" challenge:
If prop does contain the key "tracks" and its value is non-blank, then push the value onto the end of its existing tracks array.

but i keep getting this error:
If prop does contain the key "tracks" and its value is non-blank, then push the value onto the end of its existing tracks array.

please help!

this is what i have so far:
```
function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
} else if (prop === "tracks" && value !== "") {
collection[id][prop].push();
} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

Matt
@TheeMattOliver
Jun 21 2016 04:16
the way I understand it to be used is you can just call the method on the element you're accessing, in a conditional
if(thing.hasOwnProperty( variable ) ) {

        return thingIwanttoreturn;
colin aulds
@auldsyababua
Jun 21 2016 04:17
ah i see
Stefan Bekirov
@bekir0v
Jun 21 2016 04:18
var myStr = "Here is a backslash: .\n backslash.newline tab\t tab\t Here is a new line with two tabs."; // Change this line
colin aulds
@auldsyababua
Jun 21 2016 04:18
do i need to set it equal to true?
Matt
@TheeMattOliver
Jun 21 2016 04:19
@auldsy-ababua of course I could be wrong, but I don't think you do, because it already evaluates to true...that's why it works in the conditional
it's like
if (4>2) { do the thing I want};
a dumb example
but I think what's at play
William Cabell
@wbac88
Jun 21 2016 04:19
@ccuevo This one took me a while to get, but you need to nest another if...else statment in there
Matt
@TheeMattOliver
Jun 21 2016 04:19
4>2 evaluates to true
William Cabell
@wbac88
Jun 21 2016 04:20
@ccuevo Within your second "else if" statement.
Matt
@TheeMattOliver
Jun 21 2016 04:20
so we say if some condition is met, then do the thing
colin aulds
@auldsyababua
Jun 21 2016 04:20
@TheeMattOliver got it. so next question is
if true, i want it to return the property value
Chris Cuevo
@ccuevo
Jun 21 2016 04:20
@wbac88 alright i think i understand what you mean
Luneyandminions
@Luneyandminions
Jun 21 2016 04:20
@ccuevo and you need to use .hasOwnProperty otherwise it will always give you that ABBA track error
colin aulds
@auldsyababua
Jun 21 2016 04:21
i tried this...but no go
William Cabell
@wbac88
Jun 21 2016 04:21
@Luneyandminions @ccuevo Yep, that has to be in there. And you need to create an empty array to push the tracks to if there isn't one
Stefan Bekirov
@bekir0v
Jun 21 2016 04:21
''' js var myStr = "Here is a backslash: .\n backslash.newline tab\t tab\t Here is a new line with two tabs."; // Change this line '''
CamperBot
@camperbot
Jun 21 2016 04:21
:bulb: to format code use backticks! ``` more info
Matt
@TheeMattOliver
Jun 21 2016 04:21
@auldsy-ababua so i assume we're talkin about profile lookup?
but either way
colin aulds
@auldsyababua
Jun 21 2016 04:22
@TheeMattOliver
Stefan Bekirov
@bekir0v
Jun 21 2016 04:22
help format
CamperBot
@camperbot
Jun 21 2016 04:22

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

colin aulds
@auldsyababua
Jun 21 2016 04:22
function checkObj(checkProp) {
  if (myObj.hasOwnProperty(checkProp)){
    return myObj.checkProp.val;
  } else {
    return "Not Found";
  }

}
Stefan Bekirov
@bekir0v
Jun 21 2016 04:23
var myStr = "Here is a backslash: \.\n backslash.newline tab\t tab\t Here is a new line with two tabs."; // Change this line
colin aulds
@auldsyababua
Jun 21 2016 04:23
'val' is undefined
William Cabell
@wbac88
Jun 21 2016 04:23
@TheeMattOliver OK, does this work:
for (var i = 0; i < contacts.length; i++) {

  if (firstName === contacts[i])


}
Don't know why that's all gray...
David Halls
@DavidHalls
Jun 21 2016 04:23
working on the calculator, needs some thoughts, how do i get the results of the input and apply the additions
Matt
@TheeMattOliver
Jun 21 2016 04:23
@auldsy-ababua yeah, i was just gonna say, looks like the "myObj.checkprop.val" in the return statement looks like it could use some attention
colin aulds
@auldsyababua
Jun 21 2016 04:24
but if i remove it, also no go
Matt
@TheeMattOliver
Jun 21 2016 04:24
@wbac88 you're gettin there! looks great so far....
@wbacs88 you're gonna have to add something to contacts[i] to make sure your loop knows exactly what it's lookin for in there....
@auldsy-ababua pls hold let me have a look
Stefan Bekirov
@bekir0v
Jun 21 2016 04:26
This message was deleted
This message was deleted
colin aulds
@auldsyababua
Jun 21 2016 04:27
I would've thought that merely returning the objectName.objectProp would return the value of the prop.
William Cabell
@wbac88
Jun 21 2016 04:27
@TheeMattOliver if (firstName === contacts.firstName[i]) ?
Matt
@TheeMattOliver
Jun 21 2016 04:28
@auldsy-ababua I think what's happening is myObject.checkprop is also gonna return undefined...we gotta set up a statement where the code is evaluating the thing that we're lookin for in myObject....
josephdanielchang
@josephdanielchang
Jun 21 2016 04:28
guys, help with Quoting Strings with Single Quotes
for var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Matt
@TheeMattOliver
Jun 21 2016 04:29
@wbac88 you are so close my man!
William Cabell
@wbac88
Jun 21 2016 04:29
@TheeMattOliver Haha, thank you for the encouragement!
CamperBot
@camperbot
Jun 21 2016 04:29
wbac88 sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Matt
@TheeMattOliver
Jun 21 2016 04:30
your [i] was in the right place...because it's the index of contacts
YG
@yisuang1186
Jun 21 2016 04:30
Hi guys, can anyone tell me why the commentted line is WRONG?
function checkObj(checkProp) {
  var res = "Not Found";
  if (myObj.hasOwnProperty(checkProp) ) {
    // res = myObj.checkProp; -- this is wrong!!!
    res = myObj[checkProp];
  }
  return res;
}
Matt
@TheeMattOliver
Jun 21 2016 04:30
so contacts[i].firstName :)
colin aulds
@auldsyababua
Jun 21 2016 04:30
@TheeMattOliver what does that mean?
William Cabell
@wbac88
Jun 21 2016 04:30
@TheeMattOliver facepalm
David Halls
@DavidHalls
Jun 21 2016 04:30
@yisuang1186 myObj does not exist
Matt
@TheeMattOliver
Jun 21 2016 04:31
@auldsy-ababua I'm tryin to think of how best to break this one down myself too...
but checkProp is an argument we're passing to the function
YG
@yisuang1186
Jun 21 2016 04:31
@Byzgig Uh… sorry, the complete code is like this
```
@yisuang1186
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var res = "Not Found";
  if (myObj.hasOwnProperty(checkProp) ) {
    // res = myObj.checkProp; -- this is wrong!!!
    res = myObj[checkProp];
  }
  return res;
}
Matt
@TheeMattOliver
Jun 21 2016 04:32
and we pass it into the method
not using dot notation, but actually in parentheses
@auldsy-ababua like this: return myObj[checkProp];
William Cabell
@wbac88
Jun 21 2016 04:34
@TheeMattOliver That's all I can handle for the night, I'm heading to bed, but again, thank you so much for taking the time. That was a huge, huge help!
CamperBot
@camperbot
Jun 21 2016 04:34
wbac88 sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:warning: wbac88 already gave theemattoliver points
colin aulds
@auldsyababua
Jun 21 2016 04:34
wow that worked
how do i send brownie points?
Matt
@TheeMattOliver
Jun 21 2016 04:34
@wbac88 you got it
William Cabell
@wbac88
Jun 21 2016 04:34
@auldsy-ababua Just say "thanks"
colin aulds
@auldsyababua
Jun 21 2016 04:34
@\thanks
@TheeMattOliver thanks
CamperBot
@camperbot
Jun 21 2016 04:34
auldsy-ababua sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Matt
@TheeMattOliver
Jun 21 2016 04:34
@auldsy-ababua that one is hard
MrBurks
@mrburks
Jun 21 2016 04:34

can someone explain the logic behind this? with cryptic hints please?

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (i = 0; i < arr.length; i++){

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

    console.log(arr[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]]);

David Halls
@DavidHalls
Jun 21 2016 04:35
@yisuang1186 you get the value with brackets, not dot notation, best i can tell oyou
colin aulds
@auldsyababua
Jun 21 2016 04:35
now, why does bracket notation work but not cot notation
dot*
Matt
@TheeMattOliver
Jun 21 2016 04:35
so
we can use dot notation to access certain things
but really, it boils down to what we're trying to access
Srinivasan
@kksrini89
Jun 21 2016 04:36
Can someone help me to resolve "arguments optional" challenge???
David Halls
@DavidHalls
Jun 21 2016 04:36
word homie
Matt
@TheeMattOliver
Jun 21 2016 04:36
if you were trying to access the "gift" key in myObj
Srinivasan
@kksrini89
Jun 21 2016 04:36
As I don't understand how to return a function if input is single parameter.
Matt
@TheeMattOliver
Jun 21 2016 04:36
then you could use dot notation, because "gift" is already, essentially, a variable
YG
@yisuang1186
Jun 21 2016 04:36
@TheeMattOliver @Byzgig TY sir!~
CamperBot
@camperbot
Jun 21 2016 04:36
yisuang1186 sends brownie points to @theemattoliver and @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @byzgig |http://www.freecodecamp.com/byzgig
:cookie: 269 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Matt
@TheeMattOliver
Jun 21 2016 04:37
in this challenge, checkProp is an argument being passed into the function
so if we put it in dot notation
colin aulds
@auldsyababua
Jun 21 2016 04:37
but if i try to return return myObj.pet;
it tells me its an illegal return statement
shouldnt it return the value of .pet?
Matt
@TheeMattOliver
Jun 21 2016 04:37
where are you returning it?