These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Jul 2016
kevinstonge
@kevinstonge
Jul 17 2016 00:02 UTC
confirmed that this works:
inputTrimmed = inputLowercase.replace(/[^a-z0-9]/g,"");
but still would like to know how to regex parentheses!
I had to use the octal codes - my final line looked like this:
inputTrimmed = inputLowercase.replace(/\s|[,._-]|\050|\051/g,"");
thanks @kevinstonge :)
CamperBot
@camperbot
Jul 17 2016 00:05 UTC
sorry kevinstonge, you can't send brownie points to yourself! :sparkles: :sparkles:
Stephen James
@sjames1958gm
Jul 17 2016 00:12 UTC
@willcodes Sorry was offline
willcodes
@willcodes
Jul 17 2016 00:14 UTC
@sjames1958gm thank god, i've been so stumped lol. I had it at least changing the picture at one point when I called quotes[0].author
CamperBot
@camperbot
Jul 17 2016 00:14 UTC
willcodes sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1923 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2016 00:14 UTC
@kevinstonge Does \( work for matching.
willcodes
@willcodes
Jul 17 2016 00:14 UTC
@sjames1958gm but i'm sure you know that wasn't the solution lol
Stephen James
@sjames1958gm
Jul 17 2016 00:14 UTC
@willcodes What do you have now
@Chrislearns Did you get help?
kevinstonge
@kevinstonge
Jul 17 2016 00:15 UTC
@sjames1958gm it honestly wasn't working for me, gave me a little yellow warning. :\ any idea what I might have done wrong?
homercrates
@homercrates
Jul 17 2016 00:15 UTC
@Chrislearns thats not inside a function right?
willcodes
@willcodes
Jul 17 2016 00:15 UTC
var random = quotes[Math.floor(Math.random() *quotes.length)];
function randomQuote() {
 var random = quotes[Math.floor(Math.random() *quotes.length)];
 $("#thisquote").text(random.quote);

  $("#thisauthor").text("-" +random.author);
  };
function changeBackground() {
   var random = quotes[Math.floor(Math.random() *quotes.length)];
  if ($(quotes[random].author)  === "Kramer") {
      $("body").css("background-image", "linear-gradient(to top, rgba(0,0,0,0.2), rgba(0,0,0,0.5)),url('file:C:/Users/user/Desktop/freecodecamp/random quote/images/kramer.jpg'"); 
    }
    else if (quotes[random].author === "George"){
      $("body").css("background-image", "linear-gradient(to top, rgba(0,0,0,0.2), rgba(0,0,0,0.5)),url('file:C:/Users/user/Desktop/freecodecamp/random quote/images/george.jpg'"); 
    }
    else if (quotes[random]["author"] === "Elaine"){
      $("body").css("background-image", "linear-gradient(to top, rgba(0,0,0,0.2), rgba(0,0,0,0.5)),url('file:C:/Users/user/Desktop/freecodecamp/random quote/images/elaine.jpg'"); 
    }
    else if (quotes[random]["author"] === "Jerry"){
      $("body").css("background-image", "linear-gradient(to top, rgba(0,0,0,0.2), rgba(0,0,0,0.5)),url('file:C:/Users/user/Desktop/freecodecamp/random quote/images/jerry.jpg'"); 
    }
    else{
      $("body").css("background-image", "linear-gradient(to top, rgba(0,0,0,0.2), rgba(0,0,0,0.5)),url('file:C:/Users/user/Desktop/freecodecamp/random quote/images/bg.jpg'"); 
    }


  };


/*  function changeColor() {
    var change = colors[Math.floor(Math.random() *colors.length)];
    $('body').css("background", change);
    $('#getQuote').css("background", change);
  };*/

  function removeHeader() {
    $("#header").remove();
  }
  $('.btn').click(function() {

    removeHeader();
    randomQuote();
    changeBackground();

});

});
Stephen James
@sjames1958gm
Jul 17 2016 00:16 UTC
@kevinstonge yellow warning in the FCC editor? Yeah not sure, maybe got confused matching parens?
kevinstonge
@kevinstonge
Jul 17 2016 00:16 UTC
ok, I went back and replaced my 050 and 051 with ( and ) and it worked. Weird. no clue what I did wrong.
Chris Drain
@Chrislearns
Jul 17 2016 00:16 UTC
lol
kevinstonge
@kevinstonge
Jul 17 2016 00:16 UTC
thanks @sjames1958gm
CamperBot
@camperbot
Jul 17 2016 00:16 UTC
kevinstonge sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1924 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2016 00:16 UTC
@willcodes If you calc random twice you will get different numbers
Chris Drain
@Chrislearns
Jul 17 2016 00:16 UTC
I figured it out

function rot13(str) { // LBH QVQ VG!
var string = str.split(" ");
var finished = "";
var map = Array.prototype.map;
var charCodeArray = map.call(str, function (x){

  var  y = x.charCodeAt(0);

  if(y <= 77 && y >= 65){
    y =  y + 13;
 }
else  if(y >= 78 && y <= 91){
   y =  y - 13;}
  return y ;

});

for(var i = 0; i<charCodeArray.length; i++){
finished += String.fromCharCode(charCodeArray[i]);
}
return finished;
}

homercrates
@homercrates
Jul 17 2016 00:16 UTC
@Chrislearns isnt that your problem its not inside a function so its not really being turne don ey?
Stephen James
@sjames1958gm
Jul 17 2016 00:16 UTC
@Chrislearns :+1:
willcodes
@willcodes
Jul 17 2016 00:16 UTC
@sjames1958gm let me remove the other 2 var randoms
Stephen James
@sjames1958gm
Jul 17 2016 00:17 UTC
@Chrislearns Here is how to get the post to show correctly :point_down:
help format
CamperBot
@camperbot
Jul 17 2016 00:17 UTC

: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

homercrates
@homercrates
Jul 17 2016 00:17 UTC
@Chrislearns youg ot it working then?
Stephen James
@sjames1958gm
Jul 17 2016 00:18 UTC
@Chrislearns You could have done str.split("").map();
Chris Drain
@Chrislearns
Jul 17 2016 00:19 UTC
oh yea you can chain methods
@sjames1958gm
homercrates
@homercrates
Jul 17 2016 00:19 UTC
sweet
willcodes
@willcodes
Jul 17 2016 00:19 UTC
@sjames1958gm i just embeded it because as a global function it was stopping after one quote
Stephen James
@sjames1958gm
Jul 17 2016 00:19 UTC
@Chrislearns I see you had split(" ") which wouldn't split on characters is that why you didn't use string?
willcodes
@willcodes
Jul 17 2016 00:19 UTC
but it doesnt solve the problemo
Norvin Burrus
@ndburrus
Jul 17 2016 00:20 UTC
@Chrislearns
for code posting - typing shift + enter provides additional line feeds (space for posting/pasting code).
you may also find the chat & compose buttons to the right of the chat text entry area useful. the backtick/s key is located to the left of the #1 (number one) key. :sparkles:
Chris Drain
@Chrislearns
Jul 17 2016 00:20 UTC

```
function rot13(str) { // LBH QVQ VG!
var string = str.split(" ");
var finished = "";
var map = Array.prototype.map;
var charCodeArray = map.call(str, function (x){

  var  y = x.charCodeAt(0);

  if(y <= 77 && y >= 65){
    y =  y + 13;
 }
else  if(y >= 78 && y <= 91){
   y =  y - 13;}
  return y ;

});

for(var i = 0; i<charCodeArray.length; i++){
finished += String.fromCharCode(charCodeArray[i]);
}
return finished;
}

lol didn’t work
Stephen James
@sjames1958gm
Jul 17 2016 00:21 UTC
@Chrislearns Missed the ``` at the end. after shift-enter
Dexter Passenger
@DexPassenger
Jul 17 2016 00:21 UTC
Can you use .filter() on nested arrays?
Chris Drain
@Chrislearns
Jul 17 2016 00:21 UTC
@sjames1958gm
function rot13(str) { // LBH QVQ VG!
  var string = str.split(" ");
  var finished = "";
  var map = Array.prototype.map;
    var charCodeArray = map.call(str, function (x){

      var  y = x.charCodeAt(0);

      if(y <= 77 && y >= 65){
        y =  y + 13;
     }
    else  if(y >= 78 && y <= 91){
       y =  y - 13;}
      return y ;

    });
   for(var i = 0; i<charCodeArray.length; i++){
     finished += String.fromCharCode(charCodeArray[i]);
   }
  return finished;
}
nice
Stephen James
@sjames1958gm
Jul 17 2016 00:21 UTC
@Chrislearns :)
homercrates
@homercrates
Jul 17 2016 00:21 UTC
much easier
Stephen James
@sjames1958gm
Jul 17 2016 00:21 UTC
@DexPassenger yes.
Dexter Passenger
@DexPassenger
Jul 17 2016 00:22 UTC
@sjames1958gm Thank you.
CamperBot
@camperbot
Jul 17 2016 00:22 UTC
dexpassenger sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1925 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2016 00:22 UTC
@DexPassenger arr[i].filter() like that?
Dexter Passenger
@DexPassenger
Jul 17 2016 00:22 UTC
Yes exactly.
Stephen James
@sjames1958gm
Jul 17 2016 00:23 UTC
@willcodes put random = into your click handler and pass it to randomQuote and changeBackground if you make it global it may only be computing it once.
kevinstonge
@kevinstonge
Jul 17 2016 00:24 UTC
Title Case a Sentence - I feel like this is poorly written (but it works!) what could I do better here?
function titleCase(str) {
  inputAsArray = str.split(" ");
  outputString = "";
  for (i=0;i<inputAsArray.length;i++) {
    outputString += inputAsArray[i].charAt(0).toUpperCase() + inputAsArray[i].slice(1).toLowerCase() + ((i == inputAsArray.length - 1) ? "" : " ");
  }
  return outputString;
}
Stephen James
@sjames1958gm
Jul 17 2016 00:25 UTC
@kevinstonge if you build an array and use join you don't have to make that test as join doesn't put a " " at the end
Rahin Ahmed
@rahin1122
Jul 17 2016 00:25 UTC
Hi Guys I was doing following the instructions below .Here Is Instructions and code .On line 4 in instructions i could not get it . nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
kevinstonge
@kevinstonge
Jul 17 2016 00:26 UTC
so in my for loop I should push to an array and thena fter teh for loop I should join to a string?
Stephen James
@sjames1958gm
Jul 17 2016 00:26 UTC
@kevinstonge Yeah. Actually this is a good one for arraymap
function titleCase(str) {

  return str.split(' ').map(function(val) {
    return val.charAt(0).toUpperCase() + val.toLowerCase().slice(1);
  }).join(' ');

}
bitgrower
@bitgrower
Jul 17 2016 00:27 UTC
@kevinstonge getting it right is 90% of the battle at this stage in the game ... even in pro development houses, you first get it right ... and you pick up how to do things better as you go along ... keep makin' progress, getting thru the challenges ... :)
kevinstonge
@kevinstonge
Jul 17 2016 00:27 UTC
bah, I thought of using map but couldnt' see how it would work!
Rahin Ahmed
@rahin1122
Jul 17 2016 00:27 UTC

function nextInLine(arr, item) {
// Your code here
var res = arr.push(1);
var res1 = arr.shift();
return res1;

}
nextInLine([5,6,7,8,9,10,1],1);

kevinstonge
@kevinstonge
Jul 17 2016 00:27 UTC
thanks again @sjames1958gm I'm going to try to use map without looking at your code :)
CamperBot
@camperbot
Jul 17 2016 00:27 UTC
kevinstonge sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: kevinstonge already gave sjames1958gm points
kevinstonge
@kevinstonge
Jul 17 2016 00:27 UTC
thanks @bitgrower
CamperBot
@camperbot
Jul 17 2016 00:27 UTC
kevinstonge sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1141 | @bitgrower |http://www.freecodecamp.com/bitgrower
Stephen James
@sjames1958gm
Jul 17 2016 00:27 UTC
@rahin1122 add item not 1
@kevinstonge It is good that you recognized that there might be a need for improvement. The code felt clunky and you felt it :)
@ndburrus Hey you are number one on points over the last 30 days - WTG.
Norvin Burrus
@ndburrus
Jul 17 2016 00:32 UTC
@sjames1958gm thanks for noticing/commenting... now i need to refocus back to lessons & reading... :+1:
CamperBot
@camperbot
Jul 17 2016 00:32 UTC
ndburrus sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1926 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Aiden
@AidenMead
Jul 17 2016 00:32 UTC
I am completely lost on Record Collection, anyone have any advice on how to logically approach it? I'm stuck on the instructions and not knowing where to start.
And I've been staring at it for about a week.
Stephen James
@sjames1958gm
Jul 17 2016 00:33 UTC
@ndburrus Just starting on the React project for displaying this information
Norvin Burrus
@ndburrus
Jul 17 2016 00:34 UTC
@sjames1958gm sounds interesting...
Stephen James
@sjames1958gm
Jul 17 2016 00:34 UTC
@AidenMead One of the campers has a nice description of it.
https://gist.github.com/revisualize/123deb77d85079f079020ac3cd6ea5ba
Aiden
@AidenMead
Jul 17 2016 00:35 UTC
Wow, that almost makes it seem easy! Thank you @sjames1958gm
CamperBot
@camperbot
Jul 17 2016 00:35 UTC
aidenmead sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1927 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Chris Drain
@Chrislearns
Jul 17 2016 00:36 UTC
@AidenMead @sjames1958gm That’s a good description. I was going to tell him to start with a simple if statement. That way he can get those synapses firing. Also go back over the previous challenges they have all the knowledge needed to get started. Learning how to connect the dots at that point is essential.
Norvin Burrus
@ndburrus
Jul 17 2016 00:36 UTC
@sjames1958gm say, the link opens as an object...?
kevinstonge
@kevinstonge
Jul 17 2016 00:36 UTC

@sjames1958gm - my code for titleCase(str):

  stringAsArray = str.split(" ");
  fixedCaseArray = stringAsArray.map(function(val) { return val.charAt(0).toUpperCase() + val.slice(1).toLowerCase(); });
  return fixedCaseArray.join(" ");

I wonder if you'd mind commenting on how you know how much to stuff after the word 'return' because I see you put the whole damn function after the word return in your solution! Are there guidelines or rules for that?

