These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
May 2016
KingCodeV
@KingCodeV
May 23 2016 00:00
i noe
Robert-Jan
@Zorba68
May 23 2016 00:00
@KingCodeV so you would have to change the for loop exit condition to for (i = 0; i < aLong - 1 ; i ++)
Jaren Escueta
@jarenescueta731
May 23 2016 00:01
@vbouloute07 amending my earlier statement that properties are string type: properties actually can be other objects
Asma
@asma8867
May 23 2016 00:01

hi there. could please someone check my problem here: // Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

CamperBot
@camperbot
May 23 2016 00:01

welcome to FreeCodeCamp @asma8867!

Asma
@asma8867
May 23 2016 00:01
thanks.
Jaren Escueta
@jarenescueta731
May 23 2016 00:01
@asma8867 what have you tried so far?
Asma
@asma8867
May 23 2016 00:01
I do not know what should I do. I tried plenty of things, but all of them were wrong :(
KingCodeV
@KingCodeV
May 23 2016 00:01
@Zorba68 i've tried that
Asma
@asma8867
May 23 2016 00:02
my set myStr="Hello World" before the myStr[0]="H" line.
@jarenescueta731 I set myStr="Hello World" before the myStr[0]="H" line.
Robert-Jan
@Zorba68
May 23 2016 00:03
@KingCodeV and x += 1; should come at the end of the loop
Jaren Escueta
@jarenescueta731
May 23 2016 00:03
@asma8867 so the problem description mentions how you cannot change a string once it has been declared, it's immutable
KingCodeV
@KingCodeV
May 23 2016 00:03
@Zorba68 let me try that
Jaren Escueta
@jarenescueta731
May 23 2016 00:03
wiki immutable
CamperBot
@camperbot
May 23 2016 00:04

:point_right: js immutable [wiki]

JavaScript Immutable Types

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

Asma
@asma8867
May 23 2016 00:04
@jarenescueta731 yeah, but I defined a new string to meet the desire.
@jarenescueta731 but still does not work :(
Jaren Escueta
@jarenescueta731
May 23 2016 00:06
@asma8867 you aren't supposed to change above that line, instead you need to change the line "myStr[0] = "H"" into what you just did
@asma8867 define the new string on that line
Asma
@asma8867
May 23 2016 00:07
@jarenescueta731 sorry may I know which line exactly?! I am kind of confused :(
Isaac Pak
@pak11273
May 23 2016 00:07
Does anybody know if their are bugs in the OOP javascript section?
Jaren Escueta
@jarenescueta731
May 23 2016 00:08
@asma8867 the line with the comment //Fix me
Asma
@asma8867
May 23 2016 00:08
@jarenescueta731 thanks. I am going to do it ;)
Isaac Pak
@pak11273
May 23 2016 00:08
Specifically "Make Objects Properties Private"
CamperBot
@camperbot
May 23 2016 00:08
asma8867 sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Jaren Escueta
@jarenescueta731
May 23 2016 00:08
@asma8867 np let me know how it goes
Robert-Jan
@Zorba68
May 23 2016 00:08

@KingCodeV but I think you're better off rethinking the code anyhow, this doesn't seem like a good approach to me ... more something like
var maxLen= 0;

then loop through all words in the array, if the length of the current word is longer than maxLen: update maxLen to the new value
when the loop is done, maxLen should contain your answer

Asma
@asma8867
May 23 2016 00:09
@jarenescueta731 it worked :)
Isaac Pak
@pak11273
May 23 2016 00:09
I've examined my solution and I don't know why it doesn't pass, can anyone help me on this?
Jaren Escueta
@jarenescueta731
May 23 2016 00:09
@asma8867 yay :smile:
KingCodeV
@KingCodeV
May 23 2016 00:11
@Zorba68 this is making me think hard
Jaren Escueta
@jarenescueta731
May 23 2016 00:11
@pak11273 i am almost at that point, if i get it i'll help you out
Isaac Pak
@pak11273
May 23 2016 00:12
@jarenescueta731 alright, let me know when your there and i'll pm you my code
Isaac Pak
@pak11273
May 23 2016 00:18
it even works in jsbin link
Robert-Jan
@Zorba68
May 23 2016 00:18
@KingCodeV in your code, something like
var longestWord = 0;
for (i = 0; i < aLong; i ++){
      a = splits[i].length;      //  a is the length of the current word
     if (a > longestWord) {  //  if it's bigger than the longest word found so far
          longestWord = a;   // then this becomes the longest word found so far
}
KingCodeV
@KingCodeV
May 23 2016 00:20
@Zorba68 now it says i is undefined
this is getting me mad
Jaren Escueta
@jarenescueta731
May 23 2016 00:20
@pak11273 yeah the problem description is pretty vague, i even wonder if we're supposed to use a string instead of a number
Isaac Pak
@pak11273
May 23 2016 00:20
@jarenescueta731 check out my jbin link, it works there
did you find a solution that passes?
Robert-Jan
@Zorba68
May 23 2016 00:21
@KingCodeV make it var i = 0;
Jaren Escueta
@jarenescueta731
May 23 2016 00:21
@pak11273 what's the error you're getting from the editor?
@pak11273 no i haven't
KingCodeV
@KingCodeV
May 23 2016 00:21
tried @Zorba68
Isaac Pak
@pak11273
May 23 2016 00:22
@jarenescueta731 myBike.getGear() should return 3 after calling myBike.setGear(3)
myBike.getGear() should return 1 after calling myBike.setGear(1)
it passes on 4. it passes all in jsbin
Matt
@TheeMattOliver
May 23 2016 00:22
This message was deleted
This message was deleted
Isaac Pak
@pak11273
May 23 2016 00:23
@TheeMattOliver what section is that
Robert-Jan
@Zorba68
May 23 2016 00:23
@KingCodeV ok well good luck..i gotta go.. you got almost everything you need
KingCodeV
@KingCodeV
May 23 2016 00:24
@Zorba68 yeah thanks men
CamperBot
@camperbot
May 23 2016 00:24
kingcodev sends brownie points to @zorba68 :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @zorba68 |http://www.freecodecamp.com/zorba68
Matt
@TheeMattOliver
May 23 2016 00:24
@shamgar it's in the Early JavaScript portion....
It's called "Return Early Pattern for Functions" @pak11273
Jaren Escueta
@jarenescueta731
May 23 2016 00:24
@pak11273 ok i got it to pass, you're just supposed make gear = change in the setGear method
@pak11273 instead of using +=
Isaac Pak
@pak11273
May 23 2016 00:26
@jarenescueta731 ok that makes sense. however, my code was still valid.
@jarenescueta731 thanks bro!
CamperBot
@camperbot
May 23 2016 00:26
pak11273 sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Jaren Escueta
@jarenescueta731
May 23 2016 00:26
@pak11273 no probs dude
Jason Shoemaker
@kutsuya1
May 23 2016 00:27
@KingCodeV It kinda looks like this
for (number of words) {
  if (word > longest) 
    longest = word;
}
return longest;
Isaac Pak
@pak11273
May 23 2016 00:27
@jarenescueta731 so your on the same section as i am?
Jaren Escueta
@jarenescueta731
May 23 2016 00:27
@pak11273 yup
KingCodeV
@KingCodeV
May 23 2016 00:27
@kutsuya1 wait
Isaac Pak
@pak11273
May 23 2016 00:27
@jarenescueta731 cool man, when did you start fcc?
Asma
@asma8867
May 23 2016 00:27
hi there. Sorry I do not know what should I do in this step :(

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

// Your code above this line
return result;
}

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

Isaac Pak
@pak11273
May 23 2016 00:28
@jarenescueta731 I just started this thing yesterday, it's addicting..
Jason Shoemaker
@kutsuya1
May 23 2016 00:28
@KingCodeV it's fake code...I know you you want to figure it out.
Asma
@asma8867
May 23 2016 00:28
the explanation is vague!!!
KingCodeV
@KingCodeV
May 23 2016 00:28
@kutsuya1 dude i want to be your friend you got me
Jason Shoemaker
@kutsuya1
May 23 2016 00:29
@KingCodeV :)
KingCodeV
@KingCodeV
May 23 2016 00:30
@kutsuya1 xD
@kutsuya1 but now let me code
function findLongestWord(str) {
  var arreglo = str.split(" ");
  var longitud = arreglo.length;
  var a,b;
  a = 0;
  b = 0;
  for (var i = 0; i < longitud; i++)
    {
      b = longitud[i].length;
      if (b > a)
        {
          a = b;
        }
    }
  return a;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
```
Asma
@asma8867
May 23 2016 00:31
no one knows?! :(
KingCodeV
@KingCodeV
May 23 2016 00:31
it does not work, it keeps saying i is undefined
Michael Guest
@MichaelGuest
May 23 2016 00:32
@asma8867 what challenge number??
Jason Shoemaker
@kutsuya1
May 23 2016 00:32
@asma8867 first thing I do is click "run test" and see what it is looking for.
Moisés Man
@moigithub
May 23 2016 00:32
@asma8867 u need to join all those words and form a phrase
Asma
@asma8867
May 23 2016 00:32
@MichaelGuest for me its 168
Moisés Man
@moigithub
May 23 2016 00:33
@KingCodeV whats longitud ??
KingCodeV
@KingCodeV
May 23 2016 00:33
@kutsuya1 nevermind
i was using the wrong var
Asma
@asma8867
May 23 2016 00:34
@kutsuya1 I do not know what should I do and then press the run!
eeflores
@eeflores
May 23 2016 00:34
@asma8867 use the parameters to the function to form a sentence. Use spaces between the function params eg. myNoun + " " + myAdjective etc
@asma8867 assign the string you've created to the result var
Jason Shoemaker
@kutsuya1
May 23 2016 00:35
This message was deleted
Asma
@asma8867
May 23 2016 00:36
@eeflores I am so confused!!! :(
it is not clear at all for me :worried:
eeflores
@eeflores
May 23 2016 00:37
@asma8867 the function wordBlanks takes 4 string parameters. You should combine the strings passed to the wordBlanks function into a sentence.
Jason Shoemaker
@kutsuya1
May 23 2016 00:37
@asma8867 You don't need to do any code to "run test" Then you look how it failed. I call it Test-Driven programming. ;)
eeflores
@eeflores
May 23 2016 00:38
@asma8867 the wordBlanks function returns the new sentence
KingCodeV
@KingCodeV
May 23 2016 00:38
@moigithub is spanish for length
eeflores
@eeflores
May 23 2016 00:39
@asma8867 example: wordBlanks("big", "dog", "ran", "quickly"); could return the sentence "big dog ran quickly"
Moisés Man
@moigithub
May 23 2016 00:39
i know is spanish :P (im from Peru)
probably question was too poor :)
@KingCodeV
KingCodeV
@KingCodeV
May 23 2016 00:40
@moigithub am from dr, u meaned in the code?
Michael Guest
@MichaelGuest
May 23 2016 01:05
Why does this Bonfire Reverse A String return undefined??
function reverseString(str) {  
  return str.split('').reverse().join('');
}
reverseString('hello');
Jim Strickland
@JStrick999
May 23 2016 01:07

I am not sure how to return the remaining array on the slasher flick: ```

function slasher(arr, howMany) {
// it doesn't always pay to be first
if (howMany < arr.length && howMany > 0)
{
console.log("not 0, not length");
removed = arr.slice(0,howMany);
console.log(arr);
console.log(removed);

}

else if (howMany >= arr.length)
{
removed = arr.slice(0,arr.length);

}  

else {
removed = arr;
}

return arr;
}
slasher([1, 2, 3], 2);
```



function slasher(arr, howMany) {
  // it doesn't always pay to be first
  if (howMany < arr.length && howMany > 0)
    {
      console.log("not 0, not length");
  removed = arr.slice(0,howMany); 
    console.log(arr);
      console.log(removed);

    }

   else if (howMany >= arr.length)
    {
      removed = arr.slice(0,arr.length);

    }  
  else {
    removed = arr;
  }

  return arr;
} 
slasher([1, 2, 3], 2);
Jason Shoemaker
@kutsuya1
May 23 2016 01:16
@JStrick999 looked at splice() ?
bitgrower
@bitgrower
May 23 2016 01:21
try slice(0, howMany-1) ?
daiwik
@daiwik
May 23 2016 01:21
can someone help me with where art thou
any hints plz
bitgrower
@bitgrower
May 23 2016 01:23
where art thou requires .hasOwnProperty, Object.keys, and deep indexing ... @daiwik
Vick
@vbouloute07
May 23 2016 01:24
function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty();
return "Change Me!";
}
what do i put in the ( )
bitgrower
@bitgrower
May 23 2016 01:25
@JStrick999 - you need to declare the variable removed ...
Vick
@vbouloute07
May 23 2016 01:25
what property am i testing for
bitgrower
@bitgrower
May 23 2016 01:25
@vbouloute07 -- checkProp
bleujai
@bleujai
May 23 2016 01:25
@MichaelGuest You may need to refresh your browser. It worked when I used it in my browser, Chrome.
Michael Guest
@MichaelGuest
May 23 2016 01:26
@bleujai it says undefined
@but I can submit it
Vick
@vbouloute07
May 23 2016 01:26
@bitgrower my code not working
Michael Guest
@MichaelGuest
May 23 2016 01:26
@bleujai I can submit but its undefined
Vick
@vbouloute07
May 23 2016 01:26
@bitgrower myObj.hasOwnProperty(checkProp);
Michael Guest
@MichaelGuest
May 23 2016 01:26
@bleujai I changed it now it says str.split is not a function
bleujai
@bleujai
May 23 2016 01:26
@MichaelGuest I copy and pasted it and the return value was 'olleh'
Michael Guest
@MichaelGuest
May 23 2016 01:27
reverseString((str) => {  
  return str.split('').reverse().join('');
});

reverseString('hello');
try that
Chau Tung Lam Nguyen
@nctl144
May 23 2016 01:27
hey guys
i need some help on my project
bleujai
@bleujai
May 23 2016 01:27
@MichaelGuest you have unneeded ( )s
Michael Guest
@MichaelGuest
May 23 2016 01:28
@bleujai I took the ( from str out and that end ) out
bleujai
@bleujai
May 23 2016 01:28
function reverseString(str) {  
  return str.split('').reverse().join('');
}
reverseString('hello');
bitgrower
@bitgrower
May 23 2016 01:28
@MichaelGuest don't you still need to use the keyword function ?
Michael Guest
@MichaelGuest
May 23 2016 01:28
now i get unexpected token
@bitgrower I am coding in ES6
bleujai
@bleujai
May 23 2016 01:28
@MichaelGuest That returned 'olleh' for me.
Michael Guest
@MichaelGuest
May 23 2016 01:28
@bitgrower Its called arrow functions
Jim Strickland
@JStrick999
May 23 2016 01:29
@kutsuya1 @bitgrower It was splice(). Resolved problem.
Michael Guest
@MichaelGuest
May 23 2016 01:29
reverseString(str) => {  
  return str.split('').reverse().join('');
};

reverseString('hello');
bleujai
@bleujai
May 23 2016 01:29
@MichaelGuest That one does not work for me.
Michael Guest
@MichaelGuest
May 23 2016 01:29
@bleujai same lol
bleujai
@bleujai
May 23 2016 01:30
@MichaelGuest but the other one does.
Michael Guest
@MichaelGuest
May 23 2016 01:30
@bleujai alright I guess ill just do vanilla JS
bleujai
@bleujai
May 23 2016 01:30
what do you need to return for your function?
Michael Guest
@MichaelGuest
May 23 2016 01:30
@bleujai thanks
CamperBot
@camperbot
May 23 2016 01:30
michaelguest sends brownie points to @bleujai :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @bleujai |http://www.freecodecamp.com/bleujai
bleujai
@bleujai
May 23 2016 01:30
the reversed string?
Michael Guest
@MichaelGuest
May 23 2016 01:30
yeah
bleujai
@bleujai
May 23 2016 01:31
copy and paste what you had initially into your browser after you do a hard refresh.
Sometimes that's helped me before.
daiwik
@daiwik
May 23 2016 01:31
@bitgrower but how do i compare 2 keys at once
Muhammad Zaky Fauzi
@ZackOS
May 23 2016 01:31
Is there anyone here use .splice instead of .slice on chunky monkey algorithm? , i found that using .slice is more complicated than .splice
bleujai
@bleujai
May 23 2016 01:32
It would say my function wasn't working, I'd refresh and then all was correct.
daiwik
@daiwik
May 23 2016 01:32
every time i compare keys i do arr.push(collection[i]) @bitgrower
Michael Guest
@MichaelGuest
May 23 2016 01:32
@bleujai still unexpected token is a hard refresh f5?
bitgrower
@bitgrower
May 23 2016 01:32
how would you compare anything ...? how would you compare 2 values within an array? the concept is similar @daiwik
bleujai
@bleujai
May 23 2016 01:33
ctrl + F5
on PC at least
Michael Guest
@MichaelGuest
May 23 2016 01:33
ty
bleujai
@bleujai
May 23 2016 01:33
try it in repl.it and see what it returns
I think that's it
Michael Guest
@MichaelGuest
May 23 2016 01:34
@bleujai same thing
@unexpected token
bleujai
@bleujai
May 23 2016 01:34
what?
not sure why it's working for me and not for you then.
Michael Guest
@MichaelGuest
May 23 2016 01:34
@bleujai ```
@bleujai
reverseString(str) => {  
  return str.split('').reverse().join('');
};

reverseString('hello');
that works for u?
bleujai
@bleujai
May 23 2016 01:35
https://repl.it/CTuc
go here and see if it works
bitgrower
@bitgrower
May 23 2016 01:36
I don't fully understand the syntax of ES6 fat arrow functions ... but I'm not seeing immediately how you would use them with named functions, just anonymous ones ...
Michael Guest
@MichaelGuest
May 23 2016 01:36
@bleujai vanilla version does the one you did
@bitgrower check out this video https://www.youtube.com/watch?v=6sQDTgOqh-I
@bitgrower maybe thats the problem you can only use them on anonymous ones
Chau Tung Lam Nguyen
@nctl144
May 23 2016 01:40
hey guys
is there anyway to make a div in html into a link using jquery?
Charles
@GUITARPLRC
May 23 2016 01:41
@nctl144 why would you want to use jquery?
Chau Tung Lam Nguyen
@nctl144
May 23 2016 01:41
because i use function to append those html value
Charles
@GUITARPLRC
May 23 2016 01:42
@nctl144 add event listener to div
Chau Tung Lam Nguyen
@nctl144
May 23 2016 01:42
how do i do that
Charles
@GUITARPLRC
May 23 2016 01:43
@nctl144 div.click(function());
Sorry $("div").click...
Chau Tung Lam Nguyen
@nctl144
May 23 2016 01:44
yeah but what is inside the function is the prob
...
i have the link
bitgrower
@bitgrower
May 23 2016 01:44
@MichaelGuest -- looks like that's the issue ... kinda what I said, I think ... you can only it with anonymous functions (that is, you can't use it with named functions) ... just heard the guy on the video say they are single purpose ... so, no real sense in naming a function you're only going to use once ... :)
bleujai
@bleujai
May 23 2016 01:44
@MichaelGuest Arrow functions cannot be named so you cannot call it later. It's just to reduce the syntax in certain situations.
@bitgrower And he's probably not around to hear it.
Charles
@GUITARPLRC
May 23 2016 01:46
@nctl144 Google window.location
Michael Guest
@MichaelGuest
May 23 2016 01:46
@bleujai Thanks
CamperBot
@camperbot
May 23 2016 01:46
michaelguest sends brownie points to @bleujai :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave bleujai points
Charles
@GUITARPLRC
May 23 2016 01:46
Sorry again Google window object
bleujai
@bleujai
May 23 2016 01:47
@MichaelGuest Thanks for the education help. My apologies for confusing the situation for a bit.
CamperBot
@camperbot
May 23 2016 01:47
bleujai sends brownie points to @michaelguest :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @michaelguest |http://www.freecodecamp.com/michaelguest
Michael Guest
@MichaelGuest
May 23 2016 01:48
@bleujai No Problem and thanks for clarifying
CamperBot
@camperbot
May 23 2016 01:48
michaelguest sends brownie points to @bleujai :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave bleujai points
Chau Tung Lam Nguyen
@nctl144
May 23 2016 01:48
okay can anyone check my project
it seems to work at the beginning
but after you search for couple of times
it stops working
i dont get it
Michael Guest
@MichaelGuest
May 23 2016 01:49
@bleujai I asked on Stack Overflow
@bleujai this works ```
var reverseString = (str) => {  
  return str.split('').reverse().join('');
};

reverseString('hello');
You can assign it to a variable and it will return olleh
Clint
@soonerDev73
May 23 2016 01:58

The below code evaluates all the true conditions, but the false conditions are not being met. Any ideas why the false conditions aren't working??
function palindrome(str) {
// Good luck!
var other = str;
var joined = other.replace(/\s|,|./gi, "");
var lower = joined.toLowerCase();

var reversed = joined.split('').reverse().join('');

if(lower === reversed){
return true;
}
else if(lower !== reversed){
return false;
}
}

palindrome("eye");

Trenton Stiles
@blzre
May 23 2016 01:58

I have a function thats returning this answer

[[5],[10],[15]]

However the project needs me to return the answer un-nested... so like

[5, 10, 15]

Can anyone help me find out how to convert my answer please?

Chris B
@yeti-detective
May 23 2016 02:00
@blzre however you're building the array add a [0] to the end of it
@blzre so if it's like arr.push(num) make it arr.push(num[0])
Trenton Stiles
@blzre
May 23 2016 02:03
@yeti-detective Im actually not building an array im cutting and existing one, so I still need a find a way to get out of an array
```

function largestOfFour(arr) {
  // You can do this!

  //access each element in the array
  for (var i = 0; i < arr.length; i++) {
    //sort the arrays
    arr[i].sort(function(a, b) {
      return b - a;
    });

    arr[i] = arr[i].slice(0,1);
  }


  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Not sure how I would implement the push() function
bitgrower
@bitgrower
May 23 2016 02:07

or ... if you wanted to make reverseString even more terse, you could leave out the statement semicolons :)

var reverseString = (str) => { return str.split('').reverse().join('') }

@MichaelGuest @bleujai

Michael Guest
@MichaelGuest
May 23 2016 02:07
@bitgrower what do u mean by terse? short?
bitgrower
@bitgrower
May 23 2016 02:09
@blzre - I would create a new array variable and push each largest value onto the array, and then return that array ...
Gee Eem
@Gaary-A-M
May 23 2016 02:09
Screenshot 2016-05-22 at 22.07.59.png
Diego Mayer
@Chrono79
May 23 2016 02:09
@blzre why don't you do this: arr[i] = arr[i][0];?
bitgrower
@bitgrower
May 23 2016 02:09
yes -- terse = short ... less "words" (or characters ...
Michael Guest
@MichaelGuest
May 23 2016 02:09
@bitgrower yeah
bitgrower
@bitgrower
May 23 2016 02:09
I like that @Chrono79 :)
bleujai
@bleujai
May 23 2016 02:10
@MichaelGuest Nice.
Charles
@GUITARPLRC
May 23 2016 02:11
@Gaary-A-M r u missing closing }?
bitgrower
@bitgrower
May 23 2016 02:12

