These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Jul 2016
llamatarianism
@llamatarianism
Jul 05 2016 00:00
the function you pass as an argument to map isn't meant to change any variables
it's supposed to be a pure function that just returns something
Tim McIntire
@tmcintire
Jul 05 2016 00:00
Ok I'm not sure what its asking for then when it says "Use the map function to add 3 to every value in the variable oldArray, and save the results into variable newArray. oldArray should not change."
llamatarianism
@llamatarianism
Jul 05 2016 00:00
like this:
var newArray = oldArray.map(function(x) { return x + 3; });
it'll apply that function to each item in oldArray
then create an entirely separate array full of the results
Tim McIntire
@tmcintire
Jul 05 2016 00:02
I tried that code earlier, and it kept telling me "you should add three to each value of the array"
llamatarianism
@llamatarianism
Jul 05 2016 00:03
then you probably did something else that you're not telling me about
Tim McIntire
@tmcintire
Jul 05 2016 00:04
var addThree = oldArray.map(function(val) {
return val + 3;
});
llamatarianism
@llamatarianism
Jul 05 2016 00:04
it says to store it in newArray
Mark Adel
@MarkAdell
Jul 05 2016 00:04
One last problem , contacts[i].prop seems not to work ..
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i].prop;
      }else
        return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
llamatarianism
@llamatarianism
Jul 05 2016 00:04
not addThree
Tim McIntire
@tmcintire
Jul 05 2016 00:04
oh wow
llamatarianism
@llamatarianism
Jul 05 2016 00:04
@MarkAdell you have to use bracket notation
contacts[i].prop === contacts[i]["prop"]
but you want
Tim McIntire
@tmcintire
Jul 05 2016 00:05
Thank you for that
llamatarianism
@llamatarianism
Jul 05 2016 00:05
contacts[i][prop]
which is different
you have to use bracket notation for accessing properties using variables
Mark Adel
@MarkAdell
Jul 05 2016 00:06
@llamatarianism Got it, it works, Thanks!
CamperBot
@camperbot
Jul 05 2016 00:06
markadell sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 893 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Tim McIntire
@tmcintire
Jul 05 2016 00:06
Quick question, how do I do code markup in chat?
llamatarianism
@llamatarianism
Jul 05 2016 00:06
explain format
CamperBot
@camperbot
Jul 05 2016 00:06

: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

Tim McIntire
@tmcintire
Jul 05 2016 00:07
thanks @llamatarianism
CamperBot
@camperbot
Jul 05 2016 00:07
tmcintire sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 894 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Norvin Burrus
@ndburrus
Jul 05 2016 00:11
@MarkAdell you might like this: :sparkles:
Wali Gauvin
@Docwali777
Jul 05 2016 00:16
Selecting from many options with switch staatements------ am i close

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

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

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

uniforlyff
@uniforlyff
Jul 05 2016 00:17
@Docwali777 close ;)
llamatarianism
@llamatarianism
Jul 05 2016 00:18
you should be setting answer equal to those strings in your cases
Stephen James
@sjames1958gm
Jul 05 2016 00:18
@Docwali777 Your cases should all be the same, not a mixture of numbers and strings.
llamatarianism
@llamatarianism
Jul 05 2016 00:18
not just logging them
@sjames1958gm actually I think it works either way due to JS having an awful type system
though it's still bad practice
correct me if I'm wrong
Wali Gauvin
@Docwali777
Jul 05 2016 00:21
I @sjames1958gm @llamatarianism i tried different combos but i get no answers .. Is there a hint ? Without giving answer?
llamatarianism
@llamatarianism
Jul 05 2016 00:22
instead of logging stuff to the console
change the value of the answer variable
also just noticed
you're switching on answer
it should be switch (val) { ... }
because val is the input. it's the thing that changes. answer will always be an empty string when that switch statement gets evaluated
Wali Gauvin
@Docwali777
Jul 05 2016 00:31
@llamatarianism do i use consol.log() ?
llamatarianism
@llamatarianism
Jul 05 2016 00:32
no
you have to use the assignment operator
=
jellyb3lly
@jellyb3lly
Jul 05 2016 00:33
can anybody help with the algorithm coding to convert celsius to fahrenheit
i can't figure out what this function is doing and im trying to back solve the math but its not working
Gabriel Klockner
@Klockner
Jul 05 2016 00:33
let me see
jellyb3lly
@jellyb3lly
Jul 05 2016 00:33
thanks
Wali Gauvin
@Docwali777
Jul 05 2016 00:34
@jellyb3lly copy and past code
jellyb3lly
@jellyb3lly
Jul 05 2016 00:34
k

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

fahrenheit*=5/9;
fahrenheit-=32;

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

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

those two lines with fahrenheit*=5/9 and the one below are mine
and thats returning null
JaosnHsieh
@JaosnHsieh
Jul 05 2016 00:35
@jellyb3lly just put , fahrenheit = celsius * 9/5 +32;
jellyb3lly
@jellyb3lly
Jul 05 2016 00:35
oh no way
Norvin Burrus
@ndburrus
Jul 05 2016 00:36
@jellyb3lly your code says far = far * 5/9 - 32!!
jellyb3lly
@jellyb3lly
Jul 05 2016 00:36
yeah i thought i was defining it for a value of fahrenheit
to get back to celsius
thanks @JaosnHsieh
CamperBot
@camperbot
Jul 05 2016 00:37
jellyb3lly sends brownie points to @jaosnhsieh :sparkles: :thumbsup: :sparkles:
:cookie: 142 | @jaosnhsieh |http://www.freecodecamp.com/jaosnhsieh
Norvin Burrus
@ndburrus
Jul 05 2016 00:37
@jellyb3lly your function does not use celsius
jellyb3lly
@jellyb3lly
Jul 05 2016 00:37
ahh okay
thats all for now
thanks everybody
Norvin Burrus
@ndburrus
Jul 05 2016 00:37
@jellyb3lly you pass celsius into a black hole...
Wali Gauvin
@Docwali777
Jul 05 2016 00:37
@ndburrus any tips for switch statements-----

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

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

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

Norvin Burrus
@ndburrus
Jul 05 2016 00:38
Which lesson/exercise (name) is this? ...ok, have it - Selecting from many options with Switch Statements
in your cases, do something... (change answer, perhaps?) :sparkles:
also, why are we using a different variable (than that the function receives), here: switch (answer) ?
Wali Gauvin
@Docwali777
Jul 05 2016 00:41
@ndburrus ok.. I switch to switch(val)... Nothing
Brendan Kinahan
@BKinahan
Jul 05 2016 00:42
switch(val) is correct, but you should do something more than log the string to the console..
Norvin Burrus
@ndburrus
Jul 05 2016 00:42
@Docwali777 have we addressed what needs to be done inside the cases?
example: if val is equal to 1, what should happen?
Greg Duncan
@GregatGit
Jul 05 2016 00:43
@Docwali777 w3school is a great reference for stuff like this. So googling "switch js" and choosing the w3schools is a good starting point. You can also copy and paste things at https://repl.it/ to run things
@Docwali777 switch (val) is correct - inside the switch statement you need to change the value of answer
Chris Cuevo
@ccuevo
Jul 05 2016 00:49
hi i need help with the chunky monkey challenge. when i run the code, it adds one additional array that's not needed.. please help. thanks!
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newSlice = [];
  var newArray = [];

  for (var i = 0; i < arr.length; i++) {
    newSlice = arr.slice(i += i, i + size);
    newArray.push(newSlice);
  }
  return newArray;
}
Norvin Burrus
@ndburrus
Jul 05 2016 00:52
that's a pretty neat activity chart on the right.... ~~~>
João Ricardo Lhullier Lugão
@jlugao
Jul 05 2016 00:52
hey @ccuevo, instead of i++ shouldn't you increment the size you just removed?
and why are you changing the value of i inside the slice function?
not sure if I helped but take a look at those points and you will be able to solve it
William Cabell
@wbac88
Jul 05 2016 01:04
Hi guys, I'm having serious trouble with the Seek and Destroy challenge. This is the beginning of my code:
Chris Cuevo
@ccuevo
Jul 05 2016 01:04
thanks @jlugao ! that helped
CamperBot
@camperbot
Jul 05 2016 01:04
ccuevo sends brownie points to @jlugao :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @jlugao |http://www.freecodecamp.com/jlugao
clintonjohn
@clintonjohn
Jul 05 2016 01:04
@ndburrus I get a little confused when I have an if statement that can return two different values depending on the condition. It always feels like I should put an else on the second condition, but in situations like the algorithm challenge "factorialize a number", the else is not required
William Cabell
@wbac88
Jul 05 2016 01:05

function destroyer(arr) {

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

  var answer = args.filter(function(test) {



  });

  return args;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I know that the middle function is blank, I just want to know if I'm on the right track or not, as this seems more advanced that what we've done so far. I've read the MDN links, but so far they're still a little tough to understand.
clintonjohn
@clintonjohn
Jul 05 2016 01:05
Then again, I notice if I put in else statement on the second condition it also runs the challenge as a success it just is less efficient is it not ?
Norvin Burrus
@ndburrus
Jul 05 2016 01:05
@clintonjohn the factorialize a number scenario/lesson is a different animal... it's different because normally a function doesn't use itself again (or repeatedly) in/to determine/ing a result...
clintonjohn
@clintonjohn
Jul 05 2016 01:06
@ndburrus it worked with just one if statement and it worked as an if/else
for me
Islam Ibakaev
@dagman
Jul 05 2016 01:07
@wbac88 i have tweaked you solution a bit and now it works :smile:
function chunkArrayInGroups(arr, size) {
  var chunked = [],
       len = arr.length,
       i, j = size;

  for (i = 0; i < len; i+=size, j+=size) {
    chunked.push(arr.slice(i, j));
  }
  return chunked;
}

chunkArrayInGroups([1, 2, 3, 4, 5, 6], 2);
William Cabell
@wbac88
Jul 05 2016 01:08
@dagman That's not mine, sorry!
clintonjohn
@clintonjohn
Jul 05 2016 01:08
@ndburrus thanks
CamperBot
@camperbot
Jul 05 2016 01:08
clintonjohn sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 840 | @ndburrus |http://www.freecodecamp.com/ndburrus
William Cabell
@wbac88
Jul 05 2016 01:09
@dagman, I think it was:@ccuevo?
Norvin Burrus
@ndburrus
Jul 05 2016 01:09
@clintonjohn anytime! :palm_tree:
Islam Ibakaev
@dagman
Jul 05 2016 01:09
@wbac88 sorry i mistook
William Cabell
@wbac88
Jul 05 2016 01:09
That's ok! Any thoughts on mine? :-)
Norvin Burrus
@ndburrus
Jul 05 2016 01:09

@wbac88 ...lol, that's funny.... :panda_face:

@dagman That's not mine, sorry!

Islam Ibakaev
@dagman
Jul 05 2016 01:10
@ccuevo @wbac88 i have tweaked you solution a bit and now it works :smile:
function chunkArrayInGroups(arr, size) {
  var chunked = [],
        len = arr.length,
        i, j = size;

  for (i = 0; i < len; i+=size, j+=size) {
    chunked.push(arr.slice(i, j));
  }
  return chunked;
}

chunkArrayInGroups([1, 2, 3, 4, 5, 6], 2);
William Cabell
@wbac88
Jul 05 2016 01:10
@ndburrus Well, I didn't want @ccuevo to miss out!
Islam Ibakaev
@dagman
Jul 05 2016 01:11
@wbac88 what it suppose to do
William Cabell
@wbac88
Jul 05 2016 01:11
"You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments."
So, what I can't figure out it how to set up the filter function
The example given on the MDN site is different from the one here.
Islam Ibakaev
@dagman
Jul 05 2016 01:12
@wbac88 you should slice your conditions var conditions = Array.prototype.slice.call(arguments, 1);
William Cabell
@wbac88
Jul 05 2016 01:13
@dagman OK, sorry, are the conditions the 2,3 inside the array?
Islam Ibakaev
@dagman
Jul 05 2016 01:13
@wbac88 yep exactly
@wbac88 you will get them in array [2, 3]
William Cabell
@wbac88
Jul 05 2016 01:14
@dagman Yep, ok, got it.
Oh, then I can use that as part of the filter?
uniforlyff
@uniforlyff
Jul 05 2016 01:15
@wbac88 yeah that can work
Islam Ibakaev
@dagman
Jul 05 2016 01:15
@wbac88 var conditions = Array.prototype.slice.call(arguments, 1); the 1 as second argument says exclude first argument
William Cabell
@wbac88
Jul 05 2016 01:16
@dagman @uniforlyff OK, cool. Let me try to set up that filter function.
uniforlyff
@uniforlyff
Jul 05 2016 01:16
your var args will have the value [2, 3]
and your arr will have the [1, 2, 3, 4,5, 6]
or was it [1, 2, 3, 1, 2, 3]
William Cabell
@wbac88
Jul 05 2016 01:17
@uniforlyff Yeah, that last one
uniforlyff
@uniforlyff
Jul 05 2016 01:18
okay
William Cabell
@wbac88
Jul 05 2016 01:19
@dagman @uniforlyff So then do I need another function outside of the one that is provided? or should it all be run inside that function.
This is where I'm confused.
uniforlyff
@uniforlyff
Jul 05 2016 01:20
i dont understand your question but you can just return the result of filter
Islam Ibakaev
@dagman
Jul 05 2016 01:20
@wbac88 you just need to filter out numbers from arr which indexes in conditions array !==0
uniforlyff
@uniforlyff
Jul 05 2016 01:20
return arr.filter(function(c) {})
William Cabell
@wbac88
Jul 05 2016 01:22
@uniforlyff That's the function I'm talking about. What is going on with the "c" there?
uniforlyff
@uniforlyff
Jul 05 2016 01:22
o.o
c is the current value
the function takes 3 params
c, i, a
current value, index, array
Benjamin Baldivia
@Goblinlordx
Jul 05 2016 01:23
It is actually pretty simple if use Array.prototype.reduce(), initialize with an empty array to add to, then push an empty array on i%size else push to the last element in the array.
uniforlyff
@uniforlyff
Jul 05 2016 01:23
so you're taking the valeus of arr
Islam Ibakaev
@dagman
Jul 05 2016 01:23
@wbac88 i mean filter out numbers indecies of which has value of -1 in conditions array
Benjamin Baldivia
@Goblinlordx
Jul 05 2016 01:24
than you only have 2 conditions (i%size and !i%size)
really only 1 and and else clause
tkruger3902
@tkruger3902
Jul 05 2016 01:25

Can anyone tell me why these switch statements won't pass? Thanks! function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
case 1:
answer === "alpha";
break;
case 2:
answer === "beta";
break;
case 3:
answer === "gamma";
break;
case 4:
answer === "delta";
break;
}

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

Islam Ibakaev
@dagman
Jul 05 2016 01:25
@wbac88 ok this part finishes puzzle
  return arr.filter(function(el) {
      return conditions.indexOf(el) === -1;
  });
