These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Jun 2016
Gary Siu
@GarySiu
Jun 24 2016 00:00
@96street One nice trick you can do is since .replace is a string method and the returned value is also a string, you can chain them like this url = url.replace('x', lat).replace('y', lon)
James S.
@Mrblue27
Jun 24 2016 00:00

anyone have any idea of how I am suppose to start this code. I need to write wordBlanks("dog", "big", "ran", "quickly") function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Diego Mayer
@Chrono79
Jun 24 2016 00:00
which challenge? @awiso
@Mrblue27 did you read Mad Libs link?
awiso
@awiso
Jun 24 2016 00:01
@Chrono79 repeat string
Diego Mayer
@Chrono79
Jun 24 2016 00:01
Uros Tadic
@urketadic
Jun 24 2016 00:01
Hey chrono
do u know why the page stops being black and just keeps on going, what is wrong with my html/css on http://codepen.io/urketadic/full/JKbddV/
Diego Mayer
@Chrono79
Jun 24 2016 00:02
@awiso could you copy the url of the challenge? from the start and until ?
96street
@96street
Jun 24 2016 00:02
Where to from here? @GarySiu I don't know how I can use this URL to get the data
Gary Siu
@GarySiu
Jun 24 2016 00:03
@96street Here's the documentation http://api.jquery.com/jquery.getjson/ It has examples and Should be quite friendly?
96street
@96street
Jun 24 2016 00:04
Yeah I know what JSON is, just not sure how to fetch the weather using the coordinates i've got @GarySiu
Gary Siu
@GarySiu
Jun 24 2016 00:05
@96street I haven't actually used that api before but I presume it sends back details in the response. What do you get if you console.log() the response?
clintonjohn
@clintonjohn
Jun 24 2016 00:05
var lastLetterOfLastName = lastName[lastName.length - 1];
awiso
@awiso
Jun 24 2016 00:05
@Chrono79 thanks, that fixed it. Any tips for that challenge?
CamperBot
@camperbot
Jun 24 2016 00:05
awiso sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1294 | @chrono79 |http://www.freecodecamp.com/chrono79
clintonjohn
@clintonjohn
Jun 24 2016 00:05
Sorry I don't have a question
Diego Mayer
@Chrono79
Jun 24 2016 00:06
@awiso you can use a loop, but what exit condition did you use to make it infinite?
There is another way of doing it without loops, with a string method
96street
@96street
Jun 24 2016 00:06
Screen Shot 2016-06-24 at 10.05.57 am.png
@GarySiu
Diego Mayer
@Chrono79
Jun 24 2016 00:06
@urketadic sorry, I see it black
Gary Siu
@GarySiu
Jun 24 2016 00:09
@96street Ok, so what are you have problems with at the moment?
96street
@96street
Jun 24 2016 00:10
how to use my API URL to get data like weather and city @GarySiu
Aksharif
@abusharif
Jun 24 2016 00:12
need help with "Manipulating Complex Objects"? really confuse what to do?
Gary Siu
@GarySiu
Jun 24 2016 00:12
@96street Well you need an API key apparently
kayzon
@quezanw
Jun 24 2016 00:12
Hey guys could someone explain how to write a lookup table?
awiso
@awiso
Jun 24 2016 00:12
@Chrono79 this was the culprit. I knew it wouldn't work, but wanted to run it anyway. then it crached lol
  for(i=0; i<num; i++){
    num = num + num; 
  }
Diego Mayer
@Chrono79
Jun 24 2016 00:13
@awiso num grows faster than i so it'll never exit the loop
Aksharif
@abusharif
Jun 24 2016 00:13
anyone?
Diego Mayer
@Chrono79
Jun 24 2016 00:14
@abusharif Are you sure that's the challenge name?
David Halls
@DavidHalls
Jun 24 2016 00:14
@abusharif a little more specific
Aksharif
@abusharif
Jun 24 2016 00:16
@Chrono79 @Byzgig yea.. i think its new. its said "Add a new album to the myMusic object. Add artist and title strings, release_year number, and a formats array of strings."
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
David Halls
@DavidHalls
Jun 24 2016 00:17
@abusharif so make another record, just like that one
Aksharif
@abusharif
Jun 24 2016 00:17
?
Matt
@TheeMattOliver
Jun 24 2016 00:17
@aksharif the exercise wants you to create your own object, just like the example
awiso
@awiso
Jun 24 2016 00:18
@Chrono79 also, im realizing, if anything, it should be str = str + str not num
Stefan Bekirov
@bekir0v
Jun 24 2016 00:18
Hi anybody to explane me what is wrong in this code
// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me
CamperBot
@camperbot
Jun 24 2016 00:18

welcome to FreeCodeCamp @bekir0v!

Matt
@TheeMattOliver
Jun 24 2016 00:19
@aksharif your object is going to be made up of key-value pairs, just like the example
the keys are the parts of the object like "name", "title", etc
and the values are the parts of the objects that match up with each key
Aksharif
@abusharif
Jun 24 2016 00:20
@TheeMattOliver its doesn't work
Matt
@TheeMattOliver
Jun 24 2016 00:21
can you post your code here?
David Halls
@DavidHalls
Jun 24 2016 00:21
@abusharif you need to put a , after the first records last }
James Daniel Correia de Freitas
@james-freitas
Jun 24 2016 00:23
No matter what I can't pass the first and the last tests
Aksharif
@abusharif
Jun 24 2016 00:24
@TheeMattOliver
var myMusic = [
{
"artist": ["Billy Joel", "Ak"],
"title": ["Piano Man","Dufy"],
"release_year": [1973, 2016],
"formats": [
"CS", "CD",
"8T", "9T",
"LP", "LAPD" ],
"gold": true
}
// Add record here
];
James Daniel Correia de Freitas
@james-freitas
Jun 24 2016 00:24
var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs";
Someone that have passed please help me out
Diego Mayer
@Chrono79
Jun 24 2016 00:25
@james-freitas you need a period at the end (after tabs)
James Daniel Correia de Freitas
@james-freitas
Jun 24 2016 00:27
@Chrono79 Thanks a lot!
CamperBot
@camperbot
Jun 24 2016 00:27
james-freitas sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1295 | @chrono79 |http://www.freecodecamp.com/chrono79
Aksharif
@abusharif
Jun 24 2016 00:27
@james-freitas u got to put space between it
Matt
@TheeMattOliver
Jun 24 2016 00:27
@aksharif nice work there, but we need to take a different approach
the object you create should be in its own set of {} brackets
Diego Mayer
@Chrono79
Jun 24 2016 00:28
@abusharif no, no space
James Daniel Correia de Freitas
@james-freitas
Jun 24 2016 00:28
don't believe it.
Matt
@TheeMattOliver
Jun 24 2016 00:28
like this:
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }, 

  {
    "artist" : "the Velvet Underground",
    "title": "Loaded",
    "release_year": 1969,
    "formats": [
      "LP",
      "8T",
      "CD" ],
    "gold": false
  }
  // Add record here
];
does that make sense?
James S.
@Mrblue27
Jun 24 2016 00:29
@Chrono79

@Chrono79
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var wordBlanks = ("cat", "little", "ran", "quickly");

// Your code above this line
return result;
}

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

Diego Mayer
@Chrono79
Jun 24 2016 00:30
@Mrblue27 no, you have to use result, not define a new var
And did you review the challenge I told you? That's not the way to build a string with variables
Matt
@TheeMattOliver
Jun 24 2016 00:32
@abusharif let me know if that helps.....
Aksharif
@abusharif
Jun 24 2016 00:32
@TheeMattOliver i see. thank
CamperBot
@camperbot
Jun 24 2016 00:32
abusharif sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Matt
@TheeMattOliver
Jun 24 2016 00:33
no prob!
Andre
@deshon12
Jun 24 2016 00:39
hi how do i share my code when i need help?
David Halls
@DavidHalls
Jun 24 2016 00:40
help format
CamperBot
@camperbot
Jun 24 2016 00:40

: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

James S.
@Mrblue27
Jun 24 2016 00:42
@Chrono79 looking over it again
Norvin Burrus
@ndburrus
Jun 24 2016 00:42
@bekir0v did you get it resolved?
Stefan Bekirov
@bekir0v
Jun 24 2016 00:43
@ndburrus No Sir
I don't know where am I making mistake
// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me
Diego Mayer
@Chrono79
Jun 24 2016 00:45
help string immutability
CamperBot
@camperbot
Jun 24 2016 00:45

:point_right: challenge understand string immutability [wiki]

Challenge Understand String Immutability

In Javascript, String values are immutable, which means that they cannot be altered once created.

:pencil: read more about challenge understand string immutability on the FCC Wiki

Diego Mayer
@Chrono79
Jun 24 2016 00:45
@bekir0v delete last line, that's exactly what you can't do with a string
Stefan Bekirov
@bekir0v
Jun 24 2016 00:47
@Chrono79 What do you mean
Diego Mayer
@Chrono79
Jun 24 2016 00:47
@bekir0v this: myStr[0] = "H"; // Fix Me
You can't change a single letter of a string like you change an element of an array
Stefan Bekirov
@bekir0v
Jun 24 2016 00:48
I see but this tasks are little bit confused
MrBurks
@mrburks
Jun 24 2016 00:48
can any one help me? I've been stuck for a while
Jatinder singh
@jatinder751
Jun 24 2016 00:49
Hello guys, i am stuck on this problem where i have to convert celcius to farenheit, please help
Diego Mayer
@Chrono79
Jun 24 2016 00:50
your code @mrburks @jatinder751
Joseph
@revisualize
Jun 24 2016 00:50
@jatinder751 Explain to me in words how to convert Cel to Far.
@bekir0v Strings are Immutable.
Ghost
@ghost~56a80c91e610378809be5d28
Jun 24 2016 00:51
@revisualize I think he wanted help converting it :laughing:
Jatinder singh
@jatinder751
Jun 24 2016 00:51
@revisualize we take celcius(x) multiply it with 9/5 than add 32
Joseph
@revisualize
Jun 24 2016 00:52
@evan153 I'm asking him to explain the actual math that he got from the Google Seach that he did.
Diego Mayer
@Chrono79
Jun 24 2016 00:52
@jatinder751 it's celsius (just be sure your code is well written ;) )
Joseph
@revisualize
Jun 24 2016 00:52
@jatinder751 PERFECT!
Ghost
@ghost~56a80c91e610378809be5d28
Jun 24 2016 00:52
@jatinder751 Lol I know
Jatinder singh
@jatinder751
Jun 24 2016 00:52
yes now how do i write it in javascript
Joseph
@revisualize
Jun 24 2016 00:52
@jatinder751 So.. In your own words.
celsius multiply it with 9/5 than add 32
Jatinder singh
@jatinder751
Jun 24 2016 00:52
this is the first time i am having so much fun chatting in a long time
Jaren Escueta
@jarenescueta731
Jun 24 2016 00:52
hey guys, i've been stuck on one of the intermediate challenges because the editor keeps saying i'm missing a semicolon somewhere. if you could spot the error, or an error of any kind, it would really help!
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var forRemoval = [];
  var keys = Object.keys(source);
  var values = Object.values(source);

  for (var i = 0; i < collection.length; i++){ // look at each object in collection
    var j = 0;
    var trueFalse = [];
    while (j < keys.length){  // checks if collection[i] contains all source's props
      var keyExists = collection[i].hasOwnProperty(keys[j]);
      trueFalse.push(keyExists);  // records the boolean values for collection[i]
      j++;
    }
    if (($.inArray(false, trueFalse)) > -1){  // collection[i] is missing a source prop
      forRemoval.push(collection[i]);  // adds the 'incomplete' object for removal
    }
  }

  for (var k = 0; k < collection.length; k++){
    if (($.inArray(collection[k], forRemoval)) === -1){  // if object is not for removal
      arr.push(collection[k]);
    }
  }

  // Only change code above this line
  return arr;
}
Joseph
@revisualize
Jun 24 2016 00:52
celsius * 9/5 than add 32
celsius * 9/5 + 32
Jatinder singh
@jatinder751
Jun 24 2016 00:53
yes correct
Joseph
@revisualize
Jun 24 2016 00:53
@jatinder751 Okay. How can I help?
@jatinder751 What's your function?
Jatinder singh
@jatinder751
Jun 24 2016 00:54

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

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

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