@MichaelGuest - after seeing folks around here use fat arrow functions to create one-line answers for FCC functions, I'm used to seeing fat arrow functions used to compact the # of lines of code, as well as characters, "words", etc ... :)

Thanks for inspiring me to research a bit ... I haven't gotten into using them myself ... I don't think the goal is to convert all functions to fat arrow functions, any more than changing all if/else statements to use ternary operators ...

CamperBot
@camperbot
May 23 2016 02:12
bitgrower sends brownie points to @michaelguest :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @michaelguest |http://www.freecodecamp.com/michaelguest
bleujai
@bleujai
May 23 2016 02:13
@MichaelGuest Doesn't seem like you gain much when you have to declare it as a variable though. It's nice when it's used directly.
Bradford Melluish
@bradfordmelluish
May 23 2016 02:13
@blzre , why are you slicing the array with arr[i] = arr[i].slice(0,1);. Couldn't you just set the value as arr[i] = arr[i][0];?
Trenton Stiles
@blzre
May 23 2016 02:13
@Chrono79 Ayyy that helped a lot. Just had to throw that in my for loop and it worked! Thanks
CamperBot
@camperbot
May 23 2016 02:13
blzre sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 801 | @chrono79 |http://www.freecodecamp.com/chrono79
Bradford Melluish
@bradfordmelluish
May 23 2016 02:13
or create a new array to have the original preserved? like arr2[i] = arr[i][0];
Michael Guest
@MichaelGuest
May 23 2016 02:14
@bitgrower Glad to see you are trying to learn ES6 and trying to progress yourself @bleujai true haha but I like ES6
Diego Mayer
@Chrono79
May 23 2016 02:14
@blzre no problem, sometimes, the answer is simpler than we have thought
Michael Guest
@MichaelGuest
May 23 2016 02:14
I got a even shorter one now haha
Chris B
@yeti-detective
May 23 2016 02:14
@Gaary-A-M look up recursive functions in javascript.
Michael Guest
@MichaelGuest
May 23 2016 02:14
let reverseString = (str) => str.split('').reverse().join('')

