These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Aug 2016
Promise Tochi
@Promhize
Aug 13 2016 00:00
@rfaroul click the little chat icon on the right of the text input, then you can press enter without sending the message
Rachelle Faroul
@rfaroul
Aug 13 2016 00:00

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

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

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

// Change this value to test
phoneticLookup("charlie");
```

in this code, why does lookup[val] work but lookup.val doesn't?
DJ
@qualitymanifest
Aug 13 2016 00:03
@rfaroul dot notation only works with the actual string name of the property, and only if that string name has no spaces and doesn't start with a number. if you're using a variable, or a string with a space, etc, you have to use bracket notation
Rachelle Faroul
@rfaroul
Aug 13 2016 00:05
ahh thank you!
MeonAigeanta
@MeonAigeanta
Aug 13 2016 00:10
@Skaiir The code still has problems with async. It works some of the time, but not all of the time.
Valentin Serra
@Skaiir
Aug 13 2016 00:10
@MeonAigeanta I wish I would understand synchronicity.
@MeonAigeanta Oh, I think I see my problem, I will try something out.
Ray
@rbjr
Aug 13 2016 00:12
function translatePigLatin(str) {
  var vowels = ['a', 'e', 'i', 'o', 'u'];
  var consonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'];
  var way = 'way';
  var ay = 'ay';
  str = str.split('');
  for (var i = 0; i < vowels.length; i++) {
    if (str[0] === vowels[i]) {
      str = str.join('') + way;
    }
  }
  var ender = str[0];
  var ender2 = str[1];
  for (var j = 0; j < consonants.length; j++) {

     if (str[1] === consonants[j]) {
       if (str[0] === consonants[j]){
      var strRemi = str.splice(0, 1);
      var str2i = str.push(ender);
      var str2ii = str.push(ender2);
      str = str.join('') + ay;
      }
    } 

    if (str[0] === consonants[j]) {
      var strRem = str.splice(0, 1);
      var str2 = str.push(ender);
      str = str.join('') + ay;
      return str;
    } 



  }

  return str;
}

translatePigLatin("glove");
MeonAigeanta
@MeonAigeanta
Aug 13 2016 00:13
@Skaiir good luck. I am going to leave it alone for a while and see if that solves my problem.
Ray
@rbjr
Aug 13 2016 00:13
won't pass for 2 consonants
at beginning of word
plz help I'm pulling my hair out
and I'm not bald i have lots of hair
it's actually quite beautiful
Stephen James
@sjames1958gm
Aug 13 2016 00:15
@DylanSatelle missing a comma
MeonAigeanta
@MeonAigeanta
Aug 13 2016 00:16
@mickey005 Thanks for your offer of help in July
CamperBot
@camperbot
Aug 13 2016 00:16
meonaigeanta sends brownie points to @mickey005 :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @mickey005 |http://www.freecodecamp.com/mickey005
Valentin Serra
@Skaiir
Aug 13 2016 00:18
@MeonAigeanta Send me your code in private I will have a look after I've managed to find a solution to my thing.
Alexander Køpke
@alexanderkopke
Aug 13 2016 00:31
@rbjr yeah I remember. It is quite a tough one. I looked at my own code and it took me 5 minutes just to understand what it is doing
Ray
@rbjr
Aug 13 2016 00:33
haha
Alexander Køpke
@alexanderkopke
Aug 13 2016 00:39
lol lovegay. I'd say that is a pretty funny side effect of your code @rbjr
Ray
@rbjr
Aug 13 2016 00:41
hahaha I KNOW RIGHT
for some reason its not detecting the 2nd consonant
Adam Rolfson
@DarthChowder
Aug 13 2016 00:50
@mustapha88 honestly I didn’t really now where to start. I think I get the logic of the if/else statements. But I was/am not too certain on how to apply the new values to the array. I did some more searching and I think I found something that is helpful.
Lawrence Eagles
@lawrenceagles
Aug 13 2016 00:53
Please can anyone explain what is wrong with my code? It wont even pass any text. Odd Fibonacci Numbers exercise.
function fibnum (num){
  var totalOddfib = 0;
  var fibnumb = [];

  if (num === 1 || num === 2) {

    return 1;

  } else{
    fibnumb[0] = 1;
    fibnumb[1] = 1;
    fibnumb[2] = 2;

    for (i = 3; i <= num; i++) {
      fibnumb[i] = fibnumb[i-2] + fibnumb[i-1];
      if (fibnumb[i] % 2 !== 0){
        totalOddfib += fibnumb[i];
      }
    }
  }


  return totalOddfib;
}




fibnum(10);
Alexander Køpke
@alexanderkopke
Aug 13 2016 00:57
@rbjr ah I think I know why it doesn't work. You have two ifs right after each other. The first checks for second letter 'l', so the for loop iterates in the consonants until it gets to the letter 'l'. Now str[1] === consonants[j] is true but consonants[j] is 'l', so str[0] === consonants[j] can't be true because 'g' is not 'l'. And so the code doesn't run.
silver537
@silver537
Aug 13 2016 01:02
@rbjr have an if statement that tests if the word starts with a consonant, and then iterates through each letter till it encounters a vowel. at that index, you will substring or splice the word from the beginning till where the vowel is at.
@rbjr it's also easier if you use RegEx
Ray
@rbjr
Aug 13 2016 01:06
ok man ill do that
lemme see
Dillon
@DillonEngland
Aug 13 2016 01:09
Can someone tell me what the challenge Record Collection is trying to instruct me to do? The wording of these challenges is rather complex to me for some reason.
Shreas Chauhan
@shrexman
Aug 13 2016 01:09
Hello Can someone help me solve front-end JS question 190?
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

function nextInLine(arr, item) {
// Your code here
nextInLine.push(5);
nextInLine([],1);
nextInLine([2],1);
nextInLine([5,6,7,8,9],1);
nextInLine(testArr,10);
return nextInline.pop();// Change this line
}

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

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

Dillon
@DillonEngland
Aug 13 2016 01:14
Any help in deciphering the instructions would be helpful. Again, the challenge is "Record Collection."
Alexander Køpke
@alexanderkopke
Aug 13 2016 01:14
@DillonEngland basically it wants you to update the collection object with the data that is passed to the function.
Promise Tochi
@Promhize
Aug 13 2016 01:14
@lawrenceagles you shouldn't be using i < num, that will continue to loop even when fibnum[i] is already greater than num
Alexander Køpke
@alexanderkopke
Aug 13 2016 01:15
@DillonEngland but there are some conditions that must be met. id always exists but prop and value might not so you have to check for this and do the update with this in mind
Promise Tochi
@Promhize
Aug 13 2016 01:16
@lawrenceagles add an if (fibnumb[i] < num) to your loop
Moisés Man
@moigithub
Aug 13 2016 01:16
@shrexman check the documetation about push pop shift and unshift methods.. then check the challenge instructions again...
TruongNDN
@NDNTruong
Aug 13 2016 01:21
var myStr = "mot\n hai \haiba \r bonnam\";
myStr should have encoded text with the proper escape sequences and no spacing.
help me, please
CamperBot
@camperbot
Aug 13 2016 01:21
no wiki entry for: me please
TruongNDN
@NDNTruong
Aug 13 2016 01:23
@NDNTruong
var myStr = "mot\n hai \haiba \r bonnam\";
ERROR: myStr should have encoded text with the proper escape sequences and no spacing.
help me, please
ME PLEASE
Alexander Køpke
@alexanderkopke
Aug 13 2016 01:24
@DillonEngland to refresh on objects. var obj = {key: value} you can add to the object like this. obj.newKey = newValue. Then the obj will look like: {key:value, newKey:newValue}. The value of an object can be any datatype also arrays and other objects. obj.array = [1, 2, 3]; obj.someObj = { hello: 'world'}. if you want to add something to an array in an object, then you can push to it. obj.array.push(4); Or handle it like any other array, just remember its address.
silver537
@silver537
Aug 13 2016 01:24
@NDNTruong use the words they provided. not your own.
Moisés Man
@moigithub
Aug 13 2016 01:27
@NDNTruong remove extra spaces also
and use the escaped sequences on the exact position the instruction indicate
Dillon
@DillonEngland
Aug 13 2016 01:29
I'm still very confused as to what it wants me to do, do I have to make sure every record has every single property?
TruongNDN
@NDNTruong
Aug 13 2016 01:29
@silver537 tks
@DillonEngland tks
Dillon
@DillonEngland
Aug 13 2016 01:32
The instructions are like a different language to me. Part of me wishes the exact challenge instructions were clearer on what to do.
silver537
@silver537
Aug 13 2016 01:33
@DillonEngland go line by line. and try to program what it asks. you should already know that whenever it says 'if' - that's an if statement.
automatically
Dillon
@DillonEngland
Aug 13 2016 01:35
I understood that, I guess I'll just keep retrying
alhajit21
@alhajit21
Aug 13 2016 01:42
silver537
@silver537
Aug 13 2016 01:44
@alhajit21 why \h?
Ray
@rbjr
Aug 13 2016 01:56
help pig latin
CamperBot
@camperbot
Aug 13 2016 01:56

:point_right: algorithm pig latin [wiki]

Algorithm Pig Latin

: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 need to create a program that will translate from English to Pig Latin. Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an "ay". If a word begins with a vowel you just add "way" to the end. It might not be obvious but you need to remove all the consonants up to the first vowel in case the word does not start with a vowel.

Relevant Links

:pencil: read more about algorithm pig latin on the FCC Wiki

TruongNDN
@NDNTruong
Aug 13 2016 01:58
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
me please
Dillon
@DillonEngland
Aug 13 2016 02:01
help Record Collection
CamperBot
@camperbot
Aug 13 2016 02:01

:point_right: challenge record collection [wiki]

Challenge Record Collection

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

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

Norvin Burrus
@ndburrus
Aug 13 2016 02:02
This message was deleted
Diego Mayer
@Chrono79
Aug 13 2016 02:02
@NDNTruong read mad libs link and review this challenge: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Norvin Burrus
@ndburrus
Aug 13 2016 02:03
@NDNTruong :sparkles:
the exercise is asking for a sentence to be built using the 4 word types given. it may be easiest to begin by making a complete (spacing & punctuation) sentence, using the 4 words. to make sense, the complete sentence will require a few "filler" words.
alhajit21
@alhajit21
Aug 13 2016 02:03
@silver537 silly mistake still not passing tho
TruongNDN
@NDNTruong
Aug 13 2016 02:04
@ndburrus tks
@Chrono79 tks
Norvin Burrus
@ndburrus
Aug 13 2016 02:04
@NDNTruong :+1:
ahmed abouhay
@abohay
Aug 13 2016 02:06
@ndburrus However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.
i wanna you explain
Norvin Burrus
@ndburrus
Aug 13 2016 02:10

@shrexman :sparkles:
ok we need to do 2 things:

  • Add the number to the end of the array &
  • remove the first element of array

we need to identify 2 methods that can help us do this. which methods should/can we use?
this may be helpful: :sparkles:

Dillon
@DillonEngland
Aug 13 2016 02:11
Would anyone be willing to take the time to explain the solution of Record Collection to me? I've searched it up and put it in, I see it, I just need someone to walk me through how the solution works.'
Private message me
ahmed abouhay
@abohay
Aug 13 2016 02:14
function truncateString(str, num) {
  var dots = "...";
  var lngth = num - dots.length;
  var all ;
    if (str.length > num){
      all = str.slice(0,lngth) + dots;
    }else {
      return false;
    }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Promise Tochi
@Promhize
Aug 13 2016 02:16
@DillonEngland which part don't you understand?
Brandon
@Brandons42
Aug 13 2016 02:18
help Seek and Destroy
CamperBot
@camperbot
Aug 13 2016 02:18

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

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

:checkered_flag: Problem Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Relevant Links

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Stephen James
@sjames1958gm
Aug 13 2016 02:22
@abohay Where do you check for num <= 3? that is part of the instruction
Ken Haduch
@khaduch
Aug 13 2016 02:24

@DillonEngland - I came up with this supplementary explanation ( or at least an attempted supplement) - maybe it will give you a little more insight? It might be slightly dated, as they added a couple other operating conditions- but I'll post it in case it helps to clarify anything for you:

Working with the data that is given, several operations can be performed to add to, and modify, this data.
Each "album" is represented by a JavaScript object, and is indexed by an ID value, which is a numeric
 property that uniquely identifies the album.  Property values are passed as one of the function parameters,
indicating the property of an album to be modified, for example, to refer to information about the performing
artist, the property will be "artist".  A "value" parameter will also be passed as one of the function parameters.
If a value is given, the property should be added to the album object if it does not exist, or the current value
updated if the property already exists.  If the value that is passed in is blank, then the property should be
deleted.  If the property name that is specified is "tracks", and the value is blank, then the "tracks" property
should be deleted; otherwise, the new value (a new song title) should be added to the end of the "tracks"
array.

Ask if you have further questions or need some additional clarification.

Brandon
@Brandons42
Aug 13 2016 02:24
function destroyer() {
  // Remove all the values
  function seeker(val) {
    for (q = 1; q < arguments.length; q++) {
      if (arguments[q] == val) {
        return false;
      }
    }
    return true;
  }
  var arrNew = arguments[0].filter(seeker);
  return arrNew;
}
Luke
@lukenetti3
Aug 13 2016 02:25
Can someone give me some tips on how to get started with the Roman Numeral challenge. I was trying to make an array with each number being a single element in the array. I realize depending on the place of the number that the roman numeral will be different but I’m having a hard time with handling things like the 4, 5, and 6. Numbers that use that “V”. Any tips?
Brandon
@Brandons42
Aug 13 2016 02:25
Can someone help me with Seek and Destroy^^
Adrian Kopytko
@adriankopytko
Aug 13 2016 02:25

Hello, I have following code:

$(document).ready(function() {
  //getCoords();
  console.log("###");
  Weather.init().then(function() {
    console.log("success" + Weather.getInfo());
  });
});

But I get 04:22:26.545 TypeError: Weather.init(...) is undefined
error. What could be wrong? Everything works well (even Weather.init, but .then and inside not)

Sabrina Ferguson
@itsacoyote
Aug 13 2016 02:31
@Shimizo what is Weather.init()?
ahmed abouhay
@abohay
Aug 13 2016 02:31
@sjames1958gm
function truncateString(str, num) {
  var dots = "...";
  var lngth = num - dots.length;
  var all ;
  var low;
    if (str.length > num && num > 3){
      all = str.slice(0,lngth) + dots;
    }else {
      return str;
    }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Adrian Kopytko
@adriankopytko
Aug 13 2016 02:32
@itsacoyote
var Weather = (function() {
  var info = { 
    city: null, 
    country: null, 
    weather: null, 
    lat: null, 
    lon: null 
  };

  var getLocationAndWeather = function() {
    $.ajax({
      url: 'http://ip-api.com/json',
      success: function(response) {
        info.city = response.city;
        info.country = response.country;
        info.lat = response.lat;
        info.lon = response.lon;
        console.log("getLocation");
        console.log(info);
        getWeatherInLocation(info.lat, info.lon);
      }
    });
  };

  var getWeatherInLocation = function(lat, lon) {
    $.ajax({
      url: 'http://api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+lon+'&appid=5583481a78c0f6bac06274d26303f825',
      success: function(response) {
        info.weather = response.weather[0].main;
        console.log("getWeatherInLocation");
        console.log(info);
      }
    });
  };

  var init = function() {
    getLocationAndWeather();
    console.log("init");
  };

  return {
    init: init,
    getInfo: function() { return info; }
  };
})();
Stephen James
@sjames1958gm
Aug 13 2016 02:32
@abohay When str.length > and num <= 3 what do you do?
@Shimizo init returns undefined
Sabrina Ferguson
@itsacoyote
Aug 13 2016 02:33
@Shimizo If I remember correctly, .then() works when you receive a Promise, are you returning a Promise on Weather.init()?
Adrian Kopytko
@adriankopytko
Aug 13 2016 02:34
@sjames1958gm @itsacoyote What should i do? I'm new with promises, I don't know exactly what to do
Ken Haduch
@khaduch
Aug 13 2016 02:34
@lukenetti3 - for me, going through the link to the Roman numeral description and thinking about the technique for doing the conversion was very helpful. It was not a simple straightforward problem, but I found that going through and extracting the maximum number of the largest units and working down through the list was a good way to do it. I have seen a few different solutions that people posted - I think that there are a few different ways to approach it.
Stephen James
@sjames1958gm
Aug 13 2016 02:35
@Shimizo Success function and promises don't work together.
Sabrina Ferguson
@itsacoyote
Aug 13 2016 02:36
@sjames1958gm would creating a deferred and returning a promise work inside the success function, or a better way than that? Curious on my end
Ken Haduch
@khaduch
Aug 13 2016 02:36
@Shimizo - this
JS Async info
was an interesting video on async JS code - promises are discussed there.
Stephen James
@sjames1958gm
Aug 13 2016 02:36
@itsacoyote The success cannot return anything it is not called until later.
Sabrina Ferguson
@itsacoyote
Aug 13 2016 02:37
@sjames1958gm sorry, probably meant to clarify. Return a deferred promise and then resolve it in the success function of the ajax call.
Stephen James
@sjames1958gm
Aug 13 2016 02:39
@itsacoyote That's a good question. That should work. you are saying the deferred is "independent" of the $.ajax, except the success function does the resolve.
Adrian Kopytko
@adriankopytko
Aug 13 2016 02:39
@sjames1958gm @khaduch @itsacoyote Thanks! Is there a different option to do? I'm getting tired, trying to do this a few hours.
CamperBot
@camperbot
Aug 13 2016 02:39
shimizo sends brownie points to @sjames1958gm and @khaduch and @itsacoyote :sparkles: :thumbsup: :sparkles:
:star2: 1537 | @khaduch |http://www.freecodecamp.com/khaduch
:cookie: 361 | @itsacoyote |http://www.freecodecamp.com/itsacoyote
:star2: 2541 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sabrina Ferguson
@itsacoyote
Aug 13 2016 02:49
@sjames1958gm thanks for the info!
CamperBot
@camperbot
Aug 13 2016 02:49
itsacoyote sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2542 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Dillon
@DillonEngland
Aug 13 2016 02:49
@Promhize Thanks!
CamperBot
@camperbot
Aug 13 2016 02:49
dillonengland sends brownie points to @promhize :sparkles: :thumbsup: :sparkles:
:cookie: 44 | @promhize |http://www.freecodecamp.com/promhize
Promise Tochi
@Promhize
Aug 13 2016 02:51
@DillonEngland :+1: you've got this
bradulz
@bradulz
Aug 13 2016 02:53
hey guys can someone help with some css http://imgur.com/a/uSkWR . Im trying to get the title to be vertically aligned in the center, not the bottom. It is a list and they are both list items
Ken Haduch
@khaduch
Aug 13 2016 02:55
@bradulz - I think that using flexbox is one of the easiest ways to do vertical centering - here is something that you can read about: https://css-tricks.com/centering-css-complete-guide/
Brandon
@Brandons42
Aug 13 2016 03:00
Can someone help me with Seek and Destroy? My code is below
function destroyer() {
  // Remove all the values
  function seeker(val) {
    for (q = 1; q < arguments.length; q++) {
      if (arguments[q] == val) {
        return false;
      }
    }
    return true;
  }
  var arrNew = arguments[0].filter(seeker);
  return arrNew;
}
bradulz
@bradulz
Aug 13 2016 03:00
@khaduch hmm great site but doesnt explain howd I'd do it for a list. Its telling me to change the paddings but any padding changes affects both elements
Ken Haduch
@khaduch
Aug 13 2016 03:03
@bradulz - do they have to be list items? if it doesn't work for list items, they might have to be changed to a different element type? (Not sure if they didn't explain it because it won't work, or they just used a different example? List items might be more difficult to work with because they have a lot of built-in assumption? Can you post a link to the code instead of just an image?
Brandon
@Brandons42
Aug 13 2016 03:03
@bradulz Use the vertical-align.
@bradulz title {
vertical-align: middle;
}
bradulz
@bradulz
Aug 13 2016 03:05
@Brandons42 haha id actually tried vertical align on the title, the li of the title, the logo but not the li of the logo which seemed to work. Thanks guys @khaduch
CamperBot
@camperbot
Aug 13 2016 03:05
bradulz sends brownie points to @brandons42 and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @brandons42 |http://www.freecodecamp.com/brandons42
:star2: 1538 | @khaduch |http://www.freecodecamp.com/khaduch
bradulz
@bradulz
Aug 13 2016 03:05
@khaduch though how would you make them display inline without using a list
Eric Hayes
@egithub13
Aug 13 2016 03:06
This message was deleted
bradulz
@bradulz
Aug 13 2016 03:14
oh and I just realised this was Javascript help, lol my bad
Ken Haduch
@khaduch
Aug 13 2016 03:14
@bradulz - back to the flexbox - there is a lot of different control that you have. Another example is bootstrap - with the grid, you can see how they style that, although it possibly involves floats? Yeah, it does - but it works. I have seen people on here make a case for using flexbox - it handles a lot of alignment issues. (I'll admit that I haven't used it a lot, but I've gone through a lot of docs or sites that tell you how to use it.)
bradulz
@bradulz
Aug 13 2016 03:15
ok ill check it out thanks!
Eric Hayes
@egithub13
Aug 13 2016 03:16

What is wrong with my code? Mutations. Any help would be appreciated.

function mutation(arr) {

var first = arr[0].toLowerCase();
var second = arr[1].toUpperCase();

for(var i = 0; i < second.length; i++){
if(first.indexOf(second[i]) !== -1){
return true;
}
}

return false;
}

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

Sophanarith Sok
@sok213
Aug 13 2016 03:20
@egithub13 Your code is always lowercasing the first word and uppercasing the second word... when you do this, the two words will never be the same.
because "h" does not == "H"
for example.
Eric Hayes
@egithub13
Aug 13 2016 03:21
Yep. I don't know how I missed it. Thanks!! Also, whats the best way to post code with the black background?
Sophanarith Sok
@sok213
Aug 13 2016 03:21
It would make more sense to call lowercase OR uppercase on BOTH words so that you can compare them without it being case-sensitive. Get me??
silver537
@silver537
Aug 13 2016 03:22
@egithub13 :point_down:
help format
CamperBot
@camperbot
Aug 13 2016 03:22

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Sophanarith Sok
@sok213
Aug 13 2016 03:22
@egithub13 use backticks
silver537
@silver537
Aug 13 2016 03:22
@egithub13 :point_up:
Eric Hayes
@egithub13
Aug 13 2016 03:23
Thanks Sok. It wasn't intentional toUpperCase(). Three back ticks before and after?
Sophanarith Sok
@sok213
Aug 13 2016 03:24
@egithub13 yup
pahosler
@pahosler
Aug 13 2016 03:25
@egithub13 on their own line...
Sophanarith Sok
@sok213
Aug 13 2016 03:25
just make sure the code is not on the same line as the backticks, but under and above it
pahosler
@pahosler
Aug 13 2016 03:25
won't work
it'll do that
Eric Hayes
@egithub13
Aug 13 2016 03:26
Appreciate it!
pahosler
@pahosler
Aug 13 2016 03:28
This message was deleted
Brandon
@Brandons42
Aug 13 2016 03:31
function destroyer() {
  // This challenge is Seek and Destroy
//Please tell me what I'm doing wrong
  function seeker(val) {
    for (q = 1; q < arguments.length; q++) {
      if (arguments[q] == val) {
        return false;
      }
    }
    return true;
  }
  var arrNew = arguments[0].filter(seeker);
  return arrNew;
}
pahosler
@pahosler
Aug 13 2016 03:34
    var args = Array.prototype.slice.call(arguments, 1);
or...
var args = [...arguments];
help destroyer
CamperBot
@camperbot
Aug 13 2016 03:35
no wiki entry for: destroyer
pahosler
@pahosler
Aug 13 2016 03:35
help seek and destroy
CamperBot
@camperbot
Aug 13 2016 03:35

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

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

:checkered_flag: Problem Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Relevant Links

:pencil: read more about algorithm seek and destroy on the FCC Wiki

pahosler
@pahosler
Aug 13 2016 03:39
help exact change
CamperBot
@camperbot
Aug 13 2016 03:39

:point_right: algorithm exact change [wiki]

Algorithm Exact Change

: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 have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.

Relevant Links

:pencil: read more about algorithm exact change on the FCC Wiki

Milo Hartsoe
@MiloATH
Aug 13 2016 03:40
I am working an the weather app, and I am having problems with getJSON(). Can someone figure out what is wrong? https://codepen.io/Miloath/pen/pbdaLB?editors=0011
The line that is not working is js$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=b2772cc2defd6b35e7284f2be6a989cd", function(json) {
amal_magdy
@tahdy
Aug 13 2016 03:41
hi how to use Escape Sequences in Strings?
Milo Hartsoe
@MiloATH
Aug 13 2016 03:41
help escape characters
CamperBot
@camperbot
Aug 13 2016 03:41
no wiki entry for: escape characters
Milo Hartsoe
@MiloATH
Aug 13 2016 03:42
@tahdy use \ before a char (typically). which kind
i.e. "\" is \
\
it corrects \\ to \
let me try again: "\\" is \
amal_magdy
@tahdy
Aug 13 2016 03:50
@MiloATH thank you
CamperBot
@camperbot
Aug 13 2016 03:50
tahdy sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @miloath |http://www.freecodecamp.com/miloath
Norvin Burrus
@ndburrus
Aug 13 2016 03:56
@tahdy :sparkles:
ok, we need to take the given string, here:
"FirstLine newline backslash SecondLine backslash carriage-return ThirdLine" (ignore the spacing) and carefully replace the appropriate text (bold words) with the escape coding (use the Code/Output chart)...
amal_magdy
@tahdy
Aug 13 2016 03:59
@ndburrus yes i just solved it
Norvin Burrus
@ndburrus
Aug 13 2016 04:00
@tahdy that is super! very nice! :balloon:
Chad Powell
@cjpowellaz
Aug 13 2016 04:13
Hey all, I am mired in the "Title Case a Sentence" exercise for days now, I just am not getting it. As a hint, is it best to use RegEx or no?
Milo Hartsoe
@MiloATH
Aug 13 2016 04:14
help title case
CamperBot
@camperbot
Aug 13 2016 04:14

:point_right: algorithm title case a sentence [wiki]

Algorithm Title Case a Sentence

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

We have to return a sentence with title case. This means that the first letter will always be in uppercase and the rest will be in lowercase.

Relevant Links

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Milo Hartsoe
@MiloATH
Aug 13 2016 04:15
@cjpowellaz Try using substring(a,b) method and .toLowerCase()
help tolowercase
CamperBot
@camperbot
Aug 13 2016 04:15

:point_right: js string prototype tolowercase [wiki]

JavaScript String.prototype.toLowerCase()

The JavaScript method .toLowerCase() returns the same string it was called on, but in all lower case.

Syntax

str.toLowerCase()

:pencil: read more about js string prototype tolowercase on the FCC Wiki

coffeebeanzz
@coffeebeanzz
Aug 13 2016 04:15
This message was deleted
Milo Hartsoe
@MiloATH
Aug 13 2016 04:16
sorry touppercase.
print you code.
help format
CamperBot
@camperbot
Aug 13 2016 04:16

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Milo Hartsoe
@MiloATH
Aug 13 2016 04:17
@cjpowellaz print what ever you have
if you have nothing, then I would suggest using str.substring(0,1).toUpperCase() + rest of word using substring
Chad Powell
@cjpowellaz
Aug 13 2016 04:18

function titleCase(str) {
var caseChange;
var strSplit = str.split(" ");

for (var x = 0; x < strSplit.length; x++) {
changeCase = strSplit[x].charAt(0).toUpperCase();
changeCase += strSplit[x].slice(1);
}

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

I was reading the "helps", I really want to get this one without looking at a solution, but it is wearing me down
Milo Hartsoe
@MiloATH
Aug 13 2016 04:19
are you adding spaces back in?
Also make sure everything is lowercase to begin with
Chad Powell
@cjpowellaz
Aug 13 2016 04:21
1 ) split to an array (I have that down now) then, 2) convert everything to lowercase?
Milo Hartsoe
@MiloATH
Aug 13 2016 04:22
instead of js var strSplit = str.split(" "); maybe use js var strSplit = str.toLowerCase().split(" ");
format error dont include js
Chad Powell
@cjpowellaz
Aug 13 2016 04:23
oh, nice. Ok
Milo Hartsoe
@MiloATH
Aug 13 2016 04:24
Also I think you need to add spaces between each word
DJ
@qualitymanifest
Aug 13 2016 04:24
@cjpowellaz you're reassigning changeCase at the beginning of every for loop, which is why you only end up with the last word
Milo Hartsoe
@MiloATH
Aug 13 2016 04:24
maybe add changeCase += ' '; after changeCase += strSplit[x].slice(1);
@qualitymanifest is right change it to +=
masterbunny
@m4sterbunny
Aug 13 2016 04:25
I want to use // myArray.push("this"); // for updating a complex object (the adding an artist with record info challenge). What I don't understand (is multitude)- is can I use push to add the data to an array with different levels (indices)- if so do I need to name each for the push is it like a .push[0]?
Milo Hartsoe
@MiloATH
Aug 13 2016 04:26
a[0].push
@m4sterbunny
myArray[i].push("this"
Chad Powell
@cjpowellaz
Aug 13 2016 04:27
@qualitymanifest that has been bugging the jeepers out of me, I realized I was reassigning but could not figure how to get the letter back into the array.
masterbunny
@m4sterbunny
Aug 13 2016 04:27
@MiloATH Thanks - does that mean that I should push to each level seperately?
CamperBot
@camperbot
Aug 13 2016 04:27
m4sterbunny sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @miloath |http://www.freecodecamp.com/miloath
Milo Hartsoe
@MiloATH
Aug 13 2016 04:28
Celsius to Fahrenheit: (°C × 9/5) + 32 = °F
Fahrenheit to Celsius: (°F − 32) x 5/9 = °C
@Ekene96
your welcome @m4sterbunny
and yes
Ekene96
@Ekene96
Aug 13 2016 04:30
can please elaborate more @MiloATH
Milo Hartsoe
@MiloATH
Aug 13 2016 04:31
@Ekene96 use the formula (celsius)*(9/5)+32
to get fahrenheit
Ekene96
@Ekene96
Aug 13 2016 04:32
thanks @MiloATH let me try it out
CamperBot
@camperbot
Aug 13 2016 04:32
ekene96 sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @miloath |http://www.freecodecamp.com/miloath
Milo Hartsoe
@MiloATH
Aug 13 2016 04:32
your welcome @Ekene96
Norvin Burrus
@ndburrus
Aug 13 2016 04:33
@m4sterbunny this may be helpful: :sparkles:
masterbunny
@m4sterbunny
Aug 13 2016 04:35
Thanks @ndburrus, you sent me that one previous.... I am close to cracking and checking out your solution!
CamperBot
@camperbot
Aug 13 2016 04:35
m4sterbunny sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1562 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Aug 13 2016 04:35
@m4sterbunny what have you got now?
masterbunny
@m4sterbunny
Aug 13 2016 04:36
myMusicxamarin/xamarin-android@a16673d.push = [
{ "artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true}
];
Norvin Burrus
@ndburrus
Aug 13 2016 04:36
@m4sterbunny which lesson?
masterbunny
@m4sterbunny
Aug 13 2016 04:37
This message was deleted
Ekene96
@Ekene96
Aug 13 2016 04:37
Please am still confuse @m4sterbunny
still don't get it
masterbunny
@m4sterbunny
Aug 13 2016 04:37
@ndburrus Manipulating Complex Objects
silver537
@silver537
Aug 13 2016 04:38
@m4sterbunny you shouldn't use the = operator.
masterbunny
@m4sterbunny
Aug 13 2016 04:39
@Ekene96 was your question about why your FCC map is not showing all your challenges? They use Cache, sometimes you need to refresh- did you?
silver537
@silver537
Aug 13 2016 04:39
.push is a method and treated like any other function. you must input the argument.
masterbunny
@m4sterbunny
Aug 13 2016 04:39
@silver537 tried without! no luck
Milo Hartsoe
@MiloATH
Aug 13 2016 04:39
use ()
silver537
@silver537
Aug 13 2016 04:39
.push(your object in here)
please help
silver537
@silver537
Aug 13 2016 04:40
@m4sterbunny push automatically add an element to the array. so no need for the [ ]
Adam Pankowski
@losbaltica
Aug 13 2016 04:40
hi guys can you tell me whats wrong with this code?
function palindrome(str) {
  // Good luck!
  var a = str.toLowerCase();
  var b = a.replace(/^\w\d/g);

  for (i=0; i < b.length; i++) {
    if (b.charAt(i) === (b.charAt(b.length)-1)) {
      return true;
    } else {
      var c = b.split("");
      var d = c.reverse();
      var e = d.join("");
      if (b.charAt(i) === e.charAt(i)) {
        return true;
      } else {
        return false;
      }
    }
  }
}



palindrome("eye");
Milo Hartsoe
@MiloATH
Aug 13 2016 04:41
@Ekene96 assign farenheight to (celsius)*(9/5)+32
Michael Noronha
@mtn
Aug 13 2016 04:41
Working on search and replace and I've hit a bit of a snag
silver537
@silver537
Aug 13 2016 04:41
@losbaltica you're assigning methods to variables. baaaaaaad
Norvin Burrus
@ndburrus
Aug 13 2016 04:41
@m4sterbunny basically, we need to create an object similar to the given object. we can use the formatting of the existing object to match the format/syntax (with new values for the record elements). ...and, don't forget the note, here You will need to place a comma after every object in the array, unless it is the last object in the array.
Michael Noronha
@mtn
Aug 13 2016 04:41
silver537
@silver537
Aug 13 2016 04:41
@michaeltnoronha well hello there
Michael Noronha
@mtn
Aug 13 2016 04:41
@ndburrus Mind taking a look and helping me out? :P
Milo Hartsoe
@MiloATH
Aug 13 2016 04:42
@michaeltnoronha hey it is milo from PACT
Michael Noronha
@mtn
Aug 13 2016 04:42
@silver537 oh hi!
!!!!
silver537
@silver537
Aug 13 2016 04:42
you should paste your code instead of links.
Norvin Burrus
@ndburrus
Aug 13 2016 04:42
@michaeltnoronha sorry, i'm not there yet... :(
Michael Noronha
@mtn
Aug 13 2016 04:42
@MiloATH !!!!!
Chad Powell
@cjpowellaz
Aug 13 2016 04:42
This is the closest I have come yet, I am now getting an "Undefined" returned with the string:

function titleCase(str) {
var caseChange;
var strSplit = str.toLowerCase().split(" ");

for (var x = 0; x < strSplit.length; x++) {
caseChange += strSplit[x].charAt(0).toUpperCase();
caseChange += strSplit[x].slice(1);
caseChange += " ";
}

return caseChange;
}

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

masterbunny
@m4sterbunny
Aug 13 2016 04:42
@silver537 doesn't seem to do it with [] removed.
DJ
@qualitymanifest
Aug 13 2016 04:43
@cjpowellaz you need to initialize caseChange as a string.
Ekene96
@Ekene96
Aug 13 2016 04:43
<p> don't know what to do</p>
Chad Powell
@cjpowellaz
Aug 13 2016 04:43
can I assign var caseChange to a Null at the top
silver537
@silver537
Aug 13 2016 04:43
@m4sterbunny let me see how you did it
DJ
@qualitymanifest
Aug 13 2016 04:43
@cjpowellaz you don't want to assign it null, just assign it an empty string
Chad Powell
@cjpowellaz
Aug 13 2016 04:43
oh, a string
Milo Hartsoe
@MiloATH
Aug 13 2016 04:43
@michaeltnoronha Good, I just updated the website, we had some good lectures
masterbunny
@m4sterbunny
Aug 13 2016 04:43
@ndburrus I copy pasted their example and they were good with the , :)
Milo Hartsoe
@MiloATH
Aug 13 2016 04:43
mostly linear programming @michaeltnoronha
and approximation algos
Norvin Burrus
@ndburrus
Aug 13 2016 04:44
@m4sterbunny ok! :+1:
Michael Noronha
@mtn
Aug 13 2016 04:44
@MiloATH cool cool, private chat
Ekene96
@Ekene96
Aug 13 2016 04:44
@MiloATH please could you show one example
masterbunny
@m4sterbunny
Aug 13 2016 04:44
@silver537
myMusic[0].push [
{ "artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true}]
;
silver537
@silver537
Aug 13 2016 04:45
that's because you're using brackets. when you should be using parenthesis.
Michael Noronha
@mtn
Aug 13 2016 04:45
@silver537 Yous till want the sample in here? I just gave a link so you can run it
silver537
@silver537
Aug 13 2016 04:45
@m4sterbunny .push() not .push[]
@michaeltnoronha yea. i can use rep.li
Norvin Burrus
@ndburrus
Aug 13 2016 04:46
@m4sterbunny why are you using a method (push)? the lesson is manipulating complex objects, right?
silver537
@silver537
Aug 13 2016 04:47
@ndburrus in my opinion, it's better practice.
Michael Noronha
@mtn
Aug 13 2016 04:47
@silver537 So the link is fine?
masterbunny
@m4sterbunny
Aug 13 2016 04:47
@silver537 that gives me: error myMusic is not a function
Milo Hartsoe
@MiloATH
Aug 13 2016 04:48
@Ekene96 ```js
fahrenheit = celsius*(9/5)+32;
masterbunny
@m4sterbunny
Aug 13 2016 04:48
@ndburrus Yeah I did some reading and people seem to use push to add to arrays- I was like push was pretty cool let's do it!
silver537
@silver537
Aug 13 2016 04:48
@m4sterbunny post the whole code. not just your portion. i wanna see what is being used.
masterbunny
@m4sterbunny
Aug 13 2016 04:49
what method did you use? or are you gonna make me come over there and peek!
luis4flames
@luis4flames
Aug 13 2016 04:49
@m4sterbunny I'm on the same part! been at it for hours and havent been able to complete it
silver537
@silver537
Aug 13 2016 04:49
@michaeltnoronha no i meant post the code. so i can use repl.it
Norvin Burrus
@ndburrus
Aug 13 2016 04:49
@silver537 @m4sterbunny ok.. :+1:
silver537
@silver537
Aug 13 2016 04:49
i don't like clicking links.
masterbunny
@m4sterbunny
Aug 13 2016 04:49

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];