James S.
@Mrblue27
Jun 24 2016 00:54
what am i doing wrong here
Diego Mayer
@Chrono79
Jun 24 2016 00:54
@jarenescueta731 what's this? (($.inArray(false, trueFalse))
Joseph
@revisualize
Jun 24 2016 00:54
@jatinder751 So... Add the math to the function.
@jatinder751 You're returning fah so.. you should reassign the fah variable.
Jaren Escueta
@jarenescueta731
Jun 24 2016 00:55
@Chrono79 it's a jquery method that checks if the first param (value) is present in the second param (array)
@Chrono79 it returns the index of the item in the array
Ghost
@ghost~56a80c91e610378809be5d28
Jun 24 2016 00:55
@jarenescueta731 Doesn't look like you're missing any ;
Diego Mayer
@Chrono79
Jun 24 2016 00:55
@jarenescueta731 are you sure jquery works in the challenges?
Jaren Escueta
@jarenescueta731
Jun 24 2016 00:55
@Chrono79 or -1 if not
@Chrono79 i used the same method in the Two Diff Arrays challenge, so yes
Josh
@joshweaver23
Jun 24 2016 00:56
Hey all, I'm looking for a little help with an angular app. I'm trying to implement a setInterval or $interval type function, but the problem is that I'm using angular 1.0.0... why? because I couldn't (for some reason) get my nested ng-repeats to work in any other version. A fix for either nesting ng-repeats in a later version or work-around for setInterval in 1.0.0 would be amazingly appreciated! CodePen: //ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js
Rafael Nunes
@orafanunes
Jun 24 2016 00:56
Good night guys.
I just ended the challenge 271 (Seek and Destroy) but i didn't like the way that the code looks like. Tell me if there is something i can do to optimaze the code please.
function destroyer(arr,arg1,arg2,arg3) {


  return arr.filter(function(n){return n!=arg1}).filter(function(n){return n!=arg2}).filter(function(n){return n!=arg3});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Ghost
@ghost~56a80c91e610378809be5d28
Jun 24 2016 00:56
@jarenescueta731 Which challenge
Joseph
@revisualize
Jun 24 2016 00:57
@orafanunes You're overriding the lesson.
Jatinder singh
@jatinder751
Jun 24 2016 00:57
i really have no clue @revisualize where to do, i do have an idea of what to do. its my first hour in javascript, havent done any reading on it yet
Rafayel Stepanyan
@Stepanyanr
Jun 24 2016 00:57
Here is a backslash: .
Here is a new line with two tabs
Joseph
@revisualize
Jun 24 2016 00:57
@orafanunes You're really missing a key part of that lesson.. (Unless they recently changed it.
Rafayel Stepanyan
@Stepanyanr
Jun 24 2016 00:57
I cant do this
can someone help
Jaren Escueta
@jarenescueta731
Jun 24 2016 00:57
@evan153 the one i'm stuck on is called Wherefore art thou
Joseph
@revisualize
Jun 24 2016 00:58
@jatinder751 Question.. How do you re-assign a variable?
Jaren Escueta
@jarenescueta731
Jun 24 2016 00:58
@evan153 in intermediate algo scripting
Rafael Nunes
@orafanunes
Jun 24 2016 00:59
@revisualize the code did work well. but i know the its not scalable. I feel like i just took a short cut
96street
@96street
Jun 24 2016 01:00
say I access this array:
var arr = [{first: 'one', 'two'}, {second: 'ten', 'twenty'}]
would this be twenty?: second[1].value
Joseph
@revisualize
Jun 24 2016 01:01
@orafanunes You did.
Jatinder singh
@jatinder751
Jun 24 2016 01:01
it starts from the right side of the = sign and goes towards the left.@
@revisualize
Jaren Escueta
@jarenescueta731
Jun 24 2016 01:03
@96street is the 'twenty' a value without a property?
Joseph
@revisualize
Jun 24 2016 01:03
@jatinder751 So reassign fahrenheit
Diego Mayer
@Chrono79
Jun 24 2016 01:03
@jarenescueta731 is it any different than indexOf ?
96street
@96street
Jun 24 2016 01:05
{"coord":
{"lon":145.77,"lat":-16.92},
"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],
"base":"cmc stations",
"main":{"temp":293.25,"pressure":1019,"humidity":83,"temp_min":289.82,"temp_max":295.37},
"wind":{"speed":5.1,"deg":150},
"clouds":{"all":75},
"rain":{"3h":3},
"dt":1435658272,
"sys":{"type":1,"id":8166,"message":0.0166,"country":"AU","sunrise":1435610796,"sunset":1435650870},
"id":2172797,
"name":"Cairns",
"cod":200}
would name[0].value get me Cairns?
@jarenescueta731
David Halls
@DavidHalls
Jun 24 2016 01:07
@96street it would be something more like data.name
depending on what you call you return
Jaren Escueta
@jarenescueta731
Jun 24 2016 01:08
@Chrono79 it is different, indexOf would return undefined instead of -1. i guess i could check for undefined, i want to look at each object in collection and make sure it has all the source's keys. if false is present, then that means the object in question should not be in arr.
Jaren Escueta
@jarenescueta731
Jun 24 2016 01:10
ok so i googled also, turns out they're the same with slightly different syntax. inArray is actually compatible with all browsers
96street
@96street
Jun 24 2016 01:11
$.getJSON( url, function(data) {
  $city == data.name[0];
});
what if it had more than 1 value? @Byzgig
and would that code be right^?
Jaren Escueta
@jarenescueta731
Jun 24 2016 01:11
@Chrono79 i'll try indexOf and update, but it doesn't explain why i had no problem using inArray for a previous challenge
96street
@96street
Jun 24 2016 01:11
to make $city == 'Cairns'?
Diego Mayer
@Chrono79
Jun 24 2016 01:12
@jarenescueta731 It complains about { not ; I commented the 2 ifs which use $.inArray and it complains about Object.values I think it's not supported yet (either way, you don't even use it)
Jatinder singh
@jatinder751
Jun 24 2016 01:12
@revisualize thanks a lot, finally i seem to have got it.
CamperBot
@camperbot
Jun 24 2016 01:12
jatinder751 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1303 | @revisualize |http://www.freecodecamp.com/revisualize
Jaren Escueta
@jarenescueta731
Jun 24 2016 01:13
@Chrono79 yeah i forgot to get rid of values lol
James S.
@Mrblue27
Jun 24 2016 01:13
@Chrono79 it got it thanks I over thought the question didn't realize I just needed to use +
CamperBot
@camperbot
Jun 24 2016 01:13
mrblue27 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1296 | @chrono79 |http://www.freecodecamp.com/chrono79
David Halls
@DavidHalls
Jun 24 2016 01:13
@96
@96street it looks right and i assume that is how you would do it
96street
@96street
Jun 24 2016 01:15
sweet

are you sure it wouldn;t be:

```
$.getJSON( url, function(data) {
  $city == data.name[0].value;
});

?

when is .value supposed to be used?
Diego Mayer
@Chrono79
Jun 24 2016 01:16

@jarenescueta731

    if (($.inArray(false, trueFalse)) > -1) {  // collection[i] is missing a source prop
      forRemoval.push(collection[i]);  // adds the 'incomplete' object for removal
    }

I've reduced the problem to that if, if you comment it, the function works (not ok, but it runs)

David Halls
@DavidHalls
Jun 24 2016 01:16
@96street mine is just data.name
Jaren Escueta
@jarenescueta731
Jun 24 2016 01:17
@Chrono79 ok i will update
Jatinder singh
@jatinder751
Jun 24 2016 01:17
@revisualize ONe last question, how do you put multiple values fort he same variable? is it by just using a comma?
Diego Mayer
@Chrono79
Jun 24 2016 01:17
@jarenescueta731 more reducing: forRemoval.push(collection[i]); // adds the 'incomplete' object for removal
Sam Nave
@shrapnel2012
Jun 24 2016 01:20
Hey all. Quick question, I am doing the comparison with the greater than operator. I am having an issue understanding how to add the greater than operator to the indicated lines..
can anyone clarify what I am suppose to do exactly?
eeflores
@eeflores
Jun 24 2016 01:25
@shrapnel2012 what's the line?
eg. if(a > b) {
Joseph
@revisualize
Jun 24 2016 01:28
@jatinder751 Gratz. Sorry. I was AFK. I was making a salad.
andreas2249
@andreas2249
Jun 24 2016 01:29
Good evening, Campers. In the following code, the format return lookup[val]; produces the correct result. Why does this return undefined when using dot-notation, such as: return lookup.val? I thought they were equivalent forms -- and val does have the same value, right? Thanks in advance. :)
function phoneticLookup(val) {
  var lookup = {
    alpha: "Adams",
    bravo: "Boston",
    charlie: "Chicago",
  }; 
  return lookup[val];
}
console.log(phoneticLookup("bravo"));
V Arun Kumar
@arunvkumr
Jun 24 2016 01:29
@shrapnel2012 >, < , >=, <= all are comparison operators which gives 0, 1. 0 for false and 1 for true. in the challenge the examples are given how to use them.
in words.. seven is greater than three is this true or false?
in code.. 7 > 3, this will give you a value 1 as it is true and 0 if this was false.
Jatinder singh
@jatinder751
Jun 24 2016 01:29
Its all good, i figured out, thanks a ton. i sent you brownies lol, ;)@revisualize
CamperBot
@camperbot
Jun 24 2016 01:29
jatinder751 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: jatinder751 already gave revisualize points
Joseph
@revisualize
Jun 24 2016 01:30
@andreas2249 remove console.log(phoneticLookup("bravo")); and put just the phoneticLookup("bravo");
Also, your lookup object isn't complete.
@andreas2249 Otherwise your code is good.
@andreas2249 Oh.
@andreas2249 Dot notation is a string literal.
@andreas2249 What I mean by that is...
@andreas2249
myObj.name is the same as myObj["name"]
whereas myObj[name] uses the value of the variable name
Sam Nave
@shrapnel2012
Jun 24 2016 01:33
@arunkumrv thanks
CamperBot
@camperbot
Jun 24 2016 01:33
shrapnel2012 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for arunkumrv
Sam Nave
@shrapnel2012
Jun 24 2016 01:33
@eeflores thanks I think I just got it. Was a human error...hhaa
CamperBot
@camperbot
Jun 24 2016 01:33
shrapnel2012 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 771 | @eeflores |http://www.freecodecamp.com/eeflores
Diego Mayer
@Chrono79
Jun 24 2016 01:33
@jarenescueta731 I'll suggest using a counter and check that against keys.length
Joseph
@revisualize
Jun 24 2016 01:34
@andreas2249 Make sense?
@Chrono79 Am I using the correct verbiage above?
Diego Mayer
@Chrono79
Jun 24 2016 01:35
@revisualize where exactly?
I think it's ok
andreas2249
@andreas2249
Jun 24 2016 01:35
@revisualize, thank you for your prompt reply... (I'm a bit confused still and noodling it...)
CamperBot
@camperbot
Jun 24 2016 01:35
andreas2249 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1304 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 24 2016 01:35
@andreas2249 You know that everything inside of "s is a string?
andreas2249
@andreas2249
Jun 24 2016 01:37
Yes, @revisualize. And it's for that reason I'm a bit confused. The properties 'alpha,' 'bravo,' and 'charlie' are strings, too. Or do I have that part incorrect?
Joseph
@revisualize
Jun 24 2016 01:37
@andreas2249
var name = "Joseph";
console.log("name");
console.log(name);
@andreas2249 They are properties.
@andreas2249 You know how arrays work.
["a","b","c","d","e"]
Arrays are objects.
You just access them via their indexes.
Objects allow you to define the properties that you can access the value by.
{0:"a",1:"b",2:"c",3:"d",4:"e"}
@andreas2249 It really is a concept that takes a little bit of work to understand.
andreas2249
@andreas2249
Jun 24 2016 01:43

Great explanation, @revisualize. You nailed it with your code example. It was my bad. In my mind, passing "bravo" to val said to me that lookup.val = lookup[val]. I was inventing something in my head. :)

Thanks again for your time and consideration. @revisualize. I got it now. :+1:

CamperBot
@camperbot
Jun 24 2016 01:43
andreas2249 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: andreas2249 already gave revisualize points
Joseph
@revisualize
Jun 24 2016 01:44
@andreas2249 yeah... lookup.val is the same as lookup["val"] not lookup[val]
Again dot notation turns it into a string literal.
...
On another note.. This salad is f`ing amazing.
NOM NOM NOM!
andreas2249
@andreas2249
Jun 24 2016 01:45
Very good explanation, @revisualize. Thanks again. :)
CamperBot
@camperbot
Jun 24 2016 01:45
andreas2249 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: andreas2249 already gave revisualize points
JLuis Avalos
@avalos010
Jun 24 2016 01:46

var myStorage = {
"car": {
"inside":

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

}
};

myStorage.car.inside["glove box"];
var gloveBoxContents = "maps";

how do i access the nested objects
Stefan Bekirov
@bekir0v
Jun 24 2016 01:50
Hi guys
Am I doing right with this code
Joseph
@revisualize
Jun 24 2016 01:50
@avalos010 How do you access nested array elements?
Stefan Bekirov
@bekir0v
Jun 24 2016 01:50
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = ("myNoun" + "myAdjective" + "myVerb" + "myAdverb");

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("", "", "", "");
Joseph
@revisualize
Jun 24 2016 01:50
@bekir0v No. You're using strings.
Stefan Bekirov
@bekir0v
Jun 24 2016 01:51
@revisualize So What should I do
Joseph
@revisualize
Jun 24 2016 01:52
@bekir0v Use the variables that are passed through the function.
Diego Mayer
@Chrono79
Jun 24 2016 01:52

@avalos010 merge this 2 sentences:

myStorage.car.inside["glove box"];
var gloveBoxContents = "maps";

Discard what you don't need

Tyler Del Rosario
@TylerDelRosario
Jun 24 2016 01:53
help Diff Two Arrays
CamperBot
@camperbot
Jun 24 2016 01:53

:point_right: algorithm diff two arrays [wiki]

Algorithm Diff Two Arrays

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

:checkered_flag: Problem Explanation:

Check two arrays and return a new array that contains only the items that are not in either of the original arrays.

Relevant Links

:pencil: read more about algorithm diff two arrays on the FCC Wiki

revisualize @revisualize is afk :toilet:
Stefan Bekirov
@bekir0v
Jun 24 2016 01:55
@revisualize
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  myNoun = "";
  myAdjective = "";
  myVerb = "";
  myAdverb = "";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("", "", "", "");
Joseph
@revisualize
Jun 24 2016 01:56
@bekir0v Negative. You're overriding the variables.
@bekir0v result = myNoun + myAdj + myV + myA;
but, with spaces between them.
Stefan Bekirov
@bekir0v
Jun 24 2016 01:57
ok
@revisualize
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = myNoun + myAdjective + myVerb + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Joseph
@revisualize
Jun 24 2016 02:00
@bekir0v MUCH closer.
Just need to add the spaces between the variables.
Mike Short
@mikeshort10
Jun 24 2016 02:01
//////////////////////Part 1////////////////////
  var locale = document.getElementById('locale').value;
  var URL = "http://api.wunderground.com/api/5360ab95c4d3c85f/conditions/q/" + locale + ".json";
  var request = new XMLHttpRequest();
  request.open("GET", URL, false);
  request.send();
  var reply = JSON.parse(request.response);

  //establish var from JSON values
  var town = "The Weather in " + reply.current_observation.display_location.full;
  var weather = reply.current_observation.weather;
  var icon = reply.current_observation.icon_url;
  var temp = reply.current_observation.temp_f;
  var tempString = temp + String.fromCharCode(176) + "F";


///////////////////Part 2//////////////////////

$('#update').click(function() {
    var locale = document.getElementById('locale').value;
  var URL = "http://api.wunderground.com/api/5360ab95c4d3c85f/conditions/q/" + locale + ".json";
  var request = new XMLHttpRequest();
  request.open("GET", URL, false);
  request.send();
  var reply = JSON.parse(request.response);

  //establish var from JSON values
  var town = "The Weather in " + reply.current_observation.display_location.full;
  var weather = reply.current_observation.weather;
  var icon = reply.current_observation.icon_url;
  var temp = reply.current_observation.temp_f;
  var tempString = temp + String.fromCharCode(176) + "F";


////////////////////Part 3///////////////////////////////

  document.getElementById("town").innerHTML = town;
  $('#icon').attr("src", icon);
  document.getElementById("temp").innerHTML = tempString;
  document.getElementById("weather").innerHTML = weather;
  console.log(temp);
});
Hi All, I'm having issues with the above code. Probably a simple explanation, but I'm stuck. I've broken my code up into three parts. Part 1 and 2 are identical, except that Part 2 is inside of a JQuery click function. When both are in the code, Part 3 does not produce what I would like, i.e. a lot of ".innerHTML". When Part 2 is removed and Part 1 remains, it also doesn't work. However, when Part 1 is removed and Part 2 remains, Part 3 works. Can someone explain why? Shouldn't Part 1 act as global variables? Any feedback would be awesome!
Stefan Bekirov
@bekir0v
Jun 24 2016 02:01
@revisualize I did it
Joseph
@revisualize
Jun 24 2016 02:01
@bekir0v Instead of returning
"dogbigranquickly"
You want to return
"dog big ran quickly"
Joseph
@revisualize
Jun 24 2016 02:02
OH SNAP!
I have to get my arse to my haircut appointment.
Diego Mayer
@Chrono79
Jun 24 2016 02:04
@revisualize that didn't sound so well :P
Joseph
@revisualize
Jun 24 2016 02:04
Damn this unemployed life.
hehe.. I've only been unemployed for 1 day. LOL!
Anthony
@Coding-in-progress
Jun 24 2016 02:06
Hey all I am having trouble understanding what is happening in nested for loops....does anyone have a strong grasp?
Tyler Del Rosario
@TylerDelRosario
Jun 24 2016 02:06
help Roman Numeral Converter
CamperBot
@camperbot
Jun 24 2016 02:06

:point_right: algorithm roman numeral converter [wiki]

Algorithm Roman Numeral Converter

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