uniforlyff
@uniforlyff
Jul 05 2016 01:25
@tkruger3902 check switch()
Islam Ibakaev
@dagman
Jul 05 2016 01:26
@wbac88 you are only left to figure out what this crap means and you are done :smile:
William Cabell
@wbac88
Jul 05 2016 01:26
@dagman Haha, that's what I'm trying to do right now!
I have all of it except for that "el" in there.
Islam Ibakaev
@dagman
Jul 05 2016 01:27
@wbac88 you de better dive into .filter() documentation then you ll get the point
el is an element from array
tkruger3902
@tkruger3902
Jul 05 2016 01:28
@uniforlyff I've tried (val) and (answer) and neither of them have worked...I'm not sure what else to try haha
William Cabell
@wbac88
Jul 05 2016 01:28
@dagman Yep, I see that, but why is that what's in the function? In the example on the MDN page, it has this:
Islam Ibakaev
@dagman
Jul 05 2016 01:28
@wbac88 pretend you have arr = [1,2,3,4] and when you pass it throu filter
William Cabell
@wbac88
Jul 05 2016 01:28
function isBigEnough(value) { return value >= 10; } var filtered = [12, 5, 8, 130, 44].filter(isBigEnough); // filtered is [12, 130, 44]
Islam Ibakaev
@dagman
Jul 05 2016 01:29
on first iteration el gets 1
on second iteration el gets 2
you get the point
ok i should leave and have my rest sorry guys
William Cabell
@wbac88
Jul 05 2016 01:31
@dagman Thank you so much for the help!
CamperBot
@camperbot
Jul 05 2016 01:31
wbac88 sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:cookie: 598 | @dagman |http://www.freecodecamp.com/dagman
Islam Ibakaev
@dagman
Jul 05 2016 01:31
@wbac88 yw
William Cabell
@wbac88
Jul 05 2016 01:31
@uniforlyff Thank you, too!
CamperBot
@camperbot
Jul 05 2016 01:31
wbac88 sends brownie points to @uniforlyff :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @uniforlyff |http://www.freecodecamp.com/uniforlyff
Pedro Relvas
@pmrelvas
Jul 05 2016 01:50
Hi, can someone take me a quick question please? I transformed a string into an array, and now I want to filter my array so that only letters will stay in the array... how can I check if an array element is a letter?
Derick Alfaro
@dericka
Jul 05 2016 01:55
@pmrelvas
js array.replace(/[^A-Za-z]/g, ''); /*this will remove anything from an array that is not a letter A through Z(capital) and a-z (lowercase) and replace it with a space*/
Norvin Burrus
@ndburrus
Jul 05 2016 01:59
@pmrelvas Which lesson/exercise (name) is this?
Pedro Relvas
@pmrelvas
Jul 05 2016 02:00
Thx... I'm sorry, I'm new here, and I'm still a noob, but I'm getting the error "auxArray.replace is not a functioin"
@ndburrus check the palindromes (from basic algorithm scripting)
Norvin Burrus
@ndburrus
Jul 05 2016 02:09
@pmrelvas can you post your code so far?
help format @pmrelvas
this may be helpful: camperbot will provide information (if possible) when you type "help (subject)" in the chat room :) .
For an introduction on how to post code, type ("help format"). also, for code posting - typing shift + enter provides additional line feeds (space for posting/pasting code). you may also find the chat & compose buttons to the right of the chat text entry area useful. the backticks key is located to the left of the #1 (number one) key. :sparkles:
CamperBot
@camperbot
Jul 05 2016 02:09

: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

Greg Munker
@Gmunker
Jul 05 2016 02:10
function dropElements(arr, func) {
  // Drop them elements.

  var arrLen = arr.length;

  for (var i = 0 ; i<= arrLen ; i++) {
    if (!(func(arrLen))) {
      arr.shift();
    }
  }

  return arr;

}

dropElements([1, 2, 3, 4], function(n) {return n >= 3;});
I'm having some trouble with "Drop It" and I can't figure out why. If someone is available please if you could lend a hand that would be awesome!
Pedro Relvas
@pmrelvas
Jul 05 2016 02:11
thanks @ndburrus
CamperBot
@camperbot
Jul 05 2016 02:11
pmrelvas sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 844 | @ndburrus |http://www.freecodecamp.com/ndburrus
Pedro Relvas
@pmrelvas
Jul 05 2016 02:11

'''js
function palindrome(str) {
// Good luck!
var arrayAux = str.toLowerCase().split('');
arrayAux = arrayAux.filter(function(val) {
return val!==" " && val!=="_" && val!=="," && val!==".";
});
//arrayAux = arrayAux.toLowerCase();
var reverseArray = arrayAux.slice();
reverseArray.reverse();
for(var i=0; i<arrayAux.length; i++) {
if(reverseArray[i]!==arrayAux[i])
return false;
}
return true;
}

palindrome("eye");
'''

CamperBot
@camperbot
Jul 05 2016 02:11
:bulb: to format code use backticks! ``` more info
Greg Munker
@Gmunker
Jul 05 2016 02:11
and i'm not looking for an answer! I'm want to know what the issue is. Thanks in advance.
@pmrelvas use the ``` when you hit 3 in a row another 3 will pop below, put your code inside there and hit ctrl+enter
Pedro Relvas
@pmrelvas
Jul 05 2016 02:13
  function palindrome(str) {
    // Good luck!
    var arrayAux = str.toLowerCase().split('');
    arrayAux = arrayAux.filter(function(val) {
      return val!==" " && val!=="_" && val!=="," && val!==".";
    });
    //arrayAux = arrayAux.toLowerCase();
    var reverseArray = arrayAux.slice();
    reverseArray.reverse();
    for(var i=0; i<arrayAux.length; i++) {
      if(reverseArray[i]!==arrayAux[i])
        return false;
    }
    return true;
  }



  palindrome("eye");
Greg Munker
@Gmunker
Jul 05 2016 02:13
:)
Condor aka Mujahid
@leomujahid
Jul 05 2016 02:13
Sup guys, I need your help with "Escape Sequences in Strings"
Will
@Will-is-Coding
Jul 05 2016 02:16
@Gmunker The way arr.length works is it will give you, in human terms, the amount of items in the array. Like for yours it will say 4. However when iterating an array from the beginning you start at 0 and go to, in this case, 3.
Pedro Relvas
@pmrelvas
Jul 05 2016 02:17
thanks @ndburrus @dericka
CamperBot
@camperbot
Jul 05 2016 02:17
pmrelvas sends brownie points to @ndburrus and @dericka :sparkles: :thumbsup: :sparkles:
:warning: pmrelvas already gave ndburrus points
:cookie: 244 | @dericka |http://www.freecodecamp.com/dericka
CruftMaster
@CruftMaster
Jul 05 2016 02:17
i need help with fibonacci numbers challenge
Pedro Relvas
@pmrelvas
Jul 05 2016 02:17
I already figured out myself x)
SweetP-7
@SweetP-7
Jul 05 2016 02:17
I don't understand what is being asked in 172.
Norvin Burrus
@ndburrus
Jul 05 2016 02:17
@pmrelvas ok, super! nice job :+1:
Pedro Relvas
@pmrelvas
Jul 05 2016 02:18
changed that to
  function palindrome(str) {
CruftMaster
@CruftMaster
Jul 05 2016 02:18
should i store the numbers in an array? or is there another way
Will
@Will-is-Coding
Jul 05 2016 02:18
@Gmunker So look at the first line of your for loop
Pedro Relvas
@pmrelvas
Jul 05 2016 02:18
arrayAux = arrayAux.filter(function(val) {
      //return val!==" " && val!=="_" && val!=="," && val!==".";
      return val.match(/[a-z]/i);
    });
Greg Munker
@Gmunker
Jul 05 2016 02:19
@Will-is-Coding Just saw this was away from this channel for a second.
Looking at it now
Condor aka Mujahid
@leomujahid
Jul 05 2016 02:22
guys, how to do 153?
Will
@Will-is-Coding
Jul 05 2016 02:22
153?
Josh
@joshweaver23
Jul 05 2016 02:23
yeah, what numbers are people referencing?
Condor aka Mujahid
@leomujahid
Jul 05 2016 02:23
okay here is the objective: ""Escape Sequences in Strings"
Pedro Relvas
@pmrelvas
Jul 05 2016 02:23
I think they are refering to points
Will
@Will-is-Coding
Jul 05 2016 02:25
@leomujahid Post what you've got
Josh
@joshweaver23
Jul 05 2016 02:25
ah, points is not a good reference... I for example skipped many things that I am already experienced in :S
SweetP-7
@SweetP-7
Jul 05 2016 02:25
I thought they were lesson numbers. ANYwho, I'm stuck on Word Blanks.
Condor aka Mujahid
@leomujahid
Jul 05 2016 02:25
and instructions are: 1- myStr should have encoded text with the proper escape sequences and spacing.
2- myStr should have two tab characters \t
3- myStr should have one newline character \n
4- myStr should have a correctly escaped backslash character \
SweetP-7
@SweetP-7
Jul 05 2016 02:25
@Will-is-Coding What is the name of the lesson you are on?
CruftMaster
@CruftMaster
Jul 05 2016 02:26
guys, any one have any tips on sum all odd fibonacci numbers?
Will
@Will-is-Coding
Jul 05 2016 02:26
Me? Why? I'm ahead in Dynamic Web Application Projects
@leomujahid Post what code you've tried
@SweetP-7 So what part confuses you?
Pedro Relvas
@pmrelvas
Jul 05 2016 02:26
@SweetP-7 what do you need?
Condor aka Mujahid
@leomujahid
Jul 05 2016 02:26
this is what written in code box @Will-is-Coding var myStr; // Change this line
Josh
@joshweaver23
Jul 05 2016 02:27
@CruftMaster create an array of fibonacci numbers first, and then go through and remove the odd ones before summing the array
Will
@Will-is-Coding
Jul 05 2016 02:27
@leomujahid Well it should start out with more than that, as it gives you a sentence and you input the escape sequences
CruftMaster
@CruftMaster
Jul 05 2016 02:27
@joshweaver23 ok, thanks man
CamperBot
@camperbot
Jul 05 2016 02:27
cruftmaster sends brownie points to @joshweaver23 :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @joshweaver23 |http://www.freecodecamp.com/joshweaver23
Condor aka Mujahid
@leomujahid
Jul 05 2016 02:28
@Will-is-Coding i'm so confused right now
SweetP-7
@SweetP-7
Jul 05 2016 02:29
@Will-is-Coding Sorry, I thought you were the one asking about 153.
Will
@Will-is-Coding
Jul 05 2016 02:29
@leomujahid I am as well. So are you saying you haven't tried it yet? The instructions are telling you what should be inside myStr
kode00
@kode00
Jul 05 2016 02:30
@SweetP-7 result += myNoun + "," + myAdjective + "," + "," +myVerb +","+ myAdverb;
Pedro Relvas
@pmrelvas
Jul 05 2016 02:30
@SweetP-7 in word blanks you just need to use the + operator and "sum" the words and spaces
SweetP-7
@SweetP-7
Jul 05 2016 02:31
okay I wrote that correctly then (I guess) but I can't satisfy both the dog and the cat requirements.
Pedro Relvas
@pmrelvas
Jul 05 2016 02:31
@SweetP-7 user myNoun, etc... the atributes from your function
instead of "cat", "dog", etc
Josh
@joshweaver23
Jul 05 2016 02:33
best way to get help is to post your code properly formatted... this makes everything much easier to follow
e.g.
var Person = function(firstAndLast) {
    return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();
Ray
@rbjr
Jul 05 2016 02:35
help diff two arrays
CamperBot
@camperbot
Jul 05 2016 02:35

:point_right: algorithm diff two arrays [wiki]

Algorithm Diff Two Arrays

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

:checkered_flag: Problem Explanation:

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

Relevant Links

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

Condor aka Mujahid
@leomujahid
Jul 05 2016 02:35
@joshweaver23 how to do that?
Pedro Relvas
@pmrelvas
Jul 05 2016 02:35
@leomujahid help format
Josh
@joshweaver23
Jul 05 2016 02:35
help format
CamperBot
@camperbot
Jul 05 2016 02:35

: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

Lloyd Stubber
@lloydstubber
Jul 05 2016 02:49

Javascript noob after a little help with an escape sequence...

Can't seem to figure this out:

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

My code:

var myStr = 'Here is a backslash: \\. \n \t \t Here is a new line with two tabs'; // Change this line

Any help would be much appreciated!
SweetP-7
@SweetP-7
Jul 05 2016 02:50
@camperbot what is that, the left arrow (after the enter)?
@lloydstubber get rid of the spaces
@kode00 i don't understand why that is the right answer when it says the answer should output a sentence, not a string of words separated by commas.
Norvin Burrus
@ndburrus
Jul 05 2016 02:51
@lloydstubber it looks like there is an extra space at the end of the 1st sentence (before the period), maybe not. the escape characters do not require spacing. the 2nd sentence is missing punctuation. :sparkles:
Lloyd Stubber
@lloydstubber
Jul 05 2016 02:53
Legendary! Thanks so much @SweetP-7 @ndburrus
CamperBot
@camperbot
Jul 05 2016 02:53
lloydstubber sends brownie points to @sweetp-7 and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 173 | @sweetp-7 |http://www.freecodecamp.com/sweetp-7
:cookie: 845 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 05 2016 02:54
@lloydstubber you're welcome! nice work :sailboat:
Nada
@NadaH
Jul 05 2016 02:55
I don't know the requirements of this challenge
word blanks

the code

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

the text
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.

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

SweetP-7
@SweetP-7
Jul 05 2016 02:57
@NadaH I just asked about this. Scroll up a bit and you may find help!
(around 21:30)
kuldeep
@gurukd
Jul 05 2016 02:59
This message was deleted
kode00
@kode00
Jul 05 2016 03:00
@SweetP-7 You will also need to use additional strings, which will not change, and must be in between all of the provided words.
kuldeep
@gurukd
Jul 05 2016 03:01
everything is fine. Sorry
Joe Farah
@Kangiryanka
Jul 05 2016 03:03
Anyone did the wherefore art thou algorithm challenge
Norvin Burrus
@ndburrus
Jul 05 2016 03:04
@SweetP-7 if you press alt + left click (on the comment/text time stamp), you can provide a pointer, like this :point_up: July 4, 2016 10:57 PM
Greg Duncan
@GregatGit
Jul 05 2016 03:04
@Kangiryanka Yes - where are you stuck
Hassaan Hafeez
@HassHz
Jul 05 2016 03:05
Alt+Left click doesn't work for
me
Nada
@NadaH
Jul 05 2016 03:05
@SweetP-7 thanks i found it :)
CamperBot
@camperbot
Jul 05 2016 03:05
nadah sends brownie points to @sweetp-7 :sparkles: :thumbsup: :sparkles:
:cookie: 175 | @sweetp-7 |http://www.freecodecamp.com/sweetp-7
Will
@Will-is-Coding
Jul 05 2016 03:06
@SweetP-7 @NadaH The parameters passed in are variables. In this case they are strings that you are given. Inside the function they are placement pieces if you will for whatever is passed in. It's alike
var myNoun = "dog". So now you write a sentence adding in those variables(which are actually strings) given to you.
@HassHz You have to have your cursor over the time in the message, top right corner. Then alt + left click. A little tool tip will appear
Joe Farah
@Kangiryanka
Jul 05 2016 03:09
@GregatGit my "key" variable doesn't select every property of the source object: [{"a":1, "b":2}], the variable should store a and b as the properties
Greg Munker
@Gmunker
Jul 05 2016 03:12
@Will-is-Coding Thank you for your help earlier. I just realized that i was looking for the "length of the array" when i'm suppose to be looking for the value within the array. :/
CamperBot
@camperbot
Jul 05 2016 03:12
gmunker sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 444 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Ryan Garant
@protoEvangelion
Jul 05 2016 03:13
Hey there! The Cipher challenge is not allowing me to pass even though my code correctly decodes the string.
This message was deleted
Greg Duncan
@GregatGit
Jul 05 2016 03:13
@Kangiryanka can you paste up what you have done so far
Ryan Garant
@protoEvangelion
Jul 05 2016 03:14
var input = "NOPQRSTUVWXYZABCDEFGHIJKLM "; //Cipher code
var output = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; 


var inputArr = input.split(""); //convert string to array
var outputArr = output.split("");

var decoded = ""; //create variable for decoded string to be placed into

function rot13(str) { 

  var code = str.split(""); //create array from "str" argument

  for (i=0; i<str.length; i++) { //loop through "str"

    if(outputArr.indexOf(code[i]) == -1){
      decoded += code[i];
    }
    else {
      decoded += inputArr[outputArr.indexOf(code[i])];
    }

  }

return decoded;

}

rot13("SERR CVMMN!");
Lan
@lanzhiheng
Jul 05 2016 03:14
Hello World
CamperBot
@camperbot
Jul 05 2016 03:14

welcome to FreeCodeCamp @lanzhiheng!

Ryan Garant
@protoEvangelion
Jul 05 2016 03:14
Can't seem to understand the problem with this code
Nick Slaven
@nslaven22
Jul 05 2016 03:15

So on the convert Celcius to Farhenheit challenge this is what I have for my code:

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celcius * 9/5 + 32;

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

// Change the inputs below to test your code
convertToF(celcius = 20);

however, ever time I change the number in the "celcius =" parenthesis, it only puts a check mark beside the the task that asks to convert that specific number from C to F. If I change the conversion number to a different number it takes away the check mark that I just had. Any ideas on this one? Or let me know if you nee any other clarification. Thanks!!

Ryan Garant
@protoEvangelion
Jul 05 2016 03:15
@lanzhiheng Hey there!
Greg Duncan
@GregatGit
Jul 05 2016 03:16
@nslaven22 typo - you spelt celsius wrong
Hassaan Hafeez
@HassHz
Jul 05 2016 03:16
@RyanGarant I don't see charCodeAt or fromCharCode anywhere
Ryan Garant
@protoEvangelion
Jul 05 2016 03:16
Do we have to use that?
Greg Duncan
@GregatGit
Jul 05 2016 03:16
@RyanGarant everything should be inside the function
Ryan Garant
@protoEvangelion
Jul 05 2016 03:17
@Greg thank you Greg! That was the key
CamperBot
@camperbot
Jul 05 2016 03:17
ryangarant sends brownie points to @greg :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for greg
Norvin Burrus
@ndburrus
Jul 05 2016 03:17
@nslaven22 this celcius = 20 should be ##
Hassaan Hafeez
@HassHz
Jul 05 2016 03:17
@RyanGarant It worked?
Ryan Garant
@protoEvangelion
Jul 05 2016 03:17
@GregatGit Thanks!!!!!!
CamperBot
@camperbot
Jul 05 2016 03:17
ryangarant sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 653 | @gregatgit |http://www.freecodecamp.com/gregatgit
Ryan Garant
@protoEvangelion
Jul 05 2016 03:18
@HassHz Sure did thanks for asking:)
CamperBot
@camperbot
Jul 05 2016 03:18
ryangarant sends brownie points to @hasshz :sparkles: :thumbsup: :sparkles:
:cookie: 514 | @hasshz |http://www.freecodecamp.com/hasshz
Hassaan Hafeez
@HassHz
Jul 05 2016 03:18
@RyanGarant Strange, never saw it done that way
Will
@Will-is-Coding
Jul 05 2016 03:18
@Gmunker Oh that was accidental help then hah. Sorry I misunderstood and I thought you were supposed to keep dropping elements off until the array was 3 elements long. I was actually referring to you will be incrementing i higher than the amount of elements inside of arr. Which you may be doing now
Ryan Garant
@protoEvangelion
Jul 05 2016 03:18
HAHA I am strange indeed
Nick Slaven
@nslaven22
Jul 05 2016 03:18
@GregatGit boom! Thanks Greg! corrected the spelling and everything was A-OK. Thanks again!
CamperBot
@camperbot
Jul 05 2016 03:18
nslaven22 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 654 | @gregatgit |http://www.freecodecamp.com/gregatgit
Ryan Garant
@protoEvangelion
Jul 05 2016 03:18
@HassHz is there a better way to do it?
Hassaan Hafeez
@HassHz
Jul 05 2016 03:19
@RyanGarant Looks shorted than my solution :O
Greg Duncan
@GregatGit
Jul 05 2016 03:19
@RyanGarant is js you don't sometimes don't need to create new variable
var code = str.split("");
str = str.split("");
Hassaan Hafeez
@HassHz
Jul 05 2016 03:19
function rot13(str) { // LBH QVQ VG!
  var strF = "";
  for(var i = 0; i<str.length; i++){
    if(str.charAt(i).match(/[a-z]/i)){

      if(str.charAt(i).charCodeAt(0) > 77){
        strF = strF + String.fromCharCode(str.charAt(i).charCodeAt(0) - 13);
      } else {
        strF = strF + String.fromCharCode(str.charAt(i).charCodeAt(0) + 13);
      }

    } else {
      strF = strF + str.charAt(i);
    }
  }
  return strF;
}
Lol
Jonathan Mitchell
@Vanhealen
Jul 05 2016 03:20
Hoisting question:
For hoisting. Does javascript read function literal declarations before variable assignments. So variable assignments are hoisted above literal declarations because the interpreter reads them last? They are hoisted above because they are read after? So the javascript interpreter looks for the keyword ‘function’ and reads that line first
function() test{   //1)reads this line first, saves test to function inside undefined
    var a = 9;        //4) reads this line and saves variable a and assigns value to 9
    function a(){  //3) this line saves a to function inside func is undefined
    }
console.log(typeof a) //=> number.

}