myMusic(0).push [
{ "artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true}]
;

Joseph
@revisualize
Aug 13 2016 04:49
@m4sterbunny You're supposed to make two array elements.
luis4flames
@luis4flames
Aug 13 2016 04:49
oh nvm im on a few after that
Joseph
@revisualize
Aug 13 2016 04:49
[ { ... } , { ... } ]
silver537
@silver537
Aug 13 2016 04:50
@m4sterbunny oh ok. you're still using [ ]!!!!! stop it! >.<
Michael Noronha
@mtn
Aug 13 2016 04:50
function myReplace(str, before, after) {
  return( str.substring(0,str.indexOf(before))+after+str.substring(str.indexOf(before)+after.length,str.length));
}
luis4flames
@luis4flames
Aug 13 2016 04:50
you just need a coma after it instead of the closing bracket
silver537
@silver537
Aug 13 2016 04:50
@m4sterbunny
myMusic.push(input your object here);
Michael Noronha
@mtn
Aug 13 2016 04:50
@silver537 I'm aware it's not matching the cases
masterbunny
@m4sterbunny
Aug 13 2016 04:50

@silver537 still dont work
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];

myMusic(0).push
{ "artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true}
;

Joseph
@revisualize
Aug 13 2016 04:51
@m4sterbunny Why are you even using .push?
Michael Noronha
@mtn
Aug 13 2016 04:51
@silver537 What I'm confused about is that on the mall test, it's returning "malle" instead of "mall"
silver537
@silver537
Aug 13 2016 04:51
@m4sterbunny would it helped if i told you that .push() is a function?? and NEEDS parenthesis
masterbunny
@m4sterbunny
Aug 13 2016 04:51
@revisualize That's what Norvin said too!
Joseph
@revisualize
Aug 13 2016 04:51
@m4sterbunny You're just supposed to manually add the other element.
[ { ... } , { ... } ]
You do NOT need to push.
Not to mention that you're doing push incorrectly.
silver537
@silver537
Aug 13 2016 04:52
@revisualize let her do what she wants :angry: :P
Joseph
@revisualize
Aug 13 2016 04:52
var myArr = [1,2,3];
myArr.push(4); // [1,2,3,4]
masterbunny
@m4sterbunny
Aug 13 2016 04:52
@revisualize manually... what no way there has to be a way- I read that good programmers are lazy!
Joseph
@revisualize
Aug 13 2016 04:53
@m4sterbunny Good programmers are lazy.
llamatarianism
@llamatarianism
Aug 13 2016 04:53
the challenge specifically asks you to edit the actual array to add a new element
not to use push
masterbunny
@m4sterbunny
Aug 13 2016 04:54
@llamatarianism It says: Add a new album to the myMusic array.
llamatarianism
@llamatarianism
Aug 13 2016 04:54
yes
Michael Noronha
@mtn
Aug 13 2016 04:54
@silver537 Did you see the snippet I posted above? I can resend it if not
llamatarianism
@llamatarianism
Aug 13 2016 04:55
other problems:
Joseph
@revisualize
Aug 13 2016 04:55

@m4sterbunny
Note
You will need to place a comma after every object in the array, unless it is the last object in the array.

Instructions
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.

masterbunny
@m4sterbunny
Aug 13 2016 04:55
So the challenge wont let me use push even if I get my syntax right?
silver537
@silver537
Aug 13 2016 04:55
@michaeltnoronha yea. supposedly it works. 0.o
llamatarianism
@llamatarianism
Aug 13 2016 04:55
myArr is not a function, so myArr(0) breaks
luis4flames
@luis4flames
Aug 13 2016 04:55

Can someone help me with this. Ive been at it for hours trying different things and havent been able to get things going
// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

llamatarianism
@llamatarianism
Aug 13 2016 04:55
and you need parentheses around push
silver537
@silver537
Aug 13 2016 04:55
@m4sterbunny your syntax was wrong in the first place.
Michael Noronha
@mtn
Aug 13 2016 04:55
@silver537 it works except for the cases where the case is wrong, right?
Joseph
@revisualize
Aug 13 2016 04:55
@luis4flames From the code that you've posted .. You haven't done anything.
llamatarianism
@llamatarianism
Aug 13 2016 04:55
f(x); is valid JS; f x; isn't
Michael Noronha
@mtn
Aug 13 2016 04:56
@silver537 but in my repl.it, it is adding an extra e to mall
Joseph
@revisualize
Aug 13 2016 04:56
var myArr = [1,2,3];
myArr.push(4); // [1,2,3,4]
masterbunny
@m4sterbunny
Aug 13 2016 04:56
@silver537 My syntax is always wrong in the first place- I just survive with the hope that when I get it right it will work! I write bugs!
Joseph
@revisualize
Aug 13 2016 04:57
var myArrObjects = [ {a: 1} , {b: 2} ];
myArrObjects.push({c: 3}); // see... arr.push() 
                          // .. In the .push() I have an object. {c: 3}
silver537
@silver537
Aug 13 2016 04:57
@m4sterbunny but you keep using [ ]
.push() <-- this is right
.push[] <-- this is wrong
Joseph
@revisualize
Aug 13 2016 04:59
But, again. This lesson is LAZY.
masterbunny
@m4sterbunny
Aug 13 2016 04:59
@silver537 I promise I am trying out the suggestion- but something else must be wrong too
myMusic(0).push (
{ "artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true})
;
Adam Pankowski
@losbaltica
Aug 13 2016 04:59

Does somebody knows why this replace comend dont work?

js function palindrome(str) { // Good luck! var a = str.replace(/^\w\d/g, '');

Joseph
@revisualize
Aug 13 2016 04:59
@m4sterbunny Question.. Where are you getting (0) from? var myMusic = [
masterbunny
@m4sterbunny
Aug 13 2016 04:59
@revisualize Yes lazy/repeatable/less error ridden cause a typo monkey like me was not involved in moving the data
silver537
@silver537
Aug 13 2016 04:59
@m4sterbunny ok now your push is right
delete (0)
masterbunny
@m4sterbunny
Aug 13 2016 05:00
@silver537 Ah you did it! Thanks.
CamperBot
@camperbot
Aug 13 2016 05:00
m4sterbunny sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 485 | @silver537 |http://www.freecodecamp.com/silver537
masterbunny
@m4sterbunny
Aug 13 2016 05:01
So my first question was about arrays and how you add to an array that has more than one level (indice). But I get that this data has to go in at the bottom level anyway so I guess that is default.
silver537
@silver537
Aug 13 2016 05:01
@michaeltnoronha because the way you're concatenating
why not use replace?
mahfudzaji
@mahfudzaji
Aug 13 2016 05:02

hello all..anybody can help me?why this code is not working

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

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

// Only change code above this line

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

if(contacts[i].firstName!=firstName){
  return "No such contact";
}else if(contacts[i].hasOwnProperty(prop)==false){
  return "No such property";
}else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)==true){
  return  contacts[i][prop];
}

}

}

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

Joseph
@revisualize
Aug 13 2016 05:02
var myArr = [
    { 
        "Obj": "Val"
    }
  ];
The lazy way to add an object to the end.
var myArr = [
    { 
        "Object One": "Val"
    } ,
    { 
        "Object Two": "Val"
    }
  ];
mahfudzaji
@mahfudzaji
Aug 13 2016 05:02
any help appreciated
Joseph
@revisualize
Aug 13 2016 05:02
mahfudzaji
@mahfudzaji
Aug 13 2016 05:03
ok thank you @revisualize
CamperBot
@camperbot
Aug 13 2016 05:03
mahfudzaji sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1609 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 13 2016 05:04
For those of you that don't want to see those Gist.. Please type: /collapse
silver537
@silver537
Aug 13 2016 05:04
@revisualize //collapse-all
Joseph
@revisualize
Aug 13 2016 05:04
@Ekene96 You're not placing your code in the function. It is outside of the function.
silver537
@silver537
Aug 13 2016 05:04
:P
Joseph
@revisualize
Aug 13 2016 05:04
@silver537 /collapse-everything
/collapse-your-face
silver537
@silver537
Aug 13 2016 05:05
/collapse-the-world
Joseph
@revisualize
Aug 13 2016 05:05
/collapse-infinity
Ekene96
@Ekene96
Aug 13 2016 05:05
@revisualize please elaborate more. show me an example
encount
@encount
Aug 13 2016 05:05
@mahfudzaji as you iterate through the code - if for example you chose Kristain - the first clause will return no such contact (as its comparing Kristian to Akira - who is first on the list
silver537
@silver537
Aug 13 2016 05:05
@revisualize on the record, i thought you were too elaborate. xD
pahosler
@pahosler
Aug 13 2016 05:05
/collapse-carp
Joseph
@revisualize
Aug 13 2016 05:05
@Ekene96 Sure...
function coolFunc(param) {
    return param; // Code Inside of a function.
}
var str = "Code Outside of a function";
silver537
@silver537
Aug 13 2016 05:06
“As above, so below, as within, so without, as the universe, so the soul…” Hermes Trismegistus
Ekene96
@Ekene96
Aug 13 2016 05:06
thanks
Joseph
@revisualize
Aug 13 2016 05:07
"Talk is cheap. Show me the code." - Linus Torvalds (2000-08-25).
Ekene96
@Ekene96
Aug 13 2016 05:07
thanks @revisualize
CamperBot
@camperbot
Aug 13 2016 05:07
ekene96 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1610 | @revisualize |http://www.freecodecamp.com/revisualize
silver537
@silver537
Aug 13 2016 05:07
lmao
Chad Powell
@cjpowellaz
Aug 13 2016 05:07
It works! Thank you @qualitymanifest, @MiloATH
CamperBot
@camperbot
Aug 13 2016 05:07
cjpowellaz sends brownie points to @qualitymanifest and @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @miloath |http://www.freecodecamp.com/miloath
:star2: 1349 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
silver537
@silver537
Aug 13 2016 05:07
who the fuck is linus?
Joseph
@revisualize
Aug 13 2016 05:07
@silver537 I know right.. What a Noob.
@silver537 Wait, you really do know who Linus is... I hope.
@silver537 Because, if you don't... I feel sorry for you.
silver537
@silver537
Aug 13 2016 05:09
nope have no idea who that is.. who is he?
mahfudzaji
@mahfudzaji
Aug 13 2016 05:10
@encount oh oke bro...I understand it..thank you
luis4flames
@luis4flames
Aug 13 2016 05:11
Can anyone help with the record collection section of basic java script. Ive been at it for hours now and havent had any luck and doesnt seem like any light bulbs are going to shine all of a sudden for me. dont want to skip it and no option to just see answer. https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20var%20nameAlbum%20%3D%20%22album%22%3B%0A%20%20var%20nameArtist%20%3D%20%22arist%22%3B%0A%20%20var%20nameTrack%20%3D%20%22tracks%22%3B%0A%20%20%0A%20%20if%20(collection%5BnameAlbum%5D.hasOwnProperty%20%3D%3D%3D%20false%20)%20%7B%0A%20%20%20%20collection%5Bid%5D.push(%5B%5D)%3B%0A%20%20%20%20collection%5Bid%5D%0A%20%20%7D%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
@luis4flames You're doing it wrong. Let me ask you some questions.
luis4flames
@luis4flames
Aug 13 2016 05:12
sorry for huge link
sure
Tia Holiday
@tlholiday
Aug 13 2016 05:13
Doing the "Stand in Line" challenge, need help! :worried:
Joseph
@revisualize
Aug 13 2016 05:13
@luis4flames Can you code this:
If I have a variable name and it is equal to "Joseph" update the variable cool to true.
Tia Holiday
@tlholiday
Aug 13 2016 05:13
Here's what I have...
@tlholiday Can you answer those two questions?
luis4flames
@luis4flames
Aug 13 2016 05:16
there two different variables?
Joseph
@revisualize
Aug 13 2016 05:16
@luis4flames name and cool
silver537
@silver537
Aug 13 2016 05:16
@revisualize ha i view him like i view every other entrepreneur; if it aint me, i don't care.
Tia Holiday
@tlholiday
Aug 13 2016 05:17
Yes....? push and and shift?
@revisualize
Joseph
@revisualize
Aug 13 2016 05:17
@tlholiday Correct.
@tlholiday Two lines of code. And you've just solved it.
luis4flames
@luis4flames
Aug 13 2016 05:18
push to add what?
Joseph
@revisualize
Aug 13 2016 05:18
@luis4flames I was talking to @tlholiday
Adam Pankowski
@losbaltica
Aug 13 2016 05:18
Is anyone knows what is wrong here?
function palindrome(str) {
  // Good luck!
  var a = str.replace(/[^\w\d]/g, '');
  var b = a.toLowerCase();
  var c = b.split("");
  var d = c.reverse();
  var e = d.join("");

  for (i=0; i < b.length; i++) {
    if (b.charAt(i) === (b.charAt(b.length-1))) {
      return true;
    } else if (b.charAt(i) === e.charAt(i)) {
        return true;
    } else {
        return false;
      }

    }

    return b;

}



palindrome("eye");
Joseph
@revisualize
Aug 13 2016 05:19
@losbaltica Your regex.
@losbaltica What is \w? What is \d?
Tia Holiday
@tlholiday
Aug 13 2016 05:19
Ok great, but I'm throughly confused how to write that so all checkmarks turn Green. I have done it individually, but am I witting 4 seperate functions?
luis4flames
@luis4flames
Aug 13 2016 05:20
ohh k. well cool = hasOwnProperty(name); @revisualize
Brandon
@Brandons42
Aug 13 2016 05:20
function destroyer() {
  // Can someone help me with this challenge, Seek and Destroy
  function seeker(val) {
    for (q = 1;  q < arguments.length;  q++) {
      if (arguments[q] == val) {
        return false;
      }
    }
    return true;
  }
  var arrNew = arguments[0].filter(seeker);
  return arrNew;
}
luis4flames
@luis4flames
Aug 13 2016 05:20
that would make cool true
Joseph
@revisualize
Aug 13 2016 05:20
@luis4flames No.
Adam Pankowski
@losbaltica
Aug 13 2016 05:20
@revisualize \d is all digit, \w is Any Alphanumeric character
Faisal Zulfiqar
@faisal1337
Aug 13 2016 05:20
http://codepen.io/faisal1337/pen/bZONag?editors=1100 So I have this grid. Helper classes are being used to display different grid for mobile. I've nested a row inside aother row so that or mobile the layout doesn't go buggy. As I resize the browser window the layout works as expected but when I test it on a browser like blisk which emulates for mobile devices, it still shows the layout of desktop version of grid. Help me out. :worried:
Joseph
@revisualize
Aug 13 2016 05:21
@losbaltica You have \d correct. Can you give me more information about \w?
Adam Pankowski
@losbaltica
Aug 13 2016 05:21
@revisualize and ^[] is negation
Sophanarith Sok
@sok213
Aug 13 2016 05:21
@Brandons42 First off, I would say you don't need a function within a function?
Joseph
@revisualize
Aug 13 2016 05:21
@losbaltica Correct. ^ is negation.
Adam Pankowski
@losbaltica
Aug 13 2016 05:21
silver537
@silver537
Aug 13 2016 05:21
@losbaltica why don't you chain those methods instead?
Joseph
@revisualize
Aug 13 2016 05:21
@luis4flames Can you code this:
If I have a variable name and it is equal to "Joseph" update the variable cool to true.
Sophanarith Sok
@sok213
Aug 13 2016 05:21
@Brandons42 Nevermind, you could do it that way too.
Tia Holiday
@tlholiday
Aug 13 2016 05:22
Ok great, but I'm throughly confused how to write that so all checkmarks turn Green. I have done it individually, but am I witting 4 seperate functions? @revisualize
Joseph
@revisualize
Aug 13 2016 05:22
@losbaltica I know what they mean. I want to know if you know what they mean.
Ramesh syangtan
@rameshsyn
Aug 13 2016 05:22
http://regexr.com/ check your regex :D
silver537
@silver537
Aug 13 2016 05:22
@tlholiday the methods basically do the work for you.
Joseph
@revisualize
Aug 13 2016 05:23
@losbaltica \w is not just all alphanumeric characters
Greg Duncan
@GregatGit
Aug 13 2016 05:23
@losbaltica which test ios failing?
silver537
@silver537
Aug 13 2016 05:23
get the variable, chain push. and return shift.
Tia Holiday
@tlholiday
Aug 13 2016 05:23
@silver537 I don't know what you mean by that
Adam Pankowski
@losbaltica
Aug 13 2016 05:23
@revisualize i check in http://www.regexr.com/ and i got correct marks
Joseph
@revisualize
Aug 13 2016 05:23
@tlholiday It is literally just two simple lines of code.
Adam Pankowski
@losbaltica
Aug 13 2016 05:23
@revisualize ou so i guess is also _ and other?
Joseph
@revisualize
Aug 13 2016 05:23
@losbaltica Great.
Adam Pankowski
@losbaltica
Aug 13 2016 05:24
@GregatGit Check for Palindromes
Tia Holiday
@tlholiday
Aug 13 2016 05:24
@revisualize I can appreciate that you say it's simple, but to ME as a 100% newbie, it is not simple. But thank you for the help so far. I'll fight my way through it :)
CamperBot
@camperbot
Aug 13 2016 05:24
tlholiday sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1611 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 13 2016 05:24
@losbaltica You're supposed to remove all non-alphanumeric characters. Does ^\w\d include ALL non-alphanumeric charcters?
@tlholiday You've already told me the answer. .push() and .shift()
Yes....? push and and shift?
Greg Duncan
@GregatGit
Aug 13 2016 05:25
@losbaltica to make it a little easier to follow you don't need to create new variable all the time
silver537
@silver537
Aug 13 2016 05:25
@tlholiday here ya go.
arr.push(item);return arr.shift();
Joseph
@revisualize
Aug 13 2016 05:26
...
Doesn't help that the regex is still broken.
Tia Holiday
@tlholiday
Aug 13 2016 05:26
Again @silver537 & @revisualize , unfortunately I am still not understanding how I'm supposed to get all of what challenge is asking. Again, thank you, but you 2 aren't understanding my ask. All good.
CamperBot
@camperbot
Aug 13 2016 05:26
tlholiday sends brownie points to @silver537 and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: tlholiday already gave revisualize points
:cookie: 487 | @silver537 |http://www.freecodecamp.com/silver537
Joseph
@revisualize
Aug 13 2016 05:27
@tlholiday What is your current function?
@tlholiday What are you asking?
silver537
@silver537
Aug 13 2016 05:28
@tlholiday you're not asking the right questions. be more in depth to what you want to know. we can help you understand, but so far, we don't know what you're asking.
Tia Holiday
@tlholiday
Aug 13 2016 05:28
@silver537 @revisualize Obviously. Lol. It's ok. I'll figure it out. There isn't another way I can break it down so you two understand.
Joseph
@revisualize
Aug 13 2016 05:29
@tlholiday If you have have more than 1 function for that challenge. You're not understanding the instructions correctly.
Adam Pankowski
@losbaltica
Aug 13 2016 05:29
@revisualize ok i see thx. I start to looking how to and [^a-z] and /d
CamperBot
@camperbot
Aug 13 2016 05:29
losbaltica sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1612 | @revisualize |http://www.freecodecamp.com/revisualize
silver537
@silver537
Aug 13 2016 05:31
@tlholiday they want you to add the number to the end of the array which you answered with .push()
then they want you to remove the first element of the array and you answered with .shift()
in the previous challenges you have inserted a number with push by using it as array.push(number)
also in the previous challenges you have removed a number from the beginning of the array by using array.shift()
luis4flames
@luis4flames
Aug 13 2016 05:32
var name = "joseph" var cool = Boolean(name = "joseph"); @revisualize
Tia Holiday
@tlholiday
Aug 13 2016 05:32
@silver537 yes, I understand that, but they want me push 4 numbers (1, 2, 5 & 10) to the end of the array?
encount
@encount
Aug 13 2016 05:33
this works but does not pass the test - although correct output is in console - any ideas would be appreciated! function titleCase(str) {
      var ns="";

      var foo = str.split(" ");

      for (var i = 0; i < foo.length; i++) {
        var bar = foo[i];
        var cap = bar.charAt(0).toUpperCase() + bar.slice(1).toLowerCase();
        ns += cap + " "; 
      }


      return ns;
    }

    titleCase("I'm a lITtle tea pOt");
Joseph
@revisualize
Aug 13 2016 05:33
@luis4flames Still incorrect.
luis4flames
@luis4flames
Aug 13 2016 05:33
ran it on editor and got it to return as true
silver537
@silver537
Aug 13 2016 05:34
@tlholiday no, those are tests. they use those to test your code. all you're doing is creating a program. they use the testing functions to test whether your code complies with all the instances.
in other words, don't worry about those numbers. just worry about making the program work.
NixonRichard
@NixonRichard
Aug 13 2016 05:34
hi nerds
silver537
@silver537
Aug 13 2016 05:35
@NixonRichard relevant term is GEEK mofo!
Joseph
@revisualize
Aug 13 2016 05:35

@luis4flames Can you code this:
If I have a variable name and it is equal to "Joseph" update the variable cool to true.

Look:

if (name === "Joseph") {
   cool = true;
}

I have no idea where you got that things were an object or a boolean.

Adam Pankowski
@losbaltica
Aug 13 2016 05:36
function palindrome(str) {
  // Good luck!
  var a = str.toLowerCase();
  var b = a.replace(/[^a-z\d]/g, '');
  var c = a.split("");
  var d = c.reverse();
  var e = d.join("");

  for (i=0; i < b.length; i++) {
    if (b.charAt(i) === (b.charAt(b.length-1))) {
      return true;
    } else if (b.charAt(i) === e.charAt(i)) {
        return true;
    } else {
        return false;
      }
    }
}



palindrome("eye");
Ok my function almost working correctly but still is failing with palindrome("almostomla") should return false.
Greg Duncan
@GregatGit
Aug 13 2016 05:37
@losbaltica Your regexp look ok - Your problem is with your logic - it should be able to loop through the whole word/sentence/array but in your at the very first check it returns either true or false. If it gets through it should return true - the moment it finds an error it should return false
Tia Holiday
@tlholiday
Aug 13 2016 05:38
@silver537 then what am I doing wrong

function nextInLine(arr, item) {
var testArr = [1, 2, 3, 4, 5];
arr.push (2);
var removed = arr.shift();
return 2;
}

// Test Setup
var testArr = [1,2,3,4,5];
var testArr = [5, 6, 7, 8, 9];

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

Joseph
@revisualize
Aug 13 2016 05:38
@luis4flames Do you understand why I'm asking you to write this extra if statement?
Bob Sagun
@bobsagun
Aug 13 2016 05:39

I'm getting stuck
// Setup
var lastName = "Lovelace";

// Only change code below this line
var secondToLastLetterOfLastName = lastName[lastName.length - 7];
error says - secondToLastLetterOfLastName should be "c".

Greg Duncan
@GregatGit
Aug 13 2016 05:40
@losbaltica so how will it check the second letter if it has already returned true or false for the first letter?
Joseph
@revisualize
Aug 13 2016 05:40
@luis4flames Please take the time to look at the example of what I asked you to write. Then please look at the instructions for Record Collection again.
luis4flames
@luis4flames
Aug 13 2016 05:40
@revisualize to check if the property exist
Joseph
@revisualize
Aug 13 2016 05:40
NO!
Bob Sagun
@bobsagun
Aug 13 2016 05:40
err says -- secondToLastLetterOfLastName should be "c".
Joseph
@revisualize
Aug 13 2016 05:40
@luis4flames I had 0 objects in my example if.
Just two variables that were 1 string and 1 boolean.

@luis4flames Can you code this:
If I have a variable name and it is equal to "Joseph" update the variable cool to true.

Look:

if (name === "Joseph") {
   cool = true;
}
Jason Keenan
@raavin
Aug 13 2016 05:41
@tlholiday is this 'next in line' ???
Joseph
@revisualize
Aug 13 2016 05:41
@raavin Stand In Line
Tia Holiday
@tlholiday
Aug 13 2016 05:41
@raavin no "Stand in Line"
Adam Pankowski
@losbaltica
Aug 13 2016 05:41
@GregatGit i wonder :D give me a second
encount
@encount
Aug 13 2016 05:42
@losbaltica when you have regex and reversed you word why don't you just compare the old with the new to make it easier? so if oldword === new word its a palindrome
Jason Keenan
@raavin
Aug 13 2016 05:42
@tlholiday yeah that one ;)
Tia Holiday
@tlholiday
Aug 13 2016 05:42
@raavin yea, that one. Lol. Still lost and want to throw mac through the TV.
Greg Duncan
@GregatGit
Aug 13 2016 05:43
@tlholiday you should work on the params (arr and item) not on testArr
luis4flames
@luis4flames
Aug 13 2016 05:43
@revisualize because of this statement \If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.
Bob Sagun
@bobsagun
Aug 13 2016 05:43

Any one having issues with this?
// Setup
var lastName = "Lovelace";

// Only change code below this line
var secondToLastLetterOfLastName = lastName[lastName.length - 7];
error says - secondToLastLetterOfLastName should be "c".

Jason Keenan
@raavin
Aug 13 2016 05:44
@tlholiday so you need to push the second argument to the end then drop the first element of the array and return that
Greg Duncan
@GregatGit
Aug 13 2016 05:44
@losbaltica just keep in mind a function ends the moment you come to a return statement
Tia Holiday
@tlholiday
Aug 13 2016 05:46
@raavin Yea, I understand for the most part that concept, but what I don't undersand is how to do that with the 3 other numbers. I can get one to work and when I add another push it all stops working
Joseph
@revisualize
Aug 13 2016 05:46

@luis4flames Okay.. that...

// If prop isn't "tracks" and value isn't empty (""), 
if (prop != "tracks" && value != "") {
   // update or set the value for that record album's property.
}

Compare that to my question:

// If I have a variable name and it is equal to "Joseph"
if (name === "Joseph") {
   //  update the variable cool to true.
   cool = true;
}
Tia Holiday
@tlholiday
Aug 13 2016 05:46

@raavin here's what I have...

function nextInLine(arr, item) {
var testArr = [1, 2, 3, 4, 5];
arr.push (2);
var removed = arr.shift();
return 2;
}

Adam Pankowski
@losbaltica
Aug 13 2016 05:46
@GregatGit ou i see so i should loop it somehow
Jason Keenan
@raavin
Aug 13 2016 05:47
@tlholiday so you need to push 'item', shift and return the 'shifted' value. shift() returns the deleted element by the way
Joseph
@revisualize
Aug 13 2016 05:47
@tlholiday You're not pushing item ... You're not returning the removed element.
Jason Keenan
@raavin
Aug 13 2016 05:47
@tlholiday you need to arr.push(item);
Greg Duncan
@GregatGit
Aug 13 2016 05:47
@losbaltica don't return true in the loop - only false if there is a mistake - return true if you can get throught the loop
NixonRichard
@NixonRichard
Aug 13 2016 05:47
Hi there
Joseph
@revisualize
Aug 13 2016 05:47
The shift() method removes the first element from an array and returns that element. This method changes the length of the array.
NixonRichard
@NixonRichard
Aug 13 2016 05:48
what s going on ?
Tia Holiday
@tlholiday
Aug 13 2016 05:48
As in I am literally type arr.push(item); ? @raavin
Joseph
@revisualize
Aug 13 2016 05:48
@tlholiday yes.
Greg Duncan
@GregatGit
Aug 13 2016 05:50
@tlholiday remove this line var testArr = [1, 2, 3, 4, 5]; not needed at all
Jason Keenan
@raavin
Aug 13 2016 05:50
@tlholiday In this case yes, you are pushing the value in the variable, so when you run the function nextInLine(2, 1) you are pushing 1 to the array
Tia Holiday
@tlholiday
Aug 13 2016 05:50
@GregatGit that's added by FFC, I didn't add that
Joseph
@revisualize
Aug 13 2016 05:50
// How do you add a number (item) to the end of an array (arr)?
arr.push(item);
// How do you remove the first element from an array (arr)?
.shift();
..
The shift() method removes the first element from an array and returns that element.
This method changes the length of the array.
Greg Duncan
@GregatGit
Aug 13 2016 05:50
@tlholiday you have to return the item that you take out of the array - not the number 2
luis4flames
@luis4flames
Aug 13 2016 05:50
@revisualize so as the command it would be for it to push the value to the property
Joseph
@revisualize
Aug 13 2016 05:51
@luis4flames Is the property an array?
Adam Pankowski
@losbaltica
Aug 13 2016 05:51

@GregatGit


function palindrome(str) {
  // Good luck!
  var a = str.toLowerCase();
  var b = a.replace(/[^a-z\d]/g, '');
  var c = a.split("");
  var d = c.reverse();
  var e = d.join("");

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

    if (b.charAt(i) !== e.charAt(i)) {
        return false;
    } 

    return true;
  }

}