:checkered_flag: Problem Explanation:

You will create a program that converts an integer to a Roman Numeral.

:pencil: read more about algorithm roman numeral converter on the FCC Wiki

Joseph
@revisualize
Jun 24 2016 02:06
@Coding-in-progress I DO!
@Coding-in-progress
var arr = [["a1"], ["b2","c2"], ["d3","e3","f3"], ["g4","h4","i4","k4"]];
// Do you understand that this is an array of arrays?
// But, if we want to console.log all of the elements we need to
// have a loop inside of a loop
for (var i = 0; i < arr.length; i++){
   console.log("The value of arr[" + i + "] is: \t" + arr[i]);
   for (var j = 0; j < arr[i].length; j++) {
      console.log("The value of arr[" + i + "][" + j + "] is: \t\t" + arr[i][j]);
   }
}
Stefan Bekirov
@bekir0v
Jun 24 2016 02:07

@revisualize

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

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

i did this before

no result
Joseph
@revisualize
Jun 24 2016 02:07
@bekir0v You're doing strings again.
Anthony
@Coding-in-progress
Jun 24 2016 02:07
on the inner loop I don't understand the syntax of inner loop
Joseph
@revisualize
Jun 24 2016 02:07
variable + " " + variable
@Coding-in-progress How can I help? I have about 15min.
Stefan Bekirov
@bekir0v
Jun 24 2016 02:08
@revisualize
you mean i should put dog big ran quickly
Joseph
@revisualize
Jun 24 2016 02:08
no.
Anthony
@Coding-in-progress
Jun 24 2016 02:08
@revisualize var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:08
@Coding-in-progress An inner loop is just a loop nested inside another, using a different variable for the counter.
Diego Mayer
@Chrono79
Jun 24 2016 02:08
@bekir0v remove the double quotes around myNoun, etc
Anthony
@Coding-in-progress
Jun 24 2016 02:09
@Shawn-Williams I definitely get that but I guess I dont understand why you use the var[i] in the second loop
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:09
The first loop cycles through the first value of the parent array, while the second loop cycles through the current array value's children
co0lsky
@co0lsky
Jun 24 2016 02:09
@mikeshort10 Where do you put the codes? Is it within jQuery document ready function or in the head tag?
Joseph
@revisualize
Jun 24 2016 02:10
@bekir0v Remember when I said you were close with this:
result = myNoun + myAdjective + myVerb + myAdverb;
But, You're returning
"dogbigranquickly"
You want to return
"dog big ran quickly"
So, to fix that:
result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;
Anthony
@Coding-in-progress
Jun 24 2016 02:10
this comment is what sparked my confusion ...."Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array."
Joseph
@revisualize
Jun 24 2016 02:10
@Coding-in-progress Here!
@Coding-in-progress Run your code through that.
Mike Short
@mikeshort10
Jun 24 2016 02:11
@co0lsky I'm using codepen, so all the code is separated. I'm assuming that makes it operate out of the head tag. Definitely no doc ready function
Stefan Bekirov
@bekir0v
Jun 24 2016 02:11
@Chrono79
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = myNoun + myAdjective + myVerb + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks();
Joseph
@revisualize
Jun 24 2016 02:11
@Coding-in-progress Or run the code that I pasted above.
@bekir0v I just gave you the answer.
JLuis Avalos
@avalos010
Jun 24 2016 02:11

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

// Only change code below this line
myStorage.car.inside;
var gloveBoxContents = "maps";

how do i access nested Objects.
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:12
the first loop (i) iterates on the main array. the second loop iterates on the current sub-array, which you must pass in its length as the counter conditional
hence arr[i].length instead of arr.length
bsandusky
@bsandusky
Jun 24 2016 02:13
@mikeshort10 Pretty sure it has to do with the fact that wrapping part 2 in the click function makes those requests actually run. Part 1 is setting up a lot of variables, but there is nothing to trigger var request to actually run. So all those variables are empty, and part 3 has nothing to reference. In Javascript, the function is key to making async commands actually run.
Diego Mayer
@Chrono79
Jun 24 2016 02:13
@bekir0v look at what @revisualize posted :point_up: 23 de junio de 2016 23:10
Anthony
@Coding-in-progress
Jun 24 2016 02:14
@Shawn-Williams so dumb question but if you had a 3rd loop how would the next line look?
bsandusky
@bsandusky
Jun 24 2016 02:14
@mikeshort10 If you wrap part 1 in document ready, then it will run whenever the DOM is loaded and ready. Again, the way Javascript interprets that is “once the DOM is ready, the run whatever function you give me” … which could be an anon function followed by what you have in part 1
Stefan Bekirov
@bekir0v
Jun 24 2016 02:15
@Chrono79 I saw but I don't get it why is like that
kocaman
@kocaman
Jun 24 2016 02:15
Hi All, Can some one explain what is "Stand in Line” all about?
Mike Short
@mikeshort10
Jun 24 2016 02:15
@avalos several ways 1) myStorage[0][0][0] 2) myStorage["car"]["inside"]["glove box"] 3) myStorage.car.inside["glove box"]... All return "maps"
Joseph
@revisualize
Jun 24 2016 02:15
@kocaman I can!
@kocaman
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // Add the number to the end of the array,

    // then remove the first element of array.
    // The nextInLine function should 
    // then return the element that was removed.
    return item; // Change this line
}
Diego Mayer
@Chrono79
Jun 24 2016 02:15
@bekir0v because you need spaces between the words contained it the vars you're joining with +
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:15
@Coding-in-progress Say your main array contains five values and each of those can contain an array of n values. To cycle through the parent array, you would have to use arr.length because you want it to return the length of the parent array. If the child array only contained 3 values and you used arr.length, the array would iterate 5 times instead of three, which is why you have to use arr.length[i], which is the length value of the current array in that iteration.
Jaren Escueta
@jarenescueta731
Jun 24 2016 02:16
@Chrono79 i finally got it lol
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var keys = Object.keys(source);
  var values = Object.values(source);
  var allKeyValuesPresent;

  for (var i = 0; i < collection.length; i++){ // look at each object in collection
    var j = 0;
    //console.log("keys.length: "+keys.length);
    while (j < keys.length){  // checks if collection[i] contains all source's props
      //console.log("key: "+keys[j]);
      var keyExists = collection[i].hasOwnProperty(keys[j]);
      //console.log(keyExists);
      if (keyExists && collection[i][keys[j]] === values[j]){ // key-value matches source
        allKeyValuesPresent = true;
      } else {
        allKeyValuesPresent = false;
        break;
      }
      j++;
    }
    //console.log(allKeyValuesPresent);
    if (allKeyValuesPresent){
      arr.push(collection[i]);
    }
    //console.log(arr);
  }
  // Only change code above this line
  return arr;
}
kocaman
@kocaman
Jun 24 2016 02:16
Thanks I will try to read these and digest :)
Jaren Escueta
@jarenescueta731
Jun 24 2016 02:16
@Chrono79 thanks a bunch!
CamperBot
@camperbot
Jun 24 2016 02:16
jarenescueta731 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1297 | @chrono79 |http://www.freecodecamp.com/chrono79
JLuis Avalos
@avalos010
Jun 24 2016 02:16
@mikeshort10 i tried the 3rd one but it doesnt let me move on
Diego Mayer
@Chrono79
Jun 24 2016 02:16
@jarenescueta731 no problem
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:16
@Coding-in-progress third loop could be arr[i][j].length
Joseph
@revisualize
Jun 24 2016 02:16
@kocaman The comments are actually just the instructions.
V Arun Kumar
@arunvkumr
Jun 24 2016 02:16
@avalos010 you are accessing nested objects.. myStorage.car.inside in this line you are accessing myStorage object's car and car's inside property. you also need to access glove box which is inside Inside property for that use bracket notation.
and the last two statements merge them. store the value you got from accessing objects inside gloveBoxContents.
Diego Mayer
@Chrono79
Jun 24 2016 02:17
@jarenescueta731 I can send you my version if you want to take a look at it
Jaren Escueta
@jarenescueta731
Jun 24 2016 02:17
@Chrono79 ok that would be cool, probs a lot more optimized
Stefan Bekirov
@bekir0v
Jun 24 2016 02:18
@Chrono79 Anyway thank you guys
I should go back to understand it
CamperBot
@camperbot
Jun 24 2016 02:18
bekir0v sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1298 | @chrono79 |http://www.freecodecamp.com/chrono79
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:18
for (var i=0; i < arr.length; i++) {
    for (var j = 0; j < arr.length[i] {
        for (var k  = 0; k < arr.length[j] {
        }
    }
}
Anthony
@Coding-in-progress
Jun 24 2016 02:18
@Shawn-Williams OH OK so that makes sense actually
Joseph
@revisualize
Jun 24 2016 02:18
@Shawn-Williams That isn't correct.
Anthony
@Coding-in-progress
Jun 24 2016 02:18
@revisualize @Shawn-Williams thanks both for helping with this.
CamperBot
@camperbot
Jun 24 2016 02:18
coding-in-progress sends brownie points to @revisualize and @shawn-williams :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @shawn-williams |http://www.freecodecamp.com/shawn-williams
:star2: 1305 | @revisualize |http://www.freecodecamp.com/revisualize
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:19
I forgot the incrementation, I see that
V Arun Kumar
@arunvkumr
Jun 24 2016 02:19
@Shawn-Williams you are missing increment operator and the closing brackets for j and k loop.
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:20
```
for (var i=0; i < arr.length; i++) {
    for (var j = 0; j < arr.length[i]; j++) {
        for (var k  = 0; k < arr.length[j]; k++) {
        }
    }
}
```
Diego Mayer
@Chrono79
Jun 24 2016 02:20
@jarenescueta731 I've sent you a PM
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:20
@arunkumrv yeah, I typed it in a hurry
V Arun Kumar
@arunvkumr
Jun 24 2016 02:20
oh.. alright :smile:
Diego Mayer
@Chrono79
Jun 24 2016 02:21
@Shawn-Williams mind where you put your indices ;)
they should be next to arr
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:22
@Chrono79 lol...that too
for (var i=0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
        for (var k  = 0; k < arr[j].length; k++) {
        }
    }
}
@Chrono79 My fingers were moving faster than my brain...lol
I hope I didn't confuse @Coding-in-progress any more by that
Diego Mayer
@Chrono79
Jun 24 2016 02:23
the second inner loop, what's for? The one with the k
Moisés Man
@moigithub
Jun 24 2016 02:24
3d arrays !!!
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:24
lol
it was just an example of how to structure a 3d array I supposed. He asked how you would iterate through a third.
Diego Mayer
@Chrono79
Jun 24 2016 02:24
ok, but I think you should write arr[i][j].length in the exit condition @Shawn-Williams
Like this:
for (var i=0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
        for (var k  = 0; k < arr[i][j].length; k++) {
        }
    }
}
co0lsky
@co0lsky
Jun 24 2016 02:25
@mikeshort10 I have the same conclusion as yours, the part 1 should be the global variables. When part 2 is removed, part 3 should work. Does the request from part 1 get its response when you click on the #update?
Mike Short
@mikeshort10
Jun 24 2016 02:26
thanks @bsandusky! That, combined with the fact that my navigator isn't working the way I wanted it to, was the issue. I'm good now
CamperBot
@camperbot
Jun 24 2016 02:26
mikeshort10 sends brownie points to @bsandusky :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @bsandusky |http://www.freecodecamp.com/bsandusky
Mike Short
@mikeshort10
Jun 24 2016 02:28
@avalos010 try myStorage.car.inside[0]
Anthony
@Coding-in-progress
Jun 24 2016 02:28
@Shawn-Williams I actually wasn't confused but I guess I was over thinking the syntax. I appreciate everyones help
Mike Short
@mikeshort10
Jun 24 2016 02:30
@avalos010 it doesn't matter which one you use, unless your shifting or unshifting values in the rest of your code. Safest bet is to use the one with the names of the properties, so there's no confusion
Jacob Stewart
@JacobStewart1
Jun 24 2016 02:32

hey im having trouble with the Make Instances of Objects with a Constructor Function lesson in the object oriented and functional programming section. this is my code
var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 1;
};

// Only change code below this line.
Car.nickname = "Tom";
var myCar = new Car();

Shawn Williams
@Shawn-Williams
Jun 24 2016 02:32
@Chrono79 That is correct
96street
@96street
Jun 24 2016 02:32
Hey guys struggling with the weather challenge, can someone help: http://codepen.io/kingdezz/pen/pbRjPY?editors=1011
Diego Mayer
@Chrono79
Jun 24 2016 02:34
@JacobStewart1 make a new car, and then, give it a name
Car is the constructor, your car is myCar (well, it's yours, not mine, I'm not a burglar)
Jacob Stewart
@JacobStewart1
Jun 24 2016 02:34
ok thanks
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:36
@96street I recommend concatenating the lat and long values into the url rather than doing a replace. Additionally, you may find it difficult to retrieve navigator.geolocation data in Codepen, depending on your browser. I know Chrome was disabling that functionality and I had to retrieve it from another api.
96street
@96street
Jun 24 2016 02:37
it works in firefox so i'm using it on there
@Shawn-Williams
what's wrong with replace()?
gitSnake
@GitSnake
Jun 24 2016 02:39

Hi I'm stuck with the Word Blanks project. I have this:

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

// Your code above this line
return result;
}

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

Shawn Williams
@Shawn-Williams
Jun 24 2016 02:40
I just think that if you go through the trouble of placing a placeholder value in the string, such as x and y, then it is probably just as easy to replace that with ' + lat + ' and ' + long + ' and remove the replace method altogether.
var url = "api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon + "&APPID=5525405ab691940ebe96d2922ed50f6e";
V Arun Kumar
@arunvkumr
Jun 24 2016 02:45
@GitSnake add spaces between words.. you get output as dogbigranquickly make it as dog big ran quickly using spaces between words in result = mynoun + ... line.
David Halls
@DavidHalls
Jun 24 2016 02:45
@96street you need to put http:// at the start of the url
Josh
@joshweaver23
Jun 24 2016 02:45
Hey all, I'm looking for a little help with an angular app. I'm trying to implement a setInterval or $interval type function, but the problem is that I'm using angular 1.0.0... why? because I couldn't (for some reason) get my nested ng-repeats to work in any other version. A fix for either nesting ng-repeats in a later version or work-around for setInterval in 1.0.0 would be amazingly appreciated! CodePen: http://codepen.io/jweaver/pen/GqrKwr?editors=0010
96street
@96street
Jun 24 2016 02:49
@Byzgig fixed http://codepen.io/kingdezz/pen/pbRjPY?editors=1011 can you tell me why the code doesn't work
Jorge
@liberaltech
Jun 24 2016 02:51
http://codepen.io/liberaltech/pen/eZavVb?editors=0011
need help creating the computer player
Greg Munker
@Gmunker
Jun 24 2016 02:52
Hello everyone, I have a question about RegExp if anyone is available.
David Halls
@DavidHalls
Jun 24 2016 02:53
@96street your replace is not working
Diego Mayer
@Chrono79
Jun 24 2016 02:54
@Gmunker do it
Greg Munker
@Gmunker
Jun 24 2016 02:54
coo
96street
@96street
Jun 24 2016 02:54
How do you know? @Byzgig
Jorge
@liberaltech
Jun 24 2016 02:54
@96street your temp variable comes back undefined
Greg Munker
@Gmunker
Jun 24 2016 02:54
ok so RegExp is my splinter in my side with javascript and i know it's very powerful so i'm trying to understand it more...
David Halls
@DavidHalls
Jun 24 2016 02:55
@96street console.log(url);
url = url.replace('x', lat);
console.log(url);
because only one url is being printed to the console
Matt
@TheeMattOliver
Jun 24 2016 02:55
@gmunker what is your goal with RegExp right now?
Jorge
@liberaltech
Jun 24 2016 02:55
@96street correction, temp cant be found
Diego Mayer
@Chrono79
Jun 24 2016 02:55
@Gmunker if you want resources you can look at these:
help regex
CamperBot
@camperbot
Jun 24 2016 02:56