Stephen James
@sjames1958gm
Jul 17 2016 00:37 UTC
@ndburrus Yeah that is the JSON input into the project -
Here is the sample project for the project
https://codepen.io/FreeCodeCamp/full/eZGMjp/
kevinstonge
@kevinstonge
Jul 17 2016 00:37 UTC
I can see that I don't need to assign these things to variables if I'm not going to use the variables again ... I assume that's part of it
Aiden
@AidenMead
Jul 17 2016 00:38 UTC
@Chrislearns I figured the key would lay in the previous lessons, but I keep writing out code that just accesses nested objects and then get stuck, haha.
Stephen James
@sjames1958gm
Jul 17 2016 00:39 UTC
@kevinstonge You kind of have to judge whether the beginning to end loses the meaning, if it does then you have to split it up.
There is a bit of a 'who can do it shortest' competition in this chat :)
Chris Drain
@Chrislearns
Jul 17 2016 00:40 UTC
@AidenMead lol
Stephen James
@sjames1958gm
Jul 17 2016 00:40 UTC
@Chrislearns @AidenMead there is a whole long discussion about the wording of that challenge.
FreeCodeCamp/FreeCodeCamp#9380
kevinstonge
@kevinstonge
Jul 17 2016 00:41 UTC
Thanks
John Mica
@JohnMica
Jul 17 2016 00:41 UTC
hi guys
Chris Drain
@Chrislearns
Jul 17 2016 00:43 UTC
@sjames1958gm lol I don’t blame them. When I first read it I winced myself.
Aiden
@AidenMead
Jul 17 2016 00:47 UTC
it's definitely pretty rough
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:48 UTC
@sjames1958gm could you take a look at this and see why whenever i tweet out a quote.. there is a glitch and my main page goes to error
http://codepen.io/duel_drawer8/pen/WxdGzj
John Mica
@JohnMica
Jul 17 2016 00:49 UTC
i ran into an issue with the word blank - cant understand what they wnat from me :))
Stephen James
@sjames1958gm
Jul 17 2016 00:50 UTC
@Dueldrawer8 The error I saw in your html is http:www.twitter.com/intent/tweet missing //
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:50 UTC
@sjames1958gm its there
window.open("http://www.twitter.com/intent/tweet?text=" + text + '-' + author);
})
Diego Mayer
@Chrono79
Jul 17 2016 00:50 UTC
@JohnMica have you read Mad Libs link yet?
Stephen James
@sjames1958gm
Jul 17 2016 00:50 UTC
@Dueldrawer8 html not js
John Mica
@JohnMica
Jul 17 2016 00:50 UTC
yep
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:51 UTC
@sjames1958gm ah good point
John Mica
@JohnMica
Jul 17 2016 00:51 UTC
i assume is to build a quoting selfconstructing
thanks @Chrono79
CamperBot
@camperbot
Jul 17 2016 00:51 UTC
johnmica sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1546 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 17 2016 00:51 UTC
you have to build a string with the 4 parameters of you function and some more words @JohnMica
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:52 UTC
@sjames1958gm whenever i x out of the opened window the random quote page turns white?
Stephen James
@sjames1958gm
Jul 17 2016 00:52 UTC
@Dueldrawer8 Fixing that gives a different error I added target="_blank" to that a tag, and it looks like it breaks the contents of the tweet.
@Chrono79 I just started on the React project for displaying the highest ranking campers, you are number two on the recent list.
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:54 UTC
@sjames1958gm yeah it seems thats the solution.. thanks
CamperBot
@camperbot
Jul 17 2016 00:54 UTC
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1928 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2016 00:54 UTC
@Dueldrawer8 Just remove the href from the a tag in the html and I think you are golden
Diego Mayer
@Chrono79
Jul 17 2016 00:54 UTC
@sjames1958gm :+1:
Norvin Burrus
@ndburrus
Jul 17 2016 00:55 UTC
@sjames1958gm i think the json object isn't grabbing all the data. here is the data i'm seeing: https://fcctop100.herokuapp.com/
Stephen James
@sjames1958gm
Jul 17 2016 00:56 UTC
@ndburrus Hmm, interesting. That json is the link they provide in the project,
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:56 UTC
@sjames1958gm sweetness..tried to make it a little bit responsive as well..not much you can do with a box
Caleb Catt
@cattman42
Jul 17 2016 00:56 UTC
How do you markdown again?
Stephen James
@sjames1958gm
Jul 17 2016 00:56 UTC
help format
CamperBot
@camperbot
Jul 17 2016 00:56 UTC

: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

Norvin Burrus
@ndburrus
Jul 17 2016 00:56 UTC
@JohnMica 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. :sparkles:
Rahin Ahmed
@rahin1122
Jul 17 2016 00:57 UTC
@sjames1958gm Where do i add item 1 and how can i share the screenshot of codes.
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:58 UTC
@sjames1958gm one last thing, ive been trying to select the author in the blockquote and want to text-align : right.. which selector is it?
Stephen James
@sjames1958gm
Jul 17 2016 00:58 UTC
@rahin1122 item is the value passed in and posting code is right above :point_up:
Caleb Catt
@cattman42
Jul 17 2016 00:58 UTC

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

// Change these values to test
isLess(10, 15);
Norvin Burrus
@ndburrus
Jul 17 2016 00:58 UTC
@sjames1958gm what is the link? (if you have it handy...)
Stephen James
@sjames1958gm
Jul 17 2016 00:58 UTC
@Dueldrawer8 Not sure I get what you mean
Caleb Catt
@cattman42
Jul 17 2016 00:58 UTC
Can anyone help me with this please? I'm trying to eliminate if else with an equality
Stephen James
@sjames1958gm
Jul 17 2016 00:59 UTC
@ndburrus which link?
John Mica
@JohnMica
Jul 17 2016 00:59 UTC
@ndburrus I solved it - must be really late and cant make sense of it :))
John Mica
@JohnMica
Jul 17 2016 00:59 UTC
thanks @ndburrus
CamperBot
@camperbot
Jul 17 2016 00:59 UTC
johnmica sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 988 | @ndburrus |http://www.freecodecamp.com/ndburrus
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 00:59 UTC
@sjames1958gm in the random quote there is two text.. the actual quote and the author who says it. I want to shift the contents of the text of the author to the right
John Mica
@JohnMica
Jul 17 2016 00:59 UTC
gitter could be too much improved :)
its like a modern IRC
Norvin Burrus
@ndburrus
Jul 17 2016 00:59 UTC
@JohnMica you're welcome! excellent job :palm_tree:
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 01:00 UTC
just want to right align the authors name
Rahin Ahmed
@rahin1122
Jul 17 2016 01:00 UTC
@sjames1958gm Can you just write the full code for me .
Stephen James
@sjames1958gm
Jul 17 2016 01:00 UTC
@Dueldrawer8 If you use float:right it puts it way right
@rahin1122 Which challenge?
Randy Goldsmith
@Dueldrawer8
Jul 17 2016 01:01 UTC
@sjames1958gm hm, alright thanks
CamperBot
@camperbot
Jul 17 2016 01:01 UTC
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave sjames1958gm points
Stephen James
@sjames1958gm
Jul 17 2016 01:02 UTC

@rahin1122 Is it this challenge, the one about anti pattern?

if (condition) {
   return true;
} else {
  return false;
}

can be replaced by

return condition
Rahin Ahmed
@rahin1122
Jul 17 2016 01:07 UTC

@sjames1958gm Can you just have a look at my code and could you provide me a solution for this and I am just a new beginner in javascript ..function nextInLine(arr, item) {
// Your code here
var res = arr.push(1);
var res1 = arr.shift();
return res1;

}
nextInLine([5,6,7,8,9,10,1],1);

Norvin Burrus
@ndburrus
Jul 17 2016 01:10 UTC
@sjames1958gm this is interesting. it appears that the links (listed in the exercise & that being used by the alternate source) are a little different. the alternate source link is: https://fcctop100.herokuapp.com for both local & session storage, while the exercise link offered adds (to the link mentioned) the following: /api/fccusers/top/recent (requirement #8) and /alltime (ending) (requirement #9). :sparkles:
Stephen James
@sjames1958gm
Jul 17 2016 01:11 UTC
@rahin1122 You should only use arr and item in your function - you are using arr, but you need to push item onto your array not 1
@ndburrus Interesting.
@ndburrus If you click on help score on that link you found it looks a lot more like the json.
Norvin Burrus
@ndburrus
Jul 17 2016 01:12 UTC
@rahin1122 this may be helpful: :sparkles:
Stephen James
@sjames1958gm
Jul 17 2016 01:13 UTC
@ndburrus I think the project score (x50) is not in the json.
Norvin Burrus
@ndburrus
Jul 17 2016 01:14 UTC
@sjames1958gm i think you're right - i'm not sure, but lesson (non x50) points may also not be included...
kevinstonge
@kevinstonge
Jul 17 2016 01:18 UTC
function largestOfFour(arr) {
  var largestOfFourArray = [];
  for (i=0;i<arr.length;i++) {
    largestOfFourArray.push(arr[i].sort(function(a,b) { return b - a; })[0]);
  }
  return largestOfFourArray;
}
room for improvement here?
Norvin Burrus
@ndburrus
Jul 17 2016 01:21 UTC
@cattman42 is it resolved?
also, there is a "markdown" button to the lower right of the chat text entry area that you may find useful. :)
kevinstonge
@kevinstonge
Jul 17 2016 01:22 UTC
and another one :)
function confirmEnding(str, target) {
  return (str.substr(str.length-target.length) === target) ? true : false;
}
Norvin Burrus
@ndburrus
Jul 17 2016 01:23 UTC
@rahin1122 is it resolved?
Aiden
@AidenMead
Jul 17 2016 01:32 UTC
so I have a really general question about javascript objects and nesting and such, but I think if I can wrap my head around it, it may make more sense, and it revolves around the record collection challenge
Diego Mayer
@Chrono79
Jul 17 2016 01:35 UTC
@kevinstonge yes, in this line, just do this: return str.substr(-target.length) === target; true or false is inferred
kevinstonge
@kevinstonge
Jul 17 2016 01:39 UTC
@Chrono79 - thanks! I didn't realize that would return true/false all by itself!
CamperBot
@camperbot
Jul 17 2016 01:39 UTC
kevinstonge sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1547 | @chrono79 |http://www.freecodecamp.com/chrono79
Joshua Minchew
@jminchew97
Jul 17 2016 01:40 UTC
hello can somebody help me with explaining the array method sort()?
I dont understand it and its very complicated to me
I passed the test but I want to know how
kevinstonge
@kevinstonge
Jul 17 2016 01:42 UTC
sort without any arguments will just sort from low to high or from a-z ... that's the easy part, I know...
Joshua Minchew
@jminchew97
Jul 17 2016 01:42 UTC
the whole a, b
a -b, b - a, thing is very complicated lol
llamatarianism
@llamatarianism
Jul 17 2016 01:43 UTC
@jminchew97 it's a function that's used to compare two things
Joshua Minchew
@jminchew97
Jul 17 2016 01:43 UTC
I dont understand it
kevinstonge
@kevinstonge
Jul 17 2016 01:43 UTC
alternatively you can include a compareFunction with a and b as arguments (a and be represent one item in the array and then the next item). whatever math you do with those items, if it returns a negative number, it will move a in front of b. it will loop through the array multiple times until it's all sorted
llamatarianism
@llamatarianism
Jul 17 2016 01:43 UTC
basically it applies that function to 2 items in the array
Diego Mayer
@Chrono79
Jul 17 2016 01:43 UTC
@jminchew97 don't know if it helps: http://www.w3schools.com/jsref/jsref_sort.asp
llamatarianism
@llamatarianism
Jul 17 2016 01:43 UTC
if the functionr returns a positive number
it'll swap them
Joshua Minchew
@jminchew97
Jul 17 2016 01:43 UTC
swap?
llamatarianism
@llamatarianism
Jul 17 2016 01:43 UTC
otherwise, they'll remain in the same order relative to each other
kevinstonge
@kevinstonge
Jul 17 2016 01:44 UTC
move b in front of a
Joshua Minchew
@jminchew97
Jul 17 2016 01:44 UTC
oh
llamatarianism
@llamatarianism
Jul 17 2016 01:44 UTC
let's say you have this simple, 2 item array
[2, 1]
and you sort it using the function (a, b) => a - b
Joshua Minchew
@jminchew97
Jul 17 2016 01:44 UTC
ohhhhhhhh
llamatarianism
@llamatarianism
Jul 17 2016 01:44 UTC
2 - 1 == 1, which is positive
so it swaps them
Joshua Minchew
@jminchew97
Jul 17 2016 01:44 UTC
2 - 1 is negative
llamatarianism
@llamatarianism
Jul 17 2016 01:44 UTC
whereas if it was [1, 2]
Joshua Minchew
@jminchew97
Jul 17 2016 01:44 UTC
I gotcha
llamatarianism
@llamatarianism
Jul 17 2016 01:44 UTC
then it'd be 1 - 2 == -1
so it doesn't swap them
Joshua Minchew
@jminchew97
Jul 17 2016 01:45 UTC
by the way I don't know why I said negative, lol.
So this applies no matter what?
llamatarianism
@llamatarianism
Jul 17 2016 01:45 UTC
:P I decided not to pay attention to it just to be polite
yes, this applies to all sort functions
Joshua Minchew
@jminchew97
Jul 17 2016 01:45 UTC
no what what array?
llamatarianism
@llamatarianism
Jul 17 2016 01:45 UTC
here's another example:
let foo = ["bazinga", "bingo", "baz", "quux"];
foo.sort((a, b) => a.length - b.length)
^ that will sort the strings in ascending order based on their length
doesn't matter what the array is, what it contains, it just follows those simple rules.
Joshua Minchew
@jminchew97
Jul 17 2016 01:47 UTC
I think I've gotten the hang of it.
At least better than I did before.
Rachel
@rslim87
Jul 17 2016 01:50 UTC
This message was deleted
functionalStoic
@functionalStoic
Jul 17 2016 01:51 UTC
Anyone have insight into the resolving the card counting problem. Just a direction is needed
Joshua Minchew
@jminchew97
Jul 17 2016 01:51 UTC
Hey Jason I can try to help you out
Diego Mayer
@Chrono79
Jul 17 2016 01:52 UTC
evaluate card value and modify count value in one block, evaluate count value and return in another block @JasonSooter
functionalStoic
@functionalStoic
Jul 17 2016 01:52 UTC
Sounds good @jminchew97
Joshua Minchew
@jminchew97
Jul 17 2016 01:53 UTC
@JasonSooter actually I think @Chrono79 is more experienced than me! So I'll let him help you.
functionalStoic
@functionalStoic
Jul 17 2016 01:53 UTC
@Chrono79 I've got the first part. Is a switch the best method?
labanch
@labanch
Jul 17 2016 01:53 UTC
Hello all! Can anyone explain why parseInt is used in the answer for the 'Where do I belong challenge?
function getIndexToIns(arr, num) {
  // Find my place in this sorted array
 arr.sort(function(a, b){
   return a - b;
 });
 for(var i = 0; i<arr.length; i++){
   if(arr[i] >= num){
     return parseInt(i);
   } 
 }
 return arr.length;
}