palindrome("eye");

Still is something wrong :(

Jason Keenan
@raavin
Aug 13 2016 05:51
@tlholiday read https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift for what shift() does and returns, You should be able to do this challenge in 2 lines.
Tia Holiday
@tlholiday
Aug 13 2016 05:51
@silver537 @revisualize this is what I have...the same 2 boxes are still not checked off.
function nextInLine(arr, item) {
var testArr = [1, 2, 3, 4, 5];
arr.push (item);
var removed = arr.shift();
return item;
}
I've read that aleady
Before I clicked here
and stackoverflow and the chapter in eloquent javascript
Joseph
@revisualize
Aug 13 2016 05:52
@tlholiday

function nextInLine(arr, item) {
  var testArr  = [1, 2, 3, 4, 5]; // REMOVE
  arr.push (item);  
  var removed = arr.shift(); // You should be returning the shift() not setting a variable.
  return item;
}
luis4flames
@luis4flames
Aug 13 2016 05:52
@revisualize no, its just an element. The array inside is the "tracks" property
Joseph
@revisualize
Aug 13 2016 05:52
@luis4flames Can you .push() to strings?
Greg Duncan
@GregatGit
Aug 13 2016 05:52
@losbaltica take return true out of the loop
arif hussain
@arifhussain0
Aug 13 2016 05:52
need help on string.replace()
i am not sure how it works
Greg Duncan
@GregatGit
Aug 13 2016 05:53
@losbaltica put it at the end of the function (not the end of the loop)
arif hussain
@arifhussain0
Aug 13 2016 05:53
need it for palindrome exercise
Adam Pankowski
@losbaltica
Aug 13 2016 05:54
first you put what i want to select, then with what
@arifhussain0 so is like str = "adam" str.replece("a","b"); and you get str="bdbm"
Jason Keenan
@raavin
Aug 13 2016 05:54
@revisualize no, strings are immutable
Joseph
@revisualize
Aug 13 2016 05:55
@raavin I appreciate that. I was asking @luis4flames because they're working on Record Collection.
But, thanks anyway.
Jason Keenan
@raavin
Aug 13 2016 05:55
@revisualize ahh :blush:
@revisualize I realised that might be the case when I realised who had posted
Joseph
@revisualize
Aug 13 2016 05:56
Socratic Method of Teaching.
Adam Pankowski
@losbaltica
Aug 13 2016 05:56

@GregatGit ok, when i put it out it start to fail in palindrome("_eye") should return true.

and some others

Tia Holiday
@tlholiday
Aug 13 2016 05:56
@revisualize @silver537 figured it out. I wasn't returning the right thing...
luis4flames
@luis4flames
Aug 13 2016 05:56
no, so I would re asssign the entire string. But how would i make it so it holds the previous content and add the new value @revisualize
can I set a variable to equal that property and manipulate that way
Joseph
@revisualize
Aug 13 2016 05:57
@luis4flames You shouldn't be caring about the previous content.
If I have a var cool = true; and I set cool = false; Do I really care what the previous value is? I just know that I'm not one of the cool kids any more.
Jason Keenan
@raavin
Aug 13 2016 05:58
@tlholiday yay :)
@tlholiday just wondering, did you end up returning 'removed' or did you return arr.shift() directly??
Joseph
@revisualize
Aug 13 2016 06:00
So, instead of drinking and sitting in help chat on a Friday night.. I'm eating ice cream and sitting in a Help Chat.
Something is really wrong with me.
Casey Heath
@ExhibitArts
Aug 13 2016 06:01
Anyone willing to help with an experimental start up site?
Need some front and back-end devs as well as a few designers.
Pm me.
:smile:
Joseph
@revisualize
Aug 13 2016 06:01
I really shouldn't a: be eating ice cream. b: sitting in a help chat on a Friday night. c: not drinking. d: all of the above.
d!!
Jason Keenan
@raavin
Aug 13 2016 06:01
@revisualize No need to worry, I just bought non alcoholic beer to go to a party...some party
silver537
@silver537
Aug 13 2016 06:02
@revisualize boo hoo. can survive without a social life. :/
Joseph
@revisualize
Aug 13 2016 06:02
@raavin I actually had a lady friend invite me to a party that was tonight. Yeah. She didn't text me.
Adam Pankowski
@losbaltica
Aug 13 2016 06:02
Yupi! i made it :D after 1,5h of thinking :D thx @GregatGit
CamperBot
@camperbot
Aug 13 2016 06:02
losbaltica sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 735 | @gregatgit |http://www.freecodecamp.com/gregatgit
luis4flames
@luis4flames
Aug 13 2016 06:02
so to set collection[id][1] = [prop, value] @revisualize
Joseph
@revisualize
Aug 13 2016 06:03
@silver537 Meh. I need a social life if I want to get that :woman: :heart_eyes:
@luis4flames Nope.
silver537
@silver537
Aug 13 2016 06:03
lol just get a hooker
Joseph
@revisualize
Aug 13 2016 06:03
@silver537 Ick.
silver537
@silver537
Aug 13 2016 06:03
xD
whaaaaaat?
Joseph
@revisualize
Aug 13 2016 06:03
@luis4flames May I suggest going back and re-doing the JS Object Lessons?
Greg Duncan
@GregatGit
Aug 13 2016 06:03
@losbaltica :+1: you have a,b,c,d,e - try just use str and one other letter if possible
silver537
@silver537
Aug 13 2016 06:06
@losbaltica why do you declare so many variables?
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:07
var strVale = "130,235,342,124";
arr = strVale.split(',',2);
Joseph
@revisualize
Aug 13 2016 06:07
Look. Don't fault the person for assigning too many variable. This should be a learning process.
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:07
sorry
wrong paste
how do you use ajax to parse contents when the whole response contains only {} and no []
Am I making sense?
Joseph
@revisualize
Aug 13 2016 06:08
Sometimes people have to break things down step by step by step to learn. It can be helpful for some people.
@SarthakAdhikari What do you think should be returning?
@SarthakAdhikari
var strVale = "130,235,342,124";
arr = strVale.split(',',2); // => [ '130', '235' ]
silver537
@silver537
Aug 13 2016 06:09
it wasn't a sarcastic question. i was really curious
Joseph
@revisualize
Aug 13 2016 06:10
@SarthakAdhikari JSON + AJAX
...
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:11
@revisualize Wait a min
here
Now i need to parse the title, page id and other info from this
Joseph
@revisualize
Aug 13 2016 06:12
@SarthakAdhikari Okay. It's an object.
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:12
I used ajax to get this data
but I don't know what my next move should be
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:13