:point_right: js regex resources [wiki]

Regular Expressions Resources

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

Matt
@TheeMattOliver
Jun 24 2016 02:56
what type of short-term result are you trying to achieve in your code using RegExp? I'm by no means an expert but have found it useful in a couple of instances
96street
@96street
Jun 24 2016 02:56
@Byzgig why is only one URL being printed to the console..shouldn't replace() change the URL?
Greg Munker
@Gmunker
Jun 24 2016 02:56
i'm working on "Spinal Tap Case", and i know i needed to add a space before the uppercase letters, and i looked it up after hours of trying to figure it out and i can do it now, but i want to know why $1, and $2 replace with a space
96street
@96street
Jun 24 2016 02:56
Why can't temp be found? @liberaltech
Matt
@TheeMattOliver
Jun 24 2016 02:56
gotcha
Michael Karpinski
@karpimpski
Jun 24 2016 02:56
var answer = [];
var money = 0;

function checkChange(money){
  checkValue(100);
  checkValue(50);
  checkValue(20);
  checkValue(10);
  checkValue(5);
  checkValue(1);
  checkValue(.25);
  checkValue(.10);
  checkValue(.5);
  checkValue(.01);

  console.log(answer);
}

function checkValue(value){
  if(money/value >= 1){
    while(money/value >= 1){
      answer.push(value);
      money -= value;
    }
  }
}

var money = 11.36;
checkChange(money);
hey guys, just wrote up this code quick for a small change-counting app. can anybody find flaws in it? any missing bills or coins? (other than weird ones like a $2 bill)
Matt
@TheeMattOliver
Jun 24 2016 02:56
not quite there myself :)
Greg Munker
@Gmunker
Jun 24 2016 02:57
@TheeMattOliver Thanks anyways! :)
CamperBot
@camperbot
Jun 24 2016 02:57
gmunker sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Shawn Williams
@Shawn-Williams
Jun 24 2016 02:57
@Gmunker I found this website quite useful for testing regex https://regex101.com/
Matt
@TheeMattOliver
Jun 24 2016 02:57
you got it i think the regex101 is a radical site
wish i'd known about that one sooner
Greg Munker
@Gmunker
Jun 24 2016 02:57
@Chrono79 i have plenty of resources but for some reason i'm having trouble grasping what i just asked :/
Diego Mayer
@Chrono79
Jun 24 2016 02:58
@Gmunker write the complete code
$1 and $2 represent groups
Josh
@joshweaver23
Jun 24 2016 02:58
no angular pros? :(
Greg Munker
@Gmunker
Jun 24 2016 02:58
@Shawn-Williams yea i was on that site it's bookmarked, thanks!
CamperBot
@camperbot
Jun 24 2016 02:58
gmunker sends brownie points to @shawn-williams :sparkles: :thumbsup: :sparkles:
:cookie: 221 | @shawn-williams |http://www.freecodecamp.com/shawn-williams
Greg Munker
@Gmunker
Jun 24 2016 02:58
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  str = str.replace(/([a-z])([A-Z])/g, '$1 $2');

  return str;
}

spinalCase("AllThe-small Things");
David Halls
@DavidHalls
Jun 24 2016 02:58
Jorge
@liberaltech
Jun 24 2016 02:59
@96street why are you using + in your url?
Diego Mayer
@Chrono79
Jun 24 2016 02:59
@Gmunker the groups are the things inside the parentheses
so when you capture a lowercase letter followed by an uppercase letter it's replaced with the first, a space, and the capital letter
Greg Munker
@Gmunker
Jun 24 2016 02:59
i know it's not complete yet but i know what i need to do to complete it, the rest is nothing for me. I just want to know why $1, and $2 insert spaces heh
96street
@96street
Jun 24 2016 03:00
How do you know that's being printed? @Byzgig
Shawn Williams
@Shawn-Williams
Jun 24 2016 03:00
I recommend concatenating the url with the appropriate variables over the replace method
96street
@96street
Jun 24 2016 03:00
The '&' screws it up so had to @liberaltech
Shawn Williams
@Shawn-Williams
Jun 24 2016 03:00
@96street console.log(url);
Matt Stevens
@complementstudio
Jun 24 2016 03:00
Love this FreeCodeCamp, just found it ready to start contributing!
96street
@96street
Jun 24 2016 03:01
any reason why replace() isn't working on the URL @Shawn-Williams @Byzgig ?
Greg Munker
@Gmunker
Jun 24 2016 03:01
so is that what the $1 and $2 is ? $1 is the space and $2 is the uppercase?
this is whats screwing me up
Diego Mayer
@Chrono79
Jun 24 2016 03:01
@Gmunker no, $1 is the lowercase letter and $2 is the capital letter
([a-z]) first group, so $1
([A-Z]) second group, so $2
Jorge
@liberaltech
Jun 24 2016 03:02
@Byzgig i get the same with that url
Greg Munker
@Gmunker
Jun 24 2016 03:02
sorry if i sound annoying I just dont want to go through cause i looked it up, i want to understand so i can use it to it's fullest when i need to
and the space between them is the space?
'$1> < $2"
Diego Mayer
@Chrono79
Jun 24 2016 03:02
@Gmunker yes
Greg Munker
@Gmunker
Jun 24 2016 03:02
GOTCHA!
now it makes all the sense in the world!
Diego Mayer
@Chrono79
Jun 24 2016 03:03
you can rearrange people names like that
Greg Munker
@Gmunker
Jun 24 2016 03:03
damn kids and summer vacation! :(
screwing with my mind
Thank you very much @Chrono79
CamperBot
@camperbot
Jun 24 2016 03:03
gmunker sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1299 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 24 2016 03:03
For instance put last name first and such
Greg Munker
@Gmunker
Jun 24 2016 03:04
yea that is very powerful, so essentially you can use $1 through $whatever depending on how many are in the exp
David Halls
@DavidHalls
Jun 24 2016 03:04
@96street your positionError looks to be blocking it, make it last
Greg Munker
@Gmunker
Jun 24 2016 03:04
and use the $1 to replace with say $5
and it would swap them?
96street
@96street
Jun 24 2016 03:05
it only works in firefox @Byzgig
Diego Mayer
@Chrono79
Jun 24 2016 03:05
yes
Greg Munker
@Gmunker
Jun 24 2016 03:05
sexy
96street
@96street
Jun 24 2016 03:05
do you mean move the positionError function to the end?
Greg Munker
@Gmunker
Jun 24 2016 03:05
i know what i'll be practicing for a couple days
Thanks again! Feels great finally understanding something thats been a thorn for a while
Shawn Williams
@Shawn-Williams
Jun 24 2016 03:05
@96street
I'm not 100% sure why replace isn't working, but I believe it is an unnecessary step. Try instantiating the url variable like this and removing that altogether.
var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=5525405ab691940ebe96d2922ed50f6e";
Jorge
@liberaltech
Jun 24 2016 03:05
@96street separate your call structure
Diego Mayer
@Chrono79
Jun 24 2016 03:06
@Gmunker if you want to play a little with regexes try hackerrank challenges
Greg Munker
@Gmunker
Jun 24 2016 03:07
nice, just brought up the site, and it's bookmarked, maybe i'll bring the laptop to bed and play around a little :)
thanks!
96street
@96street
Jun 24 2016 03:08
@Shawn-Williams i'll try that
Shawn Williams
@Shawn-Williams
Jun 24 2016 03:09
@96street You could also use the approach shown in the link you provided. I like it as well.
var url = "http://api.openweathermap.org/data/2.5/weather?lat=";
    url += latitude;
    url += "&lon=";
    url += longitude;
    url += "&cnt=1";
That being said, It does add more lines of code.
96street
@96street
Jun 24 2016 03:10
@Shawn-Williams when I do your way
console.log(url) returns undefined
Shawn Williams
@Shawn-Williams
Jun 24 2016 03:11
hmm
David Halls
@DavidHalls
Jun 24 2016 03:12
well, i have it working, so looks like formatting issues
96street
@96street
Jun 24 2016 03:13
can you post codepen or image?
David Liendo
@DavLiendoProgramming
Jun 24 2016 03:14
i know... this sounds silly but idk what i am doign wrong
x.x
var myStr="Here is a backslash:\.\n\t\t Here is a new line with two tabs."
step 144 ...
if somebody could help me please
x:
lpcavenaghi
@lpcavenaghi
Jun 24 2016 03:23
Hello everyone!
I want your feedback on my solution to Caesars Cipher challenge:

function rot13(str) { // LBH QVQ VG!
  return str.replace(/[A-Z]/g, function(val) {
    var charCode = val.charCodeAt(0);
    charCode += (charCode <= 77) ? 13 : -13;
    return String.fromCharCode(charCode); 
  });
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Greg Munker
@Gmunker
Jun 24 2016 03:23
have a good night and thanks again!
96street
@96street
Jun 24 2016 03:23
@Byzgig ? can you show me the codepen you have working?
Samuel Cupidon
@Zerazera
Jun 24 2016 03:25
@lpcavenaghi Here's my solution.
function rot13(str) { // LBH QVQ VG!
  const alphabet = Array.from(new Array(26), (x,i) => String.fromCharCode(i + 'A'.charCodeAt(0)));
  const rot13arr = alphabet.slice(13).concat(alphabet.slice(0, 13));
  return str.split('').map(x => (rot13arr.indexOf(x) !== -1) ? alphabet[rot13arr.indexOf(x)] : x).join('');
}
lpcavenaghi
@lpcavenaghi
Jun 24 2016 03:27
@Zerazera Nice :smile:
Shawn Williams
@Shawn-Williams
Jun 24 2016 03:29
@Zerazera Breakin out the ECMA2016 ;)
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:29
var myStr = "Here is a backlash:\. \n\t\tHere is a new line with two tabs."; // Change this line
What in the world is wrong with that lol
@samfitz1 / has to be escaped too
i meant \
Todd
@TheOnlyRealTodd
Jun 24 2016 03:31

Hey guys anyone see what Im doing wrong here... This is the Profile Lookup lesson...```
function lookUpProfile(firstName, prop){
// Only change code below this line
for ( i = 0; i < contacts.length; i++)
if (contacts[i] == firstName){
if (contacts[i].hasOwnProperty[prop])
{
return prop;
}
else{
return "No such property";
}}
else
return "No such contact";

// Only change code above this line
}```

David Halls
@DavidHalls
Jun 24 2016 03:32
return prop; should be contacts[i][prop]
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:32
It is on my screen, just din't show up when I pasted it. Not sure why.
"Here is a backlash:
David Halls
@DavidHalls
Jun 24 2016 03:33
@samfitz1 there needs to be a space after :
96street
@96street
Jun 24 2016 03:33
@Byzgig that's the same thing i linked..?
Todd
@TheOnlyRealTodd
Jun 24 2016 03:33
@Byzgig thanks
CamperBot
@camperbot
Jun 24 2016 03:33
theonlyrealtodd sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 357 | @byzgig |http://www.freecodecamp.com/byzgig
David Halls
@DavidHalls
Jun 24 2016 03:33
```
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:34
Hmm.. This is exactly what I have now.
David Halls
@DavidHalls
Jun 24 2016 03:34
```
help format
CamperBot
@camperbot
Jun 24 2016 03:34