getIndexToIns([1, 2, 3], 15);
Diego Mayer
@Chrono79
Jul 17 2016 01:53 UTC
@JasonSooter switch or if/else, your choice
functionalStoic
@functionalStoic
Jul 17 2016 01:54 UTC
Ok. Got that part. Wondering about the sequencing part though. Am checking them as an array?
Diego Mayer
@Chrono79
Jul 17 2016 01:54 UTC
@labanch dunno, I think it works without it too
@JasonSooter you evaluate just 1 card at a time in your function, in the tests, it's called several times
labanch
@labanch
Jul 17 2016 01:56 UTC
@Chrono79 yeah it does. I thought parseInt only accepted strings so I was a bit confused on why it would pass with that
functionalStoic
@functionalStoic
Jul 17 2016 01:56 UTC
Ok. got it. I was thinking about the objectives wrong. Thanks for your help.
kevinstonge
@kevinstonge
Jul 17 2016 02:04 UTC
function truncateString(str, num) {
  return ((str.length <= 3) ? str.slice(0,num) + "..." : (num <=3) ? str.slice(0,num) + "..." : (num >= str.length) ? str : str.slice(0,num-3) + "...");
}
this got ugly!!
Umar Yusuf
@umaryusuf
Jul 17 2016 02:05 UTC
please I need some help, this method doed nto print myFather.name:
kevinstonge
@kevinstonge
Jul 17 2016 02:05 UTC
that works, but could anyone show me their truncate a string code??
Diego Mayer
@Chrono79
Jul 17 2016 02:06 UTC
@kevinstonge
function truncateString(str, num) {
  return num<str.length ? str.slice(0, num<=3 ? num : num -3)+"..." : str;
}
kevinstonge
@kevinstonge
Jul 17 2016 02:06 UTC
oh I knew mine was shit :) thanks @Chrono79 I'm going to study that
CamperBot
@camperbot
Jul 17 2016 02:06 UTC
kevinstonge sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: kevinstonge already gave chrono79 points
kevinstonge
@kevinstonge
Jul 17 2016 02:08 UTC
this is blowing my mind ... how do you learn to code like that?
Arcxeius
@clydebaron2000
Jul 17 2016 02:08 UTC
i am stuck on the challenge 'Record collection' for JSON objects
can anyone help me?
Diego Mayer
@Chrono79
Jul 17 2016 02:08 UTC
refactoring @kevinstonge and trying to keep it dry
Aiden
@AidenMead
Jul 17 2016 02:08 UTC
I'm stuck on the same @clydebaron2000
kevinstonge
@kevinstonge
Jul 17 2016 02:09 UTC
dry?
Diego Mayer
@Chrono79
Jul 17 2016 02:10 UTC
dry: don't repeat yourself, if you look at your code you'll see the same repeated str.slice(0,num) + "..."
kevinstonge
@kevinstonge
Jul 17 2016 02:10 UTC
yeah, that's what makes it ugly .. I just can't muster the brain power to merge all of that into one tiny line like you did.
one thing I can apply from your code is putting the conditional statement as an argument. I've never done that. I can use that in the future pretty easily. :octopus:
Diego Mayer
@Chrono79
Jul 17 2016 02:14 UTC
:+1:
kevinstonge
@kevinstonge
Jul 17 2016 02:23 UTC
@Chrono79 do you generally write your code out in longer form and then go back and refactor?
Diego Mayer
@Chrono79
Jul 17 2016 02:24 UTC
sometimes, yes, it's better to do it longer first and then trying to shrink it
Ghost
@ghost~56a80c91e610378809be5d28
Jul 17 2016 02:25 UTC
You should make a youtube series on JS :smile: @Chrono79
Islam Ibakaev
@dagman
Jul 17 2016 02:34 UTC
hey guys do u like this effect? http://codepen.io/dagman/full/qNpJgN/
Aiden
@AidenMead
Jul 17 2016 02:34 UTC
So I'm stuck on adding an array to an object, I can't figure out the correct syntax to do so.
llamatarianism
@llamatarianism
Jul 17 2016 02:42 UTC
@AidenMead adding how?
you really have to be specific, because in javascript, stuff like this is not an error:
[1, 2, 3, 4, 5] + {a: 1, b: 2}
// -> '1,2,3,4,5[object Object]'
John Freeborn
@jfx1026
Jul 17 2016 02:43 UTC
is there a way to push things to the output/codeMirror for testing? For example: can I do a console.log and check a variable's value?
Aiden
@AidenMead
Jul 17 2016 02:44 UTC
In record collection, the instructions read " If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property."
llamatarianism
@llamatarianism
Jul 17 2016 02:44 UTC
just assign to its tracks property
let object = {a: 1, b: 2, c: 3};
if (!object.hasOwnProperty("tracks")) {
  object.tracks = [];
}
object.tracks.push(5);
// -> {a: 1, b: 2, c: 3, tracks: [5]}
the important line there is object.tracks = []
John Freeborn
@jfx1026
Jul 17 2016 02:45 UTC
I feel your pain @AidenMead - this one is hurting my brain too
Aiden
@AidenMead
Jul 17 2016 02:46 UTC
if (prop === "tracks" && value === "") {
    collection[id].tracks = [];
does that look right?
John Freeborn
@jfx1026
Jul 17 2016 02:48 UTC

This isn't showing anything in the code window.

var testProp = collection.hasOwnProperty(prop);
  console.log ("testProp = " + testProp);

Why is that?

llamatarianism
@llamatarianism
Jul 17 2016 02:48 UTC
well syntactically it looks fine, but
if value is empty, you're supposed to delete the property
@jfx1026 that little window isn't console output
it's what your function returns
Aiden
@AidenMead
Jul 17 2016 02:49 UTC
right, which I don't particularly understand, these instructions are rough, haha.
John Freeborn
@jfx1026
Jul 17 2016 02:50 UTC
ok, so - how do I test a variable to see if it's actually doing what I think it should be?
Aiden
@AidenMead
Jul 17 2016 02:51 UTC
ohhh, do I need to nest if/else statements to get it to effectively do both or none?
is that what I've been missing? hmmm
Aiden
@AidenMead
Jul 17 2016 02:58 UTC
Nope, that's not working
It's just that one that I can't get at all
John Freeborn
@jfx1026
Jul 17 2016 03:03 UTC
@AidenMead - this is my mess, maybe we can help each other
function updateRecords(id, prop, value) {

  var testProp = collection.hasOwnProperty(prop);
  //console.log ("testProp = " + testProp);

  if (testProp===false) {
    collection[id][prop] = value;
    if (prop === "tracks" && value === "") {
      //collection[id].tracks = [];
      var object = {a: 1, b: 2, c: 3};
      //set tracks
      if (!object.hasOwnProperty("tracks")) {
        object.tracks = [];
      }
      object.tracks.push(5);
    }
  } else {
    return "WTF!";
  }

  return collection;
}
It's not working, so I don't know
Aiden
@AidenMead
Jul 17 2016 03:04 UTC
haha, I like your second to last return
John Freeborn
@jfx1026
Jul 17 2016 03:06 UTC
this nested If is not doing anything for me
Megan Charles
@teethnclaws
Jul 17 2016 03:06 UTC
I have a question about the increment lesson on Javascript. I'm using the ++ and it just doesn't want to take it
Aiden
@AidenMead
Jul 17 2016 03:06 UTC
I used stuff like :
if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
And it seems to be working well so far, I have all but one of the test inputs testing out correctly, it's just the one "After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element." that's still returning negative.
John Freeborn
@jfx1026
Jul 17 2016 03:07 UTC
I like the use of the && here, super logical - I just can't seem to make the mental leap to do something with the code after that
that one is failing for me also
Aiden
@AidenMead
Jul 17 2016 03:08 UTC
So I was in the chat earlier and a couple of people led me to a link where there was a discussion about the instructions and how the old wording worked better, so I approached it with that.
Megan Charles
@teethnclaws
Jul 17 2016 03:09 UTC
Nevermind - though the lesson example is a little misleading
Aiden
@AidenMead
Jul 17 2016 03:09 UTC
// Write a function which takes:
//  an id, a property (prop), and a value.
function updateRecords(id, prop, value) {
// If value is non-blank (value !== "") 
// and prop is not "tracks" 
// then update or set the value for the prop.
    // Your code here

// If the prop is "tracks" and value is non-blank,
// push the value onto the end of the tracks array.
    // Your code here

// If value is blank, 
// delete that prop.
    // Your code here

// Always return the entire collection object.
  return collection;
}
John Freeborn
@jfx1026
Jul 17 2016 03:09 UTC
@AidenMead I know that you can't push with a JSON object, you have to use dot/bracket notation only
thanks for the look on that
Aiden
@AidenMead
Jul 17 2016 03:10 UTC
Ohhh, hmmmm, maybe that's the issue I'm running into
I did use push
John Freeborn
@jfx1026
Jul 17 2016 03:12 UTC
you can only push an Array - a coder friend tells me that JS doesn't use true Arrays, but you can create them.
Aiden
@AidenMead
Jul 17 2016 03:12 UTC
So I tested that, took out my .push() line, and set it equal to the new value, and it actually caused a couple of the tests to come back negative.
John Freeborn
@jfx1026
Jul 17 2016 03:13 UTC
SORRY! Undo, quick.
Aiden
@AidenMead
Jul 17 2016 03:13 UTC
haha, no worries
I've been messing with it so much that I took my original solution (that gave me the most positives) and posted it in notes for safe keeping so I can play around.
Here's what I've got:
function updateRecords(id, prop, value) {
   if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  } else if (prop === "tracks" && value !== "") {
    collection[id].tracks.push(value);
  } else if (value === "") {
    delete collection[id][prop];
  }
  return collection;
}
John Freeborn
@jfx1026
Jul 17 2016 03:17 UTC
thanks, still plugging away
Aiden
@AidenMead
Jul 17 2016 03:18 UTC
however, when I run a test involving the .push() condition, i am actually getting an error
kevinstonge
@kevinstonge
Jul 17 2016 03:19 UTC

is it bad that it took me a half hour to figure this out?

function chunkArrayInGroups(arr, size) {
var j = Math.ceil(arr.length/size - 1);
  for(i=0;i<=j;i++) {
    arr.splice(i,size,arr.slice(i,i+size));
  }
  return arr;
}

is there an easier way that I overlooked?

Ogundele Olumide
@Lumexralph
Jul 17 2016 03:20 UTC
hi guys
am working on local weather app presently, I got my coordinates using geolcation object on JSFiddle but when I did same thing on codepen it didn't work, what might be the problem?
Kevin
@KevinBruland
Jul 17 2016 03:22 UTC
@Lumexralph using chrome?
@Lumexralph and do you have a link? It could be a bunch of things but its probably related to https vs http
Ogundele Olumide
@Lumexralph
Jul 17 2016 03:27 UTC
yes, am using chrome but working on both JSFiddle and Codepen, should there be any issue?@Benalron
Bryan
@jbhand75-coder
Jul 17 2016 03:51 UTC
If you are using Chrome then it probably has to do with HTTPS. Here is a link to the doc that explains why it will not work. https://developers.google.com/web/fundamentals/native-hardware/user-location/obtain-location?hl=en
@Lumexralph
Sorry. That was intended for
Aiden
@AidenMead
Jul 17 2016 03:53 UTC
@jfx1026 i found another way to get to the same spot that I'm in, with the same test input coming back negative. You having any luck?
James S.
@Mrblue27
Jul 17 2016 03:56 UTC

function testLogicalAnd(val) {
  // Only change code below this line

  if (val <= 50) {
    if (val >= 25 ) {
      return "Yes";
    }
  }

  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(24);
Where do I put the && operator
kevinstonge
@kevinstonge
Jul 17 2016 03:57 UTC
if (val <= 50 && val >=25) { ...
you are combining both if statements into one
John Freeborn
@jfx1026
Jul 17 2016 03:58 UTC
@AidenMead - rebuilt everything again and I'm in the same place - I think I'm getting closer though
I'm getting this error though now : collection[id][prop] = value;
James S.
@Mrblue27
Jul 17 2016 03:59 UTC
@kevinstonge Thanks I did that but was missing the second Val. Thanks for the help
CamperBot
@camperbot
Jul 17 2016 03:59 UTC
mrblue27 sends brownie points to @kevinstonge :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @kevinstonge |http://www.freecodecamp.com/kevinstonge
John Freeborn
@jfx1026
Jul 17 2016 03:59 UTC
TypeError: collection[id][prop] is undefined
Aiden
@AidenMead
Jul 17 2016 04:01 UTC
@jfx1026 can you post your code?
Tommy Izen
@TommyIzen
Jul 17 2016 04:01 UTC
can anyone tell me why this code doesn't work? Trying to solve seek and destroy
Aiden
@AidenMead
Jul 17 2016 04:01 UTC
I finally got it, had to re-write a line of code and post in in twice to work with my if/else statements without one contradicting the other, it seems
John Freeborn
@jfx1026
Jul 17 2016 04:03 UTC
the error was caused my throwing in the failing test request - when I use any other the code works (without passing the one test)
Aiden
@AidenMead
Jul 17 2016 04:05 UTC
That same thing was happening to me, I was stuck with the silly track "Take a Chance On Me" not returning positive.
But I would only get an error when I actually put in those test variables, otherwise it came back fine.
John Freeborn
@jfx1026
Jul 17 2016 04:06 UTC
I've got the reverse - the one with "Free" is failing on me now
the 5th test
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:07 UTC

in "Escape Sequences in Strings" Assignment I am codding this but it is giving error

var myStr = "FirstLine \n \ SecondLine \ \r ThirdLine"; // Change this line

John Freeborn
@jfx1026
Jul 17 2016 04:07 UTC
code here
function updateRecords(id, prop, value) {

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

  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "Free");
Renata Cavalheiro da Silva
@rezzycavalheiro
Jul 17 2016 04:07 UTC
hi guys! I'm stuck at the mad libs problem... I have absolutely no diea what to do or even where to start
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:08 UTC
can any body help
Aiden
@AidenMead
Jul 17 2016 04:10 UTC
I realized that we were both pursuing the right track, but seperately, so .hasOwnProperty is a factor
John Freeborn
@jfx1026
Jul 17 2016 04:10 UTC
@AidenMead if I comment out 'collection[id].tracks = []; - the failed test switches from 5 to 2
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:12 UTC
blob
what is wrong in this codding
Jamie
@TheJamieCrawford
Jul 17 2016 04:13 UTC

Hey, I'm doing the Global vs. Local scope functions. I'm not sure why my code isn't working:

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

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

var myOutfit = "sweater";

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

myOutfit();

Aiden
@AidenMead
Jul 17 2016 04:13 UTC
Yeah, that's where i realized the nested if/else statements came in, but also the .hasOwnProperty
Jamie
@TheJamieCrawford
Jul 17 2016 04:13 UTC

Challenge is

Do not change the value of the global outerWear
myOutfit should return "sweater"
Do not change the return statement

Aiden
@AidenMead
Jul 17 2016 04:13 UTC
if (value !== "") {

       if (prop !== "tracks") {
         collection[id][prop] = value;

       } else if(!collection[id].hasOwnProperty("tracks")) {
         collection[id].tracks = [];
         collection[id][prop].push(value);
John Freeborn
@jfx1026
Jul 17 2016 04:14 UTC
@MalickArsalan - check the markdown help for posting your code
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 04:15 UTC
In 'Seek and Destroy' the first step is to store the arguments in an array? Am I right?
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:16 UTC
@jfx1026 i dont get it
Aiden
@AidenMead
Jul 17 2016 04:16 UTC
@TheJamieCrawford it appears that you are trying to change the function name.. "myOutfit" is the function, whereas the variable "outerWear" is the variable that "myOutfit" it looking to change
Jamie
@TheJamieCrawford
Jul 17 2016 04:17 UTC
@AidenMead I don't understand >.<
John Freeborn
@jfx1026
Jul 17 2016 04:17 UTC
if you type three of these , then paste your code and three more, then your code will show up in black, like everyone else here - no screen shot needed
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:17 UTC
ok
John Freeborn
@jfx1026
Jul 17 2016 04:17 UTC
the key is the same as the ~, without shift
martinronquillo
@martinronquillo
Jul 17 2016 04:18 UTC

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

function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty("gift");
return "pony";

}

// Test your code by modifying these values
checkObj("gift");

Malick Arsalan
@MalickArsalan
Jul 17 2016 04:19 UTC
var myStr = "FirstLine\n\\SecondLine\\\ThirdLine"; // Change this line
Jamie
@TheJamieCrawford
Jul 17 2016 04:19 UTC
@AidenMead I figured it out :dancer:
martinronquillo
@martinronquillo
Jul 17 2016 04:19 UTC
Testing Objects for Properties
Jamie
@TheJamieCrawford
Jul 17 2016 04:19 UTC
thanks @AidenMead
CamperBot
@camperbot
Jul 17 2016 04:19 UTC
thejamiecrawford sends brownie points to @aidenmead :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @aidenmead |http://www.freecodecamp.com/aidenmead
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:19 UTC
Thanks :) @jfx1026
CamperBot
@camperbot
Jul 17 2016 04:19 UTC
malickarsalan sends brownie points to @jfx1026 :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @jfx1026 |http://www.freecodecamp.com/jfx1026
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:20 UTC
what is wrong in this code
var myStr = "FirstLine\n\\SecondLine\\\ThirdLine"; // Change this line
Aiden
@AidenMead
Jul 17 2016 04:21 UTC
@TheJamieCrawford So look at each name, they are separate variables. So on the outside, you wear a t-shirt. The t-shirt is part of the outfit. One a very simple level, we need to do something to change the t-shirt, or "outerWear" because it's too cold. So we do something (a function labelled the general term"myOutfit") to change the outerWear. The way you have it set up, you're taking the function "myOutfit" and trying to change it, where you should be trying to change "outerWear".
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:21 UTC
in Escape Sequences in Strings task
Aiden
@AidenMead
Jul 17 2016 04:21 UTC
Sorry if that makes it more confusing, haha. Trying to explain without re-writing the code ;)
@TheJamieCrawford Just saw you figured it out up a bit :+1:
NixonRichard
@NixonRichard
Jul 17 2016 04:23 UTC
This message was deleted
hi guyz
my weather app so far
can someone tell me why it doesnt return the weather ?
John Freeborn
@jfx1026
Jul 17 2016 04:28 UTC
@MalickArsalan - I'm looking back at mine, one sec
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:28 UTC
Sure @jfx1026
John Freeborn
@jfx1026
Jul 17 2016 04:31 UTC
@MalickArsalan - mine is failing the same first test as yours var myStr = "FirstLine\n \\\SecondLine\\\ \rThirdLine";
I must have completed this one on my machine at work and it's not saved here
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:32 UTC
ok Thanks for your Effort :)
:)
@jfx1026 - Thansk Alot
John Freeborn
@jfx1026
Jul 17 2016 04:36 UTC
@AidenMead - I finally got it, it's not pretty though
thanks @AidenMead for your tips
CamperBot
@camperbot
Jul 17 2016 04:39 UTC
jfx1026 sends brownie points to @aidenmead :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @aidenmead |http://www.freecodecamp.com/aidenmead
Need help with falsy bouncer. here's my code. i only get 1/4 of the tests.
function falsy(value) {
   if (value === false || value === null || value === 0 || value === undefined || value === "" || value === isNaN) {
     return value;
   }
}
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
   return arr.filter(falsy);
}