test(); //2)
Joe Farah
@Kangiryanka
Jul 05 2016 03:20

@Gregagit

function whatIsInAName(collection, source) {
var key= Object.getOwnPropertyNames(source).sort(); //Key is
return key;
}
whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 }, [{"a":1, "b":2}]);

Ryan Garant
@protoEvangelion
Jul 05 2016 03:20
@GregatGit Good pointer :) Thanks
CamperBot
@camperbot
Jul 05 2016 03:20
ryangarant sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: ryangarant already gave gregatgit points
Ryan Garant
@protoEvangelion
Jul 05 2016 03:21
@HassHz Thanks for sending that over. Yours looks faster because you didn't convert string into arrays
CamperBot
@camperbot
Jul 05 2016 03:21
ryangarant sends brownie points to @hasshz :sparkles: :thumbsup: :sparkles:
:warning: ryangarant already gave hasshz points
Greg Duncan
@GregatGit
Jul 05 2016 03:24

@Kangiryanka

var keys = Object.keys(source);

that will give you an array of all the properties in source

Tia Holiday
@tlholiday
Jul 05 2016 03:24

Anyone help me point out where I'm going wrong? I'm in the "Assignment with a returned value" challenge. I'm not understanding what: "You should assign processArg to processed" means...

var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}

Jonathan Mitchell
@Vanhealen
Jul 05 2016 03:24
Hoisting question:
For hoisting. Does javascript read function literal declarations before variable assignments. So variable assignments are hoisted above literal declarations because the interpreter reads them last? They are hoisted above because they are read after? So the javascript interpreter looks for the keyword ‘function’ and reads that line first
function() test{   //1)reads this line first, saves test to function inside undefined
    var a = 9;        //4) reads this line and saves variable a and assigns value to 9
    function a(){  //3) this line saves a to function inside func is undefined
    }
console.log(typeof a) //=> number.

}

test(); //2)
Thieu van Dijk
@Thieuvandijk
Jul 05 2016 03:26
@tlholiday hi
Tia Holiday
@tlholiday
Jul 05 2016 03:27
@Thieuvandijk hello!
Thieu van Dijk
@Thieuvandijk
Jul 05 2016 03:27
@tlholiday i can help you
Tia Holiday
@tlholiday
Jul 05 2016 03:27
Fantastic! I'm sure it's something I missed that i don't full understand yet
Joe Farah
@Kangiryanka
Jul 05 2016 03:27
@GregatGit if the source is [{"a":1, "b":2}]) , the keys variable will only display "a"
x981
@x981
Jul 05 2016 03:28
I'm in this challenge https://codepen.io/FreeCodeCamp/full/wGqEga/ => Anyone help me, how to make icon search
Thieu van Dijk
@Thieuvandijk
Jul 05 2016 03:28
@tlholiday you should connect the function with the variable
@tlholiday variable = function(parameter);
Tia Holiday
@tlholiday
Jul 05 2016 03:30
Ok...I'm still lost @Thieuvandijk
Om Carrasquillo
@oc2215
Jul 05 2016 03:30
Can anyone help me find the error. To my knowledge, the syntax is correct, but when I run a test, it says that It didn't return "Yes, that was true" even though it does...

function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if (wasThatTrue) {
return "yes, that was true";
} else {
return "No, that was false";
}
// Only change code above this line.

}

// Change this value to test

trueOrFalse(true);

Greg Duncan
@GregatGit
Jul 05 2016 03:30
@Kangiryanka the sources are all objects - not an object in an array
DJ
@qualitymanifest
Jul 05 2016 03:30
@oc2215 capitalize Yes in your return
Greg Duncan
@GregatGit
Jul 05 2016 03:31
CruftMaster
@CruftMaster
Jul 05 2016 03:31
i have a question about sum all primes algorithm
Thieu van Dijk
@Thieuvandijk
Jul 05 2016 03:31
@tlholiday ok. the variable = processed and the function = processArg and the parameter = 7
@tlholiday so......
@tlholiday processed = processesArg(7);
Jonathan Mitchell
@Vanhealen
Jul 05 2016 03:32
Hoisting question:
For hoisting. Does javascript read function literal declarations before variable assignments. So variable assignments are hoisted above literal declarations because the interpreter reads them last? They are hoisted above because they are read after? So the javascript interpreter looks for the keyword ‘function’ and reads that line first
function() test{   //1)reads this line first, saves test to function inside undefined
    var a = 9;        //4) reads this line and saves variable a and assigns value to 9
    function a(){  //3) this line saves a to function inside func is undefined
    }
console.log(typeof a) //=> number.

}