reverseString('Howdy');
thats short lol
Bradford Melluish
@bradfordmelluish
May 23 2016 02:14
oh
scrolls up
diego, my man :D
Chau Tung Lam Nguyen
@nctl144
May 23 2016 02:15
hey guys
do you guys know how to reload a part of the page using jquery?
Vick
@vbouloute07
May 23 2016 02:18
var secondTree = myPlants.[1].list[1];
how is this a syntax error
Diego Mayer
@Chrono79
May 23 2016 02:19
@vbouloute07 you're mixing dot and bracket notation there, but I can be wrong and you have to get rid of one dot only, what challenge is that?
Vick
@vbouloute07
May 23 2016 02:20
@Chrono79 Accessing Nested Arrays in JSON
Camille Garcia
@camgarcia53
May 23 2016 02:21
hello
Diego Mayer
@Chrono79
May 23 2016 02:21
@vbouloute07 yes, you have one dot more than needed there, try to figure out which one it is, you have 50% chances ;)
hi
Camille Garcia
@camgarcia53
May 23 2016 02:21
I'm stuck on this lesson: Iterate Through an Array with a For Loop. Here's what I have:

var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var myTotal = 0;
for (var total = 0; i < myArr.total; i++){
myTotal +=myArr[i];
console.log(myArr);
}