bouncer([7, "ate", "", false, 9]);
kevinstonge
@kevinstonge
Jul 17 2016 04:46 UTC
@jod29 I'm stuck on the same one. One thing I'm finding is that isNaN literally means "is not a number" so it will filter things like "ate" because "ate" is not a number.
James S.
@Mrblue27
Jul 17 2016 04:46 UTC
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 10 || val < 20) {
    return "Outside";
  }

  {
  return "Inside";
}
  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(10);
How do I get the inside to compute. I am only getting the Outside
@kevinstonge been stuck for 3 days now :)
kevinstonge
@kevinstonge
Jul 17 2016 04:46 UTC
my code only gets the first two:
function bouncer(arr) {
  return arr.filter(function(val){return (val===false||val===""||val===null||val===0||val===undefined) ? false : true; });
}
i only get the third one
Malick Arsalan
@MalickArsalan
Jul 17 2016 04:49 UTC
@jfx1026 - I have done but not sure what was my mistake in previous which was var myStr = "FirstLine\n\\SecondLine\\\ThirdLine"; // Change this line and var myStr="FirstLine\n\\SecondLine\\\rThirdLine";
and now*
DJ
@qualitymanifest
Jul 17 2016 04:51 UTC
@jod29 rather than specifying every kind of falsy value to filter out, try only returning truthy values. check it: https://repl.it/Ccmi
kevinstonge
@kevinstonge
Jul 17 2016 04:53 UTC
@qualitymanifest thank you!!!
CamperBot
@camperbot
Jul 17 2016 04:53 UTC
kevinstonge sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1281 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
tnx @qualitymanifest
DJ
@qualitymanifest
Jul 17 2016 04:54 UTC
np
kevinstonge
@kevinstonge
Jul 17 2016 04:54 UTC
here's my code for that one now!
function bouncer(arr) {
  return arr.filter(function(val){return (val); });
}
I hate how simple it was :)
Tommy Izen
@TommyIzen
Jul 17 2016 04:54 UTC
@TommyIzen
can anyone tell me why this code doesn't work? Trying to solve seek and destroy
https://repl.it/CcmR
DJ
@qualitymanifest
Jul 17 2016 04:55 UTC
@kevinstonge you could also return !!!!!!!!!!!!!!!!!!!!val, so long as it was an even amount of exclamation points, haha.
kevinstonge
@kevinstonge
Jul 17 2016 04:55 UTC
@qualitymanifest I'm really surprised that works for the number 0.
I think that's what stopped me from even trying it that way
@kevinstonge @qualitymanifest (head spinning) haha! that was clever!
DJ
@qualitymanifest
Jul 17 2016 04:58 UTC
@TommyIzen you're going to need to use the arguments object again on this one, and you don't want to convert it to a string
James S.
@Mrblue27
Jul 17 2016 05:09 UTC
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 10 || val < 20) {
    return "Outside";

  } 











  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(25);
How do I return the "Inside"
```
John Alcher
@alchermd
Jul 17 2016 05:15 UTC
This message was deleted
@Mrblue27 My bad, are you writing a function that checks if val is > 10 AND <20?
DJ
@qualitymanifest
Jul 17 2016 05:19 UTC
@Mrblue27 greater than/less than's are reversed
John Alcher
@alchermd
Jul 17 2016 05:20 UTC
@Mrblue27 If so, you need to change || (OR operator) into && (AND operator)
DJ
@qualitymanifest
Jul 17 2016 05:20 UTC
@alchermd that's not the case, the name of the function is testLogicalOr
John Alcher
@alchermd
Jul 17 2016 05:23 UTC
@qualitymanifest Whoops. Have you solved it yet? What was the expected result for testLogicalOr(25) ?
DJ
@qualitymanifest
Jul 17 2016 05:24 UTC
@alchermd No worries, totally understandable why you would want to check. Anyway, that should return Outside. this is the challenge https://www.freecodecamp.com/challenges/comparisons-with-the-logical-or-operator
John Alcher
@alchermd
Jul 17 2016 05:25 UTC
@qualitymanifest Gotcha. It's quite confusing for me without understanding the context of the problem haha
DJ
@qualitymanifest
Jul 17 2016 05:26 UTC
yeah for sure. i generally just ask people to link to the challenge so i can see what's expected
John Alcher
@alchermd
Jul 17 2016 05:26 UTC
@qualitymanifest In any case, I'm looking for some help too! Are you by any chance knowledgeable in RegExp?
DJ
@qualitymanifest
Jul 17 2016 05:26 UTC
@alchermd somewhat. what's up?
Rahul Nayak
@pragyes31
Jul 17 2016 05:27 UTC
hi guys, can anybody point out why I am not able to get weather info after I select city from the list box. here is my codepen : http://codepen.io/pragyesh31/full/PzERaV/
Norvin Burrus
@ndburrus
Jul 17 2016 05:30 UTC
This message was deleted
John Alcher
@alchermd
Jul 17 2016 05:31 UTC

@qualitymanifest Here's what's up:
I'm currently on the Validate Us Numbers challenge
https://www.freecodecamp.com/challenges/validate-us-telephone-numbers

I'm aware that there's a bunch of RegExp challenges that I already passed, though I used some obscure long If-Else chains that checks for each value of the string. I guess this is the perfect challenge for me to really learn RegExp.

Would you mind guiding me step by step on what should I do in this challenge?

DJ
@qualitymanifest
Jul 17 2016 05:32 UTC
@alchermd so my solution to this ended up being a one-liner, and i wrote some pseudocode to help explain what's going on. i'll give you that pseudocode... one sec

here:

Allow a 1 and a space, then area code with BOTH parens or NO parens, then allow a space/dash, three more numbers, allow another space/dash, then the last four numbers. Nothing before or after

(parens === parenthesis)
kirbyedy
@kirbyedy
Jul 17 2016 05:34 UTC
ty @qualitymanifest
CamperBot
@camperbot
Jul 17 2016 05:34 UTC
kirbyedy sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1282 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jul 17 2016 05:35 UTC
i agree, this is a very good challenge to learn regex, and is worth taking the time to really figure out. if you're not familiar with using regex101.com for testing, check that out. if you haven't been through regexone.com 's tutorial, check that out. even after that tutorial you will probably still need to refer to MDN docs on regex quite a bit, to solve that one efficiently @alchermd
@kirbyedy did i do something for you or are you just passing out brownies to be nice?? also, dang that's quite a streak you've got!
Vercaelus
@Vercaelus
Jul 17 2016 05:38 UTC
Would anyone care to spare a moment to help me understand APIs? I literally can't even.
John Alcher
@alchermd
Jul 17 2016 05:38 UTC
@qualitymanifest Thank you for the help mate! Just another one: let's say I successfully built my RegExp, what JS function do I pass it on to check if it matches string ?
CamperBot
@camperbot
Jul 17 2016 05:38 UTC
alchermd sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1283 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jul 17 2016 05:39 UTC
@alchermd np. regex goes here.test(str)
John Alcher
@alchermd
Jul 17 2016 05:42 UTC
@qualitymanifest Gotcha. I'll get back to you if I have further questions! :D
kevinstonge
@kevinstonge
Jul 17 2016 05:44 UTC
I'd like some tips on "Seek and Destroy" - the following code works, but it can't possibly be the best way to do this:
var globalArguments = [];
function destroyer(arr) {
  globalArguments[0] = arguments[1];
  globalArguments[1] = arguments[2];
  globalArguments[2] = arguments[3];
  return arr.filter(function destroyFilter(val){return (val===globalArguments[0]||val===globalArguments[1]||(globalArguments[2]&&val===globalArguments[2])) ? false : true;});
}
I know a for loops seems to make sense, but it got mad at me for defining a function inside the for loop :\ ... the filter function.
Alex T.
@lx-t
Jul 17 2016 05:46 UTC
@kevinstonge I guess you can use in method of Array to check if val is in globalArguments to shorten your code.
Vercaelus
@Vercaelus
Jul 17 2016 05:47 UTC
@kevinstonge the compiler complains about making a function inside of a loop, but it will still work. Its how I did it. I'd show you my code for comparison, but it seems to be missing
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 05:48 UTC
Hey! I have coded this solution for 'Seek and Destroy'. What do you think? Is it a good approach or not? Please tell.
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var array = [];
  array = arguments[0];
  array.push(num);

  array.sort(function sortArr(a, b)
  {
      return a - b;
  });

  return array.indexOf(num);
}

getIndexToIns([40, 60], 50);
Alex T.
@lx-t
Jul 17 2016 05:48 UTC
@kevinstonge And there's no need in naming the callback function. You're not going to use it in your code anywhere except that filter function, right?
DJ
@qualitymanifest
Jul 17 2016 05:48 UTC
@kevinstonge are you familiar with indexOf?
kirbyedy
@kirbyedy
Jul 17 2016 05:49 UTC
@qualitymanifest its for the hint about that telephone number challenge
DJ
@qualitymanifest
Jul 17 2016 05:49 UTC
@faisal1337 it's fine but it's not good practice to name a variable "array". also you don't even need to make that variable... just use arr which is passed into the function
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 05:50 UTC
Thanks. Lemme change it.
:thumbsup:
Alex T.
@lx-t
Jul 17 2016 05:51 UTC
@qualitymanifest Is it a good practice when you change a function arguments inside that function?
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 05:51 UTC
And the solution was for 'Where do I belong'. Mistake :D
Alex T.
@lx-t
Jul 17 2016 05:51 UTC
@faisal1337 Interesting idea of finding a place for a num.
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 05:52 UTC
Ahan.
DJ
@qualitymanifest
Jul 17 2016 05:53 UTC
@lx-t in this case, i don't see why not. you're changing it for one specific purpose, and you don't need it after that. and i was only recommending against calling a variable "array" because its a reserved word.
kevinstonge
@kevinstonge
Jul 17 2016 05:53 UTC
function destroyer(arr) {
  globalArguments = arguments;
  return arr.filter(function(val){return (val===globalArguments[1]||val===globalArguments[2]||val===globalArguments[3]) ? false : true;});
}
this looks a bit better ... thanks @lx-t ... but could one of you share your code for Seek and Destroy? I'm not really confident that this is the best way.
CamperBot
@camperbot
Jul 17 2016 05:53 UTC
kevinstonge sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 439 | @lx-t |http://www.freecodecamp.com/lx-t
DJ
@qualitymanifest
Jul 17 2016 05:54 UTC
correction, not a reserved word, but close enough.
Nelius Knight
@NeliusKnight
Jul 17 2016 05:55 UTC
Can someone help me on the golf app waypoint
DJ
@qualitymanifest
Jul 17 2016 05:55 UTC
@kevinstonge are you familiar with indexOf?
kevinstonge
@kevinstonge
Jul 17 2016 05:55 UTC
@qualitymanifest yes but I'm not sure how to use it in this situation
Dan Ichim
@danichim
Jul 17 2016 05:55 UTC
str.indexOf(searchValue[, fromIndex])
Alex T.
@lx-t
Jul 17 2016 05:57 UTC
@qualitymanifest I didn't know that JS can change arguments and it costed me some time to debug my script. Now, I'm avoiding changing arguments inside a function. :)
DJ
@qualitymanifest
Jul 17 2016 05:57 UTC
@kevinstonge make a real array of the additional arguments (the ones that come after arr). then run a filter on arr, removing the pieces of arr that are present (indexOf !== -1) in your newly made arguments array
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 05:58 UTC
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  arr.sort(function sortArr(a, b)
  {
      return a - b;
  });

  return arrindexOf(num);
}
Changed it.
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  arr.sort(function sortArr(a, b)
  {
      return a - b;
  });

  return arr.indexOf(num);
}
Alex T.
@lx-t
Jul 17 2016 05:58 UTC
@qualitymanifest I mean, I was surprised that a function's arguments do not belong to local namespace of a function like in some other languages.
thanks @faisal1337
CamperBot
@camperbot
Jul 17 2016 05:59 UTC
jod29 sends brownie points to @faisal1337 :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @faisal1337 |http://www.freecodecamp.com/faisal1337
DJ
@qualitymanifest
Jul 17 2016 05:59 UTC
@lx-t hm, i see what you're saying, i haven't had problems with that yet... let me test that out real quick
Cal-culator
@Cal-culator
Jul 17 2016 05:59 UTC
Hey guys! How do i run two separate loops at the same time?
Nelius Knight
@NeliusKnight
Jul 17 2016 06:00 UTC

function golfScore(par, strokes) {
  // Only change code below this line
    if (strokes == 1) {
    return "Hole-In-One!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (strokes == par - 1) {
    return "Birdie";
  } else if (strokes == par ) {
    return "Par"; 
  } else if (strokes == par + 1) {
    return "Bogey"; 
  } else if (strokes == par + 2) {
    return "Double Bogey";
  } else if (strokes >= par + 3) {
    return "Go Home!"; 
  }
  // Only change code above this line
}

// Change these values to test
golfScore(4, 1);
how is this wrong?
kevinstonge
@kevinstonge
Jul 17 2016 06:00 UTC
@qualitymanifest isn't that basically what my code does? I just use an equality to check each argument instead of checking if the index is not -1.
Cal-culator
@Cal-culator
Jul 17 2016 06:01 UTC
@NeliusKnight try checking the return spellings. FCC wants it to be exact
if its still wrong, let me know
Nelius Knight
@NeliusKnight
Jul 17 2016 06:01 UTC
Ive been on this waypoint for 3 days
and THAT was the problem?!
DJ
@qualitymanifest
Jul 17 2016 06:01 UTC
@kevinstonge yes, but using an array of the other args and indexOf is less verbose, and, much more importantly, keeps you from having to hardcode in the number of extra arguments to filter
Cal-culator
@Cal-culator
Jul 17 2016 06:01 UTC
@NeliusKnight did it work?
Nelius Knight
@NeliusKnight
Jul 17 2016 06:02 UTC
it sure did @Cal-culator thank you
CamperBot
@camperbot
Jul 17 2016 06:02 UTC
neliusknight sends brownie points to @cal-culator :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
kevinstonge
@kevinstonge
Jul 17 2016 06:02 UTC
@qualitymanifest I'm not understanding - can you show me your code for that challenge?
Nelius Knight
@NeliusKnight
Jul 17 2016 06:02 UTC
geez...
3 days just to find out it was because of capitalization
Cal-culator
@Cal-culator
Jul 17 2016 06:02 UTC
@NeliusKnight No worries. I always check the spelling from then on after that.
DJ
@qualitymanifest
Jul 17 2016 06:02 UTC
@lx-t alright, you have a good point, thanks
CamperBot
@camperbot
Jul 17 2016 06:02 UTC
qualitymanifest sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 440 | @lx-t |http://www.freecodecamp.com/lx-t
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 06:03 UTC
After I finish the Front End Section of FCC. What will be my level in JS. Beginner or Intermediate?
DJ
@qualitymanifest
Jul 17 2016 06:04 UTC
This message was deleted
kevinstonge
@kevinstonge
Jul 17 2016 06:04 UTC
yeah, I don't understand the e1 => part
why did you delete it? :)
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:06 UTC
hey all
DJ
@qualitymanifest
Jul 17 2016 06:06 UTC
i don't like to leave solutions up... someone else might come by who is working on that and see the spoiler. anyway => is basically shorthand for function() {}
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:06 UTC
need some help with the roman numeral converter
DJ
@qualitymanifest
Jul 17 2016 06:07 UTC
@kevinstonge so, make an array of the additional arguments. filter arr to remove pieces that are present in the additional elements (piece of arr.indexOf(additional element array) === -1
err !== -1
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:08 UTC
Any suggestion on how to start? I'm thinking of a named array, with the character codes for each roman numeral from 1 - 9, 10, 50, 100, 500, and 1000
DJ
@qualitymanifest
Jul 17 2016 06:12 UTC
@Torgian basically yeah. make two arrays containing equivalent numbers and roman numerals at the same index. or one two-dimensional array. don't forget about 4, 9, 40, 90, etc, as those ones go by a slightly different pattern than the rest
Cal-culator
@Cal-culator
Jul 17 2016 06:13 UTC
TypeError: str.split("").toLowerCase is not a function. (In 'str.split("").toLowerCase()', 'str.split("").toLowerCase' is undefined) How do i fix this?
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:13 UTC
Well, this is what i have, using char codes for the available roman numbers (HTML char codes)
DJ
@qualitymanifest
Jul 17 2016 06:13 UTC
@Torgian oh, no. no need for HTML char codes
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:13 UTC
might have to change that to just regular letters
ah ok
Was thinking of using the numbers as "keys" so to speak
DJ
@qualitymanifest
Jul 17 2016 06:14 UTC
@Cal-culator lowercase before splitting
@Cal-culator can't lowercase an array
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:14 UTC
or ids
kevinstonge
@kevinstonge
Jul 17 2016 06:15 UTC
@qualitymanifest that => is somehow allowing you to access arguments from destroyer inside of your filter function ... but I think I understand how it works outside of that => thing! Thank you!
CamperBot
@camperbot
Jul 17 2016 06:15 UTC
kevinstonge sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1284 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
kevinstonge
@kevinstonge
Jul 17 2016 06:15 UTC
Here is how I had to modify it to make it work:
function destroyer(arr) { 
  globalArguments = arguments;
  return arr.filter(function(val){return Array.from(globalArguments).indexOf(val) === -1;});
}
Cal-culator
@Cal-culator
Jul 17 2016 06:16 UTC
@qualitymanifest ah ok. thanks
CamperBot
@camperbot
Jul 17 2016 06:16 UTC
cal-culator sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1285 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jul 17 2016 06:17 UTC
@kevinstonge :+1: that is pretty much how i would do it in es5. only nitpicky things: it would be good to assign globalArguments with var in front of it, and if you made it an Array at the same time as you assigned it, it wouldn't have to make a new Array on each iteration of the filter, so would be a little more efficient
kevinstonge
@kevinstonge
Jul 17 2016 06:18 UTC

var globalArguments = arguments;

doesn't that already make it an array since arguments is an array?

DJ
@qualitymanifest
Jul 17 2016 06:19 UTC
@Torgian i guess you could use the numbers as keys for the actual roman values 1: "I", 4: "IV" etc. but you're trying to make an object by wrapping it in [] when you should be wrapping it in {}. also, i think this one is just easier with arrays rather than objects
Cal-culator
@Cal-culator
Jul 17 2016 06:19 UTC
I want to replace all special characters with " ". Do I have to type all special characters manually or is there a term?
DJ
@qualitymanifest
Jul 17 2016 06:19 UTC
@kevinstonge var globalArguments = Array.from(arguments)
kevinstonge
@kevinstonge
Jul 17 2016 06:19 UTC
oh I see
Markus Kiili
@Masd925
Jul 17 2016 06:20 UTC
@kevinstonge arguments is an array-like object (has numeric properties and .length property), but no array methods.
DJ
@qualitymanifest
Jul 17 2016 06:20 UTC
@kevinstonge then change it slightly inside the filter. it's a little more efficient, but nitpicky, you got the gist of it well
kevinstonge
@kevinstonge
Jul 17 2016 06:20 UTC
got it, thanks again :)
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:21 UTC
thanks @Blauelf
CamperBot
@camperbot
Jul 17 2016 06:21 UTC
chaitanyaashtekar sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2192 | @blauelf |http://www.freecodecamp.com/blauelf
Markus Kiili
@Masd925
Jul 17 2016 06:25 UTC
@faisal1337 All functions have .call(), .bind(), and .apply() methods that change how a function is called. The .call() method can determine the calling object (thisArg, the value of this inside the method) and also arguments passed into the method. If call() is used on an array method, the thisArg can be an array like object (needs to have numeric properties "0", "1" etc and .length property). So .call() allows calling array methods on array-like objects like strings (string wrappers are array-like), arguments objects, nodelists, etc. Also on your own array-like objects.
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:28 UTC
@Masd925
var x =new Boolean("null");  //I understand
if (x) console.log(1);

var y =new Boolean(null);  //should'nt execute
if (y)console.log(2);      //but does.why ??
kevinstonge
@kevinstonge
Jul 17 2016 06:30 UTC

how do I know when I can chain methods and when I can't?

For example this works:

arr.sort().indexOf(n);

but this doesn't work:

arr.push(i).indexOf(n);

chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:31 UTC
@kevinstonge because arr.sort returns an array on which indexOf works
Nathaniel Nasarow
@Torgian
Jul 17 2016 06:31 UTC
@qualitymanifest Hey mate, so something like this you think? For the array?
Markus Kiili
@Masd925
Jul 17 2016 06:31 UTC
@chaitanyaashtekar if coerces values to Boolean type, so all objects coerce to true.
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:31 UTC
@kevinstonge but arr.push(i) doesnt return an array
kevinstonge
@kevinstonge
Jul 17 2016 06:32 UTC
thank you @chaitanyaashtekar that makes sense
CamperBot
@camperbot
Jul 17 2016 06:32 UTC
kevinstonge sends brownie points to @chaitanyaashtekar :sparkles: :thumbsup: :sparkles:
:cookie: 383 | @chaitanyaashtekar |http://www.freecodecamp.com/chaitanyaashtekar
llamatarianism
@llamatarianism
Jul 17 2016 06:32 UTC
@chaitanyaashtekar @Masd925 is right. use Boolean rather than new Boolean
~
Markus Kiili
@Masd925
Jul 17 2016 06:32 UTC
@chaitanyaashtekar If you need to coerce a value to Boolean type, you should use the Boolean function Boolean(val).
kevinstonge
@kevinstonge
Jul 17 2016 06:32 UTC
do you know of a shorthand way to stuff push and indexof into the same line? like that? :)
llamatarianism
@llamatarianism
Jul 17 2016 06:33 UTC
well you could use .concat but that won't modify the array in place like .push does
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:33 UTC
@Masd925 okay. but from the mdn website----Any object whose value is not undefined or null, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement
llamatarianism
@llamatarianism
Jul 17 2016 06:33 UTC
`[1, 2, 3, 4].concat(5)
damnit
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:33 UTC
@llamatarianism i know but im asking it to clear my concept
llamatarianism
@llamatarianism
Jul 17 2016 06:33 UTC
[1, 2, 3, 4].concat(5).indexOf(5); @kevinstonge
Markus Kiili
@Masd925
Jul 17 2016 06:34 UTC
@chaitanyaashtekar Read it again. It is the same that I said.
Cal-culator
@Cal-culator
Jul 17 2016 06:34 UTC