Hi. Can someone help me? What I have to do, if I want to have console.log after Weather.init? (console log should wait until weather.init getting data from servers)

$(document).ready(function() {
  WeatherModule.init();
  console.log(WeatherModule.getInfo());
});

and

var WeatherModule = (function() {
  var info = { 
    city: null, 
    country: null, 
    weather: null, 
    lat: null, 
    lon: null 
  };

  //get an information about user, then get a weather based on user lattitude and longtitude
  var init = function() {
    $.get('http://ip-api.com/json').then(function(loc) {
      console.log(loc);
      info.city = loc.city;
      info.country = loc.country;
      info.lat = loc.lat;
      info.lon = loc.lon;
      console.log(info);
    }).then(function() {
      $.get('http://api.openweathermap.org/data/2.5/weather?lat='+info.lat+'&lon='+info.lon+'&appid=5583481a78c0f6bac06274d26303f825')
        .then(function(data) {
          console.log(data);
          info.weather = data.weather[0].main;
          console.log(info);
      });
    });
  };

  return {
    init: init,
    getInfo: function() { return info; }
  };

})();
Joseph
@revisualize
Aug 13 2016 06:14
@SarthakAdhikari You just need to access the objects inside the objects.
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:14
.then doesnt work for WeatherModule.init
or just i'm doing it wrong
Joseph
@revisualize
Aug 13 2016 06:14
@SarthakAdhikari https://repl.it/Cmht
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:14
@revisualize ok
arif hussain
@arifhussain0
Aug 13 2016 06:15
why console.log doesn't work on exercises ??
need it for debugging
silver537
@silver537
Aug 13 2016 06:16
@arifhussain0 you would have to open up the console window. the website doesn't have it's own virtual console window.
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:16
Joseph
@revisualize
Aug 13 2016 06:17
@SarthakAdhikari https://repl.it/Cmht/1
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:18
@revisualize Thanks. But I have problem getting that "290" thing since I can't use loop
CamperBot
@camperbot
Aug 13 2016 06:18
sarthakadhikari sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1613 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 13 2016 06:18
Why can't you loop?
Object.keys();
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:18
object.keys
oh
That brings back some horrible memories lol
Joseph
@revisualize
Aug 13 2016 06:19
@SarthakAdhikari https://repl.it/Cmht/2
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:20
@revisualize I get it now. Thank you very much Joseph :D :D
CamperBot
@camperbot
Aug 13 2016 06:20
sarthakadhikari sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: sarthakadhikari already gave revisualize points
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:21
and also
Kent Saeteurn
@sansae
Aug 13 2016 06:21
Hi all :) I'm working on the "Show the Local Weather" Challenge. I'm pretty much all done with it. I've completed all the user stories. The issue is with the geolocation prompt. I was wondering if any of you know how to make that geolocation prompt go away? Everytime I load the page, the data I fetch from the weather api won't render until I click on "Share Location". I've googled this issue but have not found anything useful.
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:21
I couldn't get the length of ['query']['pages'] using ['query']['pages'].length
revisualize @revisualize does a big :muscle: because he did all of that without even clicking on the pen.
Kent Saeteurn
@sansae
Aug 13 2016 06:22
What I would like is for the data that I fetched from the weather api to just show up upon loading the page.
Any ideas on how to do that?
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:22
@revisualize That's actually very cool :D
pahosler
@pahosler
Aug 13 2016 06:22
@sansae if you use the geolocate it will prompt the user to allow it
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:22
@sansae You can use IP API
pahosler
@pahosler
Aug 13 2016 06:23
@sansae there are ip geolocate apis available that won't prompt...
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:23
i mean, you have to check IP city or lattitude and longtitude
pahosler
@pahosler
Aug 13 2016 06:23
in other words get your location by IP address...
Joseph
@revisualize
Aug 13 2016 06:23
IP based Geo-location is NOT accurate.
pahosler
@pahosler
Aug 13 2016 06:23
no it isn't
Joseph
@revisualize
Aug 13 2016 06:24
In fact, It is quite inaccurate.
pahosler
@pahosler
Aug 13 2016 06:24
but it doesn't really have to be for this exercise
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:24
@revisualize Yep, it isn't. My IP is from city situated 100-150km from me, even Facebook shows me ads from this city :D
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:25
@revisualize I couldn't get the length of ['query']['pages'] using ['query']['pages'].length
what should I do?
pahosler
@pahosler
Aug 13 2016 06:25
if you are developing outside of codepen for a professional app, then you might want to use other options
Joseph
@revisualize
Aug 13 2016 06:26
@SarthakAdhikari Let me look.
pahosler
@pahosler
Aug 13 2016 06:26
you can also prompt the user for zipcode, or lat/lng
Kent Saeteurn
@sansae
Aug 13 2016 06:26
@revisualize at least in terms of city, i would have to agree with you, Joseph. I just looked up IP Geolocate API and under city, it lists a different city than mine
Joseph
@revisualize
Aug 13 2016 06:27
@sansae It can even be inaccurate for the State/Country.
@SarthakAdhikari Do Objects have .length?
Kent Saeteurn
@sansae
Aug 13 2016 06:27
@revisualize really?! wow...
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:27
@revisualize maybe L3
I thought it as an array
same like an array
Joseph
@revisualize
Aug 13 2016 06:28
An Object is not an Array
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:28
ok
Joseph
@revisualize
Aug 13 2016 06:28
an Array is an object.
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:28
ok
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:28
@SarthakAdhikari You can use Object.keys(obj).length
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:29
@Shimizo Thanks :)
CamperBot
@camperbot
Aug 13 2016 06:29
sarthakadhikari sends brownie points to @shimizo :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @shimizo |http://www.freecodecamp.com/shimizo
Joseph
@revisualize
Aug 13 2016 06:29
CRAP! repl.it is offline.
LAME!
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:30
:D :D
Kent Saeteurn
@sansae
Aug 13 2016 06:30
@revisualize I was wondering if you can give me any suggestions as to how to make that geolocate prompt go away?
pahosler
@pahosler
Aug 13 2016 06:30
@revisualize repl.it is working for me, I'm using it right now....
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:31
@pahosler refresh the page and it'll stop working
pahosler
@pahosler
Aug 13 2016 06:31
@sanse, it's a security thing, it will pop up if the user hasn't approved it
LaurenCodes
@LaurenCodes
Aug 13 2016 06:31