Diego Mayer
@Chrono79
May 23 2016 02:23
@camgarcia53 the var inside your loop is the one you use as an index
for (var total = 0; i < myArr.total; i++){ see here, what's total?
Camille Garcia
@camgarcia53
May 23 2016 02:23
@Chrono79 ok
Vick
@vbouloute07
May 23 2016 02:24
@Chrono79 cool thanks
CamperBot
@camperbot
May 23 2016 02:24
vbouloute07 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 802 | @chrono79 |http://www.freecodecamp.com/chrono79
Camille Garcia
@camgarcia53
May 23 2016 02:24
@Chrono79 no
MrSkyWanker
@MrSkyWanker
May 23 2016 02:25
Hey there, any one up to help me via pythontutor?
Vick
@vbouloute07
May 23 2016 02:25
@vbouloute07 i see what i did wrong
MrSkyWanker
@MrSkyWanker
May 23 2016 02:25
about that mutation JS chall
CamperBot
@camperbot
May 23 2016 02:25
you need to ask about @someone!
Camille Garcia
@camgarcia53
May 23 2016 02:25
@Chrono79 I don't get it
Diego Mayer
@Chrono79
May 23 2016 02:26
@camgarcia53 look at the code they gave you as an example
you have to declare an index, in the example code it's i
the for loop condition is i<ourArr.length
and then you increase i
Camille Garcia
@camgarcia53
May 23 2016 02:26
@Chrono79 i did
Charles
@GUITARPLRC
May 23 2016 02:28
@camgarcia53 myArray.total?
Diego Mayer
@Chrono79
May 23 2016 02:28
@camgarcia53 in your code:
you declared total (the name doesn't matter if you are consistent)
the loop condition is i < myArr.total (why?)
and then you increased i, not total
So, your condition becomes i < myArr[0] (myArr[0] is 2) and then you increase i so it'll loop 2 times
Do you see what's wrong now and how to fix it?
Clint
@soonerDev73
May 23 2016 02:31
I am on the palindrome algorithm and I have all of the true conditions met, but the false conditions will not meet. Anything that is not a palindrome should return false despite any specific functioning. Why is it not registering the false condition???
Diego Mayer
@Chrono79
May 23 2016 02:32
@soonerDev73 code please
Clint
@soonerDev73
May 23 2016 02:32

@Chrono79
function palindrome(str) {
// Good luck!
var other = str;
var lower = other.toLowerCase();
var joined = lower.replace(/\s|\W|.|_|1-9/g, "");

var reversed = joined.split('').reverse().join('');

return (joined === reversed);
}

palindrome("eye");

Diego Mayer
@Chrono79
May 23 2016 02:33
@soonerDev73 your regex is wrong
Isis Nallely
@isisnallely
May 23 2016 02:33
Hi, do you know how to solve the "Word Blanks"?
My head is killing me and I can't solve this
Albert Fougy
@albertfougy
May 23 2016 02:33
very simple request. What I'm doing wrong with this simple exercise for wordBlanks.
haha
asking the same question
Isis Nallely
@isisnallely
May 23 2016 02:33
hahahahahahaha
Albert Fougy
@albertfougy
May 23 2016 02:34
i'm getting a headache also
Isis Nallely
@isisnallely
May 23 2016 02:34
I'm dying here
Diego Mayer
@Chrono79
May 23 2016 02:34
@isisnallely @alfougy have you read Mad Libs link?
Albert Fougy
@albertfougy
May 23 2016 02:34
I did.
i mean. i have to write out all those sentences?
richiedSIS
@richiedSIS
May 23 2016 02:34

Hi, everyone. I'm having trouble testing for false values. I want to filter out all the false values in an array. Can anyone give me an idea why I'm unable to filter out the null values here? ```function bouncer(arr) {
// Don't show a false ID to this bouncer.

for(var i=0;i<arr.length;i++){
var value=arr[i];
if(isNaN(value) || !value || value===0 || value===null || value==="" || value=="undefined")
arr.splice(i,i+1);
}
return arr;
}

bouncer([false, null, 0, NaN, undefined, ""]);
```

```
Clint
@soonerDev73
May 23 2016 02:35
@Chrono79 if the regex wasn't right, the true conditions wouldn't be working for the example. All the actual palindromes are returning true
richiedSIS
@richiedSIS
May 23 2016 02:35
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  for(var i=0;i<arr.length;i++){
  var value=arr[i];
  if(isNaN(value) || !value || value===0 || value===null || value==="" || value=="undefined")
    arr.splice(i,i+1);
  }
 return arr;
}

bouncer([false, null, 0, NaN, undefined, ""]);
Hi, everyone. I'm having trouble testing for false values. I want to filter out all the false values in an array. Can anyone give me an idea why I'm unable to filter out the null values here?
Diego Mayer
@Chrono79
May 23 2016 02:35
Isis Nallely
@isisnallely
May 23 2016 02:35
@Chrono79 yes
Diego Mayer
@Chrono79
May 23 2016 02:35
@soonerDev73 you're turning the string in an empty one
/\s|\W|.|_|1-9/g the dot means any character if not escaped
/\W|_/g this is the right regex
Isis Nallely
@isisnallely
May 23 2016 02:36
@Chrono79 ok, let see
Clint
@soonerDev73
May 23 2016 02:37

@Chrono 79 this updated one does the same result function palindrome(str) {
// Good luck!
var other = str;
var lower = other.toLowerCase();
var joined = lower.replace(/\s|./g, "");

var reversed = joined.split('').reverse().join('');

return (joined === reversed);
}

palindrome("eye");

Isis Nallely
@isisnallely
May 23 2016 02:37
@alfougy could you solve the problem?
Diego Mayer
@Chrono79
May 23 2016 02:38
@soonerDev73 again the . if not escaped, replaces all for ""
MrSkyWanker
@MrSkyWanker
May 23 2016 02:39

Greetings,

function mutation(arr)
  {
    var sourceString = arr[0].toLowerCase();
    var checkedLetters = arr[1].toLowerCase();

    for (var i = 0; i < checkedLetters[1].length; i++)
      {
        var checkedLettersEval = checkedLetters[i];
        if (sourceString.indexOf(checkedLettersEval) === (-1))
          return false;
        else if (i == checkedLetters[1].length)
          return true;
      }

  return arr;
}

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

Can't get why my for loop isn't executing till it should do -_-

Diego Mayer
@Chrono79
May 23 2016 02:39
@MrSkyWanker checkedLetters[1].length is 1
MrSkyWanker
@MrSkyWanker
May 23 2016 02:40
How!
Albert Fougy
@albertfougy
May 23 2016 02:40
@isisnallely i'm in the middle of typing.
let you know in a sec.
Chris Hutchinson
@pablanopete
May 23 2016 02:40
hi
Albert Fougy
@albertfougy
May 23 2016 02:40
you can pair with me on livecoding.tv/alfougy
Diego Mayer
@Chrono79
May 23 2016 02:40
@soonerDev73 check your regex here: https://regex101.com
Albert Fougy
@albertfougy
May 23 2016 02:40
i'm there now.. trying to solve this thing
Diego Mayer
@Chrono79
May 23 2016 02:41
@MrSkyWanker it's a letter
MrSkyWanker
@MrSkyWanker
May 23 2016 02:41
@Chrono79 God bless u.
Diego Mayer
@Chrono79
May 23 2016 02:41
@MrSkyWanker :+1:
Chris Hutchinson
@pablanopete
May 23 2016 02:42
having a problem with a very simple lesson not sure how to code the remainder operation.
Isis Nallely
@isisnallely
May 23 2016 02:42
@alfougy oh my! I just can't!
MrSkyWanker
@MrSkyWanker
May 23 2016 02:42
Oops that's don't seems to work for brownies
Chris Hutchinson
@pablanopete
May 23 2016 02:42
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
MrSkyWanker
@MrSkyWanker
May 23 2016 02:43
Thank you so much @Chrono79
CamperBot
@camperbot
May 23 2016 02:43
mrskywanker sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 803 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 23 2016 02:43
@isisnallely @alfougy did the link I gave you clarified something? if not, paste your code and I'll help you with that
@hutchie25 how do you set a variable value?
Charles
@GUITARPLRC
May 23 2016 02:43
@isisnallely @alfougy concatenate string with variables
Isis Nallely
@isisnallely
May 23 2016 02:44
ok, this is what I'm doing

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

// Your code above this line
return result;
}

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

and it's not working, hahahahahaha
Diego Mayer
@Chrono79
May 23 2016 02:46
@isisnallely you don't have to overwrite your function parameters values
Did you see this? https://www.freecodecamp.com/challenges/constructing-strings-with-variables
You have to make a sentence with the words passed to the function, and some more, like the Mad Libs link shows you, and assign that sentence to result.
bitgrower
@bitgrower
May 23 2016 02:46

@MichaelGuest I am always working to progress myself ... just because ES6 may not be a high priority for me to learn, doesn't mean I'm not progressing ... :)

In fact, my contributions were while taking a break from my "day job" ... :)

Isis Nallely
@isisnallely
May 23 2016 02:47
@Chrono79 yes, but I really don't understand :(
Charles
@GUITARPLRC
May 23 2016 02:47
@isisnallely try result += "the" + myAdjective + myNoun....
Diego Mayer
@Chrono79
May 23 2016 02:48
@GUITARPLRC no need for the +=, just = will do (both will do, but abusing += could lead to errors)
Albert Fougy
@albertfougy
May 23 2016 02:48
@isisnallely I think I got it
since we are on the same level. let me know if you want to pair up bro
bitgrower
@bitgrower
May 23 2016 02:48
and .... @isisnallely -- take comfort in knowing that a lot of folks have trouble with this challenge ...
Isis Nallely
@isisnallely
May 23 2016 02:48
@alfougy could you send me the result
?
Albert Fougy
@albertfougy
May 23 2016 02:48
pm me if you are interested
Charles
@GUITARPLRC
May 23 2016 02:49
@Chrono79 your right, thanks for pointing that out
CamperBot
@camperbot
May 23 2016 02:49
guitarplrc sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 804 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 23 2016 02:49
@GUITARPLRC no problem :+1:
Clint
@soonerDev73
May 23 2016 02:50
@Chrono79 fixed the regex! Thank you for your help!
CamperBot
@camperbot
May 23 2016 02:50
soonerdev73 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 805 | @chrono79 |http://www.freecodecamp.com/chrono79
bitgrower
@bitgrower
May 23 2016 02:50
Hey @isisnallely -- you don't need to hit up someone else to see the answer ... you can find hints and answers in the FCC wiki ... it's actually a bit more helpful if someone can give you the insight so you can solve it yourself, though ... but the hints on the fcc wiki are given in stepwise fashion ... so you get hints first, before you are provided the answer ...
Albert Fougy
@albertfougy
May 23 2016 02:50
well.. it looks like i didn't get it.
yeah.. i'm not giving you the answer
for sure.
bitgrower
@bitgrower
May 23 2016 02:50
@alfougy what's the exact name of the challenge ?
Albert Fougy
@albertfougy
May 23 2016 02:50
i thought i was done.
word blanks
Isis Nallely
@isisnallely
May 23 2016 02:51
@alfougy oh gosh D:
bitgrower
@bitgrower
May 23 2016 02:51
:( ... I'm guessing English isn't either of your first language ... that can make it harder ...
Diego Mayer
@Chrono79
May 23 2016 02:51
@alfougy do you mind sharing your code?
bitgrower
@bitgrower
May 23 2016 02:51
help word blanks
CamperBot
@camperbot
May 23 2016 02:51

:point_right: challenge word blanks [wiki]

Challenge Word Blanks

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

:pencil: read more about challenge word blanks on the FCC Wiki

bitgrower
@bitgrower
May 23 2016 02:51
that's how you get help from the wiki ... :)
Albert Fougy
@albertfougy
May 23 2016 02:51
yeah.. the hints are in the link above
just remember the concantenation of the strings
that's all that is.
bitgrower
@bitgrower
May 23 2016 02:52
yeah, hard to know what people know about accessing the wonders of the FCC wiki ... I'm sure I don't even know half of it ... :)
Albert Fougy
@albertfougy
May 23 2016 02:52
and initialize
i thought i was done.
i'm stuck on something.
Charles
@GUITARPLRC
May 23 2016 02:53
@alfougy post your code so we can help
Albert Fougy
@albertfougy
May 23 2016 02:53
k.
one sec
bitgrower
@bitgrower
May 23 2016 02:53
^^^^ indeed ! :)
Albert Fougy
@albertfougy
May 23 2016 02:53

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

myNoun = "cat";
myAdjective = "little";
myVerb = "hit";
myAdverb = "slowly";

result = "I am a " + myNoun + " fairly " + myAdjective + " tried to " + myVerb + " albeit " + myAdverb;

// Your code above this line
return result;
}

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

Diego Mayer
@Chrono79
May 23 2016 02:53
@alfougy you too, don't have to overwrite you function parameters
delete all this:
myNoun = "cat";
myAdjective = "little";
myVerb = "hit";
myAdverb = "slowly";
Albert Fougy
@albertfougy
May 23 2016 02:54
oh.
that's what i thought.
it was already assigned with the values?
it wasn't explicit.
bitgrower
@bitgrower
May 23 2016 02:54
LOL ... yeah, consider parameters passed to your function as a gift ... :)
Albert Fougy
@albertfougy
May 23 2016 02:54
gotcha
Charles
@GUITARPLRC
May 23 2016 02:55
@bitgrower
Isis Nallely
@isisnallely
May 23 2016 02:55
READYYYYYYYYYYYYYYYYYYYYYYYYYY
IT'S DONE
Bill Steffey
@RoadstarDesign
May 23 2016 02:55
Hey there!
Isis Nallely
@isisnallely
May 23 2016 02:55
THIS IS THE CODE

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

// Your code above this line

return result;
}

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

bitgrower
@bitgrower
May 23 2016 02:55

it was already assigned with the values?

Yes: here:

wordBlanks("dog", "big", "ran", "quickly");

Albert Fougy
@albertfougy
May 23 2016 02:55
you know what?
i saw the hints in read
red
on the side
Diego Mayer
@Chrono79
May 23 2016 02:55
@alfougy if you set them inside the function, the function response is fixed no matter what values you pass to it
Albert Fougy
@albertfougy
May 23 2016 02:55
i missed that it was already assigned
got it got it.
bitgrower
@bitgrower
May 23 2016 02:56
:)
Albert Fougy
@albertfougy
May 23 2016 02:56
nice!!!
Isis Nallely
@isisnallely
May 23 2016 02:56
@camperbot YOU DA BEST!!!!
bitgrower
@bitgrower
May 23 2016 02:56
is the challenge blessing you with passes now ?
Diego Mayer
@Chrono79
May 23 2016 02:56
@isisnallely @alfougy :clap: now there are more challenges to struggle with ahead ;)
Albert Fougy
@albertfougy
May 23 2016 02:57
indeed
Bill Steffey
@RoadstarDesign
May 23 2016 02:57
I'm getting tripped up on "Stand In Line".
Albert Fougy
@albertfougy
May 23 2016 02:57
i actually redid the last few excercises before that.
so I can get that rock solid.
Isis Nallely
@isisnallely
May 23 2016 02:57
@Chrono79 HAHAHAHAHA I KNOW! I'm not gonna sleep today, this is my freaking homework
Charles
@GUITARPLRC
May 23 2016 02:57
@isisnallely we're here to help
bitgrower
@bitgrower
May 23 2016 02:57
excellent, @alfougy -- never be afraid to go back in review ... I really admire folks who are trying to understand ...
Isis Nallely
@isisnallely
May 23 2016 02:58
thanks to everyone <3 <3
Rafael J. Rodriguez
@Rafase282
May 23 2016 02:58
Hello everyone
bitgrower
@bitgrower
May 23 2016 02:59
@RoadstarDesign -- I highly recommend going back and reviewing the 4 previous challenges on array functions .push,, .pop, .shift and .unshift ... see how they are used, make sure you are comfortable using them, go back and read or re-read the MDN pages on them
Albert Fougy
@albertfougy
May 23 2016 02:59
just hang in there @isisnallely
you just have to go through the pain.
embrace the pain
Bill Steffey
@RoadstarDesign
May 23 2016 02:59
Ok @bitgrower - I will do that. Thanks for the tip.
CamperBot
@camperbot
May 23 2016 02:59
roadstardesign sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1061 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 23 2016 02:59
@RoadstarDesign - Stand In Line can be solved comfortably in 3 lines ... and can be easily (nothing fancy) shortened to 2 lines ...
Diego Mayer
@Chrono79
May 23 2016 03:00
Now that you know how to do it, didn't the challenge I referred help you (at least a little)? Just to know for the next time someone ask for this @isisnallely @alfougy
Not that it had to do with not setting the values inside the function :(
Hi @Rafase282
Rafael J. Rodriguez
@Rafase282
May 23 2016 03:01
How is it going?
Gee Eem
@Gaary-A-M
May 23 2016 03:01

@dhcodes ... by the by ... I found more succinct code that works ... I pasted it, as if I tried to copy it, I'd get the "}" errors .. lol .. yeah, that's the ticket...<br />function factorialize(num) {
var factorial = 1;
while (num !== 0){
factorial = factorial * num;
num--;
}
return factorial;
}

factorialize(5);

bitgrower
@bitgrower
May 23 2016 03:01

yeah ... @RoadstarDesign -- often people are attempting a next challenge after not quite consolidating the knowledge from the previous challenges ... or ... maybe they solved them earlier, and how they work isn't fresh in their mind ...

repetition is key to learning and remembering ...

Albert Fougy
@albertfougy
May 23 2016 03:01
@Chrono79 yes. it helped
bitgrower
@bitgrower
May 23 2016 03:01
Hey @Rafase282
Rafael J. Rodriguez
@Rafase282
May 23 2016 03:01
hola
bitgrower
@bitgrower
May 23 2016 03:02
and ... also, @alfougy -- another thing which helps repetition & learning is coming in here and helping others when you can, too ...
Albert Fougy
@albertfougy
May 23 2016 03:02
I was used to initializing before that example, that I was doing it out of habit. coding is about the unexpected and using logic to solve
it was a good one. appreciate the direction.
bitgrower
@bitgrower
May 23 2016 03:03
...and about details .... following carefully the instructions ... know what is provided, and what is expected in return ...
Albert Fougy
@albertfougy
May 23 2016 03:03
true
Diego Mayer
@Chrono79
May 23 2016 03:03
Logic is the god of coders :sparkles:
wSlitz
@wSlitz
May 23 2016 03:03
This message was deleted
Ken Truong
@kjjtruong
May 23 2016 03:04
Hey everyone I'm having a hard time getting through the Where Art Thou. Just wondering if someone can help put me in the right direction. My problem seems to stem from the objects with two or more properties
bitgrower
@bitgrower
May 23 2016 03:04
heh ... between logic and following instructions ... both are twinned to winning the coding game ... :)
Ken Truong
@kjjtruong
May 23 2016 03:04
help where art thou
CamperBot
@camperbot
May 23 2016 03:04

:point_right: algorithm where art thou [wiki]

Algorithm Where Art Thou

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about algorithm where art thou on the FCC Wiki

Ken Truong
@kjjtruong
May 23 2016 03:04

```
function whereAreYou(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line

//store keys of second argument in array
var sourceKeys = Object.keys(source);

//iterate over array of objects (first argument)
for(var i = 0; i < collection.length; i++) {
//iterate and check each object if sourceKeys value exists
for(var j = 0; j < sourceKeys.length; j++) {
if(collection[i].hasOwnProperty(sourceKeys[j])){
if(collection[i][sourceKeys[j]] == source[sourceKeys[j]]) {
arr.push(collection[i]);
}
}
}

}

console.log(arr);
// Only change code above this line
return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

bitgrower
@bitgrower
May 23 2016 03:05
@Kjjtrong ... get the properties of one, iterate thru them, then compare them to the properties of the other using .hasOwnProperty

that's the basics of it ... but there's some heavy indexing & addressing involved ...

(get the properties of the one so you can iterate thru them using Object.keys)

Ken Truong
@kjjtruong
May 23 2016 03:06

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  //store keys of second argument in array
  var sourceKeys = Object.keys(source);

  //iterate over array of objects (first argument)
  for(var i = 0; i < collection.length; i++) {
    //iterate and check each object if sourceKeys value exists
    for(var j = 0; j < sourceKeys.length; j++) {
      if(collection[i].hasOwnProperty(sourceKeys[j])){
        if(collection[i][sourceKeys[j]] == source[sourceKeys[j]]) {
          arr.push(collection[i]);
        }
      }
    }

  }

  console.log(arr);
  // Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
bitgrower
@bitgrower
May 23 2016 03:06
I found Where Art Thou challenging, but rather satisfying, once I solved it ... :)
Diego Mayer
@Chrono79
May 23 2016 03:06
This message was deleted
bitgrower
@bitgrower
May 23 2016 03:07
yeah, you are definitely getting the basics of the solution ... you might want to put your code into pythontutor.com/javascript.html to see where it might be doing something other than you expect ... :)
wSlitz
@wSlitz
May 23 2016 03:08
This message was deleted
Ken Truong
@kjjtruong
May 23 2016 03:08
@bitgrower oh ok let me check that out
Diego Mayer
@Chrono79
May 23 2016 03:08
@kjjtruong I used a counter in a solution similar to yours, to check if all the properties in one object were in the other
bitgrower
@bitgrower
May 23 2016 03:09
@richiedSIS -- hey, don't know if you're still here -- looks like your request may have gotten lost ... I struggled for hours with falsy bouncer ... until I re-read the first recommended article, after which I solved it in about 5 minutes ...
wSlitz
@wSlitz
May 23 2016 03:11

Hi, can someone tell my why my Steamroller solution is not accepted?
In console I get a flattened array.

```var result = [];

function steamrollArray(arr) {

for (var i in arr) {
if (Array.isArray(arr[i])) {
steamrollArray(arr[i]);
} else {
result.push(arr[i]);
}
}
return result;
}

steamrollArray([1, [2], [3, [[4]]]]);
```

Ken Truong
@kjjtruong
May 23 2016 03:11
@Chrono79 hmmmm alrighty..thanks for the hint
i'll make some adjustments and come back with an update. Thanks @Chrono79. Thanks @bitgrower
CamperBot
@camperbot
May 23 2016 03:12
kjjtruong sends brownie points to @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles:
:cookie: 806 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1062 | @bitgrower |http://www.freecodecamp.com/bitgrower
wSlitz
@wSlitz
May 23 2016 03:12
Which markdown to use to get formatted code in this chat?
bitgrower
@bitgrower
May 23 2016 03:13
@wSlitz ...
help formatting
CamperBot
@camperbot
May 23 2016 03:13

: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

Diego Mayer
@Chrono79
May 23 2016 03:13
This message was deleted
CamperBot
@camperbot
May 23 2016 03:13

: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

Diego Mayer
@Chrono79
May 23 2016 03:13
lag
bitgrower
@bitgrower
May 23 2016 03:13
LOL ... snap, @Chrono79
Diego Mayer
@Chrono79
May 23 2016 03:15
Maybe camperbot should not answer to the same request within a set time?
bitgrower
@bitgrower
May 23 2016 03:15
ooh I like that ...
@wSlitz - in general, you want to use a straight iteration with a for loop, not for var in arr ... there are lots of great explanations on the web as to why ...
wSlitz
@wSlitz
May 23 2016 03:21
@bitgrower is that the reason why my solution is not accepted?
bleujai
@bleujai
May 23 2016 03:25
@wSlitz I'm curious if it's because you use a global variable.
bitgrower
@bitgrower
May 23 2016 03:25
one of the problems you are having is you are re-defining result to "" each time you call your function ... if you didn't use recursion in your challenges involving factorials, you may want to go back and review how you would use recursion with it ... as factorializing a number is about as pure a recursion problem as you can get !
@wSlitz -- only one reason ... see what I just posted above, as well ...
btw -- one of the useful things I learned in learning about recursion is, the first thing a recursive function must do on entering is to determine if it's time to exit the recursion ...
bleujai
@bleujai
May 23 2016 03:28
@bitgrower Result doesn't reset since it's outside the function though.
bitgrower
@bitgrower
May 23 2016 03:28
but it's also not getting passed up the recursion chain, either ... :)
that's why I recommend looking at a recursive solution to finding factorials ... :)
Rada
@Radascript
May 23 2016 03:29

hi guys! Can someone see why when I do consecutive searches in my app, instead of replacing the result divs, it creates them twice? For eg, if I search "cat" it gives me ten unique "cat" results. If after that I search "dog" it gives me ten unique "dog" results twice. I think the issue is either with "clearSearch()" function(lines 66-71 in JS), or with the for-loop (lines 56-60) but can't seem to debug it. Any thoughts? Thank you!

http://codepen.io/RadaCodes/pen/vGwVQR?editors=1010

bleujai
@bleujai
May 23 2016 03:29
This is education for me then, does each level of the recursion not have access to the global var?
When I ran her code I saw that it gave the correct answers, best I could tell, but it wouldn't show any of the tests as completed.
bitgrower
@bitgrower
May 23 2016 03:32
well ... ideally, you shouldn't need to use a global variable ... sorry -- I didn't see that it was a global variable ... my bad ...
if it's showing as not passing, then I would review the instructions to see if there's a constraint which is missing ...
(er, constraint which needs to be applied to the code) ...
I would also check to see if the recursion is getting stopped appropriately ...
(it may be ... I haven't checked ... it's not clear in my mind...)
Diego Mayer
@Chrono79
May 23 2016 03:36
@Radascript you're appending this every time:
$('#myForm').append('<div class="dummyDiv"></div>');
Rada
@Radascript
May 23 2016 03:36
@Chrono79 I first run the clearSearch() function that should remove all the existing divs.
bleujai
@bleujai
May 23 2016 03:37
@Radascript I saw the clearSearch function but I didn't see anywhere that you called it. I did a search for it to make sure. The only place I saw was when the function was declared.
bitgrower
@bitgrower
May 23 2016 03:38
hmmm ... yeah, I just ran her algo thru pythontutor.com/javascript.html ... and it does say the value of result is correct ... and the instructions are pretty sparse ... I don't see any constraints. expect that the solution seems to return oddly ...
curious!
bleujai
@bleujai
May 23 2016 03:39
@bitgrower I was curious if they checked to see if a global variable was used and if so it would not pass a test.
Rada
@Radascript
May 23 2016 03:40
@bleujai I call it on line 6 and 14
Diego Mayer
@Chrono79
May 23 2016 03:40
@Radascript div.container is inside dummyDiv
Mohammad Albarmawi
@malbarmawi
May 23 2016 03:40
is this sentence a palindrome "1 eye for of 1 eye."
?
bleujai
@bleujai
May 23 2016 03:41
@Radascript Search didn't snap to it. I'll watch for that next time. Apologies.
Rada
@Radascript
May 23 2016 03:41
@bleujai that's ok don't apologize for trying to help me haha
bleujai
@bleujai
May 23 2016 03:41
@Radascript You're welcome then. :)
Diego Mayer
@Chrono79
May 23 2016 03:42
@Radascript
function clearSearch()
{
  $("div.dummyDiv").remove();
...
@mbarmawi obviously not, note the position of the 1s
Rada
@Radascript
May 23 2016 03:42
@Chrono79 thank you that solved it!!
CamperBot
@camperbot
May 23 2016 03:42
radascript sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 807 | @chrono79 |http://www.freecodecamp.com/chrono79
Adrian Ferrar
@aferrar
May 23 2016 03:43

Can one help me figure out why this is incorrect for the Return largest numbers in arrays section?

function sorter(a, b){
  return a - b;
}
var newarr = [];
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0 ; i < arr.length ; i++)
    {
    arr[i].sort(sorter);
    console.log(arr);
    newarr.push(parseInt(arr[i][3]));
    }
  return newarr;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

My returned array seems to be correct, but it is not passing.

wSlitz
@wSlitz
May 23 2016 03:45
@bitgrower, @bleujai tried without global variable (just hardcoded solution for first test case) and it got accepted. Looks like one shouldn't use global variables in fcc solutions :(
Baktybek
@Baktybek
May 23 2016 03:45
what am i doing wrong here?

function caseInSwitch(val) {
  var answer = "";

  case 1: 
  return "alpha";
  break;
  case 2:
  return "beta";
  break;
  case 3:
  return "gamma";
  break;
  case 4:
  return "delta";
  break;




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

// Change this value to test
caseInSwitch(1);
bleujai
@bleujai
May 23 2016 03:45
@wSlitz at least not that one.
@wSlitz Nice work though. Both times.
Diego Mayer
@Chrono79
May 23 2016 03:48
@aferrar move this inside your function:
function sorter(a, b){
  return a - b;
}
var newarr = [];
Islam Ibakaev
@dagman
May 23 2016 03:49
@aferrar it works
Diego Mayer
@Chrono79
May 23 2016 03:49
@Baktybek you're missing switch(...) { }
and don't return inside your switch, that's why return answer is at the bottom of your function
Rada
@Radascript
May 23 2016 03:50
@aferrar you are almost there. Your newArr remembers the previous array though because you are not erasing it every time you call it
Adrian Ferrar
@aferrar
May 23 2016 03:50
haha thanks @Chrono79 . thanks @Radascript I'm starting to see more and more that when all else fails... check your scopes!! :)
CamperBot
@camperbot
May 23 2016 03:50
aferrar sends brownie points to @chrono79 and @radascript :sparkles: :thumbsup: :sparkles:
:cookie: 808 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 345 | @radascript |http://www.freecodecamp.com/radascript
Rada
@Radascript
May 23 2016 03:50
so if you output console.log(newarr), you'll see that your last result is an array that is correct results of all four arrays it's running
@aferrar yw
vg22
@vg22
May 23 2016 03:51
hey I am not able to understand what is the question here .Can anyone help?

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "J"; // Fix Me

question is :Correct the assignment to myStr to achieve the desired effect.
Andrew Johnston
@puchamungee
May 23 2016 03:52
@vg22 make it “Hello world"
Baktybek
@Baktybek
May 23 2016 03:52
@Chrono79 what am i gonna put inside argument
like: switch(){
case 1:
Adrian Ferrar
@aferrar
May 23 2016 03:52
@vg22 modify the first index of myStr to make it say "Hello World"
Baktybek
@Baktybek
May 23 2016 03:52
and then what?
Diego Mayer
@Chrono79
May 23 2016 03:52
@Baktybek function caseInSwitch(val) { what's the argument of your function?
Instead of returning, set answer value
vg22
@vg22
May 23 2016 03:53
@aferrar but the comment says modify code after that line
Baktybek
@Baktybek
May 23 2016 03:54
@Chrono79 i don't know
Andrew Johnston
@puchamungee
May 23 2016 03:54
@vg22 Yup, where it says //Fix Me change the “J” to “H"
that will update the “Hello World” string
Diego Mayer
@Chrono79
May 23 2016 03:54
@Baktybek your function only has one argument, val, use that as switch argument too
Baktybek
@Baktybek
May 23 2016 03:54
@Chrono79 wait i will send u the whole instructions
@Chrono79 Instructions
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
vg22
@vg22
May 23 2016 03:56

var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

like this @puchamungee
Andrew Johnston
@puchamungee
May 23 2016 03:57
var myStr = "Jello World";

// Only change code below this line
myStr[0] = "H"; // Fix Me
that should work
remove the myStr = “Hello World”; that you added
Diego Mayer
@Chrono79
May 23 2016 03:57

@vg22 @puchamungee That WON'T work
In JavaScript, String values are immutable, which means that they cannot be altered once created.

For example, the following code:

var myStr = "Bob";
myStr[0] = "J";
cannot change the value of myStr to "Job", because the contents of myStr cannot be altered. Note that this does not mean that myStr cannot be changed, just that the individual characters of a string literal cannot be changed. The only way to change myStr would be to assign it with a new string, like this:

var myStr = "Bob";
myStr = "Job";

@vg22 delete this: myStr[0] = "H"; // Fix Me
vg22
@vg22
May 23 2016 03:59
then how will this work ?I mean I am not able to understand what they want in this level @Chrono79
Diego Mayer
@Chrono79
May 23 2016 03:59

@vg22 exactly this:

var myStr = "Jello World";
// Only change code below this line
myStr = "Hello World";

They show you, that you can't change a single character of a string once it's set.

vg22
@vg22
May 23 2016 04:00
okay got it ,Thanks @Chrono79
buiphuking
@buiphuking
May 23 2016 04:01
@Chrono79
i build pomodoro clock , do you have any advice for me, plz, i'm stuck ...
Diego Mayer
@Chrono79
May 23 2016 04:01
@buiphuking I haven't done it myself yet
buiphuking
@buiphuking
May 23 2016 04:02
@Chrono79
where did you done ? advice algorithm ?
Diego Mayer
@Chrono79
May 23 2016 04:04
@buiphuking didn't understand your last question, I said I haven't done the pomodoro clock, so my advise would be theoretical at best
bitgrower
@bitgrower
May 23 2016 04:04
heh .. well, one thing I don't recommend is running the steamroller solution using the code previously discussed, in fcc with a for loop ... I'm afraid to try it with a for in loop ... it messed up my browser something fierce ... @bluejai ... :) and now task manager says I'm always taking up at least 67% of the cpu, with 28.4% going to the task manager ... gonna have to run some system utilities on my system tomorrow ... whew!!!
Adrian Ferrar
@aferrar
May 23 2016 04:08
Hello again. For the "Confirm the Ending" task I came up with this... but I get the feeling this is just a hacked way of passing and not how it was intended to be completed.. am I off base with this one? Thanks in advance :)

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  for (var i = 0 ; i < str.length ; i++) {
    var ender = str.length - 1;
    var stringSplitter = str.split(" ");
    var splitterEnder = stringSplitter.length -1;
    var stringSplitterShorter = stringSplitter[splitterEnder].substr(2,3);
    if (str[ender] === target || stringSplitter[splitterEnder] === target || stringSplitterShorter === target) {
    return true;
  }
  else {
    return false;
    }
  }
}
confirmEnding("He has to give me a new name", "name");
Diego Mayer
@Chrono79
May 23 2016 04:11
@aferrar where are you using i inside your loop?
Adrian Ferrar
@aferrar
May 23 2016 04:12
@Chrono79 Thank you for elaborating on string value immutability!
CamperBot
@camperbot
May 23 2016 04:12
aferrar sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: aferrar already gave chrono79 points
Adrian Ferrar
@aferrar
May 23 2016 04:13
@Chrono79 ...now that I look back on it I guess the loop isn't even necessary
Diego Mayer
@Chrono79
May 23 2016 04:13
@aferrar no problem, your code is faulty
test it with this test: confirmEnding("He has to give me a new name", "fame");
Adrian Ferrar
@aferrar
May 23 2016 04:14
@Chrono79 ahh darnit. back to the drawing board! thank you for pointing this out
CamperBot
@camperbot
May 23 2016 04:14
aferrar sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: aferrar already gave chrono79 points
Diego Mayer
@Chrono79
May 23 2016 04:14
@aferrar :+1:
Use this to test your code: http://www.pythontutor.com/javascript.html
There is a one line solution to this challenge, it's not so difficult because it only uses substr
Adrian Ferrar
@aferrar
May 23 2016 04:16
@Chrono79 bit confused. just ran confirmEnding("He has to give me a new name","fame"); and returned false which is... correct, no?
@Chrono79 your link returns 404 :(
Diego Mayer
@Chrono79
May 23 2016 04:17

@aferrar fixed the link, and maybe I was wrong about the test, it's 1 am here
now, look at the values of the 3 things you compare to target:
e
name <- this is the only one that's valid: stringSplitter[splitterEnder]
me

I get what you did, because other tests don't test for a whole word

Adrian Ferrar
@aferrar
May 23 2016 04:22
@Chrono79 could I take the length of the target argument and use that as my parameter when defining the length of the substr?
Diego Mayer
@Chrono79
May 23 2016 04:23
@aferrar :fire: you burned yourself ;)
Yes, that's the way you should do it
Read substr docs, and specially about negative indexes
Adrian Ferrar
@aferrar
May 23 2016 04:25
thank you kind stranger. Damn computer talk is COMPLICATED. but slowly getting it
Diego Mayer
@Chrono79
May 23 2016 04:25
time to sleep, good luck fellow coders, don't give up
Iliana
@IlianaGovea
May 23 2016 04:27
Pls help with Assignment with a Returned Value
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:28
Hey guys! I'm stuck on the Profile Lookup problem
This message was deleted
UtkarshShukla7
@UtkarshShukla7
May 23 2016 04:28
@IlianaGovea whats the problem
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:29
I can't seem to check if the given variable is a key to a value of an object in the form of an array.
UtkarshShukla7
@UtkarshShukla7
May 23 2016 04:29
@NishantGadihoke paste your code
Eldar Tinjić
@EldarT90
May 23 2016 04:30
var App = React.createClass({
 update: function() {
   var newVal = this.props.val+1;
   this.setProps({val:newVal})
 },
  render: function(){ return (
 <button onClick={this.update}>{this.props.val}</button>
 )


} }
);


ReactDOM.render(<App val={0} />, document.body);
what should i replace setProps with
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:30
This message was deleted
CamperBot
@camperbot
May 23 2016 04:30
:bulb: to format code use backticks! ``` more info
Adrian Ferrar
@aferrar
May 23 2016 04:30
@Chrono79 perf. negative indexing using target length went smooth!
Eldar Tinjić
@EldarT90
May 23 2016 04:31
but all those react docs are very vague
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:31
This message was deleted

//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 true;
   }
  }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
It needs to check wether the firstName variable is a value of the property "firstName" in any part of the array
Adrian Ferrar
@aferrar
May 23 2016 04:33

@NishantGadihoke

if (contacts[i].firstname === firstName) {

I think your problem lies here

UtkarshShukla7
@UtkarshShukla7
May 23 2016 04:33
@NishantGadihoke part above return seems correct
now you have to check if the same object has the prop they are provideing and then return
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:34
Well the logic I'm using is that a for loop is initiated, which run till the whole length of the array.
At each value, it checks wether the "firstName" property has a value of the firstName variable.
Where am I going wrong?
UtkarshShukla7
@UtkarshShukla7
May 23 2016 04:36
@NishantGadihoke the logic is correct till this part just now yu have to check if the same object has the property prop in it and return accordingly
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:37
Yes, I got that. But the problem is that the program is not returning a value of true even if the firstName is correct.
@aferrar: Thoughts?
UtkarshShukla7
@UtkarshShukla7
May 23 2016 04:38
@NishantGadihoke firstName not firstname
Adrian Ferrar
@aferrar
May 23 2016 04:41
@NishantGadihoke @UtkarshShukla7 has got you covered. typo on that line is the reason for no boolean return. also correct with how to go about completing the lookup
@NishantGadihoke make sense?
@NishantGadihoke fix typo. add extra condition check and return accordingly
Nishant Gadihoke
@NishantGadihoke
May 23 2016 04:44
Ahh, got it to work!
Thank you so much @UtkarshShukla7 @aferrar !
CamperBot
@camperbot
May 23 2016 04:44
:cookie: 472 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
:cookie: 258 | @aferrar |http://www.freecodecamp.com/aferrar
nishantgadihoke sends brownie points to @utkarshshukla7 and @aferrar :sparkles: :thumbsup: :sparkles:
UtkarshShukla7
@UtkarshShukla7
May 23 2016 04:44
@NishantGadihoke np
Adrian Ferrar
@aferrar
May 23 2016 04:44
@NishantGadihoke np. thank you for first brownie points!
CamperBot
@camperbot
May 23 2016 04:44
aferrar sends brownie points to @nishantgadihoke :sparkles: :thumbsup: :sparkles:
:cookie: 130 | @nishantgadihoke |http://www.freecodecamp.com/nishantgadihoke
Elias Lawson-Fox
@eliaslfox
May 23 2016 04:58
Does anyone here know the node http get module
I’m trying to do learnyounode, and I am very stuck
ALMY91
@ALMY91
May 23 2016 04:58
Hi guys can anybody help me out here?
im wondering how does this work internally
Sonkeng Maldini
@sdmg15
May 23 2016 05:01
morning @ALMY91 dump it
ALMY91
@ALMY91
May 23 2016 05:02
@sdmg15 hello there this is my code
var counterA =0;
var counterB =0;

mainloop:
while(counterA<=5) {
console.log ("The value of counter A is:" + counterA);

innerloop:
while (counterB<=2){
console.log ("The value of counter B is:" + counterB);
if (counterB==1) {continue mainloop;}

counterB++}


counterA++}
@sdmg15 im just wondering how does it work internally if you could spell it out step by step it wld be easier for me to catch it . seems like my computer hanged upon running the code
Sonkeng Maldini
@sdmg15
May 23 2016 05:07
Which line specially becayse the code seem very simple :smile:
ALMY91
@ALMY91
May 23 2016 05:08
@sdmg15 actually the whole code
Sonkeng Maldini
@sdmg15
May 23 2016 05:10
Make a test and send me the console.log()
ALMY91
@ALMY91
May 23 2016 05:11
@sdmg15 i don understand what you mean by tt
kwal0203
@kwal0203
May 23 2016 05:11
@ALMY91 its an infinite loop
ALMY91
@ALMY91
May 23 2016 05:12
@kwal0203 yes i understand its an infinite loop, i just want to know how it runs internally step by step?
kwal0203
@kwal0203
May 23 2016 05:12
@ALMY91 actually, maybe it is not an infinite loop. Are you sure?
ALMY91
@ALMY91
May 23 2016 05:13
@kwal0203 if it isn an infinite loop why did my browser crashed?
Sonkeng Maldini
@sdmg15
May 23 2016 05:16
@ALMY91 its crashed because she cannot find a false condition in your loop
kwal0203
@kwal0203
May 23 2016 05:18
@ALMY91 lol I just run the script and it froze my computer
@ALMY91 does the continue command restart mainloop from the beginning?
@ALMY91 I'm thinking maybe the A++ command is never reached so the algorithm just goes between mainloop and innerloop forever. Would you agree @sdmg15 ?
Nick Papasavvas
@nickolaos77
May 23 2016 05:21
Hello guys I have started doing the second advanced algorithm javascript challenge called Symmetric difference and my problem is that I can't access the second argument passed in the function so for example args1 returns nothing. Any ideas how I can access it?
kwal0203
@kwal0203
May 23 2016 05:21
@nickolaos77 put the code up
Krishna
@krisskb
May 23 2016 05:21
Hello my friends, I am unable to call Wikipedia API. Could someone help what is wrong in this code.
$.getJSON("https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=api&limit=10&namespace=0", function(json) {
$(".message").html(json[0]);
});
getting error in console: SEC7120: Origin file: not found in Access-Control-Allow-Origin header. SCRIPT7002: XMLHttpRequest: Network Error 0x80700013, Could not complete the operation due to error 80700013.
ALMY91
@ALMY91
May 23 2016 05:21
@kwal0203 thats what im actually enquiring about
kwal0203
@kwal0203
May 23 2016 05:22
@ALMY91 I think counterA++ is never reached
Nick Papasavvas
@nickolaos77
May 23 2016 05:22

function sym(args) {

return args1;
}

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

kwal0203
@kwal0203
May 23 2016 05:22
This message was deleted
Markus Kiili
@Masd925
May 23 2016 05:22
@nickolaos77 args is the only parameter that catches the first passed argument. Use arguments object for other arguments.
kwal0203
@kwal0203
May 23 2016 05:23

function sym(args) {


  return args[1];
}

sym([1, 2, 3], [5, 2, 1, 4]);
Nick Papasavvas
@nickolaos77
May 23 2016 05:23
exactly
Kwal
Sonkeng Maldini
@sdmg15
May 23 2016 05:23
@kwal0203 yes it's it
ALMY91
@ALMY91
May 23 2016 05:23
@kwal0203
The value of counter A is :0
The value of counter B is :0
The value of counter B is :1
CounterB reached 1, go back to mainloop
The value of counter B is :2
The value of counter A is :1
The value of counter A is :2
The value of counter A is :3
The value of counter A is :4
The value of counter A is :5
i just need to know if this is what happens internally?
this was what my friend got from running the code in fiddle
but supposedly the browser is supposed to hang
so there seems to be something amiss here
kwal0203
@kwal0203
May 23 2016 05:24
@ALMY91 I ran it in fiddle and it did not do that... Yes my whole computer crashed
ALMY91
@ALMY91
May 23 2016 05:24
@kwal0203 u got to look into ur console
Nick Papasavvas
@nickolaos77
May 23 2016 05:25
@Masd925 thank you , exactly I want to access the second argument. So I will google argument object?
CamperBot
@camperbot
May 23 2016 05:25
nickolaos77 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1580 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 23 2016 05:25
@nickolaos77 yes.
kwal0203
@kwal0203
May 23 2016 05:26
@ALMY91 I did, my one had different output
@ALMY91 what happens when you run it?
ALMY91
@ALMY91
May 23 2016 05:27
@kwal0203 mine hanged im waiting for my friend to wakeup from his nap zzz
Nick Papasavvas
@nickolaos77
May 23 2016 05:27
@Masd925 Thank you so much, I accessed it allright, now it is very easy
CamperBot
@camperbot
May 23 2016 05:27
nickolaos77 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: nickolaos77 already gave masd925 points
kwal0203
@kwal0203
May 23 2016 05:28
@ALMY91 did your friend use the same code?
ALMY91
@ALMY91
May 23 2016 05:29
@kwal0203 yes
kwal0203
@kwal0203
May 23 2016 05:35
@ALMY91 put the counterB++ inside the if statement
dickorydock
@dickorydock
May 23 2016 05:36
Hi. Can someone help me figure out with Profile Lookup? Specifically "No such contact"?
Sonkeng Maldini
@sdmg15
May 23 2016 05:37
console.log("no such much contact'');
Markus Kiili
@Masd925
May 23 2016 05:37
@dickorydock Return it after checking all the contacts.
Elbert Cortez
@trip16661
May 23 2016 05:37
does anyone knows how to stop on mid run triggered by an event?
dickorydock
@dickorydock
May 23 2016 05:37
brilliant, that did it. i always forget that 'return' both returns and quits. thanks!
ALMY91
@ALMY91
May 23 2016 05:40
this is retarded
kwal0203
@kwal0203
May 23 2016 05:40
@ALMY91 wait, don't do that
Rasheed
@rachidofsky
May 23 2016 05:42
Stuck at word blanks any help?
kwal0203
@kwal0203
May 23 2016 05:43
@ALMY91 just take out the if (counterB==1) {continue mainloop;} line. Why do you need it?
@ALMY91 the problem is that the continue mainloop is making the program loop between the two loops without going forward
Elbert Cortez
@trip16661
May 23 2016 05:45
does anyone knows how to stop a function on mid run triggered by an event?
kwal0203
@kwal0203
May 23 2016 05:46
This message was deleted
@ALMY91 In step by step: 1. mainloop starts, 2. inner loop starts, 3. counterB + 1 = 1, 4. inner loop starts again, 5. b == 1 so continue mainloop, 6. main loop starts, 7. inner loop starts, 8. because counterB == 1 go back to step 5 and repeat
@trip16661 what do you mean?
Elbert Cortez
@trip16661
May 23 2016 05:47
@kwal0203 basically stoping a running function on click
kwal0203
@kwal0203
May 23 2016 05:47
@trip16661 so you have a function that is continously running then you want to click a button which will stop the function running?
Elbert Cortez
@trip16661
May 23 2016 05:47
exactly
kwal0203
@kwal0203
May 23 2016 05:47
@trip16661 can you post some code?
@trip16661 you could have a variable that stores whether the function should be running or not and then change the variable on click
Elbert Cortez
@trip16661
May 23 2016 05:48
Y i thought of that
but the thing is that
kwal0203
@kwal0203
May 23 2016 05:49
let x = 0;

if (x === 0) { run function };
Elbert Cortez
@trip16661
May 23 2016 05:49
if you are printing numbers (as a basic example)
ALMY91
@ALMY91
May 23 2016 05:49
@kwal0203 i just need to know if it happens like this
kwal0203
@kwal0203
May 23 2016 05:49
@ALMY91 did you see my step by step post?
Elbert Cortez
@trip16661
May 23 2016 05:49
and the it's in like the numb 6 when the user want to stop it
i would have to make a conditional for every action of my function
and that looks so ineficient
kwal0203
@kwal0203
May 23 2016 05:50
while ( x <= 6) {
    run function;
}
ALMY91
@ALMY91
May 23 2016 05:50
@kwal0203
The value of counter A is :0
The value of counter B is :0
The value of counter B is :1
CounterB reached 1, go back to mainloop
The value of counter A is :1
The value of counter A is :2
The value of counter A is :3
The value of counter A is :4
The value of counter A is :5

The value of counter B is :1
CounterB reached 1, go back to mainloop
The value of counter A is :1
The value of counter A is :2
The value of counter A is :3
The value of counter A is :4
The value of counter A is :5
@kwal0203 and it repeats on and on
kwal0203
@kwal0203
May 23 2016 05:51
while (x < 7) {
run function;
x++;
}
ALMY91
@ALMY91
May 23 2016 05:51
@kwal0203 is it working this way?
kwal0203
@kwal0203
May 23 2016 05:51
@ALMY91 your code will not do that. Where did you get that print out from?
ALMY91
@ALMY91
May 23 2016 05:52
@kwal0203 i wrote it myself, i just need to know how it works internally such that it hangs thats all
kwal0203
@kwal0203
May 23 2016 05:52
@ALMY91 did you see my step by step post above?
ALMY91
@ALMY91
May 23 2016 05:53
@kwal0203 yes i did
In step by step: 1. mainloop starts, 2. inner loop starts, 3. counterB + 1 = 1, 4. inner loop starts again, 5. b == 1 so continue mainloop, 6. main loop starts, 7. inner loop starts, 8. because counterB == 1 go back to step 5 and repeat
kwal0203
@kwal0203
May 23 2016 05:53
@trip16661
while (x < 7) {
run function;
x++;
}
@ALMY91 that is exactly what your function is doing
ALMY91
@ALMY91
May 23 2016 05:53
@kwal0203 isn that what my code is saying?
Elbert Cortez
@trip16661
May 23 2016 05:53
that's okay if you know how many times you are going to run your program
Adrian Ferrar
@aferrar
May 23 2016 05:54
Hello all, can anyone tell me why this code yields an infinite loop?

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arrChunky = [];
  for (var i = 0 ; i < arr.length ; i + size) {
    var sliceArray = arr.slice(i,i + size);
    arrChunky.push(sliceArray);
  }
  return arrChunky;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
kwal0203
@kwal0203
May 23 2016 05:54
@trip16661 didn't you say 6?
Elbert Cortez
@trip16661
May 23 2016 05:54
but you cant do that otherwise cuz it would throw an infinite loop
i said it as an example
Markus Kiili
@Masd925
May 23 2016 05:54
@aferrar It should be i+=size on the loop increment.
kwal0203
@kwal0203
May 23 2016 05:54
@trip16661 ok, you need to post some code so people know what you are working with and what your trying to do
Dan Couper
@DanCouper
May 23 2016 05:55
@ALMY91 the counter in the main loop never increases, it never hits the last line
Adrian Ferrar
@aferrar
May 23 2016 05:55
@Masd925 short and sweet.. I like it!! Thank you
CamperBot
@camperbot
May 23 2016 05:55
aferrar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1581 | @masd925 |http://www.freecodecamp.com/masd925
kwal0203
@kwal0203
May 23 2016 05:55
@DanCouper exactly
ALMY91
@ALMY91
May 23 2016 05:56
@DanCouper @kwal0203 could u kindly type it out its easier for me to understand much appreciated
kwal0203
@kwal0203
May 23 2016 05:57
@ALMY91 type what out?
Markus Kiili
@Masd925
May 23 2016 05:57
@aferrar That is one of the good solutions to Chunky. While loop is even slightly more elegant.
ALMY91
@ALMY91
May 23 2016 05:57
@kwal0203 ect smth like this
```js
The value of counter A is :0
The value of counter B is :0
The value of counter B is :1
CounterB reached 1, go back to mainloop
The value of counter A is :1
The value of counter A is :2
The value of counter A is :3
The value of counter A is :4
The value of counter A is :5

The value of counter B is :1
CounterB reached 1, go back to mainloop
The value of counter A is :1
The value of counter A is :2
The value of counter A is :3
The value of counter A is :4
The value of counter A is :5
```
@kwal0203 in this manner or smth so its easier for me to understand
kwal0203
@kwal0203
May 23 2016 05:58
@ALMY91 i don't see how a print out like that will help you. The problem is that your function is never reaching counterA++
@ALMY91 you asked what the function is doing internally and I made a step by step post of what it is doing
@ALMY91 I think I may be misunderstanding exactly what you are asking for?
ALMY91
@ALMY91
May 23 2016 05:59
@kwal0203 so do u mean its repeating this process?
The value of counter A is :0
The value of counter B is :0
The value of counter B is :1
CounterB reached 1, go back to mainloop
kwal0203
@kwal0203
May 23 2016 06:00
@ALMY91 yes
@ALMY91 then repeat forever
ALMY91
@ALMY91
May 23 2016 06:00
@kwal0203 god lol this is so difficult spent over an hour getting this...
Dan Couper
@DanCouper
May 23 2016 06:00
@ALMY91 Yes, you’re telling it to start the main loop again every time, so first thing it hits is the inner loop which makes it start the main loop again etc etc etc
@ALMY91 Don’t use nested while loops
kwal0203
@kwal0203
May 23 2016 06:01
@ALMY91 is this for one of the algorithm challenges?
ALMY91
@ALMY91
May 23 2016 06:01
@kwal0203 @DanCouper thank u thats what i needed to hear
CamperBot
@camperbot
May 23 2016 06:01
almy91 sends brownie points to @kwal0203 and @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 109 | @dancouper |http://www.freecodecamp.com/dancouper
:cookie: 326 | @kwal0203 |http://www.freecodecamp.com/kwal0203
ALMY91
@ALMY91
May 23 2016 06:01
@kwal0203 nope im doing up on definitive guide on javascript
kwal0203
@kwal0203
May 23 2016 06:04
@ALMY91 the book?
ALMY91
@ALMY91
May 23 2016 06:04
@kwal0203 yes the book..
kwal0203
@kwal0203
May 23 2016 06:04
@ALMY91 I think nested loops are nasty
Dan Couper
@DanCouper
May 23 2016 06:05
@ALMY91 Don’t use labels either, they’re not recommended due to being extremely confusing
ALMY91
@ALMY91
May 23 2016 06:05
@DanCouper yeah my friend told me to skip that..
Dan Couper
@DanCouper
May 23 2016 06:05
@ALMY91 very, very , very occasionally they’re useful, but I haven’t seen them used, ever, in years of looking at JS code
ALMY91
@ALMY91
May 23 2016 06:06
@kwal0203 @DanCouper i actually started coding since jan this year so its only been about 4mths.....
kwal0203
@kwal0203
May 23 2016 06:06
@DanCouper what are labels?
Dan Couper
@DanCouper
May 23 2016 06:06
@ALMY91 hah, proving the point! it’s the mainloop:
innerloop:
kwal0203
@kwal0203
May 23 2016 06:07
@DanCouper oh i didnt know they were called labels
@DanCouper look like case statements
Dan Couper
@DanCouper
May 23 2016 06:07
Yeah, I’m not even sure why they’re in the language
Arun Balaji
@arun-aji-balaji
May 23 2016 06:07

var Bike = function() {

// Only change code below this line.
var gear = 0;

this.getGear = function(num){
return num;
};
this.setGear = function(){

};

I cant fix this
kwal0203
@kwal0203
May 23 2016 06:08
var Bike = function() {

  // Only change code below this line.
  var gear = 0;

  this.getGear = function(num){
    return num;
  };
  this.setGear = function(){

  };
Arun Balaji
@arun-aji-balaji
May 23 2016 06:08
Plz help me
Dan Couper
@DanCouper
May 23 2016 06:08
@kwal0203 They’re the same as goto in other languages, but with awful confusing syntax (they look like case, but they also look like object keys as well)
ALMY91
@ALMY91
May 23 2016 06:08
@DanCouper @kwal0203 are you guys able to do an example of a do/while loop with the continue statement?
@DanCouper @kwal0203 i meant a code example ..
var count = 0;

do {console.log(count); count++;}
while (count>10);
@DanCouper @kwal0203 not too sure how to incorporate the continue keyword in here
Jaren Escueta
@jarenescueta731
May 23 2016 06:10
@ArunBalaji1995 you don't have any code in your setGear method
eeflores
@eeflores
May 23 2016 06:10
@ArunBalaji1995 @kwal0203 the getGear function shouldn't take a parameter, should return gear. the setGear function should take a parameter, assigned to gear
kwal0203
@kwal0203
May 23 2016 06:12
var Bike = function() {

  // Only change code below this line.
  var gear = 0;

  this.getGear = function(){
    return gear;
  };
  this.setGear = function(newGear){
    gear = newGear;
    return gear;
  };
eeflores
@eeflores
May 23 2016 06:12
dunno if setGear needs to return anything
kwal0203
@kwal0203
May 23 2016 06:13
@eeflores your right
var Bike = function() {

  // Only change code below this line.
  var gear = 0;

  this.getGear = function(){
    return gear;
  };
  this.setGear = function(newGear){
    gear = newGear;
  };
@eeflores would this function still work if .getGear took in gear as a parameter?
this.getGear = function(gear){
    return gear;
  };
eeflores
@eeflores
May 23 2016 06:15
there would be confusion between the object's gear and the function's gear - I would think that the function gear would be used
Markus Kiili
@Masd925
May 23 2016 06:15
@kwal0203 The parameter would be used instead of the variable.
Dan Couper
@DanCouper
May 23 2016 06:15
@ALMY91 if I were you, I would skip that for now, just know that there is syntax that lets you do that, then move onto something else. What you're creating is hard-to-follow code, and though continue is useful, it's not that important, anything you write with it probably achievable using simpler, easily understood constructs.
Jaren Escueta
@jarenescueta731
May 23 2016 06:15
@kwal0203 the purpose of getGear is to retrieve the private gear value already in place, @eeflores @Masd925 are right
kwal0203
@kwal0203
May 23 2016 06:16
@eeflores @Masd925 @jarenescueta731 yep, i see
@DanCouper @ALMY91 to be honest I've never used continue anywhere, but I'm not a professional either
ALMY91
@ALMY91
May 23 2016 06:18
@DanCouper great idea..
Jordan Shackelford
@JordanShackelford
May 23 2016 06:18
var twoConsecCharRegex = new RegExp(/([a-zA-Z0-9])\1{1}/);

  return combineChars(str).filter(function(permutation){
    return permutation.match(twoConsecCharRegex);
  }).length;
How do I filter an array so that it only shows me items that DON'T match my regular expression?
kwal0203
@kwal0203
May 23 2016 06:19
@JordanShackelford Wheres the array?
Thompson Ike
@hubhubace
May 23 2016 06:19
uysg
guys
pls help
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
ALMY91
@ALMY91
May 23 2016 06:20
@DanCouper @kwal0203 im gg off for a smoke.. be back in abit
Thompson Ike
@hubhubace
May 23 2016 06:20

function abTest(a, b) {
console.log(a || b <0);

return (a || b);

}

kwal0203
@kwal0203
May 23 2016 06:20
@JordanShackelford actually, how can you have return without a function. Is that possible?
Thompson Ike
@hubhubace
May 23 2016 06:20
this is what I can come up with
someone assist
kwal0203
@kwal0203
May 23 2016 06:21
function abTest(a, b) {  
  console.log(a || b <0);

  return (a || b); 

}
Thompson Ike
@hubhubace
May 23 2016 06:21
i cant get the test to return undefined
Jordan Shackelford
@JordanShackelford
May 23 2016 06:21
@kawl0203 ["aab","aab","aba","aba","baa","baa"]
Markus Kiili
@Masd925
May 23 2016 06:21
@JordanShackelford Try just flipping the filter callback return value with !.
Thompson Ike
@hubhubace
May 23 2016 06:21
@kwal0203 you have an idea?
@Masd925 pls explain more
Jordan Shackelford
@JordanShackelford
May 23 2016 06:23
@Masd925 Doesn't seem to work. returns 0 when it should return 2
kwal0203
@kwal0203
May 23 2016 06:23
@Masd925 @JordanShackelford how can there be a return statement without a function?
Markus Kiili
@Masd925
May 23 2016 06:24
@kwal0203 The clip must be inside a function.
Jordan Shackelford
@JordanShackelford
May 23 2016 06:24
@kwal0203 I just posted a snippet because I didn't want to cover the chat with my entire code

function permAlone(str) {

  function combineChars(chars){
    var permutations = [], words = [], firstChar;
    if(chars.length === 1){
      permutations.push(chars);
      return permutations;
    }
    firstChar = chars[0];
    chars = chars.substring(1,chars.length);
    words = combineChars(chars);
    for(var i = 0; i < words.length; i++){
      for(var j = 0; j < words[i].length + 1; j++){
        permutations.push(insertCharAt(words[i], firstChar, j));
      }
    }
    return permutations;
  }

  function insertCharAt(word, charIn, i){
    var start = word.substring(0,i);
    var end = word.substring(i,word.length);
    return start + charIn + end;
  }

  var twoConsecCharRegex = new RegExp(/([a-zA-Z0-9])\1{1}/);

  return combineChars(str).filter(function(permutation){
    return permutation.match(twoConsecCharRegex);
  }).length;
}

permAlone('aab');
Markus Kiili
@Masd925
May 23 2016 06:25
@JordanShackelford Are you trying to filter out elements that are now kept and vide versa. Or something different?
kwal0203
@kwal0203
May 23 2016 06:25
@Masd925 is combineChars(str) an array?
Thompson Ike
@hubhubace
May 23 2016 06:26
anyone there?
i need to sort this out
kwal0203
@kwal0203
May 23 2016 06:26
@hubhubace you want it to return undefined?
Thompson Ike
@hubhubace
May 23 2016 06:26
well yes
it can return values
Jordan Shackelford
@JordanShackelford
May 23 2016 06:27
Yes combineChars(str) will return an array of all the permuations of str. I have to filter out all the ones with consecutive letters
Thompson Ike
@hubhubace
May 23 2016 06:27
error abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
Jordan Shackelford
@JordanShackelford
May 23 2016 06:28
Need to find the number of permutations for str that don't have any consecutive letters
kwal0203
@kwal0203
May 23 2016 06:28
@JordanShackelford which challenge is that? I'll check what I did
Thompson Ike
@hubhubace
May 23 2016 06:29
why is npo one willing to help me?
Thompson Ike
@hubhubace
May 23 2016 06:29
anyway guys take care
just like I dont exist
kwal0203
@kwal0203
May 23 2016 06:29
@hubhubace just wait a second
Jordan Shackelford
@JordanShackelford
May 23 2016 06:29
l8r m8
Thompson Ike
@hubhubace
May 23 2016 06:30
ok better
kwal0203
@kwal0203
May 23 2016 06:30
@JordanShackelford GAHH, I completed that challenge but now my code is all gone! lol
@hubhubace is that related to one of the algorithm challenges?
Jordan Shackelford
@JordanShackelford
May 23 2016 06:30
rekt
kwal0203
@kwal0203
May 23 2016 06:30
@JordanShackelford i remember that one was a bitch
Jordan Shackelford
@JordanShackelford
May 23 2016 06:31
Yeah it's under the "Advanced Algorithm Scripting" category
Jaren Escueta
@jarenescueta731
May 23 2016 06:31
@hubhubace you could just
return undefined;
kwal0203
@kwal0203
May 23 2016 06:31
@JordanShackelford I would have thought the solution above i.e. using ! would have worked
@jarenescueta731 lol
Thompson Ike
@hubhubace
May 23 2016 06:32
i tried that but did not pass
Jordan Shackelford
@JordanShackelford
May 23 2016 06:32
me too
Thompson Ike
@hubhubace
May 23 2016 06:32
just tried again
same thing
kwal0203
@kwal0203
May 23 2016 06:32
@hubhubace do this: abTest(a,2);
Thompson Ike
@hubhubace
May 23 2016 06:33
@jarenescueta731 what should I do next?
kwal0203
@kwal0203
May 23 2016 06:33
@hubhubace do this: abTest(a,2);
Thompson Ike
@hubhubace
May 23 2016 06:33
anyone gone through this challenger?
Jaren Escueta
@jarenescueta731
May 23 2016 06:34
@hubhubace which one is it?
Thompson Ike
@hubhubace
May 23 2016 06:34
all other returns are ok
but cant return undefined
lol
kwal0203
@kwal0203
May 23 2016 06:35
@hubhubace have you tried this for the third time: abTest(a,2);
Thompson Ike
@hubhubace
May 23 2016 06:37
@kwal0203 you mean I should return abTest(a,2)?
if so I just did and nothin happened
kwal0203
@kwal0203
May 23 2016 06:38
@hubhubace your function will return undefined if you put an undefined parameter in it
Jaren Escueta
@jarenescueta731
May 23 2016 06:38
@hubhubace what is the name of the challenge you are doing?
Thompson Ike
@hubhubace
May 23 2016 06:39
Return Early Pattern for Functions
kwal0203
@kwal0203
May 23 2016 06:39
@hubhubace is it in basic, intermediate or advanced?
Thompson Ike
@hubhubace
May 23 2016 06:40
let me send you link
kwal0203
@kwal0203
May 23 2016 06:40
@hubhubace oh right, you need to check for numbers
Jaren Escueta
@jarenescueta731
May 23 2016 06:40

@hubhubace ok, this is the start right? ```
// Setup
function abTest(a, b) {
// Only change code below this line

}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
```

Thompson Ike
@hubhubace
May 23 2016 06:40
yes
Jaren Escueta
@jarenescueta731
May 23 2016 06:41
you don't have to change the test values at the bottom, just that one line in the function
earlier you tried console.log(a||b<0);
kwal0203
@kwal0203
May 23 2016 06:41
@hubhubace if (isNaN(value)) return undefined;
Thompson Ike
@hubhubace
May 23 2016 06:41
yeah
Jaren Escueta
@jarenescueta731
May 23 2016 06:41
but you actually want to see if either a <0 or b<0
kwal0203
@kwal0203
May 23 2016 06:42
@jarenescueta731 oh right
if (a || b > 0) { return undefined };
something like that i guess
but less than lol
Jaren Escueta
@jarenescueta731
May 23 2016 06:43
you need a<0 also
Thompson Ike
@hubhubace
May 23 2016 06:43
so I dont need the console.log?
Jaren Escueta
@jarenescueta731
May 23 2016 06:43
otherwise its asking if (a is true) or (b > 0)
@hubhubace nope
kwal0203
@kwal0203
May 23 2016 06:43
if (a < 0 || b < 0) { return undefined; }
Rose2014
@Rose2014
May 23 2016 06:44
hello how to send screetshot?
Jaren Escueta
@jarenescueta731
May 23 2016 06:44
@kwal0203 yes
@Rose2014 if you mean the editor-like code, you actually type 3 tick marks ```, shift-enter, type code, then 3 tick marks after
Thompson Ike
@hubhubace
May 23 2016 06:46
@jarenescueta731 thanks
CamperBot
@camperbot
May 23 2016 06:46
hubhubace sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Jaren Escueta
@jarenescueta731
May 23 2016 06:46
@hubhubace glad to help, thanks too @kwal0203
CamperBot
@camperbot
May 23 2016 06:46
jarenescueta731 sends brownie points to @hubhubace and @kwal0203 :sparkles: :thumbsup: :sparkles:
:cookie: 211 | @hubhubace |http://www.freecodecamp.com/hubhubace
:cookie: 327 | @kwal0203 |http://www.freecodecamp.com/kwal0203
Thompson Ike
@hubhubace
May 23 2016 06:46
@kwal0203 thanks
CamperBot
@camperbot
May 23 2016 06:46
hubhubace sends brownie points to @kwal0203 :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @kwal0203 |http://www.freecodecamp.com/kwal0203
Thompson Ike
@hubhubace
May 23 2016 06:50
@jarenescueta731 please why cant we just say if (a || b < 0) return undefined?
can we use switch statement to do this too?
switch case?
Rose2014
@Rose2014
May 23 2016 06:54
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card) {
    case 2:
     return count++ +" Bet";

    case 3:
      console.log(count++ +" Bet");
      break;
    case 4:
     console.log(count++ +" Bet");
      break;
@hubhubace thanks
CamperBot
@camperbot
May 23 2016 06:54
rose2014 sends brownie points to @hubhubace :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @hubhubace |http://www.freecodecamp.com/hubhubace
Connor Murphy
@papasmurph
May 23 2016 07:04
Hey guys/girls. I have a problem, this code was working last night before I went to bed but now it doesn't, which I don't even understand how that's possible but hey!
function call(){
    console.log(url);
    var myRequest = new XMLHttpRequest();
    myRequest.open("GET", url, true);
    myRequest.send(null);
    myRequest.onreadystatechange = function(){
        if(myRequest.readyState === 4 && myRequest.status === 200){
     try{
         var response = JSON.parse(myRequest.responseText);
         locale.innerHTML = response.name + " " + response.sys.country;

         var celsius = Math.round(response.main.temp - 273.15);
         var farhen = 9 / 5 * celsius + 32;
         console.log(response.weather[0].main);
       /*  if(response.weather[0].main == "Rain"){

             var body = document.getElementsByTagName("body")[0];
             body.style.backgroundImage = "url('rain.jpg')";
         }*/

         console.log(farhen);
         desc.innerHTML = response.weather[0].description;
         temp.innerHTML = celsius;
        console.log(response.weather[0].description);    
     }

        catch(e){
            console.log(e.message);
        }
}
    }; 
}
Jordan Shackelford
@JordanShackelford
May 23 2016 07:08
Can we use third party libraries for FCC challenges?
Connor Murphy
@papasmurph
May 23 2016 07:08
Yes.
Jordan Shackelford
@JordanShackelford
May 23 2016 07:08
Do you know how to import them?
Ken Nawrocki
@nawrockp
May 23 2016 07:09
@papasmurph what is the api url?
Jordan Shackelford
@JordanShackelford
May 23 2016 07:09
trying to get it. this damn webfilter at work is getting annoying
Connor Murphy
@papasmurph
May 23 2016 07:10
@nawrockp It's correct. I've tested it via console, it goes to openweathermap concating latitude, longitude and apikey
returning the expected json back in browser
Ken Nawrocki
@nawrockp
May 23 2016 07:11
If i recall correctly one of the apis requires https
Are u using codepen?
Connor Murphy
@papasmurph
May 23 2016 07:11
FML
No, local server. Fixed, nothing wrong with the code - I use noscript and and my temp allow ran out for openweathermap
Ken Nawrocki
@nawrockp
May 23 2016 07:15
So after the first if u could put an else and console.log the response code?
impossiblesingh
@impossiblesingh
May 23 2016 07:15
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) 