function palindrome(str) {
  // Good luck!
    var a=str.toLowerCase().replace(/[^A-Z0-9]+/ig, "").split("");
    var b=str.toLowerCase().replace(/[^A-Z0-9]+/ig, "").split("").reverse("");
    for (var i=0; i<a.length;i++){
        if (a[i]===b[i]){
            return true;
        }
        else if (a[i]!==b[i]){
            return false;
        }
    }
}



palindrome("almostomla");
why doesn't this code work for "almostomla"?
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:35 UTC
@Masd925 yes.okay. thank you !
CamperBot
@camperbot
Jul 17 2016 06:35 UTC
chaitanyaashtekar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2129 | @masd925 |http://www.freecodecamp.com/masd925
llamatarianism
@llamatarianism
Jul 17 2016 06:35 UTC
@chaitanyaashtekar in your example
y isn't false
it's an object that has a value of false
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:36 UTC
@llamatarianism ahhh.thanks man !
@llamatarianism thanks !
CamperBot
@camperbot
Jul 17 2016 06:36 UTC
chaitanyaashtekar sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1010 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Jul 17 2016 06:36 UTC
@Cal-culator your function only checks the first 2 letters
kevinstonge
@kevinstonge
Jul 17 2016 06:36 UTC
Thank you @llamatarianism got my one line function with that concat tip :)
CamperBot
@camperbot
Jul 17 2016 06:36 UTC
kevinstonge sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1011 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Jul 17 2016 06:36 UTC
return == break
Cal-culator
@Cal-culator
Jul 17 2016 06:37 UTC
@llamatarianism what do you mean?
can you elaborate
llamatarianism
@llamatarianism
Jul 17 2016 06:37 UTC
your loop always returns on the first iteration
and returning ends the loop
Cal-culator
@Cal-culator
Jul 17 2016 06:37 UTC
oh... i see
llamatarianism
@llamatarianism
Jul 17 2016 06:37 UTC
so you only check the first letters
Cal-culator
@Cal-culator
Jul 17 2016 06:39 UTC
@llamatarianism how do i fix it? Do i make another loop at the bottom to check?
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:39 UTC
@Cal-culator dont return true when char are equal.let the loop continue.return false only when you find them not equal
llamatarianism
@llamatarianism
Jul 17 2016 06:39 UTC
here's what you do:
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:39 UTC

@Cal-culator ```
for (var i=0; i<a.length;i++){

     if (a[i]!==b[i]){
        return false;
    }

```

damm
llamatarianism
@llamatarianism
Jul 17 2016 06:39 UTC
use .join to make a and b into strings
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:39 UTC

@Cal-culator ```
for (var i=0; i<a.length;i++){

     if (a[i]!==b[i]){
        return false;
    }

```

llamatarianism
@llamatarianism
Jul 17 2016 06:40 UTC
then compare those strings
this challenge does not need a for loop
Cal-culator
@Cal-culator
Jul 17 2016 06:41 UTC

@chaitanyaashtekar thanks
@llamatarianism thanks