test(); //2)
CruftMaster
@CruftMaster
Jul 05 2016 03:32
its saying sumPrimes(10) should return 17 but the sum of prime numbers up to 10 is 27
Thieu van Dijk
@Thieuvandijk
Jul 05 2016 03:33
sorry, processed = processArg(7) @tlholiday
x981
@x981
Jul 05 2016 03:33
Thanks @GregatGit :)
CamperBot
@camperbot
Jul 05 2016 03:33
x981 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 655 | @gregatgit |http://www.freecodecamp.com/gregatgit
CruftMaster
@CruftMaster
Jul 05 2016 03:33
nvm
Tia Holiday
@tlholiday
Jul 05 2016 03:34
@Thieuvandijk Ok, so then what conceptually is happening here?
Can you maybe point me in the direction to understand @Thieuvandijk (also thank for all the help!(
CamperBot
@camperbot
Jul 05 2016 03:35
tlholiday sends brownie points to @thieuvandijk :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @thieuvandijk |http://www.freecodecamp.com/thieuvandijk
x981
@x981
Jul 05 2016 03:36
@GregatGit How to convert search icon to input ?
Greg Duncan
@GregatGit
Jul 05 2016 03:37
@Kangiryanka
var myObj = {
   "a": 1,
   "b": 3,
   "cat": "fluffy"
}
var keys = Object.keys(myObj);
console.log(keys);  // => ["a", "b", "cat"]
Aakash Gupta
@aakash916
Jul 05 2016 03:38
Hi guys, I'm trying to reverse a string in a function. first converting it to an array and then proceeding
Here is my code
function reverseString(str) {
var arr = str.split();
arr.reverse();
var newval = arr.join();
return newval;
}
this returns the original string though. Anyone see anything wrong?
Greg Duncan
@GregatGit
Jul 05 2016 03:39
@x981 you don't - you can give it an id in the html and when some one clicks on it jQuery can fire your function
$("#searchIcon").click(function (){
   // your search functions fires here
}
Thieu van Dijk
@Thieuvandijk
Jul 05 2016 03:41
@tlholiday functions are little programs which can do things like math. this function processArg takes a argument and does +3 and than /5. You can call this function by naming the function with the parameters between (), so processArg (7). The function returns (7+3)/5. The value the function returns must be stored somewere, in this case in the value processed. so processed will be the returnvalue of the function procesArg(7), which will be 2
x981
@x981
Jul 05 2016 03:43
@GregatGit , I see. But i don't know What idea to make "search" icon miniature and "input " icon appears?
Greg Munker
@Gmunker
Jul 05 2016 03:44
@Will-is-Coding you still around?
Joe Farah
@Kangiryanka
Jul 05 2016 03:44
@aakash916 you redefined a variable
Greg Duncan
@GregatGit
Jul 05 2016 03:45
@x981 so what exactly do you want to do
x981
@x981
Jul 05 2016 03:46
@GregatGit How to make "search" icon miniature and "input " icon appears?
Greg Munker
@Gmunker
Jul 05 2016 03:47
function dropElements(arr, func) {

  arr.forEach(function(a) {

    if (func(a)) {
      return arr;
    } else {
      arr.shift();
      return arr;
    }

  });

}

dropElements([0, 1, 0, 1], function(n) {return n === 1;});

I have been working on "Drop It" for a while now and was making a stupid mistake which i now figured out, but now that i know i'm looking for the value of the array items instead of the length I feel this should work, and i cannot convince myself right now otherwise even though it's not working. Can someone please help me out here (i'm not looking for the answer, i want to learn from my mistakes!)

Thanks in advance!

Joe Farah
@Kangiryanka
Jul 05 2016 03:47
@aakash916 nevermind what i said it's the join function that's a problem
@aakash916 read about it on mozilla.org
Andy
@nolaandy
Jul 05 2016 03:48
Wondering why this code just lists the items in the array instead of adding 3 to each item in the array...
var oldArray = [1,2,3,4,5];

// Only change code below this line.

var addThree = oldArray.map(function(val) {
return val + 3;
});
var newArray = oldArray;
Greg Duncan
@GregatGit
Jul 05 2016 03:50
@x981 not sure
Andy
@nolaandy
Jul 05 2016 03:50
n/m figured it out. had to set newArray to the addThree variable
x981
@x981
Jul 05 2016 03:51
@GregatGit How to animated "search" icon miniature and "input " icon appears?
:)
You can see when click search icon.
Greg Duncan
@GregatGit
Jul 05 2016 03:55
@x981 you want a little search icon inside?
CruftMaster
@CruftMaster
Jul 05 2016 03:57
does anyone know a quick way to find all prime numbers before 977, this challenge is killing me
Joe Farah
@Kangiryanka
Jul 05 2016 04:01
@CruftMaster my friend said to me a while ago that the algorithm was quite tough
Greg Munker
@Gmunker
Jul 05 2016 04:01

That's a rough one, but i would maintain your patience, enjoy it. embrace it! The next challenge is sooooo much easier and so much more fun!!!!! :/ @CruftMaster (yes i'm a little bitter rofl).

as for the code, the best i can tell you without giving you the answer outright (i never do that) is use some loops to push everything then go through that and remove whats not needed.

and yes that was complete sarcasm about the next one...
CruftMaster
@CruftMaster
Jul 05 2016 04:02
@Kangiryanka its not as tough as it is tedious
Greg Munker
@Gmunker
Jul 05 2016 04:02
@Kangiryanka that is true thinking back on it
Joe Farah
@Kangiryanka
Jul 05 2016 04:02
@CruftMaster i'm doing the wherefore art thou one, and it's driving me nuts :/
Greg Munker
@Gmunker
Jul 05 2016 04:02
@CruftMaster I meant.
CruftMaster
@CruftMaster
Jul 05 2016 04:03
i have an if statement that is 3 lines long on this one lol probably going to be 4
Greg Munker
@Gmunker
Jul 05 2016 04:03
i'm on drop it, and i'm ready to throw my pc out the window
CruftMaster
@CruftMaster
Jul 05 2016 04:04
@Kangiryanka that one took me a while to finish
Greg Munker
@Gmunker
Jul 05 2016 04:04
@CruftMaster when you get it if you would like i'll show you how i did it to see another angle.
that is if i'm still awake, i'm crashing hard this one is actually draining everything from me
CruftMaster
@CruftMaster
Jul 05 2016 04:05
@Gmunker ok, sounds good
Joe Farah
@Kangiryanka
Jul 05 2016 04:07
@Gmunker @CruftMaster any pointers for the wherefore art thou challenge
Greg Munker
@Gmunker
Jul 05 2016 04:08
@Kangiryanka let me look at it again
x981
@x981
Jul 05 2016 04:09
@GregatGit No, sorry for bad English. When you clicked search icon, search icon will convert to "input" icon to input text want to search. I don't know how to make that.
Greg Munker
@Gmunker
Jul 05 2016 04:10
@Kangiryanka that is very weird when i click on "view solution" its taking me to my map
i'm looking at the challenge3 to see if i remember what i did
Greg Duncan
@GregatGit
Jul 05 2016 04:10
@x981 can you put a placeholder in?
x981
@x981
Jul 05 2016 04:14
No, Search icon ==> Input icon
How to make it
Greg Munker
@Gmunker
Jul 05 2016 04:14
@Kangiryanka I eventually looked for help on this one, i remember it now. But once i did i completely figured out what i was not seeing. I would recommend using a filter, and creating new arr with only the stuff you want returned.
best way to describe it without giving you the answer :)
Joe Farah
@Kangiryanka
Jul 05 2016 04:15
i'll try filter
cause i can't seem to figure it out with hasOwnProperty
Greg Munker
@Gmunker
Jul 05 2016 04:17
yea, basically just work on getting rid of everything thats not what you want within the filter function. essentially "process of elimination". Any which way you have to loop through everything at least this way it's only looping just once, instead of rechecking and rechecking etc.
Hope that helps!
Joe Farah
@Kangiryanka
Jul 05 2016 04:17
Thanks @Gmunker
CamperBot
@camperbot
Jul 05 2016 04:17
kangiryanka sends brownie points to @gmunker :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @gmunker |http://www.freecodecamp.com/gmunker
Greg Munker
@Gmunker
Jul 05 2016 04:19
Np always happy to help when i can
Emanuel Quimper
@EQuimper
Jul 05 2016 04:23
In Record Collection I don’t catch why this is not working

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

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

  if (value === '') {
    delete collection[id][prop]; // If the value is empty remove the prop
  } else if (prop === "tracks") {
    for (var p in collection[id]) { // Look if the prop inside the id have a tracks array
      if (collection[id][p] !== 'tracks') { // If not add a empty array
        collection[id].tracks = [];
      }
      collection[id].tracks.push(value);
    }
  } else {
    collection[id][prop] = value;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "Free");
Greg Duncan
@GregatGit
Jul 05 2016 04:26
@EQuimper i think this is wrong collection[id][p]
Emanuel Quimper
@EQuimper
Jul 05 2016 04:27
this is not the p comming from my for in loop ?
Jayrex Acilo
@ajayrexluega
Jul 05 2016 04:27
help Return Largest Numbers in Arrays
CamperBot
@camperbot
Jul 05 2016 04:27

:point_right: algorithm return largest numbers in arrays [wiki]

Algorithm Return largest Numbers in Arrays

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

:checkered_flag: Problem Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

:pencil: read more about algorithm return largest numbers in arrays on the FCC Wiki

bitgrower
@bitgrower
Jul 05 2016 04:28
@EQuimper -- which test case(s) don't work ?
Emanuel Quimper
@EQuimper
Jul 05 2016 04:28
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.
bitgrower
@bitgrower
Jul 05 2016 04:29
Also, @EQuimper you don't need a loop at all to solve this challenge ...
Emanuel Quimper
@EQuimper
Jul 05 2016 04:29
Yep but I like hard life :)
I already make it 3 month ago I just try to resolve it in a new way
but look like in the console the id 2468 get a empty array cause I just have the tracks free
bitgrower
@bitgrower
Jul 05 2016 04:30
well ... no need to use a loop if there's no need for one ... and FCC changed the problem anyway ...
because you are using a loop, you need to handle all the cases (that is, all the properties, or values p will take on) you are not handling p correctly when p = 'album' ...
bitgrower
@bitgrower
Jul 05 2016 04:35
when p = 'album' -- then you complete reset the value of the 'tracks' property ...
Jay
@jaylinsell
Jul 05 2016 04:43
function lookUpProfile(firstName, prop){
// Only change code below this line

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

  return "No such contact";
// Only change code above this line
}
Am I missing something? I've tried a few variations too with prop, ie. contacts[i].hasOwnProperty(prop) too, but I don't seem to be getting very far. It just keeps logging that there's "No such contact"
Will
@Will-is-Coding
Jul 05 2016 04:47
@Gmunker Need something?
bitgrower
@bitgrower
Jul 05 2016 04:48
@jaylinsell here's a thought experiment for you ... if I have 12 marbles in a bag, how many marbles do I have to look at before I know there are no black marbles in the bag ?
Jay
@jaylinsell
Jul 05 2016 04:52
All of them..?
Tad confused.. is my loop not looping through all of them?
bitgrower
@bitgrower
Jul 05 2016 04:57
no, it's not, Jay ...
oh wait ... I'm sorry -- I misread something ... sorry ...
let me look again ...
Emanuel Quimper
@EQuimper
Jul 05 2016 04:58
@bitgrower thank you this is what I got in the end. What you think about it ?

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

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

  if (value === '') {
    delete collection[id][prop]; // If the value is empty remove the prop
  } else if (prop !== "tracks") {
    collection[id][prop] = value;
  } else {
    if (!collection[id].hasOwnProperty('tracks')) {
      collection[id].tracks = [];
      collection[id].tracks.push(value);
    } else {
      collection[id].tracks.push(value);
    }
  }
  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "Free");
CamperBot
@camperbot
Jul 05 2016 04:58
equimper sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1129 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jul 05 2016 04:59
does it pass all the tests, @EQuimper ?
Emanuel Quimper
@EQuimper
Jul 05 2016 04:59
yes
Jayrex Acilo
@ajayrexluega
Jul 05 2016 05:01
Hi guys
Greg Duncan
@GregatGit
Jul 05 2016 05:01
@jaylinsellif (contacts[i].firstName === firstName)
Jayrex Acilo
@ajayrexluega
Jul 05 2016 05:02
can someone help me? I'm in the Basic Algorithm Scripting , Confirm the Ending exercise. I have problem when the str is in sentence

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor

  var newArr = [];
  newArr = str.split(' ');
  var j = newArr.length - 1;
  var last = newArr[j];
  if (last == target){
    return true;
  }else {
    return false;
  }



}

confirmEnding("Bastian", "n");
Greg Duncan
@GregatGit
Jul 05 2016 05:03
@jaylinsell you then should use hasOwnProperty
Jay
@jaylinsell
Jul 05 2016 05:04
Thanks a tonne! The contracts[i].firstName solved it. It worked without the hasOwnProperty though..?
function lookUpProfile(firstName, prop){
// Only change code below this line

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

  return "No such contact";
// Only change code above this line
}
ended up working.
Greg Duncan
@GregatGit
Jul 05 2016 05:05
@jaylinsell cool
@jaylinsell I used if (contacts[i].hasOwnProperty(prop)) but clearly works with yours
96street
@96street
Jul 05 2016 05:09
what does it mean by placeholder notification on the twitch challenge?
User Story: I will see a placeholder notification if a streamer has closed their Twitch account (or the account never existed).
Joseph
@revisualize
Jul 05 2016 05:16

@ajayrexluega This

  if (last == target){
    return true;
  }else {
    return false;
  }

is redundant. And you should just do the

return last == target;
fengzimu
@fengzimu
Jul 05 2016 05:26
Hello,everybody!I want to know what "return undefined" means?
pls
Markus Kiili
@Masd925
Jul 05 2016 05:27
@fengzimu undefined is a value in JS of type undefined. It is usually assigned by the engine to declared variables and returned if you access non-existent property values.
Aza Noriega
@MegaGM
Jul 05 2016 05:27
it returns undefined
Jayrex Acilo
@ajayrexluega
Jul 05 2016 05:28
@revisualize thanks, but same results. I want to pass this challenge. Are you done with Confirm the Ending in Basic Algorithm Scripting?
CamperBot
@camperbot
Jul 05 2016 05:28
ajayrexluega sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1370 | @revisualize |http://www.freecodecamp.com/revisualize
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:28
Need help in Java-Script
CamperBot
@camperbot
Jul 05 2016 05:28
no wiki entry for: in java-script
Jayrex Acilo
@ajayrexluega
Jul 05 2016 05:29
@revisualize btw in my code i don't have substr method. I don't how to use it
fengzimu
@fengzimu
Jul 05 2016 05:29
think you ! I have got the meaning
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:29
i am confuse in Condense arrays with reduce challenge

var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

singleVal = array.reduce(function(4, 5) {
  return 4 - 5;
}, 0;
var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal - currentVal;
}, 0);
please where am i wrong
Leonid S. Knyshov
@wiseleo
Jul 05 2016 05:32
@abhishekdevinfo You posted a line with singleVal twice. Is the bottom code replacement for the line in top code?
Jayrex Acilo
@ajayrexluega
Jul 05 2016 05:33
help Confirm the Ending
CamperBot
@camperbot
Jul 05 2016 05:33

:point_right: algorithm confirm the ending [wiki]

Algorithm Confirm the Ending

:checkered_flag: Problem Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the confirmEnding('Bastian', 'n'); case.

Relevant Links

:pencil: read more about algorithm confirm the ending on the FCC Wiki

Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:36
@wiseleo i want to use reduce in array, but i have no idea how to use reduce
Aza Noriega
@MegaGM
Jul 05 2016 05:36
@abhishekdevinfo array.reduce() takes in a function that accepts variables, not literals
Will
@Will-is-Coding
Jul 05 2016 05:36
@abhishekdevinfo Are you sure it's not supposed to be currentVal - previousVal?
Aza Noriega
@MegaGM
Jul 05 2016 05:37
actually it accepts not a previousVal but (total, currentVal)
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:37
@Will-is-Coding ya i am sure the challenge shows me an example
Will
@Will-is-Coding
Jul 05 2016 05:37
Ok
Aza Noriega
@MegaGM
Jul 05 2016 05:37
@abhishekdevinfo gimme a link to challenge please
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:37
var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal - currentVal;
}, 0);
this is the example
Aza Noriega
@MegaGM
Jul 05 2016 05:38
@abhishekdevinfo do you want to get sum of all elements in array or what? I don't know what do you want to do
Leonid S. Knyshov
@wiseleo
Jul 05 2016 05:39
@abhishekdevinfo If you want a sum, substraction does not make sense, right>
Will
@Will-is-Coding
Jul 05 2016 05:39
@abhishekdevinfo It wants you to add them
Aza Noriega
@MegaGM
Jul 05 2016 05:39
@abhishekdevinfo okay, just change minus to plus
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:40
@MegaGM yes i want to sum all the array values and assign to singleVal
kuldeep
@gurukd
Jul 05 2016 05:40
function convertHTML(str) {
  // &colon;&rpar;
  var RegEx = ["&","'","<",">",'"'];
  var patt;
  var convertedForm;
  for(var i=0; i<str.length; i++){
   patt = RegEx.indexOf(str.charAt(i));
   var Rg = new RegExp(RegEx[patt],'g');
   switch(RegEx[patt]){
     case "&":
       convertedForm = str.replace(Rg, "&amp;");
       break;
     case "'":
       convertedForm = str.replace(Rg, "&apos;");
       break;
     case '"':
       convertedForm = str.replace(Rg, "&quot;");
       break;
     case ">":
       convertedForm = str.replace(Rg, "&gt;");
       break;
     case "<":
       convertedForm = str.replace(Rg, "&lt;");
       break;
   }
  }
  return convertedForm;

}
convertHTML("<>")
My last function call is not giving me the right sol. what is wrong ? convertHTML("<>")
AnyOne
96street
@96street
Jul 05 2016 05:42
can someone tell me why .text() isn't working here?
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:43
@wiseleo sorry my mistake i changed - to + but still error bcoz i dont now what value i have to put in the place of previousVal and currentVal for sum all the values in array
kirbyedy
@kirbyedy
Jul 05 2016 05:46
@96street your console says: Uncaught TypeError: channels[channel].text is not a function
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:47
@MegaGM @Will-is-Coding @wiseleo thanks guys i got this
there is an error in the example i dont know why they put 0 in the code
CamperBot
@camperbot
Jul 05 2016 05:47
abhishekdevinfo sends brownie points to @megagm and @will-is-coding and @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @wiseleo |http://www.freecodecamp.com/wiseleo
:cookie: 226 | @megagm |http://www.freecodecamp.com/megagm
:cookie: 447 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
96street
@96street
Jul 05 2016 05:47
yeah isn't text() supposed to convert the variable to text? @kirbyedy
Markus Kiili
@Masd925
Jul 05 2016 05:48
@abhishekdevinfo 0 in the reduce code is an initial value for reduce running value.
greg
@wearenotgroot
Jul 05 2016 05:48
@96street i dont think there is a method .text() for arrays
DJ
@qualitymanifest
Jul 05 2016 05:48
no. text() can either get the text of an html element or it can assign the text of an html element
96street
@96street
Jul 05 2016 05:48
how else do you do it?
.html(channels[channel])
?
DJ
@qualitymanifest
Jul 05 2016 05:50
@96street what you have will work if you just remove the .text() from channels[channel]
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:50
@Masd925 ok
Markus Kiili
@Masd925
Jul 05 2016 05:51
@abhishekdevinfo If you omit the initial running value, reduce will take the first element as the first running value.
DJ
@qualitymanifest
Jul 05 2016 05:51
@96street when you do that you will get MedryBW for each one. the reason for that is that your ajax call is asynchronous and your for loop finishes before the ajax call is ready so you only get a URL with the last element in the array - which is medryBW
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 05:52
@Masd925 ok thanks for this info
CamperBot
@camperbot
Jul 05 2016 05:52
abhishekdevinfo sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2040 | @masd925 |http://www.freecodecamp.com/masd925
96street
@96street
Jul 05 2016 05:53
how does the for loop finish before the ajax call is ready? the ajax call is nested inside so it should be executed each time an object in the channels array iterates
@qualitymanifest
greg
@wearenotgroot
Jul 05 2016 05:54
@96street read about asynchronous functions
Ivan Aganin
@criativ
Jul 05 2016 05:54
@96street there is a way to "controll" it
Aza Noriega
@MegaGM
Jul 05 2016 05:55
@96street channels[channel] is not a jQuery element, it's a simple string.
Joseph
@revisualize
Jul 05 2016 05:55
@ajayrexluega Re-confirm the ending.. I'm not sure why you have so much code. And why you aren't just using String.prototype.substr() like the instructions suggest. It was just one return statement for me.
Ivan Aganin
@criativ
Jul 05 2016 05:55
but in my opinion when you try to controll the async code it becomes a SYNC code :)
96street
@96street
Jul 05 2016 05:55
i don't know how this is asynchronous though, as the ajax is nested inside @wearenotgroot
Joseph
@revisualize
Jul 05 2016 05:56