: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

Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:34
var myStr = "Here is a backlash: \. \n\t
David Halls
@DavidHalls
Jun 24 2016 03:34
function showPosition(pos) {
 lat = pos.coords.latitude;
 lon = pos.coords.longitude;
  APPID = '5525405ab691940ebe96d2922ed50f6e';
// console.log( lat + " : " + lon);
  var url = "http://api.openweathermap.org/data/2.5/weather?lat=x&lon=y" + "&APPID=5525405ab691940ebe96d2922ed50f6e";
  // console.log(url);
  url = url.replace('x', lat).replace('y', lon);
$.get(url, function(data) {
  console.log(data);
  var city = data.name;
  var temp = data.main.temp;
  document.getElementById('city').innerHTML = city;
  document.getElementById('weather').innerHTML = temp;
});
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:34
n\t\t Here is a new line with two tabs."
Jorge Castaño Delgado
@jhcastanod
Jun 24 2016 03:35
@samfitz1 the space and the backslach after it ...is a backslash: \.\n\t\Here...
David Halls
@DavidHalls
Jun 24 2016 03:35
@samfitz1 no spaces between escaped chars
96street
@96street
Jun 24 2016 03:35
what did you change? @Byzgig
David Halls
@DavidHalls
Jun 24 2016 03:36
i moved stuff up into the showPosition function, you had it outside of it and it wasnt giving values to lat and lon
96street
@96street
Jun 24 2016 03:37
right
is that because you can't access lat and lon outside of the showPosition() function?
Todd
@TheOnlyRealTodd
Jun 24 2016 03:37
@Byzgig js for ( i = 0; i < contacts.length; i++) if (contacts[i] == firstName){ if (contacts[i].hasOwnProperty[contacts[i][prop]]) { return contacts[i][prop]; } else{ return "No such property"; }} else return "No such contact";
hows this? Its till throwing me an error
96street
@96street
Jun 24 2016 03:38
also you changed getJSON to just get @Byzgig why/wat does that change
David Halls
@DavidHalls
Jun 24 2016 03:41
@TheOnlyRealTodd your for loop does not have { }
96street
@96street
Jun 24 2016 03:42
yesssss it's working
thanks heaps @Byzgig
CamperBot
@camperbot
Jun 24 2016 03:42
96street sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 358 | @byzgig |http://www.freecodecamp.com/byzgig
Lemmy
@imnotlammy
Jun 24 2016 03:42
Hi all!

function diffArray(arr1, arr2) {
  var newArr = [];

  for (i=0;i<arr1.length;i++) {
    //newArr.push(short.indexOf(long[i]));

    if (arr2.indexOf(arr1[i]) < 0) {
      newArr.push(arr1[i]);
    }
  }

  for (i=0;i<arr2.length;i++) {
    if (arr1.indexOf(arr2[i]) < 0) {
      newArr.push(arr2[i]);
    }
  }

  return newArr;

}

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
I finished this assignment using 2 for loops
can anyone tell me how I can do it using the filter() method instead?
An Van
@vxba
Jun 24 2016 03:44
Hi all !
How to change dialog of OnBeforeUnload function in javascrip?
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:45
Guys this code isn't working, and I'm pretty sure it is right... :(
var myStr = "Here is a backslash: \.\n\t\tHere is a new line with two tabs";
```
clintonjohn
@clintonjohn
Jun 24 2016 03:46
@imnotlammy how do you put in a snippet like that. When I cut and paste it just comes out plain on here
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:47
@clintonjohn That's a codepen file
or not
lol
Lemmy
@imnotlammy
Jun 24 2016 03:47
help format
CamperBot
@camperbot
Jun 24 2016 03:47

: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

Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:47
@clintonjohn Scratch what I said
Lemmy
@imnotlammy
Jun 24 2016 03:47
@clintonjohn help format
like this
```
code in here
```
clintonjohn
@clintonjohn
Jun 24 2016 03:51
@imnotlammy thx
CamperBot
@camperbot
Jun 24 2016 03:51
clintonjohn sends brownie points to @imnotlammy :sparkles: :thumbsup: :sparkles:
:cookie: 100 | @imnotlammy |http://www.freecodecamp.com/imnotlammy
An Van
@vxba
Jun 24 2016 03:51
@camperbot How to change dialog of OnBeforeUnload function in javascrip?
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:51
'''
Whoa
CamperBot
@camperbot
Jun 24 2016 03:51
:bulb: to format code use backticks! ``` more info
David Halls
@DavidHalls
Jun 24 2016 03:52
help OnBeforeUnload
CamperBot
@camperbot
Jun 24 2016 03:52
no wiki entry for: onbeforeunload
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:52
'''
Superduper code
CamperBot
@camperbot
Jun 24 2016 03:52
:bulb: to format code use backticks! ``` more info
Samuel Fitzsimmons
@samfitz1
Jun 24 2016 03:52
Ohhh... backticks not ''' lol
CamperBot
@camperbot
Jun 24 2016 03:52
:bulb: to format code use backticks! ``` more info
clintonjohn
@clintonjohn
Jun 24 2016 03:57
``` "thanks"
jeffreychingchan
@jeffreychingchan
Jun 24 2016 03:58
dang this is confusing
clintonjohn
@clintonjohn
Jun 24 2016 03:59
"wow"
Peter Weinberg
@no-stack-dub-sack
Jun 24 2016 03:59
any advice here? trying to set an interval so that the showTime() function is called every few seconds (5 for now so easy to tell when it's working) so that the time gets updated if the user stays on the site. I'd like to use the same method to set a longer interval for the weather to update as well, but for some reason can't get it to work... this is only a snippet, document.ready is closed on my pen. see pen for full code http://codepen.io/no_stack_dub_sack/pen/rLMbWG
$(document).ready(function() {
  var cond = "";
  var time = new Date();
  var hour = time.getHours();
  var clockHr = time.getHours();
  var clockMin = time.getMinutes();
  var seconds = time.getSeconds();
  var suffix = "";
  var aOrP = "";
  hourCorrect(hour);
  minCorrect(clockMin);
  showTime();


  function hourCorrect(num) {
    if (num > 12) {
      clockHr = (clockHr - 12)
      aOrP = "PM"
    } else {
      clockHr = clockHr
      aOrP = "AM"
    }
  }

  function minCorrect(num) {
    if (num < 10) {
      return clockMin = "0" + clockMin;
    }
  }

  function showTime() {
    document.getElementById("clockTime").innerHTML = (clockHr + ":" + clockMin + ":" + seconds + " " + aOrP);
  }

  setInterval(showTime, 5000);
clintonjohn
@clintonjohn
Jun 24 2016 04:02
hello backtick
iphone keyboard
Peter Weinberg
@no-stack-dub-sack
Jun 24 2016 04:04
I also tried just putting the contents of the showTime() function in the setInterval like:
setInterval(function() {
     contents here
}, 5000);
Anuj Upadhyay
@anuj97
Jun 24 2016 04:05
this was confusing to me too
Peter Weinberg
@no-stack-dub-sack
Jun 24 2016 04:08
i also tried exactly like above but calling the function with showTime() instead. I also tried using window.setInterval in all the same ways, as well as changing where the interval code actually was (e.g. moved to the top where all the global vars are). If I don't call the function outside of the interval, the interval begins to work - the time doesn't show up for 5 seconds, but then it doesn't refresh after another 5 seconds.
Greg Duncan
@GregatGit
Jun 24 2016 04:39
@no-stack-dub-sack i set up var myTimeKeeper and used that as setInterval so it could be passed around, used in different functions - stopped and restarted
christianws
@christianws
Jun 24 2016 04:41
Hello guys I'm on 'no repeats please' I have no idea where to go
Greg Duncan
@GregatGit
Jun 24 2016 04:54
@no-stack-dub-sack
var mytime = setInterval(function(){
    seconds++;
    $("#clockTime").html(clockHr + ":" + clockMin + ":" + seconds + " " + aOrP);
  }, 1000);
Kris Blanchette
@Aurorikin
Jun 24 2016 04:54
I'm having trouble with 146. I've gone over it over and over and searched for help and I cannot come up with anything. This is my code
var myStr = "Here is a backslash: \ .\n \t\t Here is a new line with two tabs."; // Change this line
Greg Duncan
@GregatGit
Jun 24 2016 04:56
@Aurorikin what is it called
Kris Blanchette
@Aurorikin
Jun 24 2016 04:56
Escape Sequence in Strings
UtkarshShukla7
@UtkarshShukla7
Jun 24 2016 04:56
@Aurorikin var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs.";
Kris Blanchette
@Aurorikin
Jun 24 2016 04:57
Ohh I was giving it too many spaces!
I see.. thank you :)
UtkarshShukla7
@UtkarshShukla7
Jun 24 2016 04:57
np
RAJESH KUMAR
@raz281389
Jun 24 2016 04:58

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

Kris Blanchette
@Aurorikin
Jun 24 2016 04:58
Also, how do I enter code into the chat all clean like @GregatGit
RAJESH KUMAR
@raz281389
Jun 24 2016 04:58
can someone help with the above challenge
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 04:58
@raz281389 did you undersand the question?
RAJESH KUMAR
@raz281389
Jun 24 2016 04:58
Nope
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 04:59
arr=[1,2,3,4,5] should remove the 1st item and add the item to the last
so, the array will be [2,3,4,5,6]
RAJESH KUMAR
@raz281389
Jun 24 2016 04:59
ok
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 04:59
to remove the 1st property, you've arr.shift
and to add an elemnt to the last you've push
so,you try to figure out which to use 1st
RAJESH KUMAR
@raz281389
Jun 24 2016 05:00
ok Thanks
silver537
@silver537
Jun 24 2016 05:07
@raz281389 you have to push() in the value that you shift().
Eric Bezanson
@ericbezanson
Jun 24 2016 05:09
can someone help me with where im going wrong in "find the longest word in a string"?
function findLongestWord(str) {
  var arr = str.split(" ");
  var check = 0;
  var longest;


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

findLongestWord("The quick brown fox jumped over the lazy dog");
David Halls
@DavidHalls
Jun 24 2016 05:10
longest will always be the last word
Eric Bezanson
@ericbezanson
Jun 24 2016 05:11
@Byzgig but wouldnt it only get assigned to a word that is bigger then arr[i] ?
since if the next word in the loop is smaller then it would not run through the if statement
David Halls
@DavidHalls
Jun 24 2016 05:11
no, it is getting assigned to arr[i] ... longest = arr[i]
silver537
@silver537
Jun 24 2016 05:11
I dont think you have to split.
Eric Bezanson
@ericbezanson
Jun 24 2016 05:12
hmm well what im trying to do is have it run the if statemnt only if arr[i] is greater then the check var
David Halls
@DavidHalls
Jun 24 2016 05:14
i dint see the if, let me look again
Eric Bezanson
@ericbezanson
Jun 24 2016 05:14
the check var starts at 0 but is set to the value of the first item and then if the next item is bigger then the check var vhanges
David Halls
@DavidHalls
Jun 24 2016 05:17
what is the length of arr[i][0]? what is the length of check? will arr[i].length < check ever be true
Eric Bezanson
@ericbezanson
Jun 24 2016 05:18
hmm my understanding is arr[i].length is the number of characters in the current item of the array
David Halls
@DavidHalls
Jun 24 2016 05:18
true so lets say its 5, what is the value of check on the first loop?
Eric Bezanson
@ericbezanson
Jun 24 2016 05:19
the first loop the value of check is 0 so since 5 is greater then 0 check becomes 5 and longest becomes whatever word had the 5 characters
David Halls
@DavidHalls
Jun 24 2016 05:20
no, you say if(arr[i].length 5 < check 0, if true it enters the loop, if false it moves on
Alex T.
@lx-t
Jun 24 2016 05:20
@ericbezanson Why do you assign longest when you found a word which length is less than check? Also the initial value of check is 0. It's impossible to find a word that is shorter than 0 length.
Jill DeBiase
@jilldebiase
Jun 24 2016 05:21
when iterating over arrays w/ map i keep returning oldArray [1,2,3,4,5] without 3 added to each value as the callback function
var oldArray = [1,2,3,4,5];

// Only change code below this line.

var plusThree = oldArray.map(function(val) {
   return val + 3; //add 3 to each value in oldarray
  });

var newArray = oldArray;
why isn’t it returning the array w/ values + 3?
silver537
@silver537
Jun 24 2016 05:21
Because use declared it as plusthree and not newarray
Eric Bezanson
@ericbezanson
Jun 24 2016 05:21
@lx-t ah my greater than sign is the wrong way im assuming then haha
Jill DeBiase
@jilldebiase
Jun 24 2016 05:22
@silver537 ah there it is. thank you!
CamperBot
@camperbot
Jun 24 2016 05:22
jilldebiase sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @silver537 |http://www.freecodecamp.com/silver537
Alex T.
@lx-t
Jun 24 2016 05:23
@ericbezanson Yep. It looks like just a simple math problem.
Thomas hadley
@Thadley17
Jun 24 2016 05:23

Hey I have a quick question regarding the "Return Early Pattern for Functions" exercise. It wants us to make the function return undefined if a or b is less than zero. I wrote an if statement like such

if(a || b < 0){
  return undefined;
}

It's correcting the two that need to be undefined but the rest no longer work. What am I missing? Just looking for some guidance :)

Eric Bezanson
@ericbezanson
Jun 24 2016 05:23
@lx-t @Byzgig yep it looks like the logic was correct it was just a syntax error < should have been > hahaha thanks @lx-t thanks @Byzgig
CamperBot
@camperbot
Jun 24 2016 05:23
ericbezanson sends brownie points to @lx-t and @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @lx-t |http://www.freecodecamp.com/lx-t
:cookie: 359 | @byzgig |http://www.freecodecamp.com/byzgig
Alex T.
@lx-t
Jun 24 2016 05:25
@Thadley17 You check against a is true or b is less than 0
96street
@96street
Jun 24 2016 05:26

Why isn't my Faranheit > Celcius working? http://codepen.io/kingdezz/pen/pbRjPY

(only works in firefox)

Dany Din
@danydin
Jun 24 2016 05:26
@silver537 in jill code isn't old array stay [1,2,3,4,5] because she saves it in another var so the orginial not changed, and after that she implies the old to the new so even if she chnage the plushThree to newArray if the last line stays it will go back to the original array no?
96street
@96street
Jun 24 2016 05:26
(only works in firefox btw)
silver537
@silver537
Jun 24 2016 05:28
na it creates a new one. but you can return it without assigning it.
David Halls
@DavidHalls
Jun 24 2016 05:28
@96street it returns the temp in kelvin, you need to convert it to C or F first
Thomas hadley
@Thadley17
Jun 24 2016 05:29
@lx-t Thank you sir. I just wasn't understanding how to write the conditional statement. I got it to work
CamperBot
@camperbot
Jun 24 2016 05:29
thadley17 sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @lx-t |http://www.freecodecamp.com/lx-t
96street
@96street
Jun 24 2016 05:29
right
do you know why the current function isn't working though? @Byzgig
Alex T.
@lx-t
Jun 24 2016 05:30
@Thadley17 You're welcome. I guess you just wrote the condition in a human language. :)
@96street It doesn't work 'cause your $weather is not a number. It's an object.
David Halls
@DavidHalls
Jun 24 2016 05:34
what is the value of $weather?
Thomas hadley
@Thadley17
Jun 24 2016 05:35
@lx-t You bet I did lol. It doesn't help it's 1:30 and once again I appreciate you pointing me in the right direction :)
Alex T.
@lx-t
Jun 24 2016 05:37
@96street var $weather = $('#weather'). $('#someID') returns an HTML element, not it's content.
@96street Although even if you got it's content you couldn't do math with something like 296.842 °F because it's still not a number. Maybe you can use a variable in your JavaScript to store a temperature value?
Chris Cuevo
@ccuevo
Jun 24 2016 05:42
for the palindrome problem, i'm not sure why my code isn't removing all non-alphanumeric characters :(
function palindrome(str) {
  var filtered = str.replace(/[^a-z0-9+]+/gi, '').toLowerCase();
  return filtered.split("").reverse().join("");
}
96street
@96street
Jun 24 2016 05:46
so assuming there is no F(o) @lx-t would $weather.value get the value?
David Halls
@DavidHalls
Jun 24 2016 05:49
why not use the temp number you got from the api
Eric Bezanson
@ericbezanson
Jun 24 2016 05:54
@ccuevo i used \W_ for anything thats not a word anything thats a digit and any white space as well as underscores
Chris Cuevo
@ccuevo
Jun 24 2016 05:59
thanks @ericbezanson !
CamperBot
@camperbot
Jun 24 2016 05:59
ccuevo sends brownie points to @ericbezanson :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @ericbezanson |http://www.freecodecamp.com/ericbezanson
Ahmed Shaaban
@AhmedShab
Jun 24 2016 06:09

Hey guys, hope all is well :smile:
I have a question regarding React as my main framework
The thing is I have finally managed to use React with Webpack and running it in express, but I have a new problem I can't seems to understand. If you are (e.g) using passport for authentication. Usually you would redirect template but how can you do such thing when there are no views in the server side while using react?

All I need to understand(was tryiong to say) is how would you render a dom complement in the server side while you have a SPA. Like Okay, how can you prevent a user from going to protected router using SPA and how can you display a flash message if they are not have successful signed in?

I know how to do all of that with View engine but trying to learn ReactJs

omega-lova
@omega-lova
Jun 24 2016 06:18

Iterate over arrays with Map
page link [Iterate over arrays with Map] (https://www.freecodecamp.com/challenges/iterate-over-arrays-with-map#?solution=%0Avar%20oldArray%20%3D%20%5B1%2C2%2C3%2C4%2C5%5D%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line.%0Avar%20newArray%20%3D%20oldArray.map(function(add)%7B%0A%20%20return%20add%20%2B%3D%203%3B%0A%7D)%3B)

var timesFour = oldArray.map(function(val){ return val * 4; });

how come the example demonstrated

return val *4;

instead of

return val *= 4;   

code below doesn't pass

var oldArray = [1,2,3,4,5];
var newArray = oldArray.map(function(add){
return add + 3;
});
silver537
@silver537
Jun 24 2016 06:20
it can be either way., no?
You need to return newArray.
David Halls
@DavidHalls
Jun 24 2016 06:24
add?
huh?
looks just like mine ane mine passes
and copy paste your code works for me, maybe copy, reset and paste
silver537
@silver537
Jun 24 2016 06:28
Im not on my comp. But im pretty sure its inside a function. And the function has to return so value. It looks like @omega-lova doesnt have a return statement
David Halls
@DavidHalls
Jun 24 2016 06:29
i didnt see it was a two part ??
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:30
@omega-lova you'll have to return the newArray
David Halls
@DavidHalls
Jun 24 2016 06:30
it could just be the specifics of the testing program, they are looking for val * 4 and that is it
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:30
@omega-lova and your newaarray will be [4,5,6,7,8]
Riadh
@KWFE
Jun 24 2016 06:32
hey
may i ask
how to start with js
TanayD
@TanayD
Jun 24 2016 06:33
guys need help

function findLongestWord(str) {

var ans=str.split(' ');
var ans1=ans[0];
for(var i=1;i<=ans.length;i++){
if(ans1.length<ans[i].length){
ans1=ans[i];
}
}

return ans1.length;
}

what is wrong with this?
this is the error i am getting - cannot read property 'length of undefined'
David Halls
@DavidHalls
Jun 24 2016 06:35
try ans1 = ans[i].lenght
spelled right obvi
TanayD
@TanayD
Jun 24 2016 06:35
@Byzgig tried it but same error
David Halls
@DavidHalls
Jun 24 2016 06:35
var i = 0
TanayD
@TanayD
Jun 24 2016 06:36
nope, still same error
David Halls
@DavidHalls
Jun 24 2016 06:36
challenge name
TanayD
@TanayD
Jun 24 2016 06:36
Find the Longest Word in a String
CamperBot
@camperbot
Jun 24 2016 06:36

find the longest word in a string

:zero: algorithm find the longest word in a string

David Halls
@DavidHalls
Jun 24 2016 06:38
post new code
it doesnt want a length return, it wants a word
christianws
@christianws
Jun 24 2016 06:39

can someone explain to me how you can loop through values e.g. 1-10 but start at e.g. 6?

so that some code will go through 6-10 and then go from 0-5

David Halls
@DavidHalls
Jun 24 2016 06:39
nvm
TanayD
@TanayD
Jun 24 2016 06:39
the question says that the answer should be a number
christianws
@christianws
Jun 24 2016 06:39
I saw somewhere a clever way of using the % operator for this can anyone help?
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:40
@CurlyWS what? 6 to 10 and then 0 to 5?
increment operator i=(i+1)%10 may work?
kirbyedy
@kirbyedy
Jun 24 2016 06:40
@TanayD this line is confusing for me: var ans1=ans[0];
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:40
initialise to i=6?
David Halls
@DavidHalls
Jun 24 2016 06:40
ans.lenght is 9
christianws
@christianws
Jun 24 2016 06:41

@Krish2704 so lets say you have values 'abcd'

I want to loop through from b-a (b,c,d,a)

how do I do this ?

DJ
@qualitymanifest
Jun 24 2016 06:41
ding ding :point_up:
@Krish2704 yeah either of those ideas will work if you implement them right
David Halls
@DavidHalls
Jun 24 2016 06:42
@TanayD ans.length is 9 > any word
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:42
@CurlyWS for(i=1;;(++i)%length)
@qualitymanifest yup. i know
TanayD
@TanayD
Jun 24 2016 06:42
@kirbyedy i am deriving it from the algorithm to find the largest number from the array where you assign the first element to some variable and the compare it all other numbers and swap it values if the number is greater than variable
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:42
@CurlyWS and for the condition part, dont give anything
renewu0707
@renewu0707
Jun 24 2016 06:43
Anyone can help? why the mutation challenge doesn't pass?
christianws
@christianws
Jun 24 2016 06:43
@Krish2704 thanks man. I can see it works but not sure why
CamperBot
@camperbot
Jun 24 2016 06:43
:cookie: 441 | @krish2704 |http://www.freecodecamp.com/krish2704
curlyws sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
renewu0707
@renewu0707
Jun 24 2016 06:43

function mutation(arr) {
var arr0 = arr[0].toLowerCase();
var arr1 = arr1.toLowerCase();

for(var i = 0; i < arr1.length; i++){
   if(!arr0.indexOf(arr1[i])){
     return false;
   }    
}
return true; 

}

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

Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:43
@CurlyWS inside your loop give the condition with some other variable(j), like if(j===str.length) then break
Sujal
@Sujal3757
Jun 24 2016 06:43
hello everyone
TanayD
@TanayD
Jun 24 2016 06:43
@Byzgig i have converted the string into array of words and the string is of 9 words
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:43
and initialize j=0
omega-lova
@omega-lova
Jun 24 2016 06:43
@silver537 @Krish2704 it works like a charm.. derp another return of course thanks you guys!
CamperBot
@camperbot
Jun 24 2016 06:43
omega-lova sends brownie points to @silver537 and @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 361 | @silver537 |http://www.freecodecamp.com/silver537
:cookie: 442 | @krish2704 |http://www.freecodecamp.com/krish2704
martinronquillo
@martinronquillo
Jun 24 2016 06:43
So I was having trouble on switch statements in JavaScript and I go to one of the previous excersizes to refer to and all the code is gone. How can i fix this, to where the code I once typed is displayed?
David Halls
@DavidHalls
Jun 24 2016 06:44
@TanayD lol you need a spcae, tyr str.split(" there is a space here");
Sujal
@Sujal3757
Jun 24 2016 06:44

i have a problem in this part can anyone help me:-

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) 
{
  // Your Code Here

  if(myObj.hasOwnProperty("checkProp"))
  {
     var abc=myObj.checkprop;
     return abc;
  }

else

  {
      return "not Found";
   }
}
// Test your code by modifying these values
checkObj("gift");

i cant display object value.

TanayD
@TanayD
Jun 24 2016 06:44
i did
David Halls
@DavidHalls
Jun 24 2016 06:45
help format
CamperBot
@camperbot
Jun 24 2016 06:45

: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

David Halls
@DavidHalls
Jun 24 2016 06:45
@TanayD post your code like ^^^
Norberto
@nortocode
Jun 24 2016 06:45
@Sujal3757 try removing the quotes here if(myObj.hasOwnProperty("checkProp"))
kirbyedy
@kirbyedy
Jun 24 2016 06:45
@Sujal3757 is checkProp a string ?
christianws
@christianws
Jun 24 2016 06:46
@Krish2704 can you explain to me that code please Krishna
Sujal
@Sujal3757
Jun 24 2016 06:46
@kirbyedy yes
Norberto
@nortocode
Jun 24 2016 06:46
@Sujal3757 var abc=myObj.checkprop; and this line I dont' think is working either
TanayD
@TanayD
Jun 24 2016 06:46
 function findLongestWord(str) {

  var ans=str.split(' ');
  var ans1=ans[0];
 /* for(var i=0;i<=ans.length;i++){
    if(ans1<ans[i].length){
      ans1=ans[i];
    }
  }
  */
  return ans.length;
}
ignore that comment
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:47
@CurlyWS you know how a normal loop works?
christianws
@christianws
Jun 24 2016 06:47
@Krish2704 yeah
Barış Kaşıkırık
@kasikirik
Jun 24 2016 06:48

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

  // Only change code below this line

  var phoneticLookup = {
    "alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy",         "foxtrot": "Frank"
  };

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

// Change this value to test
phoneticLookup("charlie");
What's wrong here?
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:48
var j=0;
for(var i=0;j<arr.length;(++i)%10)
{
 //your code
j++;
}
kirbyedy
@kirbyedy
Jun 24 2016 06:48
@Sujal3757 the way you wrote means you are looking for string named "checkProp"
Barış Kaşıkırık
@kasikirik
Jun 24 2016 06:49
I did not get much about object.
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:49
@CurlyWS i= 1 not 0
and modulus your arr length
Norberto
@nortocode
Jun 24 2016 06:50
@kasikirik you are returning just an empty string
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:50
so, your condition to exit the loop is with a new variable j, beccause you've go through the whole array and again comeback to the begging,so you can't do it with 'i'
since 'abcd' you've to move from b to a, so you should loop the array length times
Barış Kaşıkırık
@kasikirik
Jun 24 2016 06:50
@nortocode I need you to say more about it
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:51
so i declared a new variable and for condition chekc i used j< arr.length
renewu0707
@renewu0707
Jun 24 2016 06:51
anyone could help with the mutation string challenge?

function mutation(arr) {
var arr0 = arr[0].toLowerCase();
var arr1 = arr1.toLowerCase();

for(var i = 0; i < arr1.length; i++){
   if(!arr0.indexOf(arr1[i])){
     return false;
   }    
}
return true; 

}
mutation(["Mary", "Aarmy"]);

Norberto
@nortocode
Jun 24 2016 06:52
@kasikirik I don't know what's the code expecting to do, if you can tell me I'll try to help
Sujal
@Sujal3757
Jun 24 2016 06:52
@kirbyedy we are given a string "gift" whereas we have to get value from variable gift, so what can be done in this situation
christianws
@christianws
Jun 24 2016 06:53
@Krish2704 that's real spart I like it
*smart
Barış Kaşıkırık
@kasikirik
Jun 24 2016 06:53
@nortocode Using Objects for Lookups
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

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

  // Only change code below this line

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

// Change this value to test
phoneticLookup("charlie");
christianws
@christianws
Jun 24 2016 06:55
@Krish2704 so what is the reason for using (++i) and not (i++) ?
Norberto
@nortocode
Jun 24 2016 06:55
@kasikirik oh, someting like if phoneticLookup hasOwnProperty (val) return the value of that property then
pahosler
@pahosler
Jun 24 2016 06:55
this works but I feel like there should be a better way to do this, thoughts???
function palindrome(str) {
  var strCopy=str=str.toLowerCase();
  var re = /[a-z0-9]+/g;
  var re2 = /\S/g;
  var strArr= strCopy.match(re);
  str=strCopy=strArr.join('');
  strArr = strCopy.match(re2);
  strArr=strArr.reverse();
  strCopy = strArr.join('');
  if (str === strCopy) {
     return true;
  }else { 
    return false;
  }
}
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 06:56
@CurlyWS i++ is post increment and ++i is preincrement, i++ will do the operation first and then increment, whereas ++i will first increment and then do the operation, here the operation is modulus
Norberto
@nortocode
Jun 24 2016 06:56
@renewu0707 what's arr1.toLowerCase() ?
Jonathan Mitchell
@Vanhealen
Jun 24 2016 06:56
@pahosler I have an easier way
Sujal
@Sujal3757
Jun 24 2016 06:56
@kirbyedy i think i got through by assigning that string to the var.. here is how i did it but want to know is there other way to do it too:-
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) 
{
  // Your Code Here
  var item=checkProp;
  if(myObj.hasOwnProperty(item))
  {  
     var abc=myObj[item];
     return abc;
  }

else

  {
      return "Not Found";
   }
}
// Test your code by modifying these values
checkObj("gift");
christianws
@christianws
Jun 24 2016 06:56
@Krish2704 ok man thanks a lot !
CamperBot
@camperbot
Jun 24 2016 06:56
:warning: curlyws already gave krish2704 points
curlyws sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
Jonathan Mitchell
@Vanhealen
Jun 24 2016 06:57
simply do if (str === str.split('
str.split.reverse().join
that will evaluate whether they are the same
split.reverse().join
renewu0707
@renewu0707
Jun 24 2016 06:57
@nortocode transform string arr1 to low characters
pahosler
@pahosler
Jun 24 2016 06:57
@Vanhealen nice!
Norberto
@nortocode
Jun 24 2016 06:58
@renewu0707 yes, but what is arr1 ?
if it's an array it won't work
David Halls
@DavidHalls
Jun 24 2016 07:00
@TanayD you still working in this?
Markus Kiili
@Masd925
Jun 24 2016 07:05
@Sujal3757 You can drop all the variable declarations:
function checkObj(checkProp) {
  if(myObj.hasOwnProperty(checkProp)) return myObj[checkProp];
  return "Not Found";
}
Also, there is no reason to make a copy of the parameter var item=checkProp; because the passed string is a primitive value and thus already copied to the function parameter. With objects, like arrays, you sometimes make a copy, so you don't mutate the original array.
renewu0707
@renewu0707
Jun 24 2016 07:06
@nortocode it's a string
Olly Sholotan
@Ollysho
Jun 24 2016 07:08
I basically have zero idea for what to do in the Word Blanks excercise
I'm just so lost haha
Anyone care to help?
Norberto
@nortocode
Jun 24 2016 07:09
@renewu0707 I need the full code then to help
Markus Kiili
@Masd925
Jun 24 2016 07:09
@pahosler You can make the code shorter and easier to read by chaining some methods:
function palindrome(str) {
  str = str.replace(/[\W_]/g,"").toLowerCase();
  return str.split("").reverse().join("")===str;  
}
Sujal
@Sujal3757
Jun 24 2016 07:09
@Masd925 thanks
CamperBot
@camperbot
Jun 24 2016 07:09
sujal3757 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1968 | @masd925 |http://www.freecodecamp.com/masd925
Olly Sholotan
@Ollysho
Jun 24 2016 07:10

'''

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

// Your code above this line
return result;
}

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

CamperBot
@camperbot
Jun 24 2016 07:10
:bulb: to format code use backticks! ``` more info
Olly Sholotan
@Ollysho
Jun 24 2016 07:10

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


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
christianws
@christianws
Jun 24 2016 07:11
@Krish2704
yo man sorry to ask again but why do you think this isn't printing what I want?

var j=0;
for(var i=4;j<5;(++i)%5)
{
 //your code
 console.log(i);
j++;
}
renewu0707
@renewu0707
Jun 24 2016 07:11
@nortocode thx Norberto, i fixed, i considered -1 as false, which was incorrect.
CamperBot
@camperbot
Jun 24 2016 07:11
renewu0707 sends brownie points to @nortocode :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @nortocode |http://www.freecodecamp.com/nortocode
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 07:12
@CurlyWS your code will print 4,0,1,2,3
Markus Kiili
@Masd925
Jun 24 2016 07:12
@CurlyWS (++i)%5 calculates a modulo but you are not doing anything with the result.
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 07:12
no wait!
christianws
@christianws
Jun 24 2016 07:13
it is printing
4
5
6
7
8
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 07:16
@CurlyWS (++i)%5 is just an increment operator
remove that in the for statement
and add i=++i%5 inside the for statement
Markus Kiili
@Masd925
Jun 24 2016 07:17
@CurlyWS You are putting complicated logic (incrementing two values and a condition) to a for loop. That is usually a bad idea. Use while loop instead so the logic is easier to see.
sigursiguros
@sigursiguros
Jun 24 2016 07:17
Hi guys, would you mind helping me with my updateInventory algo

{

function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you're fired!
for (var i = 0; i<4; i++){
for (var j = 0; j<4; j++){
if (arr2i == arr1j){
arr1[j][0] = arr1[j][0] + arr2[i][0];}
else {
arr1.push(arr2[i]);
}
}
}
return arr1;
}

// Example inventory lists
var curInv = [
[21, "Bowling Ball"],
[2, "Dirty Sock"],
[1, "Hair Pin"],
[5, "Microphone"]
];

var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];

updateInventory(curInv, newInv);
}

christianws
@christianws
Jun 24 2016 07:18
@Masd925 ok can you give me an example?
sigursiguros
@sigursiguros
Jun 24 2016 07:18

`

function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you're fired!
for (var i = 0; i<4; i++){
for (var j = 0; j<4; j++){
if (arr2i == arr1j){
arr1[j][0] = arr1[j][0] + arr2[i][0];}
else {
arr1.push(arr2[i]);
}
}
}
return arr1;
}

// Example inventory lists
var curInv = [
[21, "Bowling Ball"],
[2, "Dirty Sock"],
[1, "Hair Pin"],
[5, "Microphone"]
];

var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];

updateInventory(curInv, newInv);
`

christianws
@christianws
Jun 24 2016 07:18
@Krish2704 let me try that
sigursiguros
@sigursiguros
Jun 24 2016 07:18

``

function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you're fired!
for (var i = 0; i<4; i++){
for (var j = 0; j<4; j++){
if (arr2i == arr1j){
arr1[j][0] = arr1[j][0] + arr2[i][0];}
else {
arr1.push(arr2[i]);
}
}
}
return arr1;
}

// Example inventory lists
var curInv = [
[21, "Bowling Ball"],
[2, "Dirty Sock"],
[1, "Hair Pin"],
[5, "Microphone"]
];

var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];

updateInventory(curInv, newInv);
``

backticks

function updateInventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!
    for (var i = 0; i<4; i++){
      for (var j = 0; j<4; j++){
        if (arr2[i][1] == arr1[j][1]){
          arr1[j][0] = arr1[j][0] + arr2[i][0];}
        else {
          arr1.push(arr2[i]);
          }
        } 
    }
    return arr1;
}

// Example inventory lists
var curInv = [
    [21, "Bowling Ball"],
    [2, "Dirty Sock"],
    [1, "Hair Pin"],
    [5, "Microphone"]
];

var newInv = [
    [2, "Hair Pin"],
    [3, "Half-Eaten Apple"],
    [67, "Bowling Ball"],
    [7, "Toothpaste"]
];

updateInventory(curInv, newInv);
christianws
@christianws
Jun 24 2016 07:21
I think I've got something now
check out my pen, getting close to killing all the bugs
RAJESH KUMAR
@raz281389
Jun 24 2016 07:23
```var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];
Markus Kiili
@Masd925
Jun 24 2016 07:23
@CurlyWS I just mean that with for loop the logic is hidden (hard to figure out what happens and when). With while loop the logic is easy to see. Here is a for loop written as a while loop:
for (before;condition;after){
    code
}

before
while(condition){
    code
    after
}
RAJESH KUMAR
@raz281389
Jun 24 2016 07:23
var newInv = [ [2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"] ];
var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];
christianws
@christianws
Jun 24 2016 07:24
@Masd925 ok I understand thanks !
CamperBot
@camperbot
Jun 24 2016 07:24
curlyws sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1969 | @masd925 |http://www.freecodecamp.com/masd925
TanayD
@TanayD
Jun 24 2016 07:26
@Byzgig no i got it
DJ
@qualitymanifest
Jun 24 2016 07:27
@Byzgig couple things (they may already be on your to-do list). multiple decimals are allowed, and there are floating point errors i.e. 0.1 + 0.2 === 0.30000000000000004
David Halls
@DavidHalls
Jun 24 2016 07:28
thanks buddy @qualitymanifest i know aobut the numbers, rignt now i am working on allowing to * by - umber
CamperBot
@camperbot
Jun 24 2016 07:28
byzgig sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1219 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
MrBurks
@mrburks
Jun 24 2016 07:42
Challenge help needed. -Where do I belong-
I need a translation of this ... Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.
no help? ok
96street
@96street
Jun 24 2016 07:48
Any idea why my onclick function isn't working? http://codepen.io/kingdezz/full/pbRjPY/
(only works in firefox)
Sujal
@Sujal3757
Jun 24 2016 07:49
need help in "manipulating complex objects"
Avinash Kuduvalli
@manicmarvin
Jun 24 2016 07:53
Is it my imagination or are the constructor challenges written in a format and style that's entirely different from the rest of code camp?
@Sujal3757 What help do you need wth complex objects?
kirbyedy
@kirbyedy
Jun 24 2016 08:01
@96street check your console log for error
96street
@96street
Jun 24 2016 08:05
can't see anything
@kirbyedy
I have to read the firefox console so maybe i'm missing something
kirbyedy
@kirbyedy
Jun 24 2016 08:06
@96street here is a picture
Screen Shot 2016-06-24 at 11.06.24.png
96street
@96street
Jun 24 2016 08:09
yeah as I said it only works in firefox @kirbyedy
Sujal
@Sujal3757
Jun 24 2016 08:14
@kirbyedy can you help me with manipulating complex objects
Alex T.
@lx-t
Jun 24 2016 08:15

@96street It doesn't work in firefox either. Try debugging it inserting the line console.log($weather); into your code:

$('button').on('click', function() {
  console.log($weather);
  if($weather.indexOf('C') > -1) {

and you'll see that $weather is an object and doesn't have indexOf property.

96street
@96street
Jun 24 2016 08:22
It isn't console.logging $weather for some reason
x981
@x981
Jun 24 2016 08:24
https://www.freecodecamp.com/challenges/convert-json-data-to-html#? please tell me why nothing happend when i click button.
No problem with my code
Alex T.
@lx-t
Jun 24 2016 08:26
@96street To access the content of span block you can use html function of jQuery (http://api.jquery.com/html/).
96street
@96street
Jun 24 2016 08:29
so <span> content is different to $weather content here? @lx-t
Alex T.
@lx-t
Jun 24 2016 08:30

@96street In your code

var $weather = $('#weather');

the $('#weather') selector returns an object and the thing you need is the content of the span block. To access it's content use $('#weather').html(). See the jQuery documentation, they have examples.

@96street the $('#weather') selector returns the object of the whole span block and all you need is what in between span tags, span's content
96street
@96street
Jun 24 2016 08:34
I think it's working now. How to I revert back to the original number (celcius) @lx-t
Alex T.
@lx-t
Jun 24 2016 08:35
@96street Now, the click function works but it doesn't change the temperature value between celsius and fahrenheit
96street
@96street
Jun 24 2016 08:36
Is there an easy way to revert back to the original celcius without writing an equation?
Alex T.
@lx-t
Jun 24 2016 08:37
@96street To convert back use math expression for converting fahrenheit to celsius in your else statement. And don't forget changing the temperature unit between C and F
@96street You can store both values in your JS after you get weather condition from the API and switch between them
@96street like this
var tempC, tempF;
$.getJSON(url, function(data) {
    tempC = ...;
    tempF = ...;
DavidR
@davidrinconv
Jun 24 2016 08:40
check now my wikipedia viewer... let me know feedback http://codepen.io/davidrv/full/JKRQbE/
@96street nice work but I just get loading...
Alex T.
@lx-t
Jun 24 2016 08:41
@davidrinconv Did you do such a small input field intentionally?
@davidrinconv I like the animation!
96street
@96street
Jun 24 2016 08:43
only works in firefox @davidrinconv
how do I detect a '2nd click'?
because when i want to revert back to the original number it will just execute the 2nd function
or i don
don't know what if statement to write
Abdulkarim Eskandar
@iskandar992
Jun 24 2016 08:46
hi every one
i'm right now on the challenge Everything be true

js`function truthCheck(collection, pre) {
// Is everyone being true?
function checkProperty(index, element, array) {

  return element.hasOwnProperty(pre);

}

if(collection.every(checkProperty)) { return true;}
else {
return false;
}
}`

js`function truthCheck(collection, pre) {
// Is everyone being true?
function checkProperty(index, element, array) {

  return element.hasOwnProperty(pre);

}

if(collection.every(checkProperty)) { return true;}
else {
return false;
}
}`

silver537
@silver537
Jun 24 2016 08:47
@kirbyedy dam it!! its you again with your damn picture.
Alex T.
@lx-t
Jun 24 2016 08:47
help format
CamperBot
@camperbot
Jun 24 2016 08:47

: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

Abdulkarim Eskandar
@iskandar992
Jun 24 2016 08:49
function truthCheck(collection, pre) {
  // Is everyone being true?
  function checkProperty(index, element, array) {

      return element.hasOwnProperty(pre);
  }

  if(collection.every(checkProperty)) { return true;}
  else {
    return false;
  }
}
this is the code I wrote but it's not returning true for the cases thet they should be returning true
Abdulkarim Eskandar
@iskandar992
Jun 24 2016 08:54
??
Dima Lunkin
@timonbandit
Jun 24 2016 08:56
why you use 3 variables here - function checkProperty(index, element, array) ?
christianws
@christianws
Jun 24 2016 08:57
has anyone completed 'No repeats please' ??
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 08:58
@CurlyWS can you tell me the question
DavidR
@davidrinconv
Jun 24 2016 08:58
@lx-t not sure there is a point of a bigger field... are you meaning wider?
Alex T.
@lx-t
Jun 24 2016 08:59
@iskandar992 You have wrong parameter order in your checkProperty function. Read https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/every
mayuri nayak
@mayuri14
Jun 24 2016 09:00
Can anyone help me with counting cards game?

var count = 0;

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

return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Alex T.
@lx-t
Jun 24 2016 09:00
@davidrinconv Yes, I mean wider. It's like wide enough to wrap the 'Enter' word of placeholder.
mayuri nayak
@mayuri14
Jun 24 2016 09:01
I don't understand what to do here
Alex T.
@lx-t
Jun 24 2016 09:02
@iskandar992 It's element, index, array, not index, element, array
mayuri nayak
@mayuri14
Jun 24 2016 09:02

var count = 0;

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

return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Abdulkarim Eskandar
@iskandar992
Jun 24 2016 09:03
@lx-t i'v changed them but it wasn't fixed
fluffystub
@RakshithNM
Jun 24 2016 09:04
<body>
    <canvas id="paint">May be you should try another browser.</canvas>
</body>
body { 
    margin : 0;
}
var canvas = document.getElementById('paint');
var ctx = canvas.getContext("2d");

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

var putPoint = function(e) {
    ctx.beginPath();
    ctx.arc(e.offSetX, e.offSetY, 10, 0, Math.PI * 2);
    ctx.fill();
}

canvas.addEventListener( 'mousedown' , putPoint );
working on a simple paint app using HTML5 Canvas.
Im struck i cannot find an error but it doesnt work
can anybody help?
Alex T.
@lx-t
Jun 24 2016 09:07
@iskandar992 I changed the code and it works for me.
Abdulkarim Eskandar
@iskandar992
Jun 24 2016 09:09
@lx-t you only changed the parameters order ? and it worked ?!!
Alex T.
@lx-t
Jun 24 2016 09:09
@iskandar992
function truthCheck(collection, pre) {
  // Is everyone being true?
  function checkProperty(element, index, array) {
    return element.hasOwnProperty(pre);
  }
  if(collection.every(checkProperty)) {
    return true;
  } else {
    return false;
  }
}
Sujal
@Sujal3757
Jun 24 2016 09:10
This message was deleted
@mayuri14
var count = 0;

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

  if(count > 0){
    return count + " Bet";
  } else{
    return count + " Hold";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Alex T.
@lx-t
Jun 24 2016 09:10
And teher's no point in checking if collection.every(checkProperty) is true or false and then return true or false. Just return collection.every(checkProperty)
Abdulkarim Eskandar
@iskandar992
Jun 24 2016 09:11
@lx-t it works only on one case of the possibilities try trying it on the cases of freecodecamp.com it won't work
kirbyedy
@kirbyedy
Jun 24 2016 09:11
@silver537 :D
Alex T.
@lx-t
Jun 24 2016 09:11
@iskandar992 Which test case doen't work?
Sujal
@Sujal3757
Jun 24 2016 09:12
@kirbyedy can u help me with record collection challenge
Abdulkarim Eskandar
@iskandar992
Jun 24 2016 09:12
@lx-t this for example should return false but it doesnt
truthCheck([{"single": ""}, {"single": "double"}], "single")
Alex T.
@lx-t
Jun 24 2016 09:12
@iskandar992 Oh, I guess you should check if 'property is true' not if 'property exists'
kirbyedy
@kirbyedy
Jun 24 2016 09:12
@Sujal3757 write your code and problem, someone will help
Sujal
@Sujal3757
Jun 24 2016 09:13

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

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


}



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

problem:-
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.

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.

If value is blank, delete that prop.

Always return the entire collection object.

Abdulkarim Eskandar
@iskandar992
Jun 24 2016 09:14
@lx-t yeah it seems that way js function truthCheck(collection, pre) { // Is everyone being true? function checkProperty(element, index, array) { return element.hasOwnProperty(pre) && Boolean(element[pre]); } if(collection.every(checkProperty)) { return true; } else { return false; } }
```js
function truthCheck(collection, pre) {
  // Is everyone being true?
  function checkProperty(element, index, array) {
    return element.hasOwnProperty(pre) && Boolean(element[pre]);
  }
  if(collection.every(checkProperty)) {
    return true;
  } else {
    return false;
  }
}
now it works but thanks anyway @lx-t
CamperBot
@camperbot
Jun 24 2016 09:14
iskandar992 sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @lx-t |http://www.freecodecamp.com/lx-t
silver537
@silver537
Jun 24 2016 09:15
woah... didn't need that extra function
Le Anh Duy (Andrew)
@leanhduy1998
Jun 24 2016 09:20
Hi guys, I don't really know how to do the No Repeats Please problem. How do you generate all Permutations using heap? I looked at the heap algorithm but still didn't understand it. I'm struggling with this problem.
Shraddha Parab
@Shraddha99
Jun 24 2016 09:22

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArray = [];
  var x = 0;
  for(i=0; i< size ; i++)
    {
      var arr1 = arr.slice(x,size);
      newArray.push(arr1);
      x = x + size;
    }
   return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
what is it that I am doing wrong that I get [["a" ,"b"] , []] in the console .
Alex T.
@lx-t
Jun 24 2016 09:26
@Shraddha99 Because your loop ends at the second element of your array (i< size).
@Shraddha99 To loop over every element of your array use i < arr.length-1. And don't forget to increment your index i according to size (you're incrementing by 1).
Shraddha Parab
@Shraddha99
Jun 24 2016 09:28
okay
@lx-t
but if we use i < arr.length
it will end up running it for 4 times
Alessandro
@alemaggiolini
Jun 24 2016 09:29
Hi everyone! Need help with a project using Javascript. We've created e-books that have been uploaded on our server. Plus we have an integration with Google APIs so when I type an artwork, it automatically gives me the image and the description as well as the author, etc... Now when I type an artwork I also want the system to suggest me the content-related e-books: so let's say that for example I type in "A. Warhol Campbell's Soup Cans", it gives me details about the artwork, but I want it to look through the e-books that I have previously tagged and suggest me e-books about modern art and not about Greek or Roman art. How can I do that? I was thinking about using JSON... is that correct? How can I do that?
Alex T.
@lx-t
Jun 24 2016 09:30
@Shraddha99 for(var i = 0; i < arr.length-1; i += size) and in this case you do not need to use x. Your i would be 0, 2.
mayuri nayak
@mayuri14
Jun 24 2016 09:30
@Sujal3757 Thanks
CamperBot
@camperbot
Jun 24 2016 09:30
mayuri14 sends brownie points to @sujal3757 :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @sujal3757 |http://www.freecodecamp.com/sujal3757
Marcin
@Martin89PL
Jun 24 2016 09:32
Hi everyone!
Alex T.
@lx-t
Jun 24 2016 09:32
@Shraddha99 You see, you can increment i in your loop by size.
Marcin
@Martin89PL
Jun 24 2016 09:34
I have some code. I want to sort numbers in array and add the two biggest to themselfs

var bigestOfTwoElements = function (array) {

var args = array.sort(function(a, b){
return a-b;

});

console.log(args);

return args[args.length-1] + args[args.length];

console.log(args);
};

bigestSumOfTwoElements([1,2,3,4]);
bigestSumOfTwoElements([]);
bigestSumOfTwoElements([23,45,17,12]);

It have to work that : bigestSumOfTwoElements([1,2,3,4]) // => 7
bigestSumOfTwoElements([]) // => NaN
bigestSumOfTwoElements([23,45,17,12]) // => 68
Please, help
96street
@96street
Jun 24 2016 09:37
@lx-t Can you please show me how to revert back to the original number (celcius)? @lx-t http://codepen.io/kingdezz/full/pbRjPY/
Shraddha Parab
@Shraddha99
Jun 24 2016 09:40
ok @lx-t I did this .
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArray = [];
  var x =0;
  for(i=0; i <= size; i = i + size)
    {
      var arr1 = arr.slice(i,i + size);
      newArray.push(arr1);
      x = x + size;
    }
   return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
which worked for some cases and did not for some
Cody Cass
@codycass1
Jun 24 2016 09:41
blob
Can anyone lend a hand?
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:41
hey guys :)
Marcin
@Martin89PL
Jun 24 2016 09:41

var bigestOfTwoElements = function (array) {

var args = array.sort(function(a, b){
return a-b;

});

console.log(args);

return args[args.length-1] + args[args.length];

console.log(args);
};

bigestSumOfTwoElements([1,2,3,4]);
bigestSumOfTwoElements([]);
bigestSumOfTwoElements([23,45,17,12]);
It have to work that : bigestSumOfTwoElements([1,2,3,4]) // => 7
bigestSumOfTwoElements([]) // => NaN
bigestSumOfTwoElements([23,45,17,12]) // => 68

Nathaniel Nasarow
@Torgian
Jun 24 2016 09:42
@codycass1 Is this regular expressions? I haven't gone through this yet, but I have used them a few times before
Alessandro
@alemaggiolini
Jun 24 2016 09:42
Any clues for my project?
Alex T.
@lx-t
Jun 24 2016 09:42
@96street I'm not sure about converting the value of temperature each time the user clicks the button. It'll lose it's precision because it'll be rounded back and forth. I strored two values of temperature in my code and changed between them.
Cody Cass
@codycass1
Jun 24 2016 09:43
I believe so. I just got started on javaScript
blob
Cody Cass
@codycass1
Jun 24 2016 09:44
I'm having a harder time with these challenges.
96street
@96street
Jun 24 2016 09:44
can you show your codepen? @lx-t
Alex T.
@lx-t
Jun 24 2016 09:44
@Shraddha99 Agan. You end your loop not at the end of your array.
Shraddha Parab
@Shraddha99
Jun 24 2016 09:44
yes @lx-t
I got it.
but arr.length -1 won't work too
silver537
@silver537
Jun 24 2016 09:45
@codycass1 follow what they ask you to put. then follow the table.
Shraddha Parab
@Shraddha99
Jun 24 2016 09:45
@lx-t It worked Thank You ALEX
CamperBot
@camperbot
Jun 24 2016 09:45
shraddha99 sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 357 | @lx-t |http://www.freecodecamp.com/lx-t
Alex T.
@lx-t
Jun 24 2016 09:45
@96street Actually I used even more complicated way of changing values of temperature. http://codepen.io/lx-t/pen/OXMKLR
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:46
@codycass1 can you put it into a jsfiddle and share it? Or a codepen? Also, can you tell me which challenge it is?
I don't think I've done this one
Cody Cass
@codycass1
Jun 24 2016 09:47
Escape Sequences in Strings
@Torgian This is the challenege
Barış Kaşıkırık
@kasikirik
Jun 24 2016 09:47
I need help in "Record Collection" challange
What does it ask for?
I did not get it
Mikail Bayram
@mikail1998
Jun 24 2016 09:48
Guys im doing the Wherefore art thou algorithm challenge. I dont know how to check if an object has a property value. Any kind of help will be appreciated. Thank you :smile:
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:49
huh, ok, it shows as completed on my Map, but I don't recall doing it
Barış Kaşıkırık
@kasikirik
Jun 24 2016 09:49
@mikail1998 var a = myObj.hasOwnProperty(checkProp);
Alex T.
@lx-t
Jun 24 2016 09:49
@96street Like I said right after you get the data from API you can store both temperature values in celsius and fahrenheit and then switch between them.
Mikail Bayram
@mikail1998
Jun 24 2016 09:50
@kasikirik I dont need the property itself but the value stored in that property
Pravin
@pravin07p
Jun 24 2016 09:50
@codycass1 try this \ \n\t\t
96street
@96street
Jun 24 2016 09:50
ill try that now
Shraddha Parab
@Shraddha99
Jun 24 2016 09:51
woah! @lx-t it was logic :+1:
silver537
@silver537
Jun 24 2016 09:51
@pravin07p try not to give straight answers. if he comes up to the same problem again, he won't be able to solve it on his own
Barış Kaşıkırık
@kasikirik
Jun 24 2016 09:51
I need help in "Record Collection" challange
Cody Cass
@codycass1
Jun 24 2016 09:51
That's the original way I did it, and it didn't work.
silver537
@silver537
Jun 24 2016 09:51
whats the problem?
Pravin
@pravin07p
Jun 24 2016 09:52
@silver537 the thing is its just a space between those lines.
silver537
@silver537
Jun 24 2016 09:52
@codycass1 need to be in "" and need spaces. they ask for specific escapes use the table on how to code those escapes.
svexas
@svexas
Jun 24 2016 09:53
Anyone here finished random quote generator challenge and could help me?
silver537
@silver537
Jun 24 2016 09:53
@pravin07p yea, cant risk the ability to copy and paste. you van give them straight answers without code.
Brendan Kinahan
@BKinahan
Jun 24 2016 09:54
@svexas what problem are you having?
Also good morning all o/
Krishna Sai Gullapalli
@Krish2704
Jun 24 2016 09:55
@BKinahan good morning!
Cody Cass
@codycass1
Jun 24 2016 09:55
var myStr = "\ \t \t \r \n"; // Change this line
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:55
@codycass1 ahh ok
Cody Cass
@codycass1
Jun 24 2016 09:55
This is what I put, but it's still not working.
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:55
I think I remember now
silver537
@silver537
Jun 24 2016 09:56
@codycass1 you're missing a backslash
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:56
Yes, was just about to say that
check your backslashes
Brendan Kinahan
@BKinahan
Jun 24 2016 09:57
@silver537 @Torgian FYI, unformatted code will escape the backslash, so \\ will display here as \
silver537
@silver537
Jun 24 2016 09:57
\
Brendan Kinahan
@BKinahan
Jun 24 2016 09:57
Also, that challenge has changed to require more than just escaped characters. There are currently two sentences required.
Alex T.
@lx-t
Jun 24 2016 09:58
@96street
var tempC, tempF;

$.getJSON( url, function(data) {
  var city = data.name;
  tempC = Math.round(data.main.temp - 273.15);
  tempF = tempC * 9 / 5 + 32
  document.getElementById('city').innerHTML = city;
        document.getElementById('weather').innerHTML = tempC + ' &deg' + 'C';


  var $weather = $('#weather');

$('button').on('click', function() {

  if($weather.html().indexOf('C') > -1) {
    $weather.html(tempF + ' &deg' + 'F');
  } else {
    $weather.html(tempC + ' &deg' + 'C');
  }
});
silver537
@silver537
Jun 24 2016 09:58
they're finally changing the site?
cool
kirbyedy
@kirbyedy
Jun 24 2016 09:58
@BKinahan go island go... :thumbsup: :D
silver537
@silver537
Jun 24 2016 09:58
then yea. you're missing some text with a colon
Sujal
@Sujal3757
Jun 24 2016 09:58
anyone completed record collection challenge need help
Brendan Kinahan
@BKinahan
Jun 24 2016 09:58
(but there is an open issue about it here, because it has problems: FreeCodeCamp/FreeCodeCamp#9314
kirbyedy
@kirbyedy
Jun 24 2016 09:59
they should really change the weather app project as well
Brendan Kinahan
@BKinahan
Jun 24 2016 09:59
@silver537 FCC is always changing... Users can contribute to make things better, so there's never a lack of new changes!
@kirbyedy we* :P
@kirbyedy you can help! :D
Nathaniel Nasarow
@Torgian
Jun 24 2016 09:59
anyways, can I get a code review? It works, just want to see if I can make it better
Alex T.
@lx-t
Jun 24 2016 09:59
@96street And don't forget that you're using temp variable to change the weather icon (what the heck!?). So change it to tempC or tempF, whichever suits you.
Brendan Kinahan
@BKinahan
Jun 24 2016 09:59
@kirbyedy and yeah, everyone here is pretty happy about some sports thing :P
kirbyedy
@kirbyedy
Jun 24 2016 10:00
cool :)
svexas
@svexas
Jun 24 2016 10:00
@BKinahan how do i access random quote in jquery? I have object named quotes, ID values and in id values there is a quote and an author
Nathaniel Nasarow
@Torgian
Jun 24 2016 10:00
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var hardly = arr;
  hardly.push(num);
  var sortedNumbers = function(a, b) {
    return a - b;
  };
  hardly = hardly.sort(sortedNumbers);
  return hardly.indexOf(num);
}

getIndexToIns([40, 60], 50);
Cody Cass
@codycass1
Jun 24 2016 10:00
Still not getting it. Im about to do some more "googling" to try and understand escaping better.
This site has done an amazing job of helping me learn, up until the last 2 challenges.
svexas
@svexas
Jun 24 2016 10:01
@BKinahan I tried $("#author").html(quotes.ID.author) and other variations and couldn't get it
Nathaniel Nasarow
@Torgian
Jun 24 2016 10:01
@codycass1 You'll run into frustration.
the last challenge I did took me 3 days to figure out, and I still needed to check the answer after all was said and done
Cody Cass
@codycass1
Jun 24 2016 10:01
I'm not frustrated, just confused on how they work. It'll click soon
Nathaniel Nasarow
@Torgian
Jun 24 2016 10:01
I finished maybe 80% of it
Brendan Kinahan
@BKinahan
Jun 24 2016 10:02
@Torgian hardly isn't a new array, by the way, it's just another name for the same arr array (so you might as well use arr)
silver537
@silver537
Jun 24 2016 10:02
@codycass1 are you writing the sentence it asks you to write?
Nathaniel Nasarow
@Torgian
Jun 24 2016 10:02
can I simply just push num into arr then?
Brendan Kinahan
@BKinahan
Jun 24 2016 10:02
@Torgian aside from that it looks like a pretty standard solution
Cody Cass
@codycass1
Jun 24 2016 10:02
I'm starting school in 2 weeks, but it's all for back end development. I've been trying to learn front in before so I can get a better vision for what I'm getting into.
silver537
@silver537
Jun 24 2016 10:02
@codycass1 with exact puncutations, spacing?
Markus Kiili
@Masd925
Jun 24 2016 10:03
@Torgian If you wan't to copy the array (reasonable so you don't mutate the original) do: var hardly = arr.slice();
96street
@96street
Jun 24 2016 10:03
thankyou @lx-t
CamperBot
@camperbot
Jun 24 2016 10:03
96street sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 358 | @lx-t |http://www.freecodecamp.com/lx-t
Brendan Kinahan
@BKinahan
Jun 24 2016 10:03
@svexas if you want a random one, you'll have to either form an array of IDs and choose a random one using Math.random(), or add some method to your object that returns a random ID
Nathaniel Nasarow
@Torgian
Jun 24 2016 10:03
ah, yeah makes sense @Masd925
Cody Cass
@codycass1
Jun 24 2016 10:04
To me it looks correct, but I don't have any text in there anymore because everything turned white. Lemme try a few diff ways
Sujal
@Sujal3757
Jun 24 2016 10:04
@kasikirik did u completed record collection challenge?
Alex T.
@lx-t
Jun 24 2016 10:05
@96street I missed a semicolon at the end of tempF = tempC * 9 / 5 + 32.
Barış Kaşıkırık
@kasikirik
Jun 24 2016 10:05
no @Sujal3757 please help me out
96street
@96street
Jun 24 2016 10:05
fixed
Barış Kaşıkırık
@kasikirik
Jun 24 2016 10: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(JSON.stringify(collection));

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

if (value !==""){
  if (prop == "tracks"){
   arrayCheck = collection.hasOwnProperty(tracks);
    if (arrayCheck === false){
      tracks = [];
      tracks.push(value);
    }
    else{
      tracks.push(value);
    }
  }
}
else {
  //Delete that prop.
  delete collection.prop;
}
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Stephen James
@sjames1958gm
Jun 24 2016 10:07
@kasikirik Are you missing an else for prop === "tracks" ?
@sjames1958gm Also you need to use [id] to get to correct collection object, and [] whenever using variables
mhdesignctgbd
@mhdesignctgbd
Jun 24 2016 10:08
@silver537
96street
@96street
Jun 24 2016 10:11
@lx-t dI tried to make the icon only appear after the weather has loaded but it screws up do you know why http://codepen.io/kingdezz/full/pbRjPY/
Markus Kiili
@Masd925
Jun 24 2016 10:12
@kasikirik This also doesn't do too much: tracks = []; You should be accessing collection
Quotes here ("tracks") <-
Uros Tadic
@urketadic
Jun 24 2016 10:13
Hey, how can i edit my script on http://codepen.io/urketadic/pen/JKbddV so the html button triggers even if i press enter. I mean i found the code for it but i dont know how to implement it
Alex T.
@lx-t
Jun 24 2016 10:14
@96street Try using display: block; style for your img tag.
96street
@96street
Jun 24 2016 10:14
it already is @lx-t
Markus Kiili
@Masd925
Jun 24 2016 10:14
@kasikirik .prop does not work because
The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
96street
@96street
Jun 24 2016 10:14
#icon {
  width: 80px;
  height: 80px;
  margin: 0 auto;
  display: block;
  display: none;
}
oh whoops
svexas
@svexas
Jun 24 2016 10:15
maybe someone knows why i cant use number here? $("#quote").html(quotes.0.quote)
Pravin
@pravin07p
Jun 24 2016 10:15
http://awesomescreenshot.com/0d35z3db38 can anyone help me with this..
96street
@96street
Jun 24 2016 10:16
@lx-t The reason i used display: none is so the placeholder img isn't shown
is there any way to just have a fully transperant img as a source?
so it doesn't show anything
Stephen James
@sjames1958gm
Jun 24 2016 10:17
@svexas Is it an array? That isn't valid syntax for an array.