```

function palindrome(str) {
// Good luck!
var a=str.toLowerCase().replace(/[^A-Z0-9]+/ig, "").split("");
var b=str.toLowerCase().replace(/[^A-Z0-9]+/ig, "").split("").reverse("");
for (var i=0; i<a.length;i++){
if (a[i]===b[i]){
}
else if (a[i]!==b[i]){
return false; break;
}
}
return true;
}

palindrome("almostomla");

CamperBot
@camperbot
Jul 17 2016 06:41 UTC
cal-culator sends brownie points to @chaitanyaashtekar and @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1012 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:cookie: 384 | @chaitanyaashtekar |http://www.freecodecamp.com/chaitanyaashtekar
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:41 UTC
yes you could just use ====
Cal-culator
@Cal-culator
Jul 17 2016 06:42 UTC

function palindrome(str) {
  // Good luck!
    var a=str.toLowerCase().replace(/[^A-Z0-9]+/ig, "").split("");
    var b=str.toLowerCase().replace(/[^A-Z0-9]+/ig, "").split("").reverse("");
    for (var i=0; i<a.length;i++){
        if (a[i]===b[i]){
        }
        else if (a[i]!==b[i]){
            return false; break;
        }
    }
  return true;
}



palindrome("almostomla");
I just changed it to that
It worked
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:42 UTC
@llamatarianism try return a===b no need of for loop
llamatarianism
@llamatarianism
Jul 17 2016 06:42 UTC
actually comparison doesn't work that way for arrays
[1, 2, 3] !== [1, 2, 3] because they're different objects
the solution is, like I said, to make them into strings
then compare them
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:43 UTC
yes.but they are strings.so it will work
llamatarianism
@llamatarianism
Jul 17 2016 06:43 UTC
no they're not
chaitanya ashtekar
@chaitanyaashtekar
Jul 17 2016 06:45 UTC
ahh.you are right .he didnt .join them later.i didnt read correctly
thanks @llamatarianism
CamperBot
@camperbot
Jul 17 2016 06:45 UTC
:warning: chaitanyaashtekar already gave llamatarianism points
chaitanyaashtekar sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
Lee
@leebut
Jul 17 2016 06:53 UTC

Hello folks.
I'm trying to understand, 'Nesting for loops'. I got a working solution, but I don't understand what 'j' is doing.

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

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

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

It looks like 'j' is checking the length of the container array and then moving to the next item. However, how is it moving in and out of each of the nested arrays [0], [1] and [2]?

kirbyedy
@kirbyedy
Jul 17 2016 06:54 UTC
I think j is looping through each element of the specified array
because you have array of arrays
Markus Kiili
@Masd925
Jul 17 2016 06:55 UTC
@leebut arr[i] is one subarray and j loop loops through its indices.
Cal-culator
@Cal-culator
Jul 17 2016 06:57 UTC
TypeError: str.toUpperCase.split is not a function. (In 'str.toUpperCase.split(" ")', 'str.toUpperCase.split' is undefined)
How do i fix this?
Markus Kiili
@Masd925
Jul 17 2016 06:58 UTC
@Cal-culator .toUpperCase().split()
Cal-culator
@Cal-culator
Jul 17 2016 06:59 UTC
@Masd925 ah ok thanks
CamperBot
@camperbot
Jul 17 2016 06:59 UTC
cal-culator sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2130 | @masd925 |http://www.freecodecamp.com/masd925
Kamil Malek
@KamilMalek
Jul 17 2016 07:00 UTC
Hey guys, in 'Wherefore art thou' intermediate algorithm scripting I'm getting ReferenceError: keys is not defined while using sourceKeys = Object.keys(source);. Can anyone tell me why?
Markus Kiili
@Masd925
Jul 17 2016 07:01 UTC
@KamilMalek Code seems right. Where are you testing it?
Kamil Malek
@KamilMalek
Jul 17 2016 07:02 UTC
Right in the fCC code editor
Markus Kiili
@Masd925
Jul 17 2016 07:02 UTC
Try refreshing the page.
Kamil Malek
@KamilMalek
Jul 17 2016 07:02 UTC
All right
Keone Martin
@Athaman
Jul 17 2016 07:02 UTC
inside the function right?
Kamil Malek
@KamilMalek
Jul 17 2016 07:02 UTC
Yes
Refreshing didn't help
Lee
@leebut
Jul 17 2016 07:03 UTC
@Masd925 does that mean the line italics product = product arr[i][j]; * is using [i] to count the index of the container array and [j] is counting the indices of the nested array?
Kamil Malek
@KamilMalek
Jul 17 2016 07:03 UTC
Here's the whole snippet:
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  // There was a for loop involved. The first part involved getting the keys from the source
  sourceKeys = Object.keys(source);

  return collection.filter(function (obj){
    for(var i = 0; i < keys.length;i++){
    if(!obj.hasOwnProperty(sourceKeys[i]) || obj[sourceKeys[i]] !== source[sourceKeys[i]]) {
      return false; 
     }
    }
    return true; 
  });
  }
  // Only change code above this line
Markus Kiili
@Masd925
Jul 17 2016 07:03 UTC
@leebut Yes, i means the arr element index (elements of arr are arrays).
Keone Martin
@Athaman
Jul 17 2016 07:04 UTC
@KamilMalek put var before sourceKeys
Kamil Malek
@KamilMalek
Jul 17 2016 07:04 UTC
@Athaman Still nothing
And I tested in on a different machine just to make sure
Keone Martin
@Athaman
Jul 17 2016 07:05 UTC
oh wait, it's the keys.length in your for loop
Kamil Malek
@KamilMalek
Jul 17 2016 07:06 UTC
@Athaman Oh my god, thanks
CamperBot
@camperbot
Jul 17 2016 07:06 UTC
kamilmalek sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 605 | @athaman |http://www.freecodecamp.com/athaman
Kamil Malek
@KamilMalek
Jul 17 2016 07:06 UTC
Such a stupdi one
Thank you :)
Keone Martin
@Athaman
Jul 17 2016 07:06 UTC
hah, it happens :D
Lee
@leebut
Jul 17 2016 07:08 UTC
@Masd925 Thank you. I partially understand it. I'm thinking that var product should be defined globally to make it accessible to console.log() or document.GetElementById("id").innerHTML = ;
CamperBot
@camperbot
Jul 17 2016 07:08 UTC
leebut sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2131 | @masd925 |http://www.freecodecamp.com/masd925
Cal-culator
@Cal-culator
Jul 17 2016 07:21 UTC
Why does this happen?
TypeError: a[i].join is not a function. (In 'a[i].join("")', 'a[i].join' is undefined)

function titleCase(str) {
  var a= str.split(" ");
  var b=[];
  var c=[];
  var d=[];
  for (var i=0;i<a.length;i++){
    b=a[i].split("");
    b[0].toUpperCase();
    c.push(b[0]);
    d= c.join("").toUpperCase().split("");
    b[0].replace(d[i]);
    a[0].replace(d[i]);
    a[i].join("");
  }
  a.join(" ")
  console.log(a);
}

titleCase("I'm a little tea pot");
this is the code
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:24 UTC
@Cal-culator don't put the brackets...it shud only be a.join("");
Cal-culator
@Cal-culator
Jul 17 2016 07:25 UTC
Which join? the one inside the loop?
@ekleung123
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:25 UTC
wait...did u mean a[i].push?
by doing a[i].join, you're saying only to join one element in the array, which wouldn't make sense
Cal-culator
@Cal-culator
Jul 17 2016 07:26 UTC
@ekleung123 If i write a.join(""), wouldn't it mean join all of the words together?
I just want it to join words together
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:27 UTC
doing a.join("") would convert the array into a string
Cal-culator
@Cal-culator
Jul 17 2016 07:27 UTC
@ekleung123 let me try that
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:27 UTC
["apple","boy","cat"] becomes "apple, boy, cat"
Markus Kiili
@Masd925
Jul 17 2016 07:29 UTC
With just .join(""), it becomes 'appleboycat', but you can define the delimiter as you like.
jiajinning
@jiajinning
Jul 17 2016 07:31 UTC
can you help me ?
Chris
@capozzic1
Jul 17 2016 07:31 UTC
Hello. My name is Chris. I'm having a big issue with my hangman game that I feel like should have been simple. Can anyone help? I am trying to append the user's input(a single letter) to one of the underscores(which represents a missing letter). https://jsfiddle.net/jtpsj5eu/16/
jiajinning
@jiajinning
Jul 17 2016 07:32 UTC
my code run out is good ! but it con't ?why ?

function repeat(str, num) {
// repeat after me
if(num<0){
return "";
}
else {
var strs = "";
for(var i=0;i<num;i++){
strs +=str;
}
return '"'+strs+'"';
}

}

repeat("abc", 1);

Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:32 UTC
@Cal-culator You're also not using the replace method propertly. In the replace method, you have to tell what you want to replace and what you want to replace it with. Example: string.replace("this","that");
Cal-culator
@Cal-culator
Jul 17 2016 07:33 UTC
@ekleung123 Ah ok
@ekleung123 Going to fix that
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:35 UTC
@jiajinning - ur second return statement doesn't work. Just say "return strs"
Cal-culator
@Cal-culator
Jul 17 2016 07:37 UTC
@ekleung123 can i only use the replace function for strings?
Evgueni
@Redoras
Jul 17 2016 07:38 UTC
Hello
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:39 UTC
function repeat(str, num) {
// repeat after me
if(num<0){
return false;
} else {
var strs = "";
for (var i=0;i<num;i++) {
strs +=str;
}
return strs;
}
Chris
@capozzic1
Jul 17 2016 07:40 UTC
Any ideas on the hangman underscore issue?
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:40 UTC
@Cal-culator - You can't use the replace method on arrays. Read this: http://www.w3schools.com/jsref/jsref_replace.asp
jiajinning
@jiajinning
Jul 17 2016 07:41 UTC
@ekleung123 thank you
CamperBot
@camperbot
Jul 17 2016 07:41 UTC
jiajinning sends brownie points to @ekleung123 :sparkles: :thumbsup: :sparkles:
:cookie: 101 | @ekleung123 |http://www.freecodecamp.com/ekleung123
Cal-culator
@Cal-culator
Jul 17 2016 07:41 UTC
@ekleung123 then how do i replace in array? I tried assigning but it didn't work
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:42 UTC
to replace one value over another, you just declare a value over it..for example, let's say your array = ["apple","boy","cat"]
if you want to replace boy with girl, you say array1 = "girl";
it's array[ 1] = "girl"
Cal-culator
@Cal-culator
Jul 17 2016 07:43 UTC

function titleCase(str) {
  var a= str.split(" ");
  var b=[];
  var c=[];
  var d=[];
  var e="";
  var f=[];
  for (var i=0;i<a.length;i++){
    b=a[i].split("");
    d= c.join("").toUpperCase().split("");
    b[0]=d[i];
    a[i]= b.join("");
  }
  a.join(" ");
  console.log(a);
}

titleCase("I'm a little tea pot");
I tried doing this
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:44 UTC
you can't join only 1 element in an array
you can say a = b.join("");
Cal-culator
@Cal-culator
Jul 17 2016 07:45 UTC
What i am trying to do is split the string below into individual words. And then in the loop, split the words into array.
Blauelf
@Blauelf
Jul 17 2016 07:45 UTC
@Cal-culator You might want to str.toLowerCase().split(" ") (to remove uppercase letters within words), also, you don't return the result of a.join(" ") (it won't change a but return a string, which you currently ignore)
Hari Adhikari
@harryac07
Jul 17 2016 07:48 UTC
Hello,
I need help in problem 'Sum all Odd Fibonacci Numbers'. I didn't get the idea how to proceed. I need hints.
Thanks
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:49 UTC
@Cal-culator I haven't done that exercise you're doing...but what is it supposed to return with titleCase("I'm a little tea pot")
Cal-culator
@Cal-culator
Jul 17 2016 07:50 UTC
@ekleung123 its supposed to return the first letters of each word upper case
So basically, it should return I'm A Little Tea Pot
Blauelf
@Blauelf
Jul 17 2016 07:51 UTC
Have you tried toLowerCase before splitting into words, and actually returning a.join(" ")?
Cal-culator
@Cal-culator
Jul 17 2016 07:52 UTC
@Blauelf Why do i need to lower case? I don't understand
Blauelf
@Blauelf
Jul 17 2016 07:52 UTC
@Cal-culator the input material might be all-caps, and only the first letter should be uppercase.
This message was deleted
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 07:54 UTC

@Cal-culator
function titleCase(str) {
var a = str.split(" ");
var b = [];
for (var i=0; i<a.length; i++) {
b.push(a[i].charAt(0).toUpperCase());
}
return b;
}

var y = titleCase("I'm a little tea pot");
console.log(y);

this puts each letter in an array and returns the first letter of each word
Blauelf
@Blauelf
Jul 17 2016 07:54 UTC
@Cal-culator You are doing some odd things with your one-letter variables. I don't really understand why most of them are there. You might be better off giving them meaningful names, like "words" for "a" (it's an array of all the words), "word" or "currentWord" or something like that for "b" (it's an array of the characters in the current word), ...
For example. you call c.join, with c always being the empty array. The result of that line is an array containing a single empty string.
Cal-culator
@Cal-culator
Jul 17 2016 08:00 UTC
@Blauelf Yeah... going to scrap it and start over
Blauelf
@Blauelf
Jul 17 2016 08:01 UTC
@Cal-culator If you don't want to split the individual words (the split on empty string), I would suggest using substring, substr, or slice on the word string for obtaining the rest of the word, and concatenate the capitalized first letter with the rest using operator +.
Shivam Mehta
@shivam13
Jul 17 2016 08:01 UTC
how to use images from my google drive in code pen??
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:01 UTC
haha i misread the assignemnet, i thought it's supposed to only return the first letter in each word
its not much diff to return each word with the first letter capitalzied...i'll work on it now
vmohan9
@vmohan9
Jul 17 2016 08:04 UTC
Can anybody help me with the seek and destroy question? I am stuck as the input is taken as a single array.
Kevin
@KevinBruland
Jul 17 2016 08:05 UTC
@vmohan9 sure, look into arguments
@vmohan9 short answer... you can use "arguments[x]" inside the function, so argument[0] would be the array, argument1 would be the first number out of the array, argument2 would be the second... etc
but I do strongly recommend reading the MDN page they link to
vmohan9
@vmohan9
Jul 17 2016 08:07 UTC
yeah I tried that way but it did not pass all the sections... sure I will check on them. What is the use of object in this particular question?
Shivam Mehta
@shivam13
Jul 17 2016 08:08 UTC
how to use images from my google drive in code pen??
Kevin
@KevinBruland
Jul 17 2016 08:08 UTC
I did not use an object, so I can't say @vmohan9
vmohan9
@vmohan9
Jul 17 2016 08:09 UTC
cool. Thanks @Benalron
CamperBot
@camperbot
Jul 17 2016 08:09 UTC
vmohan9 sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @benalron |http://www.freecodecamp.com/benalron
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:09 UTC
@harryac07 @Blauelf
function destroyer(arr) {
  // Remove all the values

  var args =arr.slice.call(arguments);
  for (var i = 0;i<args.length;i++)
    {
      if (arr[i] == args[i])
        {
          return arr;
        }
    }

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
can u guys help
Kevin
@KevinBruland
Jul 17 2016 08:10 UTC
@vmohan9 np, GL
Blauelf
@Blauelf
Jul 17 2016 08:10 UTC
@MohammadHasham Don't randomly tag people.
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:10 UTC
@Blauelf Apology.
@Blauelf Can you help me with this?
Kevin
@KevinBruland
Jul 17 2016 08:11 UTC
@MohammadHasham try to run through it mentally and see what it would be doing each time
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:12 UTC
@Benalron I have no clue about this challenge can you help me a lil
@Benalron How can i incorporate the filter?
KnoX
@knox97
Jul 17 2016 08:13 UTC
Mohammad what are you supose to do or return?
Kevin
@KevinBruland
Jul 17 2016 08:13 UTC
@MohammadHasham the first run of the for loop causes the if statement to be, "if 1 == [1, 2, 3, 1, 2, 3]", so that doesnt trigger... the second run through is, if 2 == 2, return arr... so it's returning (ending the entire function, and giving the value of the entire arr)
@MohammadHasham remember, arguments[0] is the array
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:14 UTC
@Benalron then should i store the value in another variable?
and then return that at the end
Kevin
@KevinBruland
Jul 17 2016 08:15 UTC
@MohammadHasham thats one way to do it that would work... but you don't want to return... return ends the entire function
KnoX
@knox97
Jul 17 2016 08:15 UTC
Yeah you need to make an adfitional if statement that checks if it has more then one value
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:15 UTC
@Benalron Is it really necesary yo use filter()
Kevin
@KevinBruland
Jul 17 2016 08:16 UTC
@MohammadHasham but youre also checking each argument against only 1 items in the array... you need to make it so you are checking each argument (other than arguments[0], the array] against EVERY number in the array
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:16 UTC

@Cal-culator
function titleCase(str) {
var a = str.split(" "), b = [];
for (var i=0; i<a.length; i++) {
var x = a[i]
x = x.charAt(0).toUpperCase() + a[i].slice(1,a.length+1);
b.push(x);
}
return b
}

var y = titleCase("I'm a little tea pot");
console.log(y); // yields "I'm A Little Tea Pot"

Kevin
@KevinBruland
Jul 17 2016 08:16 UTC
no... I did it using 2 for loops, @MohammadHasham
KnoX
@knox97
Jul 17 2016 08:16 UTC
If it does than loop through its value or even a good while loop that will loop through every index that has value over 1
Cal-culator
@Cal-culator
Jul 17 2016 08:16 UTC
@ekleung123 I got it

function titleCase(str) {
  var a=str.toLowerCase().split(" ");
  var b=[];
  var c=[];
  var d="";
  var e=[];
  var f=[];
  var g=[];
  for (var i=0; i<a.length;i++){
      b=a[i].split("");
      console.log(b);
      c.push(b[0]);
      console.log(c);
      d = c.join("").toUpperCase();
      console.log(d);
      e= d.split("");
      console.log(e);
      b[0]=e[i];
      f=b.join("");
      console.log(f);
      g.push(f);
  }
  return g.join(" ");



}

titleCase("I'm a little tea pot");
Ignore the console.log();
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:17 UTC
@Cal-culator you dont need to declare so many arrays
Kevin
@KevinBruland
Jul 17 2016 08:17 UTC
@Cal-culator that is a very interesintg solution
Cal-culator
@Cal-culator
Jul 17 2016 08:18 UTC
@ekleung123 I know. I did it because i was starting to get confused.
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:18 UTC
i'm not sure that solution would work for every sentence you pass to titleCase
Kevin
@KevinBruland
Jul 17 2016 08:18 UTC
@Cal-culator remember arrays can have arrays inside of them, like, [ [0,1 ], [2,3 ], [3,4 ], [4,5 ], ]
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:18 UTC
@Cal-culator just try my code .... it does it properly
Cal-culator
@Cal-culator
Jul 17 2016 08:18 UTC
@Benalron I tried that but it didn't work the way I wanted so I tried a much more simple algorithm
@ekleung123 I did. Its pretty concise. Thanks
CamperBot
@camperbot
Jul 17 2016 08:19 UTC
cal-culator sends brownie points to @ekleung123 :sparkles: :thumbsup: :sparkles:
:cookie: 102 | @ekleung123 |http://www.freecodecamp.com/ekleung123
Cal-culator
@Cal-culator
Jul 17 2016 08:20 UTC
@ekleung123 I didn't know charAt and slice works in JavaScript
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:21 UTC
@Cal-culator what other langauge do you know?
Cal-culator
@Cal-culator
Jul 17 2016 08:21 UTC
C++ but haven't used it in a long time so need to refresh
@ekleung123 Java
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:21 UTC
yeah some of the syntax between java and javascript are similar
Cal-culator
@Cal-culator
Jul 17 2016 08:22 UTC
@ekleung123 yeah but JavaScript is so much more easier and more user Oriented
KnoX
@knox97
Jul 17 2016 08:25 UTC
I tried java and got lost in it, but guys one question is it realy better than js? I mean can it do something that js cant?
Cal-culator
@Cal-culator
Jul 17 2016 08:26 UTC
@knox97 Java Script is for browser developing
It can't run on its own while Java can.
It depends on what you are trying to write.
Promise Tochi
@Promhize
Jul 17 2016 08:27 UTC
hello everyone, please i want this code to remove the second and third arguments from the first argument which is the array. But it is returning true for every elem, i cant find the bug, or is there a better way to go about it?
function destroyer(arr) {
  // Remove all the values
  var basearr = arr[0];
  var arglength = arguments.length;

  var newarray = [];

  for (var i = 1; i < arglength; i++) {
      newarray.push(arguments[i]);
  }

  console.log(newarray);

 var finalarray = arguments[0].filter(function(elem, index, array) {
        elem = false;
        for (i = 0; i < newarray.length; i++) {
            if (newarray[1] !== elem) {
                elem = true;
            }
        }

          return elem;
      });


  arr = finalarray

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
KnoX
@knox97
Jul 17 2016 08:28 UTC
I wouldnt agree with that there is nodeJS and it has v8 from google integrated in it @Cal-culator
Eric Ka-Yeung Leung
@ekleung123
Jul 17 2016 08:29 UTC
@Promhize so it it supposed to return [1,2,3,1,2,3]
Markus Kiili
@Masd925
Jul 17 2016 08:29 UTC
@Promhize You should try to find an argument equal to elem, and then return false. After loop return true.
Promise Tochi
@Promhize
Jul 17 2016 08:30 UTC
supposed to return just [1,1] it is to remove the occurences of 2 and 3 @ekleung123
@Masd925 because the function can except different numbers of arguments, i cant hard code the arguments,so i decided to loop through them first and created an array from them
there seems to be something wrong with the loop, when i remove the loop and pass, newarray[1], it removes all the occurrences of 3
Lee
@leebut
Jul 17 2016 08:41 UTC
Hello Folks! I'm doing the Profile Lookup Challenge. I want to test it part-by-part, but even when the name is a name in the array, it shows 'No such contact' despite the part about bob having a green tick. How can it be right and wrong at the same time?
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
kevinstonge
@kevinstonge
Jul 17 2016 08:43 UTC
contacts[i].firstName
Lee
@leebut
Jul 17 2016 08:44 UTC
@kevinstonge Ah, so I have to include the index number to the object access part?
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:44 UTC
Which API FCC used for sample 'Random Quote Machine' does anyone know?
kevinstonge
@kevinstonge
Jul 17 2016 08:45 UTC
it's an array of objects in this exercise, so yes.
Lee
@leebut
Jul 17 2016 08:47 UTC
@kevinstonge Okay. Thank you. It still shows 'No such contact', though. Is that because the task in incomplete?
CamperBot
@camperbot
Jul 17 2016 08:47 UTC
leebut sends brownie points to @kevinstonge :sparkles: :thumbsup: :sparkles:
kevinstonge
@kevinstonge
Jul 17 2016 08:47 UTC
show's no such contact for who?
actually... that's poorly written, it will return no such contact the very first time contacts[i].firstName is not the contact name :)
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:48 UTC

@faisal1337

var args =arr.slice.call(arguments);

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

function consta(arr)
{
  for (var i = 0 ; i<arr.length;i++)
    {
      if (arr[i] == args[i])
        {

        }
    }
}

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

what i need to put in the if conditions in consta()

Blauelf
@Blauelf
Jul 17 2016 08:48 UTC
@leebut You return "No such contact" when there's at least one mismatch, not only if all the names are mismatches.
voidfire
@voidfire
Jul 17 2016 08:48 UTC
Meow, Anyone in the mood to explain a bit recursion to me? I seem to be getting wrong idea about how to factorialize a number
Blauelf
@Blauelf
Jul 17 2016 08:49 UTC
@MohammadHasham The var args line has to be inside destroyer, just like your consta function.
kevinstonge
@kevinstonge
Jul 17 2016 08:49 UTC
I'd switch that to a === and work from there. If it finds a match it should return something (and you'll need to build some conditional statements to return the correct thing)
Keone Martin
@Athaman
Jul 17 2016 08:49 UTC
@voidfire sure, recursion is basically you make a function with a base case that returns stuff, then if that base case isn't met you call the function again inside the function with an altered parameter
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:50 UTC
@MohammadHasham why would you put them outside destroyer function?
Both args line and the consta should be inside the destroyer.
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:50 UTC
@Blauelf Then i wont be able to use args in the second function
@faisal1337 Okay i'll try that
Blauelf
@Blauelf
Jul 17 2016 08:50 UTC
@MohammadHasham I told you to put both inside destroyer. If the function is inside the same scope, it can see args.
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:51 UTC
Put both inside.
And then worry about the condition.
jamesmillerho
@jamesmillerho
Jul 17 2016 08:51 UTC
` js
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:51 UTC
@faisal1337 @Blauelf Okay
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:51 UTC
@Blauelf can you tell me about the API the sample project used? Random Quote Machine. What's its name?
jamesmillerho
@jamesmillerho
Jul 17 2016 08:51 UTC
codePen doesn't ask my location. Why?
$(document).ready(function(){

  if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
$("#data").html("a" + position.coords.latitude + "<br>longitude: " + position.coords.longitude);});
};

})
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:52 UTC
@jamesmillerho try to do it in the FCC editor.
Lee
@leebut
Jul 17 2016 08:53 UTC
@Blauelf Oh. Thank you. Making my way into the nested array now.
CamperBot
@camperbot
Jul 17 2016 08:53 UTC
leebut sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2193 | @blauelf |http://www.freecodecamp.com/blauelf
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:53 UTC
Do I need to put Javascript code in Codepen in <script> tags or not?
jamesmillerho
@jamesmillerho
Jul 17 2016 08:54 UTC
@faisal1337 what is that
Blauelf
@Blauelf
Jul 17 2016 08:55 UTC
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:55 UTC
@jamesmillerho are you using CodePen to complete the challenge?
And putting the code from Codepen.io to FCC editor?
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:55 UTC