{
  if (myObj.hasOwnProperty===true){ 
    return myObj[checkProp];
  }
  else return "Not Found";

}

// Test your code by modifying these values
checkObj("pet");
what is wrong with these?
ihemant360
@ihemant360
May 23 2016 07:16
How to use \r in javascript string
Ken Nawrocki
@nawrockp
May 23 2016 07:16
Nevermind just read your message
Asha
@ashamishra
May 23 2016 07:17

Javascript - "Profile Lookup Incomplete" First three condition is not getting satisfied with this code. A little help required . function lookUpProfile(firstName, prop){
// Only change code below this line
//return contacts[1];

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

}

// Only change code above this line
}

Jaren Escueta
@jarenescueta731
May 23 2016 07:20
@hubhubace sorry for the late reply. using (a || b < 0) is not the same as (a < 0 || b < 0). the "less-than/greater-than" operators take precedence over boolean (&&, ||) operators. if (a || b < 0) is the same as if (a) OR if (b < 0). but the challenge wants to know if either a is less than 0, or if b is less than 0.
kwal0203
@kwal0203
May 23 2016 07:21
let square = (color) => {
    let self = this;
  self.color = color;
}  

let square = function(color) {
    let self = this;
  self.color = color;
}

var x = new square('red');

console.log(x);
Anybody know why the first block of code is not considered a constructor whereas the second one is?
Jaren Escueta
@jarenescueta731
May 23 2016 07:22
@kwal0203 what is => supposed to do?