@ajayrexluega
The substr() method returns the characters in a string beginning at the specified location through the specified number of characters.

Syntax
str.substr(start[, length])
Parameters

start
Location at which to begin extracting characters. If a negative number is given, it is treated as strLength + start where strLength is the length of the string (for example, if start is -3 it is treated as strLength - 3.)

length
Optional. The number of characters to extract.

Markus Kiili
@Masd925
Jul 05 2016 05:56
@96street You bind functions to ajax calls and then your code finishes. Those callback functions run when the responses come.
greg
@wearenotgroot
Jul 05 2016 05:57
Joseph
@revisualize
Jul 05 2016 05:57
@ajayrexluega
var str = 'abcdefghij';
console.log('(-3): '     + str.substr(-3));     // '(-3): hij'
@ajayrexluega In fact, the instructions CLEARLY state to use one of the substring methods.
96street
@96street
Jul 05 2016 06:02
@Masd925 how would I go about this then? to append a different name to each <a>
Joe Farah
@Kangiryanka
Jul 05 2016 06:04
any1 did the wherefore art thou challenge
Vikash Saini
@Enigma10
Jul 05 2016 06:07
about @abhishekdevinfo
CamperBot
@camperbot
Jul 05 2016 06:07
:cookie: 248 | @abhishekdevinfo |http://www.freecodecamp.com/abhishekdevinfo
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 06:08
@Enigma10 Hello
This message was deleted
CamperBot
@camperbot
Jul 05 2016 06:12
abhishekdevinfo sends brownie points to @enigma10 :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @enigma10 |http://www.freecodecamp.com/enigma10
Markus Kiili
@Masd925
Jul 05 2016 06:25
@Kangiryanka Yes.
Chaitya Shah
@Chaitya62
Jul 05 2016 06:41
Hey guys
Any one here familiar with scrollr?
Nhan Nguyen
@nhannh23
Jul 05 2016 07:10
Hello all
Markus Kiili
@Masd925
Jul 05 2016 07:13
@nhannh23 Hi.
Nhan Nguyen
@nhannh23
Jul 05 2016 07:17
@Masd925 Hi, LOL gamer confirmed
96street
@96street
Jul 05 2016 07:29
Is there a callback function here? http://codepen.io/kingdezz/pen/zBzBaZ?editors=1010
Ivan Aganin
@criativ
Jul 05 2016 07:32
@96street kind of :)
The part before and about .ajax
I'm doing the same thing right now :)
The Twitch API works a little bit different
Puvendran Pillay
@puven12
Jul 05 2016 07:33
is an alternative to cloud9 because i wanna do it in my local machine
Ivan Aganin
@criativ
Jul 05 2016 07:34
Instead of giving you a callback, you must "check" each of "Twitch streamers" channels are they online or not...
@96street I hope it makes sense to you?
Nhan Nguyen
@nhannh23
Jul 05 2016 07:36
Guys, just want to ask, are your returning twitch streamer status? For what?
Markus Kiili
@Masd925
Jul 05 2016 07:39
@96street There are two callback functions there. The whole thing inside $(document).ready(...) and also the ajax success success: ...
Ivan Aganin
@criativ
Jul 05 2016 07:44
people LOVE the JQuery... but have no idea what is going on... that's why I stay away from it...
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 07:46
hi to all members
need an advice on reverse a string algo
i write two function they result the same but i want to know which one is better

function reverseString(str) {
  var arr = [];
  arr = str.split('');
  var newArr = [];
  for (var i = 0; i < (arr.length); i++) {
    newArr.unshift(arr[i]);
  }
  str = newArr.join('');
  return str;
}

reverseString("hello");

function reverseString(str) {
  var arr = [];
  arr = str.split('');
  var newArr = [];
  for (var i = (arr.length - 1); i >= 0; i--) {
    newArr.push(arr[i]);
  }
  str = newArr.join('');
  return str;
}

reverseString("hello");
Will
@Will-is-Coding
Jul 05 2016 07:49
@abhishekdevinfo Those both work, but look into this documentation
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 07:49
any advice will be helpful for me
@Will-is-Coding ok give a sec
Nhan Nguyen
@nhannh23
Jul 05 2016 07:50
Both work, but you can do like this "123".split('').reverse().join('');
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 07:51
@nhannh23 OMG is that really possible
Markus Kiili
@Masd925
Jul 05 2016 07:51
@abhishekdevinfo You don't need arrays there:
function reverseString(str) {
  var result = "";
  var len = str.length;
  for (var i=0;i<len;i++) {
    result += str.charAt(len-1-i);
  }
  return result;
}
Nhan Nguyen
@nhannh23
Jul 05 2016 07:51
@abhishekdevinfo just try in console
Will
@Will-is-Coding
Jul 05 2016 07:52
@nhannh23 Is the best way without reinventing the wheel.
Magnus Holm
@mghlm
Jul 05 2016 07:52
What’s wrong with my search function? Thanks
var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: 1234567890,
        address: ["123 Microsoft Rd. blabla"]
        },
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: 0987654321,
        address: ["321 Apple Blvd. blablabla"]
        }
}
var list = function(contacts) {
    for(var friends in contacts) {
        console.log(friends);
        }
}

var search = function(name) {
    for(var search in friends) {
        if(friends[search].firstName === "name") {
            console.log(friends[search]);
        }
        else {
            console.log("No matches");
        }
    }
}
Markus Kiili
@Masd925
Jul 05 2016 07:52
@abhishekdevinfo Using array methods is still simplest (somewhat slower though).
Eswar Kiran
@eswarkiran
Jul 05 2016 07:52
Both does take same time it's just a increment and decrement used in two different ways
Will
@Will-is-Coding
Jul 05 2016 07:53
@m4gnusholm You're saying for(var search in friends) but search will be a friend inside friends
So you just need search.firstName
Eswar Kiran
@eswarkiran
Jul 05 2016 07:53
@abhishekdevinfo Both does take same time it's just a increment and decrement used in two different way
Will
@Will-is-Coding
Jul 05 2016 07:53
So maybe rename search to friend ( the variable not the function )
Magnus Holm
@mghlm
Jul 05 2016 07:54
@Will-is-Coding ohh.. so it doesn’t matter what i rename it to?
the var
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 07:54
@Will-is-Coding @nhannh23 @Masd925 thanks guys this help is really awsome. carryon
CamperBot
@camperbot
Jul 05 2016 07:54
abhishekdevinfo sends brownie points to @will-is-coding and @nhannh23 and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for nhannh23
:star2: 2042 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 448 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Will
@Will-is-Coding
Jul 05 2016 07:55
@m4gnusholm You're also checking if their firstName is name which there are none named name
@m4gnusholm Nope, name it whatever you please
Eswar Kiran
@eswarkiran
Jul 05 2016 07:55
@abhishekdevinfo and also no need to use array you can directly take string but in case of C you must take array and assign the length of the array before given any value or char to array
Magnus Holm
@mghlm
Jul 05 2016 07:55
@Will-is-Coding i thought i was checking if their firstName match the parameter (name) that I search for?
Will
@Will-is-Coding
Jul 05 2016 07:56
Its the equivalent of for( var i = 0; i < friends.length; i++ ) { friends[i].someProperty; }
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 07:56
@eswarkiran ok thanks
CamperBot
@camperbot
Jul 05 2016 07:56
abhishekdevinfo sends brownie points to @eswarkiran :sparkles: :thumbsup: :sparkles:
:cookie: 9 | @eswarkiran |http://www.freecodecamp.com/eswarkiran
Will
@Will-is-Coding
Jul 05 2016 07:56
@m4gnusholm Then you would remove the quotes around "name" as that is a literal string, not the variable/parameter sent in
Nhan Nguyen
@nhannh23
Jul 05 2016 07:56
@m4gnusholm change you IF to => if (search.firstName === name)
Magnus Holm
@mghlm
Jul 05 2016 07:57
@Will-is-Coding sure, of course.
Will
@Will-is-Coding
Jul 05 2016 07:57
^ as @nhannh23 said
Magnus Holm
@mghlm
Jul 05 2016 07:58
@nhannh23 ok, if i do that it still says no matches if i seach for “Bill"
Will
@Will-is-Coding
Jul 05 2016 07:58
Show us the search function again
Magnus Holm
@mghlm
Jul 05 2016 07:58
if I put search("Bill");
var search = function(name) {
    for(var i in friends) {
        if(search.firstName === name) {
            console.log(friends[search]);
        }
        else {
            console.log("No matches");
        }
    }
}

search("Bill");
Eswar Kiran
@eswarkiran
Jul 05 2016 07:59
@abhishekdevinfo you're welcome
Nhan Nguyen
@nhannh23
Jul 05 2016 07:59
@m4gnusholm oops, give the FOR statement back => for (var search in friends)
Will
@Will-is-Coding
Jul 05 2016 08:00
@m4gnusholm Not quite. search is the name of your function. What for(var i in friends) means is for( var element in array) { console.log('This is an element in my array ' + element); }
Magnus Holm
@mghlm
Jul 05 2016 08:00
@nhannh23 but will said…..
Will
@Will-is-Coding
Jul 05 2016 08:00
I was telling you the equivalent of what for(var i in array) was
Since you misunderstood
Magnus Holm
@mghlm
Jul 05 2016 08:01
damn.. i don’t understand it :(
Will
@Will-is-Coding
Jul 05 2016 08:02
for( var i = 0; i < arr.length; i++ ) {
   console.log(arr[i]);
}
for( var element in arr ) {
    console.log(element);
}
Both print the same thing
Magnus Holm
@mghlm
Jul 05 2016 08:02
oh
Markus Kiili
@Masd925
Jul 05 2016 08:03
@m4gnusholm Try returning the result instead of console.log and put returning "No matches" after the loop.
Magnus Holm
@mghlm
Jul 05 2016 08:03
@Masd925 the assignment says to log it
Markus Kiili
@Masd925
Jul 05 2016 08:03
@m4gnusholm ok
Magnus Holm
@mghlm
Jul 05 2016 08:05
i still don’t understand why it doesn’t work..
var search = function(name) {
    for(var search in friends) {
        if(search.firstName === name) {
            console.log(friends[search]);
        }
        else {
            console.log("No matches");
        }
    }
}

search("Bill");
shouldn’t this work??
Zelite
@zelite
Jul 05 2016 08:06
@m4gnusholm what do you expect this line does: if(search.firstName === name) ?
Will
@Will-is-Coding
Jul 05 2016 08:06
Not quite
Look at what you're returning/logging
Magnus Holm
@mghlm
Jul 05 2016 08:07
@zelite hmm.. print the result if there’s a match?
Zelite
@zelite
Jul 05 2016 08:08
@m4gnusholm ah.. ok, i was confused by the var search and the fact that the function was called search
Will
@Will-is-Coding
Jul 05 2016 08:08
Yes it is confusing, should rename it friend
for( var friend in friends ) reads a lot easier than confusing it with the function name
Magnus Holm
@mghlm
Jul 05 2016 08:09
ok sure, i thought it was supposed to be the same. gonna change it
how about this
var search = function(name) {
    for(var friend in friends) {
        if(friends[friend].firstName === name) {
            console.log(friends[friend]);
        }
        else {
            console.log("No matches");
        }
    }
}

search("Bill");
Will
@Will-is-Coding
Jul 05 2016 08:10
It can be whatever you like it to be, but the clearer the better
friend is not an index number @m4gnusholm It is one of the objects inside of friends
Magnus Holm
@mghlm
Jul 05 2016 08:11
god damnit
Will
@Will-is-Coding
Jul 05 2016 08:12
I'm sure we're not explaining too well, sorry. I should be heading to bed shortly
Zelite
@zelite
Jul 05 2016 08:13
@m4gnusholm what's the name of the challenge you're working on? I want to find it in my map
Magnus Holm
@mghlm
Jul 05 2016 08:13
no no, i’m sure it’s just me who’s having a hard time understanding
Markus Kiili
@Masd925
Jul 05 2016 08:13
@Will-is-Coding friend is one of the property keys for which the property value is an object.
Will
@Will-is-Coding
Jul 05 2016 08:13
@Masd925 No, it is an object inside of the friends array
Magnus Holm
@mghlm
Jul 05 2016 08:13
@zelite actually it’s a codecademy task - i just got completely stuck in fcc and had to try something else.
Markus Kiili
@Masd925
Jul 05 2016 08:14
@Will-is-Coding friends is an object, not an array.
Will
@Will-is-Coding
Jul 05 2016 08:14
@Masd925 Oh I saw square brackets, not curly
Zelite
@zelite
Jul 05 2016 08:15
@m4gnusholm the contact list project?
Magnus Holm
@mghlm
Jul 05 2016 08:15
yep
Will
@Will-is-Coding
Jul 05 2016 08:15
Then yes they are property keys. But that's a bit odd to have it a large object, not an array, but eh
Magnus Holm
@mghlm
Jul 05 2016 08:15
7/8 “Search for a friend"
@zelite
Zelite
@zelite
Jul 05 2016 08:16
Does the function log the correct name? @m4gnusholm
maybe you're missing this part of the instructions "it should log that friend's contact information to the console and return it."
Will
@Will-is-Coding
Jul 05 2016 08:17
Alright let @Masd925 guide you now, clearly too tired and dumb to help anymore heh
Magnus Holm
@mghlm
Jul 05 2016 08:17
@zelite It looks like this:
var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: 1234567890,
        address: ["123 Microsoft Rd. blabla"]
        },
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: 0987654321,
        address: ["321 Apple Blvd. blablabla"]
        }
}
var list = function(contacts) {
    for(var friends in contacts) {
        console.log(friends);
        }
}