@faisal1337


function destroyer(arr) {
  // Remove all the values  
  var args =arr.slice.call(arguments);


function consta(args)
{

  for (var i = 0 ; i<arr.length;i++)
    {
      if (arr[i] == args[i])
        {

        }
    }
}
}

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

@Blauelf is it okay? and when i am returning anything in consta() it does not return what is the issue here?

Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:55 UTC
@Blauelf thanks.
CamperBot
@camperbot
Jul 17 2016 08:55 UTC
faisal1337 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2194 | @blauelf |http://www.freecodecamp.com/blauelf
jamesmillerho
@jamesmillerho
Jul 17 2016 08:56 UTC
@faisal1337 I just type the code on codePen.io
Blauelf
@Blauelf
Jul 17 2016 08:56 UTC
@MohammadHasham You have no return statement, so destroyer implicitly returns undefined. Also, you never use consta. Oh, and consta would implicitly return undefined in all cases, too.
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:56 UTC
Put it back in freecodecamp edior.
editor
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:57 UTC
@Blauelf @faisal1337 Now what should i do?
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:57 UTC
Now make the condition
use indexOf()
it will help.
Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:57 UTC
@faisal1337 Now the condition would be made in second function?
Blauelf
@Blauelf
Jul 17 2016 08:58 UTC
@MohammadHasham Add return statements to both of your functions, and fix the condition in consta. If you want consta to be used by filter, it should not have a parameter named args, since this shadows the variable in the outer scope.
jamesmillerho
@jamesmillerho
Jul 17 2016 08:58 UTC
@faisal1337 but I am building the weather app so I have to do it on codePen
不得不错
@hnsxxscyx
Jul 17 2016 08:59 UTC
Hi,everyone. Can you tell me where is my code wrong?
Aleksandr Vinogradskiy
@patapum86
Jul 17 2016 08:59 UTC

Hi, can you please help me with my code var Bike = function() {

// Only change code below this line.
this.getGear = function(change) {
return change;
};
this.setGear = function(change) {
return change;
};

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);