I’m having trouble passing values to an API field:
My API request looks like this:

let request = require('request');
request.get({
    url: "https://api.nytimes.com/svc/search/v2/articlesearch.json",
    qs: {
        'api-key': "d3a29a2e27b04abd8f15260942e362d9",
        'q': "title ix",
        'begin_date': "19720101",
        'fl': "headline",
        'hl': "true"
    },
}, (err, response, body) => {
    body = JSON.parse(body);
});

The documentatin says to give it a Comma-delimited list of fields.I've tried sending the 'fl' field an array, a JSON object, etc but nothing seems to work. How I can pass the fl field both "headline" and "pub_date"?

pahosler
@pahosler
Aug 13 2016 06:32
I'll just keep using it for now and not refresh :D
Joseph
@revisualize
Aug 13 2016 06:32
blob
pahosler
@pahosler
Aug 13 2016 06:32
opened in a new tab, offline for maint.
Joseph
@revisualize
Aug 13 2016 06:32
:)
Well.. crap What to do with my life now that repl.it is currently offline???
I'm also out of ice cream.
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:34
@Shimizo var length = Object.keys(['query']['pages']).length;
console.log(length);
this doesnt work either
LaurenCodes
@LaurenCodes
Aug 13 2016 06:34
@revisualize you could help me figure out my API problem =D
Joseph
@revisualize
Aug 13 2016 06:35
@LaurenCodes If you're working on an API ... You're smarter than I am.
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:35
@SarthakAdhikari var length = Object.keys(query.pages).length; ?
show me code ;)
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:35
yes
JS line 8
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:36
@SarthakAdhikari
success:function(data){
        var length = Object.keys(['query']['pages']).length;
        console.log(length);
      }