var search = function(name) {
    for(var friend in friends) {
        if(friend.firstName === name) {
            console.log(friend);
        }
        else {
            console.log("No matches");
        }
    }
}

search("Bill");
@Will-is-Coding Well thanks a lot for helping anyway
CamperBot
@camperbot
Jul 05 2016 08:18
m4gnusholm sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 449 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Nhan Nguyen
@nhannh23
Jul 05 2016 08:18
then the Search function shouldn't be like that
Casey Heath
@ExhibitArts
Jul 05 2016 08:18
Could you guys tell me what you think of this logo I made? - https://www.youtube.com/watch?v=bGkpNKaczqo
Zelite
@zelite
Jul 05 2016 08:18
I have very similar code on mine:
var search = function(name){
    for (var key in friends){
        if (friends[key].firstName === name){
            console.log(friends[key]);
            return friends[key];
        }
}
}
Markus Kiili
@Masd925
Jul 05 2016 08:18
@m4gnusholm console.log("No matches"); belongs after the loop.
Zelite
@zelite
Jul 05 2016 08:19
@m4gnusholm Note that I'm making console.log and return. Both are part of the specification
Nhan Nguyen
@nhannh23
Jul 05 2016 08:19
@m4gnusholm can you give this function a try?
function search (name) { if (friends[name]) console.log(friends[name]); else console.log('not match'); }
sorry for wrong markdown
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:21
one more advice please
Zelite
@zelite
Jul 05 2016 08:21
@m4gnusholm And, as @Masd925 mentioned, the console.log("No matches"); should be out of the loop. Only after you checked all the contacts, you can know that there are no matches. as it stands then you say "no matches" after every check of name.
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:21
in Factorialize a Number
Magnus Holm
@mghlm
Jul 05 2016 08:21
ok gonna try
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:21

function factorialize(num) {
  var total = 1;
  for(var i = 1; i <= num; i++) {
    total *= i;
  }
  num = total;
  return num;
}

factorialize(5);
this is correct
but
var total = 1;
function fac(num) {
     total *= num;
     var count = num--;
     fac(count);
}
whats wrong with this
Zelite
@zelite
Jul 05 2016 08:24
@abhishekdevinfo on the last example you're using a global variable ( total ) to store the result. So, your function does not return any value, it puts it on the global variable instead. Second, you have no stop condition. fac(count) is always called after every time you decrease count. But you never stop decreasing count
so you'll go into a infinite loop
Devan
@devanfarrell
Jul 05 2016 08:25
So I’m working on the seek and destroy algorithm and my code works properly and gets the proper answers but code camp won’t accept them and I can’t figure out why…
function triggerMan(value){
  return value !== this;
}
function destroyer(arr) {
  var filteredArr = [];
  for(i = 1; i < arguments.length; i++){
    arr = arr.filter(triggerMan, arguments[i]);
  }
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I’ve run completely out of ideas...
Markus Kiili
@Masd925
Jul 05 2016 08:25
@devanfarrell Try != inside callback.
Magnus Holm
@mghlm
Jul 05 2016 08:25
@nhannh23 @zelite @Masd925 Ok, i put the no match out of the loop. but now it says unexpected end of input
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:25
@zelite ok thanks i am correcting it give me a min
CamperBot
@camperbot
Jul 05 2016 08:25
abhishekdevinfo sends brownie points to @zelite :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @zelite |http://www.freecodecamp.com/zelite
Devan
@devanfarrell
Jul 05 2016 08:26
@Masd925 It worked! WHY?!?!?!?!
@Masd925 Thank you by the way
CamperBot
@camperbot
Jul 05 2016 08:26
devanfarrell sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2043 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 05 2016 08:26
@devanfarrell The value of this is coerced to an (Number) object, and value is a number primitive.
Zelite
@zelite
Jul 05 2016 08:26
@m4gnusholm check your parentesis. sound likes you're forgetting to close something, or have a closing parentesis on the wrong place
Markus Kiili
@Masd925
Jul 05 2016 08:27
@devanfarrell It would be better to filter only once and put the loop inside the callback. You can pass arguments as value of this so there are no coercion problems.
Devan
@devanfarrell
Jul 05 2016 08:29
@Masd925 That probably would have been easier. I got slightly obsessed with why it wasn’t working haha.
Magnus Holm
@mghlm
Jul 05 2016 08:29
@zelite I feel like this should be right though?
var search = function(name) {
    for(var friend in friends) {
        if(friends[friend].firstName === name) {
            console.log(friends[friend]);
        }
    }
    else {
        console.log("no match");
    }
}
Zelite
@zelite
Jul 05 2016 08:30
@m4gnusholm what is the message you get when you submit that code?
Magnus Holm
@mghlm
Jul 05 2016 08:30
unexpected token else
syntaxError
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:30
@zelite i think i sort out my 2nd problem but i have no idea how to solve the 1st
var total = 1;
function fac(num) {
     total *= num;
     var count = 0;
     if(num !== 0) {
          count = num--;
         fac(count);
     }

}
Markus Kiili
@Masd925
Jul 05 2016 08:30
@devanfarrell You can also turn the arguments object into an array and use indexOf if you like. Even magic like this works:
function destroyer(arr) {
  return arr.filter(function(val) {
    return Array.prototype.indexOf.call(this,val,1)===-1;
  },arguments);
}
Magnus Holm
@mghlm
Jul 05 2016 08:30
haha
i think this assignment is too hard
Devan
@devanfarrell
Jul 05 2016 08:32
@Masd925 Coming from c and c++ this stuff is insanity. I feel like I have to start thinking a completely different way to do some of this things.
Zelite
@zelite
Jul 05 2016 08:32
@m4gnusholm
var search = function(name) {
    for(var friend in friends) {
        if(friends[friend].firstName === name) {
            console.log(friends[friend]);
        }
    }

        console.log("no match");

}
that should make the error go away. you had a else, after the for loop. That is a syntax error. However, you're still missing to return the friends[friend]
The instructions say " it should log that friend's contact information to the console and return it."
Markus Kiili
@Masd925
Jul 05 2016 08:33
@devanfarrell Yes, using functions as control flow needs different mindset.
Nhan Nguyen
@nhannh23
Jul 05 2016 08:34
@zelite is right, should work
Magnus Holm
@mghlm
Jul 05 2016 08:35
@zelite yeaarrhhh it works it works
@zelite thanks man
CamperBot
@camperbot
Jul 05 2016 08:35
m4gnusholm sends brownie points to @zelite :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @zelite |http://www.freecodecamp.com/zelite
Nhan Nguyen
@nhannh23
Jul 05 2016 08:35
I think there should be a return in if, otherwise you always have log no match even you have that name in friends
Magnus Holm
@mghlm
Jul 05 2016 08:35
@zelite one more questions: why didn’t i have to put else?
Nhan Nguyen
@nhannh23
Jul 05 2016 08:37
@m4gnusholm syntax error, FOR statement doesn't have else
Magnus Holm
@mghlm
Jul 05 2016 08:38
@zelite btw. this assignment was way too hard for me to understand. i just started learning to code three weeks ago, have just done javascript for a week or so. do you think this is something an ultra beginner should know?
@nhannh23 oh ok, didn’t know
@nhannh23 thanks for your help!
CamperBot
@camperbot
Jul 05 2016 08:38
m4gnusholm sends brownie points to @nhannh23 :sparkles: :thumbsup: :sparkles:
:cookie: 3 | @nhannh23 |http://www.freecodecamp.com/nhannh23
Donovan
@dnvn999
Jul 05 2016 08:40
Hi guys, I would like to ask why cant we include var i = 0 and i++ into while loop?
Markus Kiili
@Masd925
Jul 05 2016 08:41
@dnvn999 You can.
redixhumayun
@redixhumayun
Jul 05 2016 08:41

Hey, I'm having some trouble with the Make A Person challenge. I am very confused by what they mean when they say, "Fill in the object constructor with the following methods below:
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
setFullName(firstAndLast)"

What do they mean by fill it with the methods? Do I make separate functions with each of those names and then invoke them using a method call? Any help will be appreciated.

Markus Kiili
@Masd925
Jul 05 2016 08:41
@dnvn999 You can do any for with while and vice versa.
Donovan
@dnvn999
Jul 05 2016 08:42
I see, can you explain why we dont for challenge - chunky monkey?
Sayed Afif
@sayedafif
Jul 05 2016 08:43

can someone help me with Wherefore art thou challenge?

For example, if the first argument is [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], and the second argument is { last: "Capulet" }, then you must return the third object from the array (the first argument), because it contains the property and its value, that was passed on as the second argument.

can someone give the code by using- for (in)

Markus Kiili
@Masd925
Jul 05 2016 08:43
@dnvn999 For goes well with slice that doesn't mutate the array and mess up indices. If you use while, you just chop off pieces of arr and don't iterate arr indices.
@sayedafif You have to loop or iterate collection and then source keys.
Donovan
@dnvn999
Jul 05 2016 08:46
@Masd925 difference between for and while loop?
Sayed Afif
@sayedafif
Jul 05 2016 08:47

@Masd925
``` function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var a= Object.keys(source);
var text = "";
var x;
for (x in collection){
for(a in source){
if(collection[x][a]===source[a]){
arr.push(collection[x]);
}
}
}
return arr;
// Only change code above this line

} ```

Markus Kiili
@Masd925
Jul 05 2016 08:47
@dnvn999 The logic of for loop is hidden (you have to remember what the three parts of for loop definition are). With while loop the logic is seen on the code. Therefore for loop suits only very simple logic (incrementing some index and some simple condition).
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:48
This message was deleted
Markus Kiili
@Masd925
Jul 05 2016 08:48
@sayedafif The property values need to match for all the source keys before you push.
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:49
var total = 1;
function fac(num) {
     total *= num;
     var count = 0;
     if(num !== 0) {
          count = num--;
          fac(count);
     }
     return total;

}
Markus Kiili
@Masd925
Jul 05 2016 08:50
@sayedafif Also for...in loop is not meant for iterating array indices.
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:50
this code give the an error
Donovan
@dnvn999
Jul 05 2016 08:50
@Masd925 Thanks, I finally get the git of using while loop for that challenge. :D
CamperBot
@camperbot
Jul 05 2016 08:50
dnvn999 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2044 | @masd925 |http://www.freecodecamp.com/masd925
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 08:50
fac(5);
VM2352:2 Uncaught RangeError: Maximum call stack size exceeded
Markus Kiili
@Masd925
Jul 05 2016 08:55
@abhishekdevinfo =num-- assigns before decrementing -> infinite recursion
Abhishek Baliyan
@abhishekdevinfo
Jul 05 2016 09:04
@Masd925 the console still give me the same error when i call it
Anon3333
@Anon3333
Jul 05 2016 09:12

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

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

var myCar = new Car();

var myBike = new Bike();
what's wrong with this
Magnus Holm
@mghlm
Jul 05 2016 09:15
I guess I have a problem with my curly brackets, can anyone tell me where?
for(var count = 1; count < 21; count++) {

    if(count % 3) {
        console.log("Fizz"); 

    if else(count % 5) {
        console.log("Bizz"); 

    if else(count % 3 && 5) {
        console.log("FizzBizz");
        }
    }

else {
        console.log(count);
    }
}
Jason Keenan
@raavin
Jul 05 2016 09:15
@m4gnusholm two curly brackets after the if and first if else
bradulz
@bradulz
Jul 05 2016 09:15
@m4gnusholm the first if must have a closing bracket before the if else
Magnus Holm
@mghlm
Jul 05 2016 09:16
@bradulz ohh
Devan
@devanfarrell
Jul 05 2016 09:16
@Masd925 So, follow up question on that coersion error I was experiencing earlier with the seek and destroy assignment. That return should just be returning a boolian variable. Was it just not letting me complete the assignment simply because I had that coersion error in my code or was there more to it than that?
bradulz
@bradulz
Jul 05 2016 09:16
@m4gnusholm the second one too
 if(count % 3) {
        console.log("Fizz"); 
}
    if else(count % 5) {
        console.log("Bizz"); 
}

also if a statement after an if statement if just one line, you dont need curly braces at all

 if(count % 3) 
        console.log("Fizz"); 

    if else(count % 5) 
        console.log("Bizz");

will also work

Magnus Holm
@mghlm
Jul 05 2016 09:18
now it looks like this and still doesn’t work
for(var count = 1; count < 21; count++) {

    if(count % 3) {
        console.log("Fizz"); 
    }

    if else(count % 5) {
        console.log("Bizz"); 
    }

    if else(count % 3 && 5) {
        console.log("FizzBizz");
        }
    }

else {
        console.log(count);
    }
}
Jason Keenan
@raavin
Jul 05 2016 09:18
@m4gnusholm should be else if
Magnus Holm
@mghlm
Jul 05 2016 09:18
@raavin ohh yeah
Sayed Afif
@sayedafif
Jul 05 2016 09:18
@m4gnusholm else if. not if else
Jason Keenan
@raavin
Jul 05 2016 09:18
@m4gnusholm not if else :)
bradulz
@bradulz
Jul 05 2016 09:19
@m4gnusholm the curly brace before else doesnt need to be there
Magnus Holm
@mghlm
Jul 05 2016 09:19
@raavin @sayedafif @bradulz ok, thank you !!
CamperBot
@camperbot
Jul 05 2016 09:19
m4gnusholm sends brownie points to @raavin and @sayedafif and @bradulz :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @sayedafif |http://www.freecodecamp.com/sayedafif
:cookie: 288 | @bradulz |http://www.freecodecamp.com/bradulz
:cookie: 440 | @raavin |http://www.freecodecamp.com/raavin
Jason Keenan
@raavin
Jul 05 2016 09:19
@m4gnusholm Try indenting properly and you'll get less lost
Magnus Holm
@mghlm
Jul 05 2016 09:20
@raavin do you mean use the tab key?
bradulz
@bradulz
Jul 05 2016 09:21
@m4gnusholm yes
Magnus Holm
@mghlm
Jul 05 2016 09:22
do you guys know of a course that teaches you to do that?
or, i guess it makes sense how..
i’ll try
Devan
@devanfarrell
Jul 05 2016 09:22
@m4gnusholm Khan acadamy has a quick little video I think.
Jason Keenan
@raavin
Jul 05 2016 09:22
@m4gnusholm Yeah, the closing brace should align with the opening 'if', the final brace with the 'for' with the inside statements indented one 'tab' further on the the enclosing statement etc.
Magnus Holm
@mghlm
Jul 05 2016 09:23
@devanfarrell cool, i’ll check it out
Magnus Holm
@mghlm
Jul 05 2016 09:24
@devanfarrell thank you
CamperBot
@camperbot
Jul 05 2016 09:24
m4gnusholm sends brownie points to @devanfarrell :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @devanfarrell |http://www.freecodecamp.com/devanfarrell
bradulz
@bradulz
Jul 05 2016 09:24
anyone know what /(\w).*\1/i this regexp means?
Magnus Holm
@mghlm
Jul 05 2016 09:24
@raavin Thank you
CamperBot
@camperbot
Jul 05 2016 09:24
m4gnusholm sends brownie points to @raavin :sparkles: :thumbsup: :sparkles:
:warning: m4gnusholm already gave raavin points
Devan
@devanfarrell
Jul 05 2016 09:25
@m4gnusholm The videos are designed for all ages so try not to be offended if they sound a bit condisending.
Vipul Basapati
@bvipul
Jul 05 2016 09:25
I dont undersatnd the Record Collection problem. can someone explain it to me
Magnus Holm
@mghlm
Jul 05 2016 09:25
@devanfarrell oh, i won’t. the more explaining the better :)
Brendan Kinahan
@BKinahan
Jul 05 2016 09:26
@bradulz "match any word-character ([a-zA-Z0-9_]), followed by zero or more of any character, followed by the first-matched word-character again. don't worry about case, find only the first match."
Magnus Holm
@mghlm
Jul 05 2016 09:27
If I want to say “if X is both divisible by 3 AND 5” can I write it like this:
(count % 3 && 5 === 0)
X is count
bradulz
@bradulz
Jul 05 2016 09:28
@BKinahan thanks, thats explained alot clearer than some websites
CamperBot
@camperbot
Jul 05 2016 09:28
bradulz sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1912 | @bkinahan |http://www.freecodecamp.com/bkinahan
Eswar Kiran
@eswarkiran
Jul 05 2016 09:28
This message was deleted
Devan
@devanfarrell
Jul 05 2016 09:28
@m4gnusholm Nope, you’ll have to seperate them.
Nhan Nguyen
@nhannh23
Jul 05 2016 09:28
@m4gnusholm (count % (3 * 5) === 0)
Eswar Kiran
@eswarkiran
Jul 05 2016 09:28
This message was deleted
Devan
@devanfarrell
Jul 05 2016 09:29
^^ or that.
Magnus Holm
@mghlm
Jul 05 2016 09:29
@nhannh23 why is that? doesn’t that say (count % 15 === 0) ?
@devanfarrell how can i seperate them?
Eswar Kiran
@eswarkiran
Jul 05 2016 09:29
This message was deleted
Devan
@devanfarrell
Jul 05 2016 09:30
@m4gnusholm Correct, that’s what it’s saying but because they are both prime numbers it works.
Nhan Nguyen
@nhannh23
Jul 05 2016 09:30
@m4gnusholm try to do if you have to pass 2 parameters into your func
Vikash Saini
@Enigma10
Jul 05 2016 09:30
@BKinahan One question for you?
Rohit
@rht18
Jul 05 2016 09:30
what's wrong with this? https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for%20(var%20i%3D0%3B%20i%3Ccontacts.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20firstName)%20%7B%0A%20%20%20%20%20%20return%20contacts%5Bi%5D.prop%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20%22No%20such%20contact%22%3B%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
Brendan Kinahan
@BKinahan
Jul 05 2016 09:30
@bvipul these instructions might help, they're the new ones but they haven't gone up yet: https://github.com/FreeCodeCamp/FreeCodeCamp/issues/9539#issuecomment-230292480
Devan
@devanfarrell
Jul 05 2016 09:31
@m4gnusholm To seperate them all you would say is ((count % 3 === 0) && (count % 5 === 0) )
Vikash Saini
@Enigma10
Jul 05 2016 09:31
@electrored your condition is right.
Magnus Holm
@mghlm
Jul 05 2016 09:31
@devanfarrell ahh, ok thank you
CamperBot
@camperbot
Jul 05 2016 09:31
m4gnusholm sends brownie points to @devanfarrell :sparkles: :thumbsup: :sparkles:
:warning: m4gnusholm already gave devanfarrell points
Rohit
@rht18
Jul 05 2016 09:31
then what's wrong?
Brendan Kinahan
@BKinahan
Jul 05 2016 09:31
@electrored contacts[i] might not have the property you're looking for. if it doesn't, return "No such property."
Rohit
@rht18
Jul 05 2016 09:31
@Enigma10
Brendan Kinahan
@BKinahan
Jul 05 2016 09:32
@electrored currently your code returns undefined if the property is not found
Rohit
@rht18
Jul 05 2016 09:32
i know @BKinahan .. but it's failing on other test as well
it always gives "no such contact"
Brendan Kinahan
@BKinahan
Jul 05 2016 09:32
@electrored the other problem is you use dot notation for prop, which is a variable, so you should use bracket notation instead.
Rohit
@rht18
Jul 05 2016 09:33
if condition is always returning false
oh ok.. thanks @BKinahan
CamperBot
@camperbot
Jul 05 2016 09:33
electrored sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1913 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jul 05 2016 09:33
@Enigma10 did you have a question?
Rohit
@rht18
Jul 05 2016 09:33
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for%20(var%20i%3D0%3B%20i%3Ccontacts.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20if%20(contacts%5Bi%5D%5BfirstName%5D%20%3D%3D%20firstName)%20%7B%0A%20%20%20%20%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20%22No%20such%20contact%22%3B%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
check this now. still not working @BKinahan
Magnus Holm
@mghlm
Jul 05 2016 09:34
@devanfarrell it doesn’t work when i seperate them though
code looks like this>
Rohit
@rht18
Jul 05 2016 09:34
oh sorry
got it @BKinahan
Magnus Holm
@mghlm
Jul 05 2016 09:34
    else if((count % 3 === 0) && (count % 5 === 0)) {
        console.log("FizzBuzz");
Magnus Holm
@mghlm
Jul 05 2016 09:35
i have to print fizzbuzz if count is divisible by both 3 and 5
full code:
Brendan Kinahan
@BKinahan
Jul 05 2016 09:35
@m4gnusholm are you checking for FizzBuzz numbers first? all FizzBuzz numbers are both Fizz and Buzz, so if you check Fizz or Buzz before FizzBuzz it'll match one of those and you won't get FizzBuzz :)
Magnus Holm
@mghlm
Jul 05 2016 09:35
for(var count = 1; count < 21; count++) {

    if(count % 3 === 0) {
        console.log("Fizz"); 
    }

    else if(count % 5 === 0) {
        console.log("Buzz"); 
    }

    else if((count % 3 === 0) && (count % 5 === 0)) {
        console.log("FizzBuzz");
        }

else {
        console.log(count);
    }
}
Brendan Kinahan
@BKinahan
Jul 05 2016 09:35
ah, yup
Magnus Holm
@mghlm
Jul 05 2016 09:36
@BKinahan oh, so check fizzbuzz numbers first?
Rohit
@rht18
Jul 05 2016 09:36
how to post code here? @BKinahan @m4gnusholm
Devan
@devanfarrell
Jul 05 2016 09:36
@m4gnusholm It’ll never make it that far.
Brendan Kinahan
@BKinahan
Jul 05 2016 09:36
@m4gnusholm yeah, imagine your input is 15, you will match the condition of the first if, and so the else ifs won't get checked.
Vikash Saini
@Enigma10
Jul 05 2016 09:36
@BKinahan
Trying to understand your code . But i didn't understand single word of it.
Brendan Kinahan
@BKinahan
Jul 05 2016 09:37
@Enigma10 which code? :)
Vikash Saini
@Enigma10
Jul 05 2016 09:37
@BKinahan
const updateInventory = (a,b) =>{
  b.forEach(e=>{
    let c = a.findIndex(v=>v[1]==e[1]);
    if (c>=0) a[c][0]+=e[0];
    else a.push(e);
  });
  return a.sort((a,b)=>a[1]>b[1]);
};

updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]]);
Magnus Holm
@mghlm
Jul 05 2016 09:37
@electrored pres ``` and then either html, css, js depending on your code, then press enter and paste.
Devan
@devanfarrell
Jul 05 2016 09:37
@m4gnusholm Once a if statement works it will never keep going through the else if statements. Because you’re looking for 15 which is both a multiple of 3 and 5 it’ll always hit that 3 before it hits the final one.
Magnus Holm
@mghlm
Jul 05 2016 09:37
@BKinahan of course, thanks
CamperBot
@camperbot
Jul 05 2016 09:37
m4gnusholm sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1914 | @bkinahan |http://www.freecodecamp.com/bkinahan
shweta rajput
@ShwetaRajput
Jul 05 2016 09:38
@BKinahan have you solved mutations alogorithm?
Vikash Saini
@Enigma10
Jul 05 2016 09:38
about @ShwetaRajput
CamperBot
@camperbot
Jul 05 2016 09:38
:warning: no user found for shwetarajput
shweta rajput
@ShwetaRajput
Jul 05 2016 09:39

function mutation(arr) 
{
  if(arr.indexOf(0)===arr.indexOf(1))
  {
   return true;
     }
        else{
    return false;
               }
                  }

mutation(["hello", "hey"]);
@Enigma10 this is my code
Brendan Kinahan
@BKinahan
Jul 05 2016 09:39
@Enigma10 it uses some features from ES6. const and let are like slightly different vars. Also I use arrow functions as a shortcut for function(v){ return v; } (the arrow function would be v=>v;). I think findIndex is an ES6 method, too
shweta rajput
@ShwetaRajput
Jul 05 2016 09:39
@BKinahan this is my code
Magnus Holm
@mghlm
Jul 05 2016 09:40

@BKinahan @devanfarrell But check out how they put the instructions:

"For numbers divisible by 3, print out "Fizz".
For numbers divisible by 5, print out "Buzz".
For numbers divisible by both 3 and 5, print out "FizzBuzz" in the console.
Otherwise, just print out the number."

Brendan Kinahan
@BKinahan
Jul 05 2016 09:40
@ShwetaRajput neither 0 or 1 are found in arr, because those are numbers and the elements of arr are strings. so both are false, and false===false so your function will always return true.
Magnus Holm
@mghlm
Jul 05 2016 09:40
@BKinahan @devanfarrell Makes you just think you have to do it in that order :)
Rohit
@rht18
Jul 05 2016 09:40

```
// Setup
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.";

// Example
var expressionToGetSoftware = /software/gi;
var softwareCount = testString.match(expressionToGetSoftware).length;

// Only change code below this line.

var expression = /./gi; // Change this Line

// Only change code above this line

// This code counts the matches of expression in testString
var andCount = testString.match(expression).length;

Brendan Kinahan
@BKinahan
Jul 05 2016 09:40
@m4gnusholm yup, it makes more sense to explain it that way, but the order of logic in solving a problem isn't always the same as the order of how the problem is explained ;)
shweta rajput
@ShwetaRajput
Jul 05 2016 09:41
@BKinahan but these are indexes.. i thought..
Eswar Kiran
@eswarkiran
Jul 05 2016 09:41
if(num != 0) {
count = num--;
num =count;
return fac(num);
}
return total;
} @abhishekdevinfo
Magnus Holm
@mghlm
Jul 05 2016 09:41
@BKinahan sneaky :smile:
Vikash Saini
@Enigma10
Jul 05 2016 09:41
@ShwetaRajput it will return index number
Rohit
@rht18
Jul 05 2016 09:41
// Setup
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.";

// Example
var expressionToGetSoftware = /software/gi;
var softwareCount = testString.match(expressionToGetSoftware).length;


// Only change code below this line.

var expression = /./gi;  // Change this Line

// Only change code above this line

// This code counts the matches of expression in testString
var andCount = testString.match(expression).length;
Markus Kiili
@Masd925
Jul 05 2016 09:42
@devanfarrell The code doesn't work with !== because it compares an object with number and therefore the callback always returns true and removes nothing from arr.
Brendan Kinahan
@BKinahan
Jul 05 2016 09:44
@electrored do you have a question? :)
Vikash Saini
@Enigma10
Jul 05 2016 09:46
@BKinahan Looks like it need to learn ES6 :P
shweta rajput
@ShwetaRajput
Jul 05 2016 09:46

function mutation(arr) 
{
  if(arr.indexOf("hello")===arr.indexOf("hey"))
  {
   return true;
     }
        else{
    return false;
               }
                  }

mutation(["hello", "hey"]);
@BKinahan check my code
@BKinahan in rest cases it is working but not i case sensitivity. how to do that
Vikash Saini
@Enigma10
Jul 05 2016 09:47
@ShwetaRajput Change your string into Lower Case
Brendan Kinahan
@BKinahan
Jul 05 2016 09:48
@ShwetaRajput that checks if both words have the same position within arr, which will only be true if they are the same word. anyway, would that code look the same if the input was ["first", "second"]? What would "hello" and "hey" have to do with anything in that context? The idea of the challenge is to check if each letter in the second word is present in the first word :)
Vikash Saini
@Enigma10
Jul 05 2016 09:48
@ShwetaRajput use string.toLowerCase
Eswar Kiran
@eswarkiran
Jul 05 2016 09:49
@m4gnusholm you can write seperately as ((count%3 == 0)&&(count%5 == 0))
Anthony Ho
@chiho13
Jul 05 2016 09:49
what's the difference between immutable and mutable in javascript? does it have to do with memory management? immutable stores variables by value, mutable point to variable by reference?
Sasha
@magnittt
Jul 05 2016 09:50
@ShwetaRajput how are you show image of code ?
Anthony Ho
@chiho13
Jul 05 2016 09:50
This message was deleted
Markus Kiili
@Masd925
Jul 05 2016 09:51
@chiho13 Primitives are immutable and objects can be mutable or immutable.
Vikash Saini
@Enigma10
Jul 05 2016 09:52
about @ShwetaRajput
Markus Kiili
@Masd925
Jul 05 2016 09:52
@chiho13 Variables store primitive values or references to objects.
CamperBot
@camperbot
Jul 05 2016 09:52
:warning: no user found for shwetarajput
Brendan Kinahan
@BKinahan
Jul 05 2016 09:53
@magnittt
```js
your code here
```
:point_up: July 5, 2016 9:38 AM I think you tried that already @Enigma10
Eswar Kiran
@eswarkiran
Jul 05 2016 09:55
This message was deleted
````js
Vikash Saini
@Enigma10
Jul 05 2016 09:59
@BKinahan i was checking your code and your code mistakenly submit as my code .
@BKinahan Anyway i am still working on problem :(
Anthony Ho
@chiho13
Jul 05 2016 10:08
@Masd925 so in primitive values, if you assign a new string to the same variable, it'd just be two separate values?
var a = 3;
a = 4;
Markus Kiili
@Masd925
Jul 05 2016 10:08
@chiho13 Yes, the old value is overwritten.
var b=a; would assign a copy of the value in a to variable b.
Anthony Ho
@chiho13
Jul 05 2016 10:13
@Masd925 if a was an object, b would point to a as a reference. Under the hood would be one copy? - mutable objects?
Markus Kiili
@Masd925
Jul 05 2016 10:15
@chiho13 Same way a reference would be copied from a to b. Both variables could then use the same object.
Nothing to do with mutability. Mutability deals with changing the content or properties of the primitive value or referenced object.
Eswar Kiran
@eswarkiran
Jul 05 2016 10:17
if(num != 0) 
{
      count = num--;
      num =count;
return fac(num);
}
return total;
}
@abhishekdevinfo
Anthony Ho
@chiho13
Jul 05 2016 10:21
@Masd925 isnt mutable objects more memory efficient?
LukaLyptus
@LukaLyptus
Jul 05 2016 10:22
Hey campers. Could someone please help me with understanding switch statement.
Jason Keenan
@raavin
Jul 05 2016 10:22
@eswarkiran you should use !== to compare with 0
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:22
blob
yo guys can you help me our with this task
Markus Kiili
@Masd925
Jul 05 2016 10:23
@chiho13 I think so, but there is a benefit if no other process can alter the value you have in a variable. Avoids many problems.
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:23
i rly get stucked
Brendan Kinahan
@BKinahan
Jul 05 2016 10:23
@LukaLyptus In basic terms, a switch compares its input against its cases, and runs the code block for the case that matches
LukaLyptus
@LukaLyptus
Jul 05 2016 10:23

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

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

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