Muhammad Hasham
@MohammadHasham
Jul 17 2016 08:59 UTC
@Blauelf Okay i'll try that
不得不错
@hnsxxscyx
Jul 17 2016 08:59 UTC
function chunk(arr, size) {<br> // Break it up.<br> var arr1 = [];<br> var arr2 = [];<br> for(var i=0; i<arr.length; ){<br> for(var j=0; j<size; j++,i++){<br> arr2[j] = arr[i];<br> }<br> arr1.push(arr2);<br> }<br> return arr1;<br>}<br><br>chunk(["a", "b", "c", "d"], 2);<br>
Faisal Zulfiqar
@faisal-zulfiqar
Jul 17 2016 08:59 UTC
@jamesmillerho I don't know then. Sorry :/
不得不错
@hnsxxscyx
Jul 17 2016 08:59 UTC
...sorry
Aleksandr Vinogradskiy
@patapum86
Jul 17 2016 08:59 UTC
myBike.getGear() should return 4 after calling myBike.setGear(4). and it does not
Blauelf
@Blauelf
Jul 17 2016 08:59 UTC
@hnsxxscyx No HTML here.
help format
CamperBot
@camperbot
Jul 17 2016 09:00 UTC

: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

不得不错
@hnsxxscyx
Jul 17 2016 09:00 UTC
sorry,How push it?
function chunk(arr, size) {<br> // Break it up.<br> var arr1 = [];<br> var arr2 = [];<br> for(var i=0; i<arr.length; ){<br> for(var j=0; j<size; j++,i++){<br> arr2[j] = arr[i];<br> }<br> arr1.push(arr2);<br> }<br> return arr1;<br>}<br><br>chunk(["a", "b", "c", "d"], 2);<br>
I'm so sorry
Leow Wei Xiang
@boyboi86
Jul 17 2016 09:01 UTC
@hnsxxscyx u can try putting 3 ticks before and after your codes
`
不得不错
@hnsxxscyx
Jul 17 2016 09:01 UTC
function chunk(arr, size) {<br>  // Break it up.<br>  var arr1 = [];<br>  var arr2 = [];<br>  for(var i=0; i<arr.length; ){<br>    for(var j=0; j<size; j++,i++){<br>      arr2[j] = arr[i];<br>    }<br>    arr1.push(arr2);<br>  }<br>  return arr1;<br>}<br><br>chunk(["a", "b", "c", "d"], 2);<br>
yes,markdown
Blauelf
@Blauelf
Jul 17 2016 09:01 UTC
Now replace the <br> with line breaks (Shift+Return)
BTW, you can edit your posts using the three dot menu that appears when you hover over a post.
Leow Wei Xiang
@boyboi86
Jul 17 2016 09:01 UTC
@hnsxxscyx 不错嘛
不得不错
@hnsxxscyx
Jul 17 2016 09:01 UTC
sorry,wait
unction chunk(arr, size) {
  // Break it up.
  var arr1 = [];
  var arr2 = [];
  for(var i=0; i<arr.length; ){
    for(var j=0; j<size; j++,i++){
      arr2[j] = arr[i];
    }
    arr1.push(arr2);
  }
  return arr1;
}

chunk(["a", "b", "c", "d"], 2);
Blauelf
@Blauelf
Jul 17 2016 09:02 UTC
:+1:
不得不错
@hnsxxscyx
Jul 17 2016 09:02 UTC
原来有中国人,救我。。
英语太不行了
耽误大家的时间了,抱歉
Blauelf
@Blauelf
Jul 17 2016 09:02 UTC

@hnsxxscyx You might want to move the var arr2 = []; inside the outer loop, before the inner loop. This way you get a fresh array for each iteration of the outer loop.

And maybe you need a check like j<size && i<arr.length instead of just j<size for not including undefineds when arr.length is not a multiple of size.

不得不错
@hnsxxscyx
Jul 17 2016 09:04 UTC
Why is not new now? Every '=' didn't cover it?
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:05 UTC

@faisal1337 @Blauelf

function destroyer(arr) {
  // Remove all the values  
  var args =arr.slice.call(arguments);


function consta()
{
  var max = [2,3];
  for (var i = 0 ; i<arr.length;i++)
    {
      if (arr[i] == max[i])
        {
          return true;
        }
    }
 return false;
}
  var new_array ;
     for (var i = 0;i<arr.length;i++)
      {
        new_array= arr.filter(consta);
      }
  return new_array;
}

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

I have harcoded [2,3] in max for the time being later on i'll work on that but why is still it is being tangled?

不得不错
@hnsxxscyx
Jul 17 2016 09:05 UTC
Ok, I'll try,thanks.@Blauelf
Lee
@leebut
Jul 17 2016 09:06 UTC
Hello again. Back to the Profile Lookup.
I've got a tick for 'No such property', but I'm having trouble accessing the nested array. I've tried many things, so I'm not being lazy.
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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


}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
不得不错
@hnsxxscyx
Jul 17 2016 09:06 UTC
@Blauelf Thanks.
CamperBot
@camperbot
Jul 17 2016 09:06 UTC
hnsxxscyx sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2195 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Jul 17 2016 09:06 UTC
@hnsxxscyx When pushing arr2 to arr1, you copy a reference to arr2 (or more to the object arr2 is referencing) to the end of arr1. When you change arr2 now, so does the array you just pushed. That's why you should replace the content of arr2 by another empty array.
不得不错
@hnsxxscyx
Jul 17 2016 09:06 UTC
ok,I know
It's like c, array is a address.
kevinstonge
@kevinstonge
Jul 17 2016 09:07 UTC
@leebut if you say return "no such contact" when contacts[i].firstName !== firstName ... it will return "no such contact" the very first time it finds an objects in which firstname is not the one passed to it... and since there are four different objects with four different first names; you will almost always get "no such contact" returned. you must begin with === and move from there.
and when it hits "return" the function exits and that value is returned, so anything written after that will not be executed.
Lee
@leebut
Jul 17 2016 09:09 UTC
@kevinstonge, it's a mess, then.
kevinstonge
@kevinstonge
Jul 17 2016 09:10 UTC
yeah
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:10 UTC

@Blauelf

function destroyer(arr) {
  // Remove all the values  
  var args =arr.slice.call(arguments);


function consta()
{
  var max = [2,3];
  for (var i = 0 ; i<arr.length;i++)
    {
      if (arr[i] == max[i])
        {
          return true;
        }
    }
 return false;
}
  var new_array ;
     for (var i = 0;i<arr.length;i++)
      {
        new_array= arr.filter(consta);
      }
  return new_array;
}

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

I have hardcoded [2,3] for the time being but i am still left with an empty array when i return new_array? where am i wrong?

Lee
@leebut
Jul 17 2016 09:10 UTC
@kevinstonge As my code is wrong, the system shouldn't give green ticks to show that part as working.
kevinstonge
@kevinstonge
Jul 17 2016 09:11 UTC
it's returning the right answer for the wrong reasons :)
Lee
@leebut
Jul 17 2016 09:11 UTC
@kevinstonge yeah, but that is misleading me. It's not good to learn that way.
Blauelf
@Blauelf
Jul 17 2016 09:12 UTC

@MohammadHasham consta should take one argument, a value, You should then iterate args (ignoring the first element, as this is equal to arr), and compare the args element to the passed value. On match, return false, after the loop return true.

And no need for another loop in destroyer if you are going to use filter.

kevinstonge
@kevinstonge
Jul 17 2016 09:13 UTC
think of those checkboxes as clues to help you write the algorithm correctly; just because you get a green check mark, doesn't mean your algorithm is any good at all. You need to get them all and understand why you are getting each one.
不得不错
@hnsxxscyx
Jul 17 2016 09:13 UTC
@Blauelf It's gone,thank you very much.
Lee
@leebut
Jul 17 2016 09:13 UTC
@kevinstonge I've spent about 40 hours on this JavaScript section. A lot of that is from lack of clarity.
不得不错
@hnsxxscyx
Jul 17 2016 09:13 UTC
But if I write like this
function chunk(arr, size) {
  // Break it up.
  var array = [];
  for(var i=0; i<arr.length; i++){
    array[i] = arr[i];
  }
  for(i=0,h=0; h<arr.length; i++,h++){
    for(var j=0; j<size; j++){
      array[i][h] = arr[h]; 
    }
  }
  //arr = array;
  return array;
}

chunk(["a", "b", "c", "d"], 2);
Why "typeError: 0 is read-only"
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:15 UTC
I have made some changes is that okay ,
Blauelf
@Blauelf
Jul 17 2016 09:16 UTC
@hnsxxscyx Your inner loop does the same thing size times. Also, you try to access properties of numbers (array contains numbers, you try to use them as arrays)
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:16 UTC
@Blauelf

function destroyer(arr) {
  // Remove all the values  
  var args =arr.slice.call(arguments);


function consta()
{
  var max = [2,3];
  for (var i = 0 ; i<arr.length;i++)
    {
      for (var j=0;j<max.length;j++)
        {
      if (arr[i] == max[j])
        {
          return true;
        }
        }
    }
 return false;
}

        new_array= arr.filter(consta);

  return new_array;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Blauelf
@Blauelf
Jul 17 2016 09:17 UTC
@MohammadHasham Remove that max thing. AND consta SHOULD TAKE AN ARGUMENT. Also, don't loop over arr in consta, but args. And still wrong condition, and true/false inverted.

There's little use in a function passed to filter if it does not take at least one argument.

Filter will call it with three arguments (the current element, its index in the array, and the array itself), and the function will ignore all of them.

kevinstonge
@kevinstonge
Jul 17 2016 09:20 UTC
For the "Build a Random Quote Machine" challenge, I'm supposed to find my own quote api? why don't they provide one?
Blauelf
@Blauelf
Jul 17 2016 09:24 UTC
Can only guess: Different people might prefer different quotes. And searching for an API that's appropriate and its documentation is a realistic task.
kevinstonge
@kevinstonge
Jul 17 2016 09:24 UTC
good point :)
Shivam Mehta
@shivam13
Jul 17 2016 09:24 UTC
i cant access weather icons from google drive what can i do any one help me please
icons extension is ".svg"
Lee
@leebut
Jul 17 2016 09:29 UTC
Is this getting closer to the Profile List?
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++){
  if (contacts.firstName === firstName){
   for (var j = 0; j < contacts[i]; j++){
     if (contacts[i] === prop){
       return contacts[i][firstName] + contacts[i][prop][j];
     }
   }
  }
}
// Only change code above this line
}
kevinstonge
@kevinstonge
Jul 17 2016 09:32 UTC
@leebut I don't think you need a j-loop; if firstName you can return contacts[i][prop] or "No such property" ... after the i-loop you can return "no such contact"
Blauelf
@Blauelf
Jul 17 2016 09:32 UTC
Also, it's contacts[i].firstName, not contacts.firstName
Lee
@leebut
Jul 17 2016 09:35 UTC
I've taken over two hours doing this challenge. Time for a break. Thank you for helping @Blauelf and @kevinstonge :) I used to think I was a logical person. Obviously not. Time to buy some Spok ears.
CamperBot
@camperbot
Jul 17 2016 09:35 UTC
leebut sends brownie points to @blauelf and @kevinstonge :sparkles: :thumbsup: :sparkles:
:warning: leebut already gave kevinstonge points
:warning: leebut already gave blauelf points
Victor Fischer Scattone
@VFS
Jul 17 2016 09:35 UTC
I'm on the first javascript exercise that uses the map method - "Iterate over arrays with map". I didn't understand how to use that to iterate trough all elements
Just realised how to do that! :)
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:43 UTC
@faisal1337 What does it mean when indexOf return -1
@Blauelf
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:44 UTC
How would one use a JS constructor in an ansychronus JSONP api call?
The instance returns permaturely as undefined:
Blauelf
@Blauelf
Jul 17 2016 09:44 UTC
indexOf returns -1 if the element is not found in the array (same goes for string's indexOf, which searches for substrings)
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:45 UTC
var getResults = function(){

  var streamers = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

  $.getJSON('https://api.twitch.tv/kraken/channels/OgamingSC2/?callback=?', function(data1) {

    $.getJSON('https://api.twitch.tv/kraken/streams/OgamingSC2/?callback=?',function(data2){
      console.log(data1);
      console.log(data2);

    });

  });
}
and the constructor:
function Streamer(resultStream,resultChannel){
  this.name = resultChannel.display_name;
  this.image = resultChannel.game + ": " + resultChannel.logo;
  this.description = resultChannel.status;
  this.online = (resultStream.stream != null);

  console.log(resultStream);
  console.log(resultChannel);

}
This works, but when I use : var streamer = new Streamer(data1,data2); and console.log(streamer); it logs undefined
as if the instance returned earlier than the response : l
Blauelf
@Blauelf
Jul 17 2016 09:47 UTC
Where do you log streamer? Is this after (in time!) the new Streamer? Maybe on the line right after that?
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:49 UTC
oh sorry I removed that, here you go :smile:
var getResults = function(){

  var streamers = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

  $.getJSON('https://api.twitch.tv/kraken/channels/OgamingSC2/?callback=?', function(data1) {

    $.getJSON('https://api.twitch.tv/kraken/streams/OgamingSC2/?callback=?',function(data2){
      console.log(data1);
      console.log(data2);
      var streamer = new Streamer(data1,data2);
      console.log(streamer);
    });

  });
}
Victor Fischer Scattone
@VFS
Jul 17 2016 09:51 UTC
On "Condense Arrays with reduce" my solution passed the tests, but I'm unsure if this is the "best way" to use the reduce method. What do you think?
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(singleVal, el){
  return singleVal + el;
});


//singleVal = array;
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:52 UTC
@victorso I think that's how your supossed to use it , as an accumalator
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:52 UTC

@Blauelf

function destroyer(arr) {

  var args = Array.prototype.slice.call(arguments);


 args.splice(0,1);

  return arr.filter(consta);

 function consta(element) 
 {  
    return args.indexOf(element) == -1;
  }
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

How does the return args.indexOf ... is acting ?

Jonathan Leon
@Wo1v3r
Jul 17 2016 09:52 UTC
@victorso you can also check the wiki
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:52 UTC
@Blauelf would that not always return false or -1
Blauelf
@Blauelf
Jul 17 2016 09:53 UTC
@MohammadHasham consta returns true if element is not in args, and false if it is (so the result of indexOf is the index, which is >=0)
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:54 UTC
@Blauelf http://codepen.io/Wo1v3r/pen/BzJbgX?editors=1011 here if youll see on the console, both data1 and data2 log -first- defined and streamer instance logs as undefined
after clicking any of the three buttons atm
Victor Fischer Scattone
@VFS
Jul 17 2016 09:55 UTC
@Wo1v3r But why am I defining the accumulator as a separate variable before using the reduce method? Wouldn't that way be better?
var array = [4,5,6,7,8];
//var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(singleVal, el){
  return singleVal + el;
}, 0);


//singleVal = array;
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:55 UTC
@Blauelf What does the 'element' does in consta it is still the args?
Blauelf
@Blauelf
Jul 17 2016 09:56 UTC
@MohammadHasham element is just an arbitrary name for the array element that filter will pass to the function. As you use arr.filter, it is an element of arr.
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:56 UTC
@victorso Well yes , you could also not define it at all because it's defaults @ zero, but they said change only below this line so I guess you have to use it
Victor Fischer Scattone
@VFS
Jul 17 2016 09:57 UTC
@Wo1v3r Ok, thanks Jonathan!
CamperBot
@camperbot
Jul 17 2016 09:57 UTC
victorso sends brownie points to @wo1v3r :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @wo1v3r |http://www.freecodecamp.com/wo1v3r
Muhammad Hasham
@MohammadHasham
Jul 17 2016 09:57 UTC
@Blauelf So how does it know that we need an array and why it has missed the other two elements [2,3]
Jonathan Leon
@Wo1v3r
Jul 17 2016 09:57 UTC
@victorso That's more exact : 'Note: If initialValue isn't provided, reduce will execute the callback function starting at index 1, skipping the first index. If initialValue is provided, it will start at index 0.' you can shift 0 into the first place
and reduce it so it does 0+4+5... without any other paramaters
or any value @ first index for that matter
andrew45655
@andrew45655
Jul 17 2016 10:02 UTC

function titleCase(str) {
str=str.toLowerCase();
var word;
var i=0;
var position=0;
var np=0;
var long;
word=str.split(' ');
str=str.split('');

str[0]=str[0].toUpperCase();
//return str;

for(i=0;i<30;i++){
long=word[i].length;
np=position+long+1+np;
str[np].toUpperCase();

}
str=str.join();
//return str;
}
Could any one help with the error inside for loop?
the compiler keep saying cannot read property 'toUpperCase' of underfined and cannot read property 'length' of underfined

Victor Fischer Scattone
@VFS
Jul 17 2016 10:02 UTC
@Wo1v3r Yeah, nice. There is no need for passing 0 as the second parameter to the reduce method.
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:03 UTC
@victorso Yup I just think that in most cases you wouldn't use reduce in that way , but that's great to know
Puvendran Pillay
@puven12
Jul 17 2016 10:05 UTC
hey guys i need your opinion on something, i just skipped the algorithm challenges and data visualisation and went straight to the backend challenges. Bad Idea? or Not?
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:08 UTC
@Blauelf OK blaeuelf I reduced this problem a bit, if you could check the codepen, creating an instance on the first json callback works, but the problem seems to be with nested getjson, how would i avoid that?
Victor Fischer Scattone
@VFS
Jul 17 2016 10:08 UTC

@andrew45655

` ```` ` ```` ` javascript

[code goes here]

` ```` ` ```` `

formats to:

code goes here
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:09 UTC
@puven12 well keep checking the wiki after you succeeded each challenge and see if there are things used that you completely didn't know about
Victor Fischer Scattone
@VFS
Jul 17 2016 10:10 UTC
@victorso Sorry for my reply. Enclose your code between 3 backticks so it has syntax highlight
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:10 UTC
@Blauelf Thanks
CamperBot
@camperbot
Jul 17 2016 10:10 UTC
mohammadhasham sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2196 | @blauelf |http://www.freecodecamp.com/blauelf
Victor Fischer Scattone
@VFS
Jul 17 2016 10:10 UTC
:worried:
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:11 UTC

@Wo1v3r

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.

  var x = arr.concat(num);
  var c = x.sort();
  return c;
  //return c.indexOf(num);

}

getIndexToIns([5, 3, 20, 3], 5);

why is it not sorting correctly?

@Blauelf
Mukul Sahi
@mukulsahi52
Jul 17 2016 10:11 UTC
can someone help me out?
Brendan Kinahan
@BKinahan
Jul 17 2016 10:12 UTC
@MohammadHasham without a compare function, sort() sorts alphabetically: http://mdn.io/sort
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:13 UTC
@MohammadHasham ^ :D
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:14 UTC
Should i use a compare function and return its value would that be enough
Keone Martin
@Athaman
Jul 17 2016 10:15 UTC
more specifically by ascii code so 12 and 8 are read as "12" vs "8" and 1 is lower than 8 so 12 is considered smaller.
yeah if you use a function that returns a comparison of a and b
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:18 UTC
@Athaman @Wo1v3r @BKinahan Thanks
CamperBot
@camperbot
Jul 17 2016 10:18 UTC
mohammadhasham sends brownie points to @athaman and @wo1v3r and @bkinahan :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @wo1v3r |http://www.freecodecamp.com/wo1v3r
:cookie: 606 | @athaman |http://www.freecodecamp.com/athaman
:star2: 2003 | @bkinahan |http://www.freecodecamp.com/bkinahan
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:18 UTC
Completed That!
Puvendran Pillay
@puven12
Jul 17 2016 10:18 UTC
@Wo1v3r what wiki ?
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:19 UTC
@puven12 The FCC wiki, when you're on a challenge just click the Wiki in the navbar
Puvendran Pillay
@puven12
Jul 17 2016 10:19 UTC
@Wo1v3r sure
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:19 UTC
it will open current challenge's hints and solution, just make sure you understand all the solutions and didn't iss out on anything
Puvendran Pillay
@puven12
Jul 17 2016 10:20 UTC
@Wo1v3r thanks man. it is very useful
CamperBot
@camperbot
Jul 17 2016 10:20 UTC
puven12 sends brownie points to @wo1v3r :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @wo1v3r |http://www.freecodecamp.com/wo1v3r
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:22 UTC
HI! I was reading up documentation on Objects.keys() and dont really understand what it does. What does enumerable properties mean?
Defeds
@defeds
Jul 17 2016 10:23 UTC

Could someone potentially help me figure out what i'm doing wrong?

My code is:

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(i = 1; i < arr.length; i++) {
for(n = 1; n < arr[i].length; n++) {
return product * arr[i][n];
}
}
// Only change code above this line
return product;
}

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

andrew45655
@andrew45655
Jul 17 2016 10:24 UTC

When i want to make first letter of each word to upper case, I get error touppercase undefined and 'length' underfined
javascript
[function titleCase(str) {
str=str.toLowerCase(); //lower case all words
var word;
var i=0;
var position=0;
var np=0;
var long;
word=str.split(' '); //split to words
str=str.split(''); //split to letters

str[0]=str[0].toUpperCase(); //upper case the first letter
//return str;

for(i=0;i<30;i++){
long=word[i].length; //get length of words
np=position+long+1+np; //update position of words
str[np].toUpperCase(); //change target word to uppre case

}
str=str.join();
return str;
}]

Tomáš Kalný
@Sleepy-guy
Jul 17 2016 10:26 UTC
hello :D so I finished sum all numbers in range yesterday but my code seems ehm too much comlicated for that simple task :D any ideas
function sumAll(arr) {
 var min = Math.min.apply(Math,arr);
  var max= Math.max.apply(Math,arr);
  var number = [];
  var final = 0;
  for (var i = min+1; i < max; i++) {
    number.push(i);
  }
  var result = number.map(function(bam){
    final += bam;
 });

 return final + max + min;
}

sumAll([5, 10]);
?
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:27 UTC
@Sleepy-guy Mine was even more complicated
So I think youre good :)
@defeds Youre returning two things currently. Product AND product * arr[i][n]
Defeds
@defeds
Jul 17 2016 10:30 UTC
@JuiceDrinker I get a syntax error if i try to do product * arr[i][n]; :/
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:30 UTC
Can you repost your code using ```js please?
Defeds
@defeds
Jul 17 2016 10:31 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(i = 1; i < arr.length; i++) {
    for(n = 1; n < arr[i].length; n++) {
       product = product * arr[i][n];
    }
  }
  // Only change code above this line
  return product;
}
Brendan Kinahan
@BKinahan
Jul 17 2016 10:31 UTC
@Sleepy-guy since there are only two numbers, you could use Math.max(arr[0],arr[1]) instead of using apply
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:31 UTC
One thing to note is that you can write product *= arr[i][n]
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:31 UTC

@BKinahan

function rot13(str) { // LBH QVQ VG!
  var s;
  s = str.charCodeAt(0+13);

  return str.fromCharCode(s);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Why is fromCharCode() giving an error?

@Athaman
Brendan Kinahan
@BKinahan
Jul 17 2016 10:32 UTC
@Sleepy-guy there's also a mathematical formula for the sum of numbers in a range if you want something really simple :P
Defeds
@defeds
Jul 17 2016 10:33 UTC
@Sleepy-guy product *= arr[i][n], i get the red X next to my code
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:33 UTC
dont forget the semicolon
Defeds
@defeds
Jul 17 2016 10:33 UTC

```function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(i = 1; i < arr.length; i++) {
for(n = 1; n < arr[i].length; n++) {
product * arr[i][n];
}
}
// Only change code above this line
return product;
}

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

Brendan Kinahan
@BKinahan
Jul 17 2016 10:33 UTC
@MohammadHasham .fromCharCode is called on String, not just any string
Defeds
@defeds
Jul 17 2016 10:33 UTC
woops
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:33 UTC
also you can hover over the red cross and it will tell you what the problem is
Muhammad Hasham
@MohammadHasham
Jul 17 2016 10:33 UTC
@BKinahan I c.
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:34 UTC
@defeds It should be *=
Brendan Kinahan
@BKinahan
Jul 17 2016 10:34 UTC
@defeds starting at 1 for i and n will cause problems. arrays indices start at 0
Tomáš Kalný
@Sleepy-guy
Jul 17 2016 10:34 UTC
@JuiceDrinker oh :D because there is a link with reduce but I dont know hot to use reduce here :D but thanks:D
CamperBot
@camperbot
Jul 17 2016 10:34 UTC
sleepy-guy sends brownie points to @juicedrinker :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for juicedrinker
Defeds
@defeds
Jul 17 2016 10:34 UTC
@JuiceDrinker Ohhhhh!
@BKinahan @JuiceDrinker Thank you both so much!
CamperBot
@camperbot
Jul 17 2016 10:34 UTC
defeds sends brownie points to @bkinahan and @juicedrinker :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for juicedrinker
:star2: 2004 | @bkinahan |http://www.freecodecamp.com/bkinahan
Robert Skalko
@RobertSkalko
Jul 17 2016 10:34 UTC
quick question why doesn't this work? it's a random quote api.
JuiceDrinker
@JuiceDrinker
Jul 17 2016 10:34 UTC
@BKinahan, What does enumerable properties mean?
Robert Skalko
@RobertSkalko
Jul 17 2016 10:34 UTC
$.getJSON("http://quotes.stormconsultancy.co.uk/random.json?callback=?", function(data) {
  console.log(data);

});
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:35 UTC
Can someone tell me why 'streamer' logs as undefined ? :( http://codepen.io/Wo1v3r/pen/BzJbgX?editors=0111
Tomáš Kalný
@Sleepy-guy
Jul 17 2016 10:36 UTC
@BKinahan yea I really didn't know how to use that math max because it didn't work properly on array :D
Brendan Kinahan
@BKinahan
Jul 17 2016 10:36 UTC
@JuiceDrinker there are some great answers about that here: http://stackoverflow.com/questions/17893718/what-does-enumerable-mean
jamesmillerho
@jamesmillerho
Jul 17 2016 10:36 UTC
$(document).ready(function(){

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

 $.getJSON('http://api.openweathermap.org/data/2.5/weather?lat='+position.coords.latitude+'&lon='+position.coords.longitude+'&appid=833dc2ccd1bb85729f4b968468cc1ad5', function(json){
 $("#data").html(JSON.stringify(json))});

});
};
})
$("#data").html(JSON.stringify(json))
^
the api content doesn't display on the page
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:36 UTC
@robertx32 Are you in https or http codepen?
Brendan Kinahan
@BKinahan
Jul 17 2016 10:36 UTC
@Sleepy-guy you can use the new ES6 spread operator for that! Math.max(...arr)
Robert Skalko
@RobertSkalko
Jul 17 2016 10:37 UTC
no http at all,
Jonathan Leon
@Wo1v3r
Jul 17 2016 10:38 UTC
@robertx32 it works on my end, use this: codepen.io/Treborx555/pen/xOpvkW?editors=0002
i get this in the console
Object {
  author: "E. W. Dijkstra",
  id: 15,
  permalink: "http://quotes.stormconsultancy.co.uk/quotes/15",
  quote: "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration."
}
theres a problem with your button though
but the getson works
Limping Llama
@LimpingLlama
Jul 17 2016 10:40 UTC

Robert Skalko
@RobertSkalko
Jul 17 2016 10:40 UTC
thanks, will check
Limping Llama
@LimpingLlama
Jul 17 2016 10:40 UTC
How about this

All.good?
Robert Skalko
@RobertSkalko
Jul 17 2016 10:41 UTC
wow it works, did you change anything?
Brendan Kinahan
@BKinahan
Jul 17 2016 10:41 UTC
such concise code :P
Limping Llama
@LimpingLlama
Jul 17 2016 10:41 UTC
Well I did a quick Google and it turns out
I needed to use
Something along the lines of
Kinda lkke
With the jist of
Brendan Kinahan
@BKinahan
Jul 17 2016 10:42 UTC
gitter does allow messages that are longer than a handful of words, by the way.
Limping Llama
@LimpingLlama
Jul 17 2016 10:42 UTC
Um quite
No
It
Doesn't
O
N
L
Y
[space]
A
[space]
S
I
N
G
L
E
[space]
E
L
T
T
E
R
LimpingLlama @LimpingLlama doesn't understand life