So:
Kent Saeteurn
@sansae
Aug 13 2016 06:37
@pahosler I understand it's a security thing, but my question is, is there a way to remove that prompt (i.e. always allow the sharing of user's location without prompting said user)? If yes, how is it done (without using IP geolocation API's)?
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:38
@sansae I don't think that is possible
Kent Saeteurn
@sansae
Aug 13 2016 06:38
i found this ==> https://developers.google.com/web/updates/2015/04/permissions-api-for-the-web?hl=en and thought I was super close to figuring out a way, then... nothing
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:38
@SarthakAdhikari Object.keys(data.['query']['pages']).length;
try it
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:38
ok
pahosler
@pahosler
Aug 13 2016 06:39
@LauraCodes I'm getting an array of [Object]s when I run that code...
Kent Saeteurn
@sansae
Aug 13 2016 06:39
dang it... how the heck did FCC do it in their example app? There's loads the api data without any prompt at all... :(
everything just shows up...
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:40
@sansae Wohoo.
Kent Saeteurn
@sansae
Aug 13 2016 06:40
@SarthakAdhikari sad face
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:40
@sansae send me you weather app
pahosler
@pahosler
Aug 13 2016 06:41
@LaurenCodes
node thing.js 
{ response: 
   { meta: { hits: 3589, time: 257, offset: 0 },
     docs: 
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ] },
  status: 'OK',
  copyright: 'Copyright (c) 2013 The New York Times Company.  All Rights Reserved.' }
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 06:41
@Shimizo you put a period after 'data'. :P
@Shimizo But after I remove that period, it worked like a charm. thanks
CamperBot
@camperbot
Aug 13 2016 06:41
sarthakadhikari sends brownie points to @shimizo :sparkles: :thumbsup: :sparkles:
:warning: sarthakadhikari already gave shimizo points
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:41
;)
Darth Skywalker
@adityaparab
Aug 13 2016 06:42
Anyone here with some good sense of color combinations? I am artistically void and could use some help making my WikiViewer pretty :D
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:43
@adityaparab check color pickers in google
pahosler
@pahosler
Aug 13 2016 06:43
@adityaparab I just put an image behind mine, looked pretty cool too.... or what @Shimizo said :D
Darth Skywalker
@adityaparab
Aug 13 2016 06:44
I have many color pickers. All they do is help me extract the code for that color. What I'm struggling with is selecting right colors
I'm using material design and I don't wanna use the default pallets.
Bilyan Hadzhi
@bilyanhadzhi
Aug 13 2016 06:45
@adityaparab Make sure you scroll through the default CSS colors, they can be pretty cool
@adityaparab You can check em all out in Inspect Element
Darth Skywalker
@adityaparab
Aug 13 2016 06:46
@Billy5500 : Oh! Yes. Already did. But found nothing to my satisfaction.
silver537
@silver537
Aug 13 2016 06:46
well if it isnt stewie vader
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:46
$(document).ready(function() {
  WeatherModule.init();
  console.log(WeatherModule.getInfo());
});
Console.log should wait until WeatherModule.init will be finished. How can I do this?
Darth Skywalker
@adityaparab
Aug 13 2016 06:47
@Shimizo : Use promise.
Share your code for init
I'll tell you what to modify
Bilyan Hadzhi
@bilyanhadzhi
Aug 13 2016 06:47
@adityaparab Do you mind sharing your project?
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:47
var WeatherModule = (function() {
  var info = { 
    city: null, 
    country: null, 
    weather: null, 
    lat: null, 
    lon: null 
  };

  //get an information about user, then get a weather based on user lattitude and longtitude
  var init = function() {
    $.get('http://ip-api.com/json').then(function(loc) {
      console.log(loc);
      info.city = loc.city;
      info.country = loc.country;
      info.lat = loc.lat;
      info.lon = loc.lon;
      console.log(info);
    }).then(function() {
      $.get('http://api.openweathermap.org/data/2.5/weather?lat='+info.lat+'&lon='+info.lon+'&appid=5583481a78c0f6bac06274d26303f825')
        .then(function(data) {
          console.log(data);
          info.weather = data.weather[0].main;
          console.log(info);
      });
    });
  };

  return {
    init: init,
    getInfo: function() { return info; }
  };

})();
Darth Skywalker
@adityaparab
Aug 13 2016 06:48
@Billy5500 : Sure! Hold on, let me get done with @Shimizo
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:50
@adityaparab I tried, but I failed many times.
Darth Skywalker
@adityaparab
Aug 13 2016 06:51