Sorry to spam the chat I don't know how else to post code
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:24

// Setup
function abTest(a, b) {
// Only change code below this line

// Only change code above this line
if (a,b > 0 ){
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

}

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

Brendan Kinahan
@BKinahan
Jul 05 2016 10:24
@LukaLyptus you don't have a switch statement there. check the syntax in the instructions.
bot format
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:24
abTest(-2,2) should return undefined
CamperBot
@camperbot
Jul 05 2016 10:24

: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

Brendan Kinahan
@BKinahan
Jul 05 2016 10:25
@Glebasty1 @LukaLyptus :point_up: July 5, 2016 10:24 AM
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:25
cant deal with only 1 test
Jason Keenan
@raavin
Jul 05 2016 10:25
@eswarkiran actually, I'm not sure what you are trying to do. The code is a bit messed up. What is fac()? I'm assuming you are decrementing num so you can just use num--; by itself
Brendan Kinahan
@BKinahan
Jul 05 2016 10:25
@Glebasty1 you have changed code below the line that says you should only change code above that line, and your condition is incorrect :)
Fourbits
@Fourbits
Jul 05 2016 10:26
@Glebasty1 You want to check if a or b are less than 0 (like if (a<0){...}); if so, return undefined
and don't change the original code
Wilmer Rodriguez
@wilmerRodriguez
Jul 05 2016 10:26
Hello world
CamperBot
@camperbot
Jul 05 2016 10:26

welcome to FreeCodeCamp @wilmerRodriguez!

Fourbits
@Fourbits
Jul 05 2016 10:27
just add to it
Wilmer Rodriguez
@wilmerRodriguez
Jul 05 2016 10:27
Need some insight on my code, can't seem to find the problem i'm having...
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:28
yea thx) guys)
Wilmer Rodriguez
@wilmerRodriguez
Jul 05 2016 10:28
<div class="row">
<div class="col-xs-6">
<button class="btn btn-block btn-primary"><i class="fa fa-thumbs-up"></i> Like</button>
</div>
<div class="col-xs-6">
<button class="btn btn-block btn-info"><i class="fa fa-info-circle"></i> Info</button>
</div>
<div class="col-xs-6">
<button class="btn btn-block btn-danger"><i class="fa fa-trash"></i> Delete</button>
</div>
</div>
Nest all of your radio buttons inside one div with the class row.
Nest each of your radio buttons inside its own div with the class col-xs-6.
Make sure each of your div elements has a closing tag.
Gleb Sabakarov
@Glebasty1
Jul 05 2016 10:28
@Fourbits thx
CamperBot
@camperbot
Jul 05 2016 10:28
glebasty1 sends brownie points to @fourbits :sparkles: :thumbsup: :sparkles:
:cookie: 338 | @fourbits |http://www.freecodecamp.com/fourbits
efeselgr
@efeselgr
Jul 05 2016 10:28
@wilmerRodriguez go to help channel
this is javascript help channel
Wilmer Rodriguez
@wilmerRodriguez
Jul 05 2016 10:28
oh haha
i knew that
sorry
Popovici Raul
@raulGX
Jul 05 2016 10:29
hello, anyone having an idea why I CAN'T access variable outside of an GETJSON call?
LukaLyptus
@LukaLyptus
Jul 05 2016 10:29
<code goes here>
Markus Kiili
@Masd925
Jul 05 2016 10:29
@wilmerRodriguez Try to find the specific channel, and if there is nobody at the moment, try general chat.
Wilmer Rodriguez
@wilmerRodriguez
Jul 05 2016 10:30
ok cool, thanks
efeselgr
@efeselgr
Jul 05 2016 10:30
i would like to know what is wrong with the code:(Chunky monkey bonfire)

function chunkArrayInGroups(arr, size) {
  // Break it up.
     var x = [[]];
  var a = 0;
  while(arr.length>1){
      for(i=0;i<size;i++){
        x[a][i] = arr.shift();
        if(arr.length<1){
          break;
        }       
      }
      }
       a=a+1;

  return x;


}

chunkArrayInGroups([0, 1, 2, 3, 4, 5,6,7,8,9], 4);
Wilmer Rodriguez
@wilmerRodriguez
Jul 05 2016 10:30
@Masd925 thanks
CamperBot
@camperbot
Jul 05 2016 10:30
wilmerrodriguez sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2045 | @masd925 |http://www.freecodecamp.com/masd925
Sasha
@magnittt
Jul 05 2016 10:30
``` ds
Markus Kiili
@Masd925
Jul 05 2016 10:31
@raulGX You should be able to. Remember that ajax callback functions run when the request succeeds (asynchronously).
Sasha
@magnittt
Jul 05 2016 10:31

```js fdfd

```

Popovici Raul
@raulGX
Jul 05 2016 10:32

var toSearch = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
$(document).ready(function() {

for (var i = 0; i < toSearch.length; ++i){
var link = "https://api.twitch.tv/kraken/streams/" + toSearch[i] + "?callback=?";
$.ajax({
dataType: 'json',
url: link,
async: false,
type: "GET",
success: function(data){
console.log(toSearch[i]);

  }
});
}

});

sorry still new at this :(
Marcin
@Grygier94
Jul 05 2016 10:33

Hello! I have a problem with wather app, I get location from ipinfo.io and then use latitude and longituted in url to openwathermap api but I'm trying to store it in variable but I can't access it so I'm doing something wrong probably. Here is my code:

var url;

function getLocationByIP() {
  $.getJSON('http://ipinfo.io', function(data){
    lat = data.loc.substr(0, data.loc.indexOf(','));
    lon = data.loc.substr(data.loc.indexOf(',')+1);

    url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid=d932c1605a8cb1060468b96a1cfc20c7";
});
  return url;
}

How can I return or get the url from the function?a

Sasha
@magnittt
Jul 05 2016 10:33
This message was deleted
Popovici Raul
@raulGX
Jul 05 2016 10:35
@Grygier94 I had the same problem. I solved it by nesting another json call inside the getting location one
Marcin
@Grygier94
Jul 05 2016 10:36
@raulGX Thanks, I'll try it out
CamperBot
@camperbot
Jul 05 2016 10:36
grygier94 sends brownie points to @raulgx :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @raulgx |http://www.freecodecamp.com/raulgx
Markus Kiili
@Masd925
Jul 05 2016 10:36
@raulGX Are all the console.logs returning the same string?
LukaLyptus
@LukaLyptus
Jul 05 2016 10:36

I am still confused here

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line


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

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

Why is there a var answer = ""; inside the switch statement?

Popovici Raul
@raulGX
Jul 05 2016 10:36
they are returning undefined
Brendan Kinahan
@BKinahan
Jul 05 2016 10:37
@efeselgr seems you're missing a } someplace
efeselgr
@efeselgr
Jul 05 2016 10:37
@BKinahan no the code works
just not the way i want it to be
Popovici Raul
@raulGX
Jul 05 2016 10:38
@Masd925 just look at @Grygier94 example above it's the same issue as mine
Sasha
@magnittt
Jul 05 2016 10:38
<function nextInLine(arr, item) {
  // Your code here
  arr.push();
  var mama = arr.shift();
  return mama;  
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 2)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));>
how i modify second console?
Markus Kiili
@Masd925
Jul 05 2016 10:41
@raulGX After the for loop runs out, the value of i is toSearch.length. The value on which the condition returns false and the loop terminates.
Popovici Raul
@raulGX
Jul 05 2016 10:42
@Masd925 yes, but my problem is getting 8 console logs of undefined
Markus Kiili
@Masd925
Jul 05 2016 10:42
@raulGX Because there is no element at index toSearch.length
var arr = [1,2,3];
for (var i=0;i<arr.length;i++) {}
console.log(i);      // 3
console.log(arr[i]); // undefined
Your index is outside the indices of the array when all the callbacks are executed.
Popovici Raul
@raulGX
Jul 05 2016 10:47
so it loops through the array and every iteration of the ajax call prints the same undefined item?
Marcin
@Grygier94
Jul 05 2016 10:47
@raulGX I just did like you said and it works, just don't get why I couldn't assign it to global variable, thanks again
CamperBot
@camperbot
Jul 05 2016 10:47
grygier94 sends brownie points to @raulgx :sparkles: :thumbsup: :sparkles:
:warning: grygier94 already gave raulgx points
Markus Kiili
@Masd925
Jul 05 2016 10:48
@raulGX The loop runs and binds the callbacks to ajax calls and the loop terminates at i=toSearch.length. Then when callbacks are run, they all access the same non-existent array element toSearch[toSearch.length]
LukaLyptus
@LukaLyptus
Jul 05 2016 10:49
@BKinahan thanks
CamperBot
@camperbot
Jul 05 2016 10:49
lukalyptus sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1915 | @bkinahan |http://www.freecodecamp.com/bkinahan
96street
@96street
Jul 05 2016 10:50

any idea why this isn't working? http://codepen.io/kingdezz/pen/zBzBaZ?editors=0010

it's only appending one name from the array

Popovici Raul
@raulGX
Jul 05 2016 10:50
@Masd925 makes total sense now
but how do I make it execute the call at every iteration
@Masd925 I declared a variable k outside the loop and I incremented it inside the ajax call like this $("#output").append(toSearch[k++]);
Stephen James
@sjames1958gm
Jul 05 2016 10:54
@96street try passing your values (url, channels[channel]) in to callAjax rather than accessing them as globals. Likely when your callback happens the global channel is the last entry in the array.
Vikash Saini
@Enigma10
Jul 05 2016 10:55
about @sjames1958gm
CamperBot
@camperbot
Jul 05 2016 10:55
:star2: 1722 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 05 2016 10:55
@magnittt push requires a parameter (you aren't doing anything with item)
Popovici Raul
@raulGX
Jul 05 2016 10:57
@96street I had the same problem declare an index variable outside the ajax call and then increment it only INSIDE the ajax call
96street
@96street
Jul 05 2016 11:00
I did that but had the same outcome @raulGX @sjames1958gm
Popovici Raul
@raulGX
Jul 05 2016 11:00
@96street can you post the changed code?
Stephen James
@sjames1958gm
Jul 05 2016 11:02
@96street That doesn't solve the problem - go back to your previous code and pass channels[channel] into callAjax and use the parameter instead of channels[channel]
Here is a fork, with that proposed change.
Popovici Raul
@raulGX
Jul 05 2016 11:04
thanks @sjames1958gm that cleared a lot
CamperBot
@camperbot
Jul 05 2016 11:04
raulgx sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1723 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Popovici Raul
@raulGX
Jul 05 2016 11:04
didn't know you could pass in more arguments
96street
@96street
Jul 05 2016 11:05
ahh thanks i wasn't sure what you were trying to say @sjames1958gm
CamperBot
@camperbot
Jul 05 2016 11:05
96street sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1724 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 05 2016 11:05
@96street :+1:
Stefan du Bois
@buttertje
Jul 05 2016 11:06
hey guys and gals
96street
@96street
Jul 05 2016 11:07
can you just explain to me how exactly the 2 parameters of callAjax are working? @sjames1958gm
how did you manage to shorten channels[channel] to just channel
Popovici Raul
@raulGX
Jul 05 2016 11:08
hey @buttertje
@96street in de declaration u use channel as a name holder can be replaced with cookies
shweta rajput
@ShwetaRajput
Jul 05 2016 11:09

function mutation(arr) {

  var a=arr[0].toLowerCase();
  var b=arr[1].toLowerCase();
  for(i=0;i<arr.length;i++)
        {
           if(b.indexOf(a[0])==a.indexOf(b[1])){
             return true;
           }
               else{
                 return false;
               }        }


    }

mutation(["heLLo", "Hey"]);
@Masd925 why my code not running
96street
@96street
Jul 05 2016 11:09
@raulGX not sure what you're trying to say
Popovici Raul
@raulGX
Jul 05 2016 11:09
and when you use the function u use it with the url and channels[channel]
shweta rajput
@ShwetaRajput
Jul 05 2016 11:09
@Masd925 it is mutations algo
Markus Kiili
@Masd925
Jul 05 2016 11:10
@ShwetaRajput You need to loop the characters of b, and check with indexOf if they are (not) found on a.
Vikash Saini
@Enigma10
Jul 05 2016 11:10
@ShwetaRajput Hello
shweta rajput
@ShwetaRajput
Jul 05 2016 11:11
@Masd925 means i should start from 1
Markus Kiili
@Masd925
Jul 05 2016 11:11
@ShwetaRajput No need to loop arr.
Vikash Saini
@Enigma10
Jul 05 2016 11:12
@ShwetaRajput a.indexOf(b[i]);
96street
@96street
Jul 05 2016 11:13
that's the same one? @raulGX
the same codepen
Vikash Saini
@Enigma10
Jul 05 2016 11:13
@ShwetaRajput
a.indexOf(b[i]);
Popovici Raul
@raulGX
Jul 05 2016 11:13
@96street wait it didn't save
Stephen James
@sjames1958gm
Jul 05 2016 11:14
@96street parameters are just references to the names that you use in the call - so when passing channels[channel] into callAjax the js interpreter will change channel point to the same value as channels[channel] - if the the name channel is confusing you it could have been named anything inside callAjax.
Vikash Saini
@Enigma10
Jul 05 2016 11:14
@ShwetaRajput IF idex item of b contain in a then this '''a.indexOf(b[i]); ''' return true .
CamperBot
@camperbot
Jul 05 2016 11:14
:bulb: to format code use backticks! ``` more info
Popovici Raul
@raulGX
Jul 05 2016 11:14
Joni petriashvili
@Jonhnwhantcoding
Jul 05 2016 11:16
can anyone help my onj this topic


var myStr = "\\ \n \t \t";// Change this line
issue myStr should have necoded text with the proper escape sequences ans spacing
Popovici Raul
@raulGX
Jul 05 2016 11:17
just copy the sentence
shweta rajput
@ShwetaRajput
Jul 05 2016 11:18
@Enigma10
function mutation(arr)
{

  var a=arr[0].toLowerCase();
  var b=arr[1].toLowerCase();
  for(i=1;i<b.length;i++)
        {
           if(b.indexOf(b[i])==a.indexOf(a[i]))
           {
             return true;
               }
               else
               {
                 return false;
                               }       
                                  }
                                    }
Popovici Raul
@raulGX
Jul 05 2016 11:18
and remove the spaces between '\'\ and '\'\n @Jonhnwhantcoding
Joni petriashvili
@Jonhnwhantcoding
Jul 05 2016 11:18
@raulGX not working
Vikash Saini
@Enigma10
Jul 05 2016 11:19
@ShwetaRajput Paste My if condition there
Popovici Raul
@raulGX
Jul 05 2016 11:19
@Jonhnwhantcoding could you copy the string you are given and your string?