@Shimizo : There are two ways. Quicker way is

change your

var init = function() {

to

var init = function(cb) {

and then change your 2nd then from

info.weather = data.weather[0].main;
console.log(info);

to

info.weather = data.weather[0].main;
console.log(info);
cb(info);

And then you will call your init function like


WeatherModule.init(function(data){
    console.log(data);
    console.log(WeatherModule.getInfo());

    //both things should log the same thing

});
@Shimizo THis is a traditional way called callback pattern
Adrian Kopytko
@adriankopytko
Aug 13 2016 06:54
@adityaparab Thank you so much!
CamperBot
@camperbot
Aug 13 2016 06:54
shimizo sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 554 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
Aug 13 2016 06:58

@Shimizo : Now the glorious way of native promises

First, change your init function to

var init = function() {
  return new Promise(function(resolve, reject){
    $.get('http://ip-api.com/json').then(function(loc) {
      console.log(loc);
      info.city = loc.city;
      info.country = loc.country;
      info.lat = loc.lat;
      info.lon = loc.lon;
      console.log(info);
    }).then(function() {
      $.get('http://api.openweathermap.org/data/2.5/weather?lat='+info.lat+'&lon='+info.lon+'&appid=5583481a78c0f6bac06274d26303f825')
        .then(function(data) {
          console.log(data);
          info.weather = data.weather[0].main;
          console.log(info);
          resolve(info); // this will return the thenable object.
      });
    });
  });
};

Then call your init function like

WeatherModule
  .init()
  .then(function(data){
    console.log(data);
    console.log(WeatherModule.getInfo());
  });
Ken Aguilar
@piq9117
Aug 13 2016 07:02
anybody know graphQL?
Adrian Kopytko
@adriankopytko
Aug 13 2016 07:02

@adityaparab Maybe you know... I want to make a method, inside it will be a switch and some options which will set icon
Something like this:

var method = function(arg) {
  switch(arg) {
    case "Clouds":
blah blah
}

//set up a icon etc
}

Is there a better idea to make this function? Any pattern?

Bilyan Hadzhi
@bilyanhadzhi
Aug 13 2016 07:04
@Shimizo Which API are you using?
Adrian Kopytko
@adriankopytko
Aug 13 2016 07:05
@Billy5500 open weather api from exercise and ip-api.com
Darth Skywalker
@adityaparab
Aug 13 2016 07:06
@Shimizo : Switch is as perfomance deficient as if. So you're better off using object lookup like
var method = function(arg){
  return  {
    "iconKey1":"Clouds",
    "iconKey2":"Rain",
    "iconKey3":"Sunny",
  .... and so on
  }[arg];
}
Adrian Kopytko
@adriankopytko
Aug 13 2016 07:06
@adityaparab I like the way of native promises
Darth Skywalker
@adityaparab
Aug 13 2016 07:07
Here your iconKeyn will be any thing you wanted to make cases in switch out of.
@Billy5500 : Give me some time, I am deploying the project on github
about WikiViewer colors
CamperBot
@camperbot
Aug 13 2016 07:08
you need to ask about @someone!
Darth Skywalker
@adityaparab
Aug 13 2016 07:09
Go to hell @camperbot
Adrian Kopytko
@adriankopytko
Aug 13 2016 07:09
@adityaparab Very good and quality advices! Thanks so much!
CamperBot
@camperbot
Aug 13 2016 07:09
shimizo sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: shimizo already gave adityaparab points
Bilyan Hadzhi
@bilyanhadzhi
Aug 13 2016 07:09
@adityaparab No problem! I guess you develop it locally and not on codepen?
Darth Skywalker
@adityaparab
Aug 13 2016 07:09
@Billy5500 : Yes, I like structured code. on codepen it's just one file with Giant blob of code.
really ugly
ahmed abouhay
@abohay
Aug 13 2016 07:10
function truncateString(str, num) {
  var dots = "...";
  var lngth = num - dots.length;
  var all ;
  var low;
    if (str.length > num && num > 3){
      all = str.slice(0,lngth) + dots;
    }else {
      return str;
    }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Quino
@flamenquim
Aug 13 2016 07:11
Good morning1
!*
ahmed abouhay
@abohay
Aug 13 2016 07:11
@kaylarosevaughn
Ken Aguilar
@piq9117
Aug 13 2016 07:11
@kaylarosevaughn var remainder = 11 % 3;
ahmed abouhay
@abohay
Aug 13 2016 07:11
function truncateString(str, num) {
  var dots = "...";
  var lngth = num - dots.length;
  var all ;
  var low;
    if (str.length > num && num > 3){
      all = str.slice(0,lngth) + dots;
    }else {
      return str;
    }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Quino
@flamenquim
Aug 13 2016 07:12
Guys, just a little doubt
@kaylarosevaughn
Kayla Vaughn
@kaylarosevaughn
Aug 13 2016 07:13
lol, thank you @piq9117
CamperBot
@camperbot
Aug 13 2016 07:13
kaylarosevaughn sends brownie points to @piq9117 :sparkles: :thumbsup: :sparkles:
:cookie: 207 | @piq9117 |http://www.freecodecamp.com/piq9117
Quino
@flamenquim
Aug 13 2016 07:13
@kaylarosevaughn replace the semicolon after "remainder" with an "="
Quino
@flamenquim
Aug 13 2016 07:15
So, guys, just wondering, so let's say that
var str = "hello" and I apply str.split() then it remains the same, but
then I apply str.split('') and it is divided into single letters, why?
uamesl03
@uamesl03
Aug 13 2016 07:15
eh nvm I think I might need to swap to html5 anyways for what I am going to be doing.
Ken Aguilar
@piq9117
Aug 13 2016 07:16
@uamesl03
// Setup
var a;
var b = 2;

// Only change code below this line
a = 7;
b = a;
uamesl03
@uamesl03
Aug 13 2016 07:16
oh thanks
ahmed abouhay
@abohay
Aug 13 2016 07:16
@piq9117
function truncateString(str, num) {
  var dots = "...";
  var lngth = num - dots.length;
  var all ;
  var low;
    if (str.length > num && num > 3){
      all = str.slice(0,lngth) + dots;
    }else {
      return str;
    }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
uamesl03
@uamesl03
Aug 13 2016 07:16
I get it now. Thanks alot. I forgot it works from right to left.
Ken Aguilar
@piq9117
Aug 13 2016 07:17
@flamenquim your telling the function that you wanna split them with each character
@abohay yo! whats the goal on this challenge?
sorry i havent done this but tell me what the goal is..
Carlos Zavaleta
@nerdyamigo
Aug 13 2016 07:19
anyone got any tips on the Drop it algorithm challenge?
Quino
@flamenquim
Aug 13 2016 07:19
@piq9117 yeah but why it's used the empty string? I cannot find a logical meaning on it
@piq9117 well maybe I should just accept it as a fact
Ken Aguilar
@piq9117
Aug 13 2016 07:22
lol.. thats how split function works..
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 07:22
http://s.codepen.io/sarthakadhikari/debug/wWNWQb ->> can anyone help me with this? error on the console ;)
Daniel Lee
@twdaniel
Aug 13 2016 07:24
hi, I got stuck on the "Using Object for Lookups" challenge, it should be corrected in the code
Ken Aguilar
@piq9117
Aug 13 2016 07:24
@SarthakAdhikari its ur Object.keys(data)
LaurenCodes
@LaurenCodes
Aug 13 2016 07:25
hi guys
I’m having a scope issue, can anyone help?
Ken Aguilar
@piq9117
Aug 13 2016 07:25
post code ur code here..
Darth Skywalker
@adityaparab
Aug 13 2016 07:25
@LaurenCodes : Post your code
Carlos Zavaleta
@nerdyamigo
Aug 13 2016 07:25
@flamenquim is like that by default
LaurenCodes
@LaurenCodes
Aug 13 2016 07:25
let data = [‘hi'];

request.get({
    url: "https://api.nytimes.com/svc/search/v2/articlesearch.json",
    qs: {
        'api-key': "d3a29a2e27b04abd8f15260942e362d9",
        'q': "title ix",
        'begin_date': "19720101",
        'hl': "true"
    },
}, function(err, response, body) {
    body = JSON.parse(body);
    data = data.concat(body.response.docs);
    console.log(data);
});

console.log(data);
SarthakAdhikari
@SarthakAdhikari
Aug 13 2016 07:25
@piq9117 ok.. what now :3
Daniel Lee
@twdaniel
Aug 13 2016 07:25

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

// Only change code below this line

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

};

result = lookup.val;
// Only change code above this line
return result;
}

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

LaurenCodes
@LaurenCodes
Aug 13 2016 07:26
There’s two different things being logged
Carlos Zavaleta
@nerdyamigo
Aug 13 2016 07:26

@flamenquim form the MZDN
Parameters

separator
Optional. Specifies the character(s) to use for separating the string. The separator is treated as a string or a regular expression. If separator is omitted, the array returned contains one element consisting of the entire string. If separator is an empty string, str is converted to an array of characters.

Ken Aguilar
@piq9117
Aug 13 2016 07:27
@SarthakAdhikari i cant debug ur code.. can you link me to ur codepen
Object.keys(); returns a list of keys..
LaurenCodes
@LaurenCodes
Aug 13 2016 07:28
@piq9117 @adityaparab any idea why data logs two different results?
Ken Aguilar
@piq9117
Aug 13 2016 07:29
@LaurenCodes yes.. it should be hi and whatever is in that function
Darth Skywalker
@adityaparab
Aug 13 2016 07:29
@LaurenCodes : Yes, I am assuming you 1st log says 'hi` and then 2nd log shows data from the server.
Carlos Zavaleta
@nerdyamigo
Aug 13 2016 07:29
^ agree
LaurenCodes
@LaurenCodes
Aug 13 2016 07:30
Yes, but why don’t they both show the same result?
Ken Aguilar
@piq9117
Aug 13 2016 07:30
function(err, response, body) {
    body = JSON.parse(body);
    data = data.concat(body.response.docs);
    console.log(data); // this should be logging something else.. it's encapsulation
}
Carlos Zavaleta
@nerdyamigo
Aug 13 2016 07:30
the data variable inside the function is inside its own lexical scope, so its on its little world
LaurenCodes
@LaurenCodes
Aug 13 2016 07:30
Is it because it takes a while to execute
Ken Aguilar
@piq9117
Aug 13 2016 07:31
no.. its being encasulated..
LaurenCodes
@LaurenCodes
Aug 13 2016 07:31
It actually logs “yea” and then the additional concatination
So it’s not inside it’s own lexical scope
Ken Aguilar
@piq9117
Aug 13 2016 07:31
const data = 'Im on the outside';

function somfn () {
  const data = 'Cant touch me'
}
console.log(data); // 'im on the outside'
LaurenCodes
@LaurenCodes
Aug 13 2016 07:32

For example, this

let data = ['yea'];

function(err, response, body) {
    console.log(data); // this should be logging something else.. it's encapsulation
}

This actually logs “yea”

Darth Skywalker
@adityaparab
Aug 13 2016 07:33

@LaurenCodes : When your code runs, request.get is an async function. That means when you call request.get node (assuming you're using node based on request package) send the request and proceed further and then go on to log hi. (because that is what data is initialized with in the beginning). When request.get responds, you invoke it's call back and overwrite value of data. that is why you get two different.

You assumption that just because I have overwritten value of data on the line before last log, so the last log, therefore, should show new value is flawed. Becuase this isasync :)

Ken Aguilar
@piq9117
Aug 13 2016 07:33
This message was deleted
whoa.. youre not declaring the data inside ur function. so who knows whats your gonna log
LaurenCodes
@LaurenCodes
Aug 13 2016 07:34
OK, I see — the inside can see the outside, the outside can’t get inside. Is that a dumbed down version
Carlos Zavaleta
@nerdyamigo
Aug 13 2016 07:35
@adityaparab awesome explanation!
LaurenCodes
@LaurenCodes
Aug 13 2016 07:35
I’d like to have an array variable outside the function which I can concat to — what’s a good way to do that and maintain a clean scope?
Mateusz Szymański
@matszym
Aug 13 2016 07:35
@LaurenCodes Not really, it can with getters and setters methods
LaurenCodes
@LaurenCodes
Aug 13 2016 07:36
@adityaparab Thanks for the explanation!
CamperBot
@camperbot
Aug 13 2016 07:36
laurencodes sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 556 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
Aug 13 2016 07:36

@Billy5500 :smile:

here it is

Current Version - https://adityaparab.github.io/React/wikiviewer-v2/

Older version (functional) - https://adityaparab.github.io/React/wikiviewer/

Older version doesn't have keyboard input enabled. In currect version, I am intergrating keyboard navigation. You can navigate using arrow keys on the autocomplete dropdown

Now help me with making it prettier :P
Ken Aguilar
@piq9117
Aug 13 2016 07:39
@twdaniel what are you trying to do?
LaurenCodes
@LaurenCodes
Aug 13 2016 07:39
@adityaparab Sorry to bother you more! In the previous example, what’s a good practice to change the global variable “data” from inside the callback function?
Daniel Lee
@twdaniel
Aug 13 2016 07:40
I got stuck on challenge
can u help to figure our where is the problem?
Ken Aguilar
@piq9117
Aug 13 2016 07:41
whats the goal of the problem?
Mateusz Szymański
@matszym
Aug 13 2016 07:42
@LaurenCodes There is no good way of doing that, function you are writing at best case scenarion shouldnt depend on external global variables. Make the function return a value, and then asign it to variable, dont do it inside function
Daniel Lee
@twdaniel
Aug 13 2016 07:42
to display the one attribute in the object
LaurenCodes
@LaurenCodes
Aug 13 2016 07:42
@matszym Thank you, I’ll do that from now on. new to JS! =)
CamperBot
@camperbot
Aug 13 2016 07:42
laurencodes sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 140 | @matszym |http://www.freecodecamp.com/matszym
Daniel Lee
@twdaniel
Aug 13 2016 07:43
call the function "charlie" and it can bring out "Chicago"
Mateusz Szymański
@matszym
Aug 13 2016 07:44
@LaurenCodes Take a look on the article and the video in the article, writing pure functions will save you a lot of headache
https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-pure-function-d1c076bec976#.ywbno96la
Ken Aguilar
@piq9117
Aug 13 2016 07:44
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

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

  };

  result = lookup[val];
  // Only change code above this line
  return result;
}
@twdaniel use bracket notation lookup[val] instead of lookup.val
Daniel Lee
@twdaniel
Aug 13 2016 07:46
wow, it works, thank you very much, it stuck me for hours
Darth Skywalker
@adityaparab
Aug 13 2016 07:46
@LaurenCodes : first of all, keeping your data global is a bad practice. There is no "right way" of setting global data. Just assign new values to it anywhere in any way( its global after all)
Ken Aguilar
@piq9117
Aug 13 2016 07:48
@LaurenCodes and always declare your variable with const or let..
LaurenCodes
@LaurenCodes
Aug 13 2016 07:49
@piq9117 everything’s defined lol.
Darth Skywalker
@adityaparab
Aug 13 2016 07:51
@piq9117 : there is a huge difference between let and var. so it's not a good idea to make a rule of thumb saying always use let. Whether to use let or var is a contextual decision :)
Ken Aguilar
@piq9117
Aug 13 2016 07:52
good.. i think if you did a return data.concat(body.response.doc) instead data = data.concat(..)
people still use var?
var is just bad.. i take my money and run whenever i see var.. lol..
i usually use const and immutable.js
This message was deleted
luis4flames
@luis4flames
Aug 13 2016 07:55
how would i create an empty array into a JSON Object so i can then enter a value into that array?
Ken Aguilar
@piq9117
Aug 13 2016 07:56
const data = {
  arr: []
}
like that?
luis4flames
@luis4flames
Aug 13 2016 07:56

function updateRecords(id, prop, value) {

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

return collection;
}

its from within a function though
Ken Aguilar
@piq9117
Aug 13 2016 07:57
function updateRecords(id, prop, value) {  
  if(prop !== "tracks" && value !== "") {
    collection[id][prop].push(value);
  } else if ( prop == "tracks" && collection[id].hasOwnProperty(prop) === false) {
    collection[id].push(prop[()]);
    collection[id][prop].push(value);
  } else if ( prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  } else if ( value === "") {
    delete collection[id][prop];
  } else 

  return collection;
}
whats your data like?
Chris
@capozzic1
Aug 13 2016 07:58
I am doing the javascript "Find the Largest Number in an Array" problem, and I accidentally cheated while looking for about more information with what .apply does. Can someone explain the "math" argument to the apply function to me?

function largestOfFour(arr) {

return arr.map(function(array) {
return Math.max.apply(Math, array);

});

is the function
luis4flames
@luis4flames
Aug 13 2016 07:58
I wrote it as collection[id].push(prop[()]); but that was really just a guess of how i thought it might work. but get a syntaxt error with ')'
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"
}
};