These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
May 2016
Andrew Schmidthuber
@calicode
May 03 2016 00:01
forEach is a method that will execute a function once for each item in an array. a simple example would be
```
var numbers = [1,2,3,4];
Stephen James
@sjames1958gm
May 03 2016 00:01
@ciant The outer forEach is looping over the array in json, then for each item (stored in val) the keys (property names) are retrieved (Object.keys) into another array keys. The the second forEach loops over that array calling the new function for each key the key is then used to get the value for that key (val[key]) to build html
Andrew Schmidthuber
@calicode
May 03 2016 00:02
var numbers = [1,2,3,4];
numbers.forEach(function(value) {
console.log(value * 2);  
}

would log 2 4 6 8 to console
and basically yea what @sjames1958gm said.
Cian
@ciant
May 03 2016 00:08
So this is adding the property names of each value to the variable keys?
 var keys = Object.keys(val);
z5014823
@z5014823
May 03 2016 00:11
This message was deleted
hey, can anyone see why this is happening?
Stephen James
@sjames1958gm
May 03 2016 00:20
@ciant Yes
Cian
@ciant
May 03 2016 00:23
@sjames1958gm In this second loop of the variable keys, when it concatenates val[key] where is that coming from?
keys.forEach(function(key) {
          html += "<b>" + key + "</b>: " + val[key] + "<br>";
I'm guessing that is the value related to that key in the original json file?
Stephen James
@sjames1958gm
May 03 2016 00:23
@ciant The outer loop has val from the original json, and the key from the Object.keys() call.
Cian
@ciant
May 03 2016 00:25
@sjames1958gm thanks, you've made it less of a mystery. I appreciate it
CamperBot
@camperbot
May 03 2016 00:25
ciant sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 917 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Cian
@ciant
May 03 2016 00:25
@calicode thanks
CamperBot
@camperbot
May 03 2016 00:25
ciant sends brownie points to @calicode :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @calicode |http://www.freecodecamp.com/calicode
Stephen James
@sjames1958gm
May 03 2016 00:25
[{a: 1, b:2, c:3}] if this is the json, the first pass in the outer loop val = {a:1,b:2,c:3} then keys = ["a", "b", "c"] so in the second loop the first time key="a" so val[key] = 1;
Cian
@ciant
May 03 2016 00:27
So on the first loop when it passes in val it's actually passing in the entire object?
Stephen James
@sjames1958gm
May 03 2016 00:27
Yes, because that is the first entry of the array
Ragnar
@raggy833
May 03 2016 00:27

Hi guys, I am stuck with this problem. I can make one work but I don't know how to make all of them work at the same time...
1: nextInLine([], 1) should return 1
2: nextInLine([2], 1) should return 2
3: nextInLine([5,6,7,8,9], 1) should return 5

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

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

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

Cian
@ciant
May 03 2016 00:27
ahhh! okay! thanks again!
Omid
@omidqayoumi
May 03 2016 00:28
about to start the algorithm scripting challenges :shipit:
CamperBot
@camperbot
May 03 2016 00:28
you need to ask about @someone!
Stephen James
@sjames1958gm
May 03 2016 00:28
@omidqayoumi good luck
Omid
@omidqayoumi
May 03 2016 00:29
thanks :)
Coy Sanders
@coymeetsworld
May 03 2016 00:37
@raggy833 youll need to use some array functions on arr to do what you need to do
henrywashere
@henrywashere
May 03 2016 00:46
need help with this exercise:
A common anti-pattern is to use an if/else statement to do a comparison and then return true/false:

function isEqual(a,b) {
  if (a === b) {
    return true;
  } else {
    return false;
  }
}
Since === returns true or false, we can simply return the result of the comparison:

function isEqual(a,b) {
  return a === b;
}
Instructions
Fix the function isLess to remove the if/else statements.

i wrote

return a === b;

didnt go through
Stephen James
@sjames1958gm
May 03 2016 00:48
@henrywashere That looks correct.
@henrywashere Refresh browser?
@henrywashere my code is isLess
henrywashere
@henrywashere
May 03 2016 00:49
i also deleted the if/else statements
so it loooks like this
function isLess(a, b) {
  // Fix this code
 return a === b; 
}
Stephen James
@sjames1958gm
May 03 2016 00:49
@henrywashere If the function is isLess then why ===
William Barnes
@wcbarnes
May 03 2016 00:50

I am not sure where I am going wrong. I ran this in the console and I get a random number.

//Change randomFraction to return a random number instead of returning 0.
function randomFraction() {

// Only change code below this line.

return Math.random();

// Only change code above this line.
}

Also, How do I denote markdown in chat?
Stephen James
@sjames1958gm
May 03 2016 00:51
@wcbarnes hmm that worked to me
help format
CamperBot
@camperbot
May 03 2016 00:51

: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 the code.

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

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

Stephen James
@sjames1958gm
May 03 2016 00:51
@wcbarnes try refreshing the browser
William Barnes
@wcbarnes
May 03 2016 00:52
@sjames1958gm That worked. Thanks
CamperBot
@camperbot
May 03 2016 00:52
wcbarnes sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 918 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 03 2016 00:53
@henrywashere how does isLess and return a===b make sense together?
henrywashere
@henrywashere
May 03 2016 00:57
no idea
Stephen James
@sjames1958gm
May 03 2016 00:58
@henrywashere if you saw function isLess(a,b) { } what would you think it would be testing a === b or something else?
henrywashere
@henrywashere
May 03 2016 00:59
a===b?
Stephen James
@sjames1958gm
May 03 2016 01:00
Wouldn't something that tested a is less than b be more in line with isLess?
Matt James
@thirteenten
May 03 2016 01:00
Good evening everyone
Stephen James
@sjames1958gm
May 03 2016 01:01
evening
Matt James
@thirteenten
May 03 2016 01:01
i need someone to help me review some code I wrote for the "Where art thou" challenge
henrywashere
@henrywashere
May 03 2016 01:01
oh nevermind i got it lol
Stephen James
@sjames1958gm
May 03 2016 01:01
post
@henrywashere :smile: :+1:
henrywashere
@henrywashere
May 03 2016 01:02
thanks @sjames1958gm
CamperBot
@camperbot
May 03 2016 01:02
henrywashere sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 919 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Matt James
@thirteenten
May 03 2016 01:02
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var objKeys = Object.keys(source);
  var bool = false;
  var bool2 = false;
  var hasProperty = function(arrVal){

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

      // Check 'source' keys against 'collection' keys
      for(var j=0; j < arrVal.length; j++){
        if(collection[i].hasOwnProperty(arrVal[j])){
          bool = true;
        } else {
          bool = false;
          j = arrVal.length + 1; // Break out of for loop
        }
      }

      // Check 'source' key values against 'collection' key values
      if(bool){
        for(var k=0; k < arrVal.length; k++){
          var value = arrVal[k];

          if(collection[i][value] === source[value]){
            bool2 = true;
          } else {
            bool2 = false;
            k = arrVal.length + 1; // Break out of for loop
          }
        }
      }

      // Push 'collection' obj value if all conditions are met
      if(bool2){
        arr.push(collection[i]);
      }
    }
  };

  hasProperty(objKeys);

  // Only change code above this line
  return arr;
}
so this passes every test except the following:
whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 })
for some reason { "a" : 1 } is able to make it through the conditions when it is bundled in an array with other object values
but when it is ran on its own, the return is an empty array as it should be.
Stephen James
@sjames1958gm
May 03 2016 01:05
@thirteenten - You can check the existence and the value in the same loop. seem odd that you call an inner function when you could just execute the code inline.
dontchaknow
@dontchaknow
May 03 2016 01:06
how do I express in regex 1 or no character? like 14 or just 4.
Stephen James
@sjames1958gm
May 03 2016 01:06
? is 0 or 1 character
@thirteenten you don't reset bool and bool2 for each pass.
Matt James
@thirteenten
May 03 2016 01:09
meaning I dont need to reset it to false on the else side of the if statement>
*?
Stephen James
@sjames1958gm
May 03 2016 01:10
@thirteenten if(!collection[i].hasOwnProperty(arrVal[j]) || collection[i][arrVal[j]] !== source[arrVal[j]])) { bool = false; break; }
Aparna
@Aparna-S
May 03 2016 01:10
i am now doing "Using Objects for Lookups" challenge
i modified the switch to lookup table, but dono how to call it

this is my code -
// Setup
function phoneticLookup(val) {
var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
Stephen James
@sjames1958gm
May 03 2016 01:13
@Aparna-S val is passed in so you want to use it to look up the result - you overwrite it
Aparna
@Aparna-S
May 03 2016 01:15
@sjames1958gm how to we bring the connection between val, result and lookup , here?
Matt James
@thirteenten
May 03 2016 01:15
@sjames1958gm im sorry but im not following where I should implement that code.
Jack
@jackdois
May 03 2016 01:16
This message was deleted
Stephen James
@sjames1958gm
May 03 2016 01:16
@thirteenten In your first loop then your second loop is not needed.
Inside loop
@Aparna-S Look at the example to the left how is the object and variable used to set the value
Matt James
@thirteenten
May 03 2016 01:17
@sjames1958gm Ok I see it now.
@sjames1958gm Is that the reason { "a": 1} is able to slip through my current code?
because im still confused as to why it gets through when it is lumped together with multiple values in an array but on its own it doesnt make it through as it should.
Stephen James
@sjames1958gm
May 03 2016 01:20
@thirteenten The reason it slips through is that you don't reset bool / bool2 so even though {"a":1} might set bool to false bool2 might still be true from previous pass
Aparna
@Aparna-S
May 03 2016 01:20
@sjames1958gm this is the example , where they assign alpha variable to a new variable value

var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"

Matt James
@thirteenten
May 03 2016 01:21
@sjames1958gm Ohhhhhh, ok i am seeing it now!
Stephen James
@sjames1958gm
May 03 2016 01:21
@Aparna-S so in your case lookup is alpha and val is value.
Matt James
@thirteenten
May 03 2016 01:21
@sjames1958gm Thank you!
CamperBot
@camperbot
May 03 2016 01:21
thirteenten sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 920 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Aparna
@Aparna-S
May 03 2016 01:23
@sjames1958gm we can't do like this right lookup[val];
and return result is also there
:(
Li
@NLStom
May 03 2016 01:23
hello guys
do you guys know where I can find answer of freeonlinecode
Francisco Franco
@frenktico
May 03 2016 01:23
Hi ppl good night
:)
I don't know @NLStom sorry!
Li
@NLStom
May 03 2016 01:24
I write my code and passed already, but I just think there must be a better way to write the code

function convertToRoman(num) {
var roman = "";
while(num>=1000){
if(num>=1000&&num%1000>=0)
{
roman=roman.concat("M");
num -= 1000;
}
}
if(num>=900&&num%900>=0)
{
roman=roman.concat("CM");
num -= 900;
}
if(num>=800&&num%800>=0)
{
roman=roman.concat("DCCC");
num -= 800;
}
if(num>=700&&num%700>=0)
{
roman=roman.concat("DCC");
num -= 700;
}
if(num>=600&&num%600>=0)
{
roman=roman.concat("DC");
num -= 600;
}
if(num>=500&&num%500>=0)
{
roman=roman.concat("D");
num -= 500;
}
if(num>=400&&num%400>=0)
{
roman=roman.concat("CD");
num -= 400;
}
if(num>=300&&num%300>=0)
{
roman=roman.concat("CCC");
num -= 300;
}
if(num>=200&&num%200>=0)
{
roman=roman.concat("CC");
num -= 200;
}
if(num>=100&&num%100>=0)
{
roman=roman.concat("C");
num -= 100;
}
if(num>=90&&num%90>=0)
{
roman=roman.concat("XC");
num -= 90;
}
if(num>=80&&num%80>=0)
{
roman=roman.concat("LXXX");
num -= 80;
}
if(num>=70&&num%70>=0)
{
roman=roman.concat("LXX");
num -= 70;
}
if(num>=60&&num%60>=0)
{
roman=roman.concat("LX");
num -= 60;
}
if(num>=50&&num%50>=0)
{
roman=roman.concat("L");
num -= 50;
}
if(num>=40&&num%40>=0)
{
roman=roman.concat("XL");
num -= 40;
}
if(num>=30&&num%30>=0)
{
roman=roman.concat("XXX");
num -= 30;
}
if(num>=20&&num%20>=0)
{
roman=roman.concat("XX");
num -= 20;
}
if(num>=10&&num%10>=0)
{
roman=roman.concat("X");
num -= 10;
}
if(num>=9&&num%9>=0)
{
roman=roman.concat("IX");
num -= 9;
}
if(num>=8&&num%8>=0)
{
roman=roman.concat("VIII");
num -= 8;
}
if(num>=7&&num%7>=0)
{
roman=roman.concat("VII");
num -= 7;
}
if(num>=6&&num%6>=0)
{
roman=roman.concat("VI");
num -= 6;
}
if(num>=5&&num%5>=0)
{
roman=roman.concat("V");
num -= 5;
}
if(num>=4&&num%4>=0)
{
roman=roman.concat("IV");
num -= 4;
}
if(num>=3&&num%3>=0)
{
roman=roman.concat("III");
num -= 3;
}
if(num>=2&&num%2>=0)
{
roman=roman.concat("II");
num -= 2;
}
if(num>=1&&num%1>=0)
{
roman=roman.concat("I");
num -= 1;
}
return roman;
}

convertToRoman(7234);

this is what I wrote in Roman Numeral Converter
I just feel like very ugly, and wonder how can make this code cleaner
Boris
@boris-in-london
May 03 2016 01:26
i havnt done the roman numeral algorithm yet, but from what you posted looks like a switch statement could help with all those if statements.
Li
@NLStom
May 03 2016 01:26
@frenktico oh, no problem~
Matt James
@thirteenten
May 03 2016 01:28
@NLStom I used two different arrays: one that held roman numeral values and the other that held the corresponding interger values with corresponding index values
im not sure if you know, but if you click on the FCC Wiki, there are hints and answers to all challenges.
Li
@NLStom
May 03 2016 01:29
FCC wiki?
@thirteenten where I can click the FCC wiki?
Francisco Franco
@frenktico
May 03 2016 01:30
I believe it is this one https://www.freecodecamp.com/wiki
Matt James
@thirteenten
May 03 2016 01:30
@NLStom in the navbar for the main Free Code Camp page, there is a link to "Wiki" between "Chat" and "About"
@frenktico That is the one
Francisco Franco
@frenktico
May 03 2016 01:30
on the main page there's a button called Wiki that directs us to this link
:)
I never clicked hahaha always struggling with the code trying hard to understand
:'(
Stephen James
@sjames1958gm
May 03 2016 01:31
@frenktico On every challenge page the Wiki link is there
Francisco Franco
@frenktico
May 03 2016 01:31
Yes it is but I have never followed
At the beginning there were so many information that I got quite lost.
Stephen James
@sjames1958gm
May 03 2016 01:31

@NLStom

function convertToRoman(num) {
  var roman = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
  var arabic = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];

  var result = "";

  var i = 0;
  while (num > 0) {
    if (num >= arabic[i]) {
      result += roman[i];
      num -= arabic[i];
    }
    else {
      i++;
    }
  }

 return result;
}

```

Li
@NLStom
May 03 2016 01:33
@sjames1958gm Thanks guys!
CamperBot
@camperbot
May 03 2016 01:33
nlstom sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 921 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Li
@NLStom
May 03 2016 01:34
@thirteenten Thank you, I found the wiki already~
CamperBot
@camperbot
May 03 2016 01:34
nlstom sends brownie points to @thirteenten :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @thirteenten |http://www.freecodecamp.com/thirteenten
Li
@NLStom
May 03 2016 01:34
I guess I will check it up if I am not happy of my owncode
in the future
Jorge
@liberaltech
May 03 2016 01:39
https://codepen.io/liberaltech/pen/QNZeKw?editors=0110
I finally got these letters to curve can some help me align them, ive been try for a few hours now :/
Stephen James
@sjames1958gm
May 03 2016 01:39
@NLStom It is good that you complete the challenge on your own. Then you can learn from others after.
Joseph
@revisualize
May 03 2016 01:41
@sjames1958gm Oh! That's a good idea... While loop.. I used a for loop.
Bill Stiber
@bstiber
May 03 2016 01:42
Hey everybody.. I know this should be simple but for some reason I can't get the computer to agree with me.. What is the formula if var myVar =87 and I am trying to get 88? This doesn't work>>
myVar = myVar++;
Stephen James
@sjames1958gm
May 03 2016 01:43
@bstiber myVar++ will increment myVar without the need to assign it.
Bill Stiber
@bstiber
May 03 2016 01:44
So the answer is just myVar++?
Stephen James
@sjames1958gm
May 03 2016 01:44
@bstiber I don't know try it :)
Bill Stiber
@bstiber
May 03 2016 01:44
wow now I feel stupid.. Thanks a million!
Boris
@boris-in-london
May 03 2016 01:44
the ++ operator is so odd... it makes the addition AFTER you invoke it.
lol
Bill Stiber
@bstiber
May 03 2016 01:45
Been trying to hack that for like ever lol. Time to give it a rest.
bitgrower
@bitgrower
May 03 2016 01:45
right, there's a pre-increment and a post-increment operator ...
if you want it to perform the addition BEFORE setting the variable, you would use ++MyVar instead of MyVar++
Boris
@boris-in-london
May 03 2016 01:45
if you put ++ before it should work as you thought var myVar = ++myVar, but @sjames1958gm 's solution is cleaner imo.
Stephen James
@sjames1958gm
May 03 2016 01:46
@boris-in-london Yeah, and that is what the challenge required.
myvar = myvar++ doesn't actually increment myvar cause it resets it
Boris
@boris-in-london
May 03 2016 01:49
lol yeah, i came across this issue in the pomodoro project, kept wondering why it wont increment UP! just kept resting. its a sure way to rage out...
Stephen James
@sjames1958gm
May 03 2016 01:49
@boris-in-london Hey boris how about Leicester City
Boris
@boris-in-london
May 03 2016 01:50
ay!
bitgrower
@bitgrower
May 03 2016 01:50
pre & post increments are very common operators in a number of languages ... and a good source of interview questions ... :)
Bill Stiber
@bstiber
May 03 2016 01:52
Thanks again guys I'm learning as much from you all as I am in the tutorials
Boris
@boris-in-london
May 03 2016 01:53
:smile: now im in a great mood...
D.Mills
@millsdee74
May 03 2016 01:54
Thanks @Rafase282 and @rahul1992 for your help with Algorithm: Where do I belong
CamperBot
@camperbot
May 03 2016 01:54
millsdee74 sends brownie points to @rafase282 and @rahul1992 :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @rahul1992 |http://www.freecodecamp.com/rahul1992
:star2: 1206 | @rafase282 |http://www.freecodecamp.com/rafase282
Stephen James
@sjames1958gm
May 03 2016 01:54
@boris-in-london Glad my Chelsea could do something useful this season.
bjk116
@bjk116
May 03 2016 01:58
I'm trying to sort an array from least to most using Array.sort()
Is it necessary to write a different function just to compare the numbers to put inside .sort()?
anthonyjl92
@anthonyjl92
May 03 2016 01:58

does anyone know how i can remove newlines in a string using regex?
For example if i have:

<script> bob the builder </script>
var h=3;

<html>

i want it to look like

<script> bob the builder </script> var h=3;<html>

where i remove all the new lines

bjk116
@bjk116
May 03 2016 02:01
nevermind I figured it out.
Stephen James
@sjames1958gm
May 03 2016 02:02
@anthonyjl92 string.replace(/\n/g, "");
anthonyjl92
@anthonyjl92
May 03 2016 02:15
@sjames1958gm ty!
CamperBot
@camperbot
May 03 2016 02:15
anthonyjl92 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 922 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Casey Woelfle
@Cwoelfle
May 03 2016 02:15

Hi everyone I am stuck on "escaping literal quotes in strings" Could anyone kindly guide me to finding out what I did wrong?

var myStr = "I am a \"double quoted\" string inside \"double quotes\" "; // Change this line

Stephen James
@sjames1958gm
May 03 2016 02:20
@Cwoelfle That looks correct - try refreshing the browser
Miguel Asse
@cubang8r
May 03 2016 02:21
Hi everyone, I'm having issues with the Profile Lookup problem and have searched the past two nights to no avail
Casey Woelfle
@Cwoelfle
May 03 2016 02:21
@sjames1958gm refreshing doesn't fix the issue. Any other suggestions sir?
Miguel Asse
@cubang8r
May 03 2016 02:21
I feel like I'm close, does someone mind taking a look at my code?
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 if (contacts[i][firstName] !== firstName){
        return "No such contact";
}
  else if (contacts[i].hasOwnProperty(prop) === undefined){
    return "No such property";
  }
}
Leo Berlin
@leober
May 03 2016 02:23
I am not sure what I am doing wrong here

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

// Only change code below this line

myStorage.inside("glove box");

myStorahe has to return in JSON the map value
bitgrower
@bitgrower
May 03 2016 02:26
@loeber -- I recommend you review the other lessons on objects -- like how to address different parts of an object ... there are 2 ways: object notation, or dot notation ...
Leo Berlin
@leober
May 03 2016 02:27
@bitgrower thanks I will check that right now.
CamperBot
@camperbot
May 03 2016 02:27
leober sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1027 | @bitgrower |http://www.freecodecamp.com/bitgrower
Stephen James
@sjames1958gm
May 03 2016 02:28
@cubang8r Until you have tested all the contacts you shouldn't return no such contacts
JG2k1617
@JG2k1617
May 03 2016 02:28
Hi Guys. Im really stuck on the Stand in Line lesson in the javascript section. For some reason I can not really grasp what it is asking for. In my case I dont really know where to start. anyone else having issues with this same lesson?
Robert
@Brayn7
May 03 2016 02:28
@NLStom oh man i just finished that one you wanna see my code?
bitgrower
@bitgrower
May 03 2016 02:28
@cubang8r -- you're doing something many people get wrong on this challenge .... you need to look at all of the contacts before you can say there is no such contact
Stephen James
@sjames1958gm
May 03 2016 02:29
@Cwoelfle It might be that extra blank at the end between the quotes?
bitgrower
@bitgrower
May 03 2016 02:29
@JG2k1617 -- review the previous 4 challenges, which use .pop, .push, .shift & .unshift -- you will use 2 of these array functions to solve the challenge "Stand In Line"
@Brayn7 -- please don't post answers in this room ... you can either do it in private, or you can post to the codeReview room
JG2k1617
@JG2k1617
May 03 2016 02:31
Thanks @sjames1958gm ! i was looking over those recently and i think im close. I am just glad to know I am in the right direction. I feel like im really learning the most when i get completely stuck. funny how that works
CamperBot
@camperbot
May 03 2016 02:31
jg2k1617 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 923 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
bitgrower
@bitgrower
May 03 2016 02:32
LOL ... were those meant for me, @JG2k1617 ?
Stephen James
@sjames1958gm
May 03 2016 02:33
@JG2k1617 yeah bitgrower helped
JG2k1617
@JG2k1617
May 03 2016 02:33
hahaha yes sorry about that. Thanks @bitgrower !
CamperBot
@camperbot
May 03 2016 02:33
jg2k1617 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1028 | @bitgrower |http://www.freecodecamp.com/bitgrower
JG2k1617
@JG2k1617
May 03 2016 02:33
my apologies
its been a long day
bitgrower
@bitgrower
May 03 2016 02:33
yeah, auto-complete in gitter sucks ...
no apologies necessary -- like I say, gitter's auto-complete sucks -- I think we've all gotten stung by it ...
...and...you are most welcome ! :)
Chris Cullen
@123xylem
May 03 2016 02:36
help Seek and Destroy
CamperBot
@camperbot
May 03 2016 02:36

:point_right: algorithm seek and destroy [wiki]

Explanation:

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

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

Robert
@Brayn7
May 03 2016 02:38
@bitgrower :+1:
D.Mills
@millsdee74
May 03 2016 02:39
@n00b thanks for the explanation with Ceasar Cipher. Not really clear although I do understand better. Hope it doesn't bite me . Gotta keep moving forward. One!
CamperBot
@camperbot
May 03 2016 02:39
millsdee74 sends brownie points to @n00b :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for n00b
bitgrower
@bitgrower
May 03 2016 02:39
Seek and Destroy -- one of my favorites ... :)
Robert
@Brayn7
May 03 2016 02:40
@123xylem read about arguments object
bitgrower
@bitgrower
May 03 2016 02:41
^^^^ in detail !
Chris Cullen
@123xylem
May 03 2016 02:41
@Brayn7 thanks... I already know I can call it like an array
CamperBot
@camperbot
May 03 2016 02:41
123xylem sends brownie points to @brayn7 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @brayn7 |http://www.freecodecamp.com/brayn7
Robert
@Brayn7
May 03 2016 02:41
@123xylem what is the part you are stuck on? like whats your thought process?
bitgrower
@bitgrower
May 03 2016 02:42
it's very cool -- but tricky ... and NO you cannot call it EXACTLY like an array ... it is "array-like" -- but you cannot use array methods with it ... you can use array.length with it, and index into it like an array -- but after that, the sameness with an array pretty much stops ...
Chris Cullen
@123xylem
May 03 2016 02:42
args.indexOf(value).filter(value)
 var ar= arguments[0];
   var nd= arguments[1];
   var rd= arguments[2];

   for(i=0;i<ar.length;i++)

   { if (ar[i] === nd)
    ar.filter(nd);


   }
I tried to say if 2nd arg has anything in first arg.. remove 2nd arg
But it says 2 is not a function
lcassettai
@lcassettai
May 03 2016 02:44
@123xylem i think you have to pass a function to filter
Robert
@Brayn7
May 03 2016 02:44
@123xylem i personally made the last two args into one array with Array.prototype.slice.call(arguments); and slice
bitgrower
@bitgrower
May 03 2016 02:44
where's the rest of your code ? it seems like you are missing various things (among others, possibly a bracket after the first line you are showing)
and to filter something, you need to return either true or false in the array.filter callback function so that array-filter knows what to filter out
Chris Cullen
@123xylem
May 03 2016 02:46
@bitgrower Yea sorry that was the main bit of it.. I copy pasted... The top line isnt part of it.
Robert
@Brayn7
May 03 2016 02:46
@lcassettai @bitgrower @123xylem second what they said about passing the function into the filter
Chris Cullen
@123xylem
May 03 2016 02:47
@bitgrower Could what I did work if I added a certain line?
bitgrower
@bitgrower
May 03 2016 02:47
uhhhhhhh ... no ...
Chris Cullen
@123xylem
May 03 2016 02:48
yea Im startiing from scratch.. I know theres a way to do this with 1 line of code... I tried using my own way first but il do it the " proper way"
Bobby McDonald
@BobbyMcWho
May 03 2016 02:48
This Weather App is driving me nuts, can't find a decent APO
API*
bitgrower
@bitgrower
May 03 2016 02:48
okay -- you are getting an erro on the first line you are showing ... indexOf is going to return either a number (the position) or -1 -- which means you are handing a number, not an array to the filter function ...
Robert
@Brayn7
May 03 2016 02:48
@BobbyMcWho does the challenge not suggest a certain api?
Bobby McDonald
@BobbyMcWho
May 03 2016 02:49
@Brayn7 I thought people said that it will not work in Chrome?
Robert
@Brayn7
May 03 2016 02:49
@BobbyMcWho worked great for me
bitgrower
@bitgrower
May 03 2016 02:49

@123xylem -- people get in MORE trouble and waste MORE time trying to be clever .... first get a working solution .. THEN you can worry about it making it into a 1-line function, or faster, or whatever ...

...that is ABSOLUTELY how it is done in professional software development

...and it's really far too painful to do it the other way ... just sayin' (experience speaks here)
CamperBot
@camperbot
May 03 2016 02:50
no wiki entry for: with and operator httpswwwfreecodecampcomchallengescomparisons-with-the-logical-and-operator
Robert
@Brayn7
May 03 2016 02:50
@bitgrower i learned that the hard way too
Dylan
@dhcodes
May 03 2016 02:51
@BobbyMcWho have you tried the open weather map api suggested in the challenge?
Chris Cullen
@123xylem
May 03 2016 02:51
@bitgrower Its not like I know a working solution though... I tried to do it in a way that used what I already knew even though I kknew it was inefficient
Robert
@Brayn7
May 03 2016 02:51
@BobbyMcWho its super easy to use
Dylan
@dhcodes
May 03 2016 02:51
@Alhaji24 what's your question?
Bobby McDonald
@BobbyMcWho
May 03 2016 02:51
@dhcodes I'm going to try that now, someone had said that it wasn't good before
thanks @dhcodes and @Brayn7
CamperBot
@camperbot
May 03 2016 02:51
bobbymcwho sends brownie points to @dhcodes and @brayn7 :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @brayn7 |http://www.freecodecamp.com/brayn7
:cookie: 724 | @dhcodes |http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
May 03 2016 02:51
@BobbyMcWho it's as good as you need
welcome
Bobby McDonald
@BobbyMcWho
May 03 2016 02:52
Would you all recommend geolocation or IP tracking?
bitgrower
@bitgrower
May 03 2016 02:52
well - trying to do it fancier won't solve that problem, @123xylem -- you can do it with slice and/or splice, filter, and indexOf ... and a good handle on how the arguments object works ...
Robert
@Brayn7
May 03 2016 02:53
@BobbyMcWho i did geo it was easy... but i didnt try ip
bitgrower
@bitgrower
May 03 2016 02:53
from what I can see, you need to review what happens when chaining functions (or not chain them at all) -- and you definitely need to review array.filter ... (multiple issues on that one)
Dylan
@dhcodes
May 03 2016 02:53
@Alhaji24 right, but what is your question. What's your code?
Alhaji Turay
@Alhaji24
May 03 2016 02:53
not going through
Robert
@Brayn7
May 03 2016 02:54
@bitgrower @123xylem yeah def what he said read the helpful links on the side there
Alhaji Turay
@Alhaji24
May 03 2016 02:54

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

if (val > '25' && val < '50') {
return "Yes";
}
return "No";
}

Dylan
@dhcodes
May 03 2016 02:54
@Alhaji24 you have your numbers written as strings
take the single quotes off 25 and 50 and try that
Chris Cullen
@123xylem
May 03 2016 02:55
@bitgrower @Brayn7 Did you guys have previous coding education before this? Sometimes I read the links and I get lost in the terminology.. I have a rough grasp on what I read but Somethings are very confusing
Alhaji Turay
@Alhaji24
May 03 2016 02:55
no strings
bitgrower
@bitgrower
May 03 2016 02:55
^^^ what @dhcodes said ...
Alhaji Turay
@Alhaji24
May 03 2016 02:55
still not working
Casey Woelfle
@Cwoelfle
May 03 2016 02:56
@sjames1958gm that was the issue, thank you stephen, much appreciated.
CamperBot
@camperbot
May 03 2016 02:56
cwoelfle sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 924 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
bitgrower
@bitgrower
May 03 2016 02:57
yes AND array.filter and splice and arguments object were new to me .... array.filter -- never seen anything like it before (only a tiny bit of functional programming in python last summer) ... and arguments object -- never seen anything like it before ... splice was not a method or function I'd ever used before ...
Dylan
@dhcodes
May 03 2016 02:57
@Alhaji24 let me go look at the challenge really fast
Robert
@Brayn7
May 03 2016 02:57
@123xylem personally...i am just learning on my own, its gunna be hard but stay determined. everything you do it one step closer even if it a small baby step. keep asking questiions and getting help from smart people on this chat room. no question is too dumb.
bitgrower
@bitgrower
May 03 2016 02:57
I spent MANY MANY hours on Seek & Destroy ...
Brandon Huynh
@brandonvhuynh
May 03 2016 02:57
Can someone help me with convert celsius to fahrenheit?
Chris Cullen
@123xylem
May 03 2016 02:57
@Brayn7 @bitgrower thanks
CamperBot
@camperbot
May 03 2016 02:57
123xylem sends brownie points to @brayn7 and @bitgrower :sparkles: :thumbsup: :sparkles:
api offline
api offline
bitgrower
@bitgrower
May 03 2016 02:58
...and ALL of those hours were worthwhile ... in terms of my understanding & what I learned ...
Dylan
@dhcodes
May 03 2016 02:58
@Alhaji24 the directions say less than or equal to
Robert
@Brayn7
May 03 2016 02:58
@brandonvhuynh what part you need help with
Dylan
@dhcodes
May 03 2016 02:58
and greater than or equal to @Alhaji24 so you need to add = to each one
Casey Woelfle
@Cwoelfle
May 03 2016 02:58
@brandonvhuynh what part are you stuck on sir?
Dylan
@dhcodes
May 03 2016 02:58
after the comparison operator
Alhaji Turay
@Alhaji24
May 03 2016 02:58
@dhcodes ok thanks
CamperBot
@camperbot
May 03 2016 02:58
alhaji24 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
api offline
bitgrower
@bitgrower
May 03 2016 02:59
sometimes it helps to just take your code into one of the js playgrounds and play with it -- but I'm thinking array-filter -- you should have already had a challenge using that, no ?
bitgrower @bitgrower sends coffee to @camperbot ... wakey wakey
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 02:59
https://www.freecodecamp.com/challenges/record-collection
please can anyone help me with this challenge?

// Only change code below this line
function updateRecords(id, prop, value) {
if(value !== "" && prop !=="tracks"){
collection.id.artist=value;
}
else if(prop==="tracks"&&value !==""){
collection.id.tracks.push(value);
}
else if(value===""){
collection.id.pop(prop);
}

return collection;
}

Brandon Huynh
@brandonvhuynh
May 03 2016 03:00

@Brayn7 @Cwoelfle I am not entirely sure how to begin solving the problem. This is what I am given:

function convertToF(celsius) {
return fahrenheit;
}

convertToF(30);

Miguel Asse
@cubang8r
May 03 2016 03:00
Thanks @bitgrower and @sjames1958gm! Not solved but making progress :-)
CamperBot
@camperbot
May 03 2016 03:00
cubang8r sends brownie points to @bitgrower and @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
api offline
bitgrower
@bitgrower
May 03 2016 03:00
how comfortable are you with objects @MarynaNogtieva ?
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:00
it says TypeError: Cannot set property 'artist'
bitgrower
@bitgrower
May 03 2016 03:00
Keep it up -- the persistence will pay off @cubang8r
Robert
@Brayn7
May 03 2016 03:01
@brandonvhuynh well you need to take the arg and change it. to be vague and let you imagination get you there
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:01
@bitgrower
I'm confused how to get to the artist value
EricOber
@EricOber
May 03 2016 03:02
hey everyone im having trouble understanding what to do with this challenge "Record Collection" can someone help me?
// 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 




  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:03

how comfortable are you with objects @MarynaNogtieva ?

// 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 !== "" && prop !=="tracks"){
collection.id.artist=value;
}
else if(prop==="tracks"&&value !==""){
collection.id.tracks.push(value);
}
else if(value===""){
collection.id.pop(prop);
}

return collection;
}

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

bitgrower
@bitgrower
May 03 2016 03:04
you need to review how to address different parts of an object, @Am3ricanPaladin -- as does @MarynaNogtieva ... there are 2 basic ways ... dot & bracket notation...
bracket notation is far more flexible -- dot notation can only be used under some very restrictive conditions ...
EricOber
@EricOber
May 03 2016 03:04
oh right i remember that
George
@clefnetwork
May 03 2016 03:05
anyone have any ideas on functional programming exercises? really trying to strengthen my callbacks
Robert
@Brayn7
May 03 2016 03:05
@bitgrower how far have you gone in fcc
EricOber
@EricOber
May 03 2016 03:05
its like album.track versus album[track]
bitgrower
@bitgrower
May 03 2016 03:05
yeah -- may be good to go review those object challenges ... you will need them ...
haven't done any of the web projects, have done all but 3 of the js challenges...
I've been taking some detours ... :)
Robert
@Brayn7
May 03 2016 03:06
@bitgrower those are always good :)
bitgrower
@bitgrower
May 03 2016 03:06
right -- and if track is variable, you cannot use album.track
I've enjoyed them @Brayn7 :) ... think they've broadened out my understandings & background nicely ... :)
EricOber
@EricOber
May 03 2016 03:07
so then why dont people just use bracket notation exclusively?
bitgrower
@bitgrower
May 03 2016 03:07
good question, @Am3ricanPaladin ..
someone else will have to answer that -- but, I think it can make your code clearer if you are explicitly referencing THAT property -- no sense in making it a variable ...
EricOber
@EricOber
May 03 2016 03:09
maybe its an organizational type of thing? yea i think i will exclusively use bracket notation then. thanks @bitgrower
CamperBot
@camperbot
May 03 2016 03:09
am3ricanpaladin sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
api offline
bitgrower
@bitgrower
May 03 2016 03:09
...and, if you did, you would have to use quotes ... ['artist']
EricOber
@EricOber
May 03 2016 03:09
always quotes
bitgrower
@bitgrower
May 03 2016 03:10
quotes if it's a literal property name ...
EricOber
@EricOber
May 03 2016 03:10
ah
bitgrower
@bitgrower
May 03 2016 03:10
otherwise it will try to interpret it as a variable (at least that's how I understand it ... )
EricOber
@EricOber
May 03 2016 03:10
so with this challenge, these are the instructions: Write a function which takes an id, a property (prop), and a value.
For the given id in collection:
If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.
If value is blank, delete that prop.
Always return the entire collection object.
Robert
@Brayn7
May 03 2016 03:10
@bitgrower nice i have done some projects for friends but nothing special.
Chris Cullen
@123xylem
May 03 2016 03:11
var args = Array.prototype.slice.call(arguments[1] + [2]);
How do I make these 2 args into an array?
EricOber
@EricOber
May 03 2016 03:11
what does that mean write a function which takes an id, a property and a value for the given id?
Chris Cullen
@123xylem
May 03 2016 03:11
I know how to do all 3 but when I split them I dont know
bitgrower
@bitgrower
May 03 2016 03:12
convert the arguments into an array -- all of them ... then worry about splitting them out ... there are suggestions as to the functions you can use to do that within the instructions ...
k all ... I'm outta here -- have a good day/evening/afternoon/night ... :)
Dan Gallegos
@gallegos20
May 03 2016 03:13
Hey guys
I'm a bit stuck on Accessing objects with bracket notation..
code is as follows
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj["16"];       // Change this Line
var player = playerNumber;
Not sure what I'm doing wrong here.. I'm getting p;ayer to be equal to Montana
Says I should be using bracket notation to access testObj (thought I was...)
and playerNumber should be a number.
Omid
@omidqayoumi
May 03 2016 03:16
need some help on reverse a string algorithm challenge
function reverseString(str) {
  var array = [];
  for (i = 0; i < str.length; i++){
  array[i] = str.charAt(i);
  }
  array = array.reverse();
  array = array.join();
}

reverseString("hello");
oh I forgot to return it, how silly
Dan Gallegos
@gallegos20
May 03 2016 03:18
Anyone on my issue?
It says I should use bracket notation to access testObj.. I feel like I am?
lol wow I'm dumb
nvm
Robert
@Brayn7
May 03 2016 03:19
@gallegos20 reset the challenge and see if that helps
Dan Gallegos
@gallegos20
May 03 2016 03:19
No I'm stupid.
They wanted me to call it as
var player = testObj[playerNumber]
so, use my playerNumber variable to pass in the number and return to associated string
lol
Robert
@Brayn7
May 03 2016 03:20
@gallegos20 if i recall i did the same thing on several challenges so dont worry bout it
@gallegos20 you got it yo
Dan Gallegos
@gallegos20
May 03 2016 03:21
thanks @Brayn7
CamperBot
@camperbot
May 03 2016 03:21
gallegos20 sends brownie points to @brayn7 :sparkles: :thumbsup: :sparkles:
api offline
Omid
@omidqayoumi
May 03 2016 03:22
did my first algorithm yayy
Robert
@Brayn7
May 03 2016 03:23
@omidqayoumi niiiiccceee!
Dan Gallegos
@gallegos20
May 03 2016 03:23
grats
Omid
@omidqayoumi
May 03 2016 03:23
feels great when I solve my own problem :D
Jonathon Lopez
@JonathonLLopez
May 03 2016 03:25

Need a little help here:

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.


var count = 0;

function cc(card) {
  // Only change code below this line
  if (count == < 0) {
    return count + " Hold";
  } else if (count > 0) {
    return count + " Bet";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:38
This message was deleted
Dan Gallegos
@gallegos20
May 03 2016 03:38
@MarynaNogtieva hey
@MarynaNogtieva do a SWITCH
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:39
@gallegos20 I've alredy done that
@gallegos20 solved the problem
Brian Danowski
@mailtruck
May 03 2016 03:39
hi, I made a calculator app using eval(), but I heard a while ago that it's not a good idea to use eval like ever... is it fine for the sake of this calculator app example, or is there a better way to do the calculations?
Dan Gallegos
@gallegos20
May 03 2016 03:39
@MarynaNogtievaOk :)
Johnny K Juarez
@Reapnsow
May 03 2016 03:39
Is there a bug with the Introducing Else If Statements lesson?
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:39
@JonathonLLopez you need to do SWITCH
Dan Gallegos
@gallegos20
May 03 2016 03:40
@JonathonLLopez Yes, a few challenge back from that for refresher
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:40
@JonathonLLopez here is the hint: switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count ++;
break;
Dan Gallegos
@gallegos20
May 03 2016 03:41
yes.. remember, Case as in "In the case of" - 2 then 3, 4, 5, 6, Add 1 to count
etc.
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 03:41

@JonathonLLopez then you can check the count
if(count>0){
return count + " Bet";
}

hope, you got an idea

Chris Cullen
@123xylem
May 03 2016 03:41

Is this returning the empty second argument because its false? If so is it possible for me to return the whole array with args[1] missing? Or should I just go about this another way?```js
function destroyer(arr) {
var ar= arguments[0];
var nd= arguments[1];
var rd= arguments[2];
function work(){
for(i=0;i<ar.length;i++)

{ if (ar[i] === nd)
return false;

else {return true;}
}}arr.filter(work);
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

```

Is this returning the empty second argument because its false? If so is it possible for me to return the whole array with args[1] missing? Or should I just go about this another way? js function destroyer(arr) { var ar= arguments[0]; var nd= arguments[1]; var rd= arguments[2]; function work(){ for(i=0;i<ar.length;i++) { if (ar[i] === nd) return false; else {return true;} }}arr.filter(work); } destroyer([1, 2, 3, 1, 2, 3], 2, 3);
oops
function destroyer(arr) { var ar= arguments[0]; var nd= arguments[1]; var rd= arguments[2]; function work(){ for(i=0;i<ar.length;i++) { if (ar[i] === nd) return false; else {return true;} }}arr.filter(work); } destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Johnny K Juarez
@Reapnsow
May 03 2016 03:47

function testElseIf(val) {
if (val > 10) {
return "Greater than 10";
} else if (val < 5) {
return "smaller than 5";
} else{
return "Between 5 and 10";
}
}

// Change this value to test
testElseIf(0);

keep getting red X on testElseIf(0) should return "Smaller than 5"
and it does give me that return, but it's not acknowledging it
Dan Gallegos
@gallegos20
May 03 2016 03:48
try and switch order
do between 5 and 10 second
then less than 5 as the else
if(val > 10) {
return "Greater than 10";
} else if(val >= 5) {
return "Between 5 and 10";
} else{
return "smaller than 5";
}
Johnny K Juarez
@Reapnsow
May 03 2016 03:51
ahhh, thanks @gallegos20
CamperBot
@camperbot
May 03 2016 03:51
reapnsow sends brownie points to @gallegos20 :sparkles: :thumbsup: :sparkles:
api offline
Chris Cullen
@123xylem
May 03 2016 03:51
I am now getting arg0 to log... So my syntax is ok but my function isnt quite right... Any tips?

function destroyer(arr) {
 var ar= arguments[0];
   var nd= arguments[1];
   var rd= arguments[2];
function work(){
   for(i=0;i<ar.length;i++)

   { if (ar[i] === rd)
    return false;


  else {return true;}
   }}
  var result = arr.filter(work);
  return result;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Dan Gallegos
@gallegos20
May 03 2016 03:51
@Reapnsow Let me know if it works lol
Chris Cullen
@123xylem
May 03 2016 03:52
{ if (ar[i] === rd)
return false;
I thought this would search arg0 and if it was the same as arg1 it would remove it from arg0
buiphuking
@buiphuking
May 03 2016 03:56
anyone understand heap's algorithm , help me
Bobby McDonald
@BobbyMcWho
May 03 2016 04:02
Can anyone help me figure out why my second API won't call?
var zip = "";
var deg = "";
$(document).ready(function () {  
    $.ajax({
        type:'GET',
        url: 'http://ip-api.com/json',
        success:function(data){
           zip = data.zip;
            $('#address').text(zip);
        },
        complete: getTemp
    });




       function getTemp(){
            $.ajax({
               type:'GET',
                url:('http://api.openweathermap.org/data/2.5/weather?zip=' + zip + ',us'),
                success:function(data){
                    deg = data.main.temp;
                 $('#temp').text(deg);}});}
});
Jonathon Lopez
@JonathonLLopez
May 03 2016 04:07
@MarynaNogtieva I've almost got it, but there's still an error:

var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    count++;
      return count + " Bet";
      break;
    case 7:
    case 8:
    case 9:
      return count + " Hold";
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
    count --;
      return count + " Hold";
  }
    if (count > 0){
      return count + " Bet";
    } else if (count < 0) {
      return count + " Bet";
    }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc('J'); cc(9); cc(2); cc(7);
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 04:11

@JonathonLLopez
Yeah, don't use return statement in your switch;
if you use return, code will not be executed after that(so there is no point in using break)

I solved it by following:
function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count ++;
break;

case 7:
case 8:
case 9:

break;

case 10:
case "J":
case "Q":
case "K":
case "A":
  count --;

}
if(count>0){
return count + " Bet";
}

else{
return count + " Hold";
}

Jonathon Lopez
@JonathonLLopez
May 03 2016 04:16
@MarynaNogtieva Ahh, that makes sense. That was a little tricky for me. I just wanted to make sure I fully understood it
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 04:17
@JonathonLLopez
Yeah, it was tricky.
Jonathon Lopez
@JonathonLLopez
May 03 2016 04:18
@MarynaNogtieva Thank you for your help
CamperBot
@camperbot
May 03 2016 04:18
jonathonllopez sends brownie points to @marynanogtieva :sparkles: :thumbsup: :sparkles:
api offline
Maryna Nogtieva
@MarynaNogtieva
May 03 2016 04:19
@JonathonLLopez
No problem
henrywashere
@henrywashere
May 03 2016 04:21
help counting cards
CamperBot
@camperbot
May 03 2016 04:21

:point_right: challenge counting cards [wiki]

Checkpoint: Counting Cards

About Blackjack

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Value Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'

Instructions

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Example Output:

:pencil: read more about challenge counting cards on the FCC Wiki

henrywashere
@henrywashere
May 03 2016 04:22
can anyone help me with this?
Bobby McDonald
@BobbyMcWho
May 03 2016 04:23
Yeah this weather API is definitely not working for me
Chris Cullen
@123xylem
May 03 2016 04:34
Shouldnt this at least filter the first arg array??? Not sure why Its not filtering anything
function destroyer(arr) {

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


var result =args.filter(function(v,i,a) {return args.indexOf(v) == i;});
return result;

} 

destroyer([1, 2, 3, 1, 2, 3],2,3);
Mick
@MickBass
May 03 2016 04:36
Word Blanks... what the hell do you do the instructions are useless.. I have no idea what Im meant to acheive
Chris Cullen
@123xylem
May 03 2016 04:37
as far as I understand it im saying.. Filter args at index value of Value(the numbers in array)... If they are equal to their index value then keep them otherwise delete.. Their index value is stored only once so any duplicatsed should be removed
Kris
@KrisGeyer
May 03 2016 04:38
I got through the card counting puzzle by making an if function which would affect the variable count, you actually only need to do it for less than 7 and more than 10 (with also a lot of "or" with strings such as "J" || "Q"...) Then I did a switch for the responses in the count. I had to create a new Bet variable. so Switch (count){
sorry.. switch (count){ case 5: bet = "bet 5"; break;
Omid
@omidqayoumi
May 03 2016 04:40
@henrywashere show your code
Adit Jain
@aditj
May 03 2016 04:43
function lookUpProfile(firstName, prop){
// Only change code below this line
  var c = -1;
for(var i=0;i<contacts.length;i++)
  {
    if((contacts[i].firstName===firstName) && (contacts[i].hasOwnProperty(prop)===true)){
      c=1;
        return contacts[i][prop];



     }
    else if((contacts[i].firstName===firstName)&&(contacts[i].hasOwnProperty(prop)===false)){
      c=1;
        return "No Such Property";

      }
    else {
      c=-1;
    }

}
  if(c==-1){
  return"No such Contact";
  }
// Only change code above this line
}
Why does it not run? Please Help!
Martialis39
@Martialis39
May 03 2016 04:44
Hello guys!
Search and replace, how do I check for a capital letter?
should I use a regex?
Greg D
@mosaic-greg
May 03 2016 04:45
@Martialis39 maybe use String.charCodeAt() or regex
Martialis39
@Martialis39
May 03 2016 04:46
@mosaic-greg good idea! Thanks :)
CamperBot
@camperbot
May 03 2016 04:46
martialis39 sends brownie points to @mosaic-greg :sparkles: :thumbsup: :sparkles:
:cookie: 350 | @mosaic-greg |http://www.freecodecamp.com/mosaic-greg
Greg D
@mosaic-greg
May 03 2016 04:47
np
Adit Jain
@aditj
May 03 2016 05:06
Anyone?
Omid
@omidqayoumi
May 03 2016 05:07
I'll check it out thanks ^^ @Mashadim
CamperBot
@camperbot
May 03 2016 05:07
omidqayoumi sends brownie points to @mashadim :sparkles: :thumbsup: :sparkles:
:cookie: 353 | @mashadim |http://www.freecodecamp.com/mashadim
EricOber
@EricOber
May 03 2016 05:09
ello
got a question for the experts in the room
what other "things" (dont know what to call them) can I use other than if else statements?
anyone?
Stevo
@PinCove
May 03 2016 05:13
@Am3ricanPaladin are you still on the album collection challenge?
celoos
@celoos
May 03 2016 05:16
mm I'm having some issues with the escape sequences... for some reason they're not being processed.
To check that I wasn't doing it wrong - I took the code from the previous challenge involving double quotes and that doesn't process either.
GowthamReddyAmbati
@GowthamReddyAmbati
May 03 2016 05:19
Hi All, i'm working on Random Quote Machine.. I'm stuck with the twitter share feature
Would you please help me on this?
Emma Clark
@sapphirestone
May 03 2016 05:21
@celoos from memory I had the same problems with escape sequences
christianws
@christianws
May 03 2016 05:27

function isLess(a, b) {
// Fix this code
switch(a,b){
case (a===b) :
return false;
case (a >= b):
return true;
}

}

I'm having trouble with this code from the return 'boolean values from function' campfire

celoos
@celoos
May 03 2016 05:27
@sapphirestone so... skip it? :P
christianws
@christianws
May 03 2016 05:32
ahh man was so easy no worries
Emma Clark
@sapphirestone
May 03 2016 05:34
@celoos I did skip it, but I think I will have to complete it eventually
marcsnts
@marcsnts
May 03 2016 05:34
skip what @sapphirestone
Emma Clark
@sapphirestone
May 03 2016 05:36
the escape sequences exercise
marcsnts
@marcsnts
May 03 2016 05:36
you gota space them out
Emma Clark
@sapphirestone
May 03 2016 05:37
@CurlyWS I think your problem might be with the ":" after case()
marcsnts
@marcsnts
May 03 2016 05:37
and a single backslash is written as \\
This message was deleted
Emma Clark
@sapphirestone
May 03 2016 05:39
Oh no wait... what I advised might not be correct @CurlyWS
Chris Cullen
@123xylem
May 03 2016 05:43
Can someone explain the arr.filterFunction to me here? It seems very basic and for instance why do they use the word element?
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  args.splice(0, 1);
  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  });
}
Emma Clark
@sapphirestone
May 03 2016 05:44
You may want to check if you can use case arguements inside a switch statement @CurlyWS
devpaaji
@devpaaji
May 03 2016 05:44
how can i push my FCC code to Github
christianws
@christianws
May 03 2016 05:44
@sapphirestone I am unsure but the problem was really simple
Chris Cullen
@123xylem
May 03 2016 05:44
help format
CamperBot
@camperbot
May 03 2016 05:44

: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 the code.

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

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

christianws
@christianws
May 03 2016 05:45
it was just return a<b; (something like that anyway) one line
switch statement was not needed
thanks
```
Goun Choe
@lenaChoe
May 03 2016 05:46

hey guys.. I'm trying to use Wikipedia API's json results! but I kept having this error messages: index.html:1 XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=coffee. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.

Does anyone know how to deal with this??

christianws
@christianws
May 03 2016 05:46
```
asd
```
EricOber
@EricOber
May 03 2016 05:50
hey @PinCove I am on the Record Collection challenge, yes.
Stevo
@PinCove
May 03 2016 05:53
@Am3ricanPaladin my code is not working, I've been working on it for roughly an hour. I've tried if statements and switch, can't get either to work. I also constantly get the TypeError: Cannot read property 'push' of undefined. Struggling to .push anything into my arrays. How are things on your end?
devpaaji
@devpaaji
May 03 2016 05:54
@PinCove are you working on JS algorithms part
marcsnts
@marcsnts
May 03 2016 05:55
@PinCove show your code
EricOber
@EricOber
May 03 2016 05:55
ah right, weve only learned if statments and switch statements so far
those are called "arguments" right?
marcsnts
@marcsnts
May 03 2016 05:56
?
whats called arguments
Stevo
@PinCove
May 03 2016 05:56
@devpaaji I'm in the "Basic JavaScript" section right now, currently working on the challenge "Record Collection". Give me one moment and I will send my code @marcsnts .
EricOber
@EricOber
May 03 2016 05:57
I am also working on the "record collection" challenge
marcsnts
@marcsnts
May 03 2016 05:58
show me your codes
EricOber
@EricOber
May 03 2016 05:59
I dont have anything yet. I am at a loss of what to do
but here is the starting out code
Stevo
@PinCove
May 03 2016 06:00
I have never shared my code on this before, should I just Copy Paste, or would you prefer I figure out how to put it up with the background and all?
marcsnts
@marcsnts
May 03 2016 06:00
i dont really case
EricOber
@EricOber
May 03 2016 06:00
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
marcsnts
@marcsnts
May 03 2016 06:00
care
my tip for these challenges
are to make sure all the requests are made
i do that first

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

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

If value is blank, delete that prop.

marcsnts
@marcsnts
May 03 2016 06:02
so i'd make an if (condition) { dowhatever; }
Stevo
@PinCove
May 03 2016 06:02

// 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(prop!=="artist" && value!=="" )
collection[id][prop].push(value);

return collection;
}

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

EricOber
@EricOber
May 03 2016 06:02
steve you gotta push three of these ``` then type js after that
```js
Stevo
@PinCove
May 03 2016 06:02
@marcsnts Here is what i have thus far, it doesn't seem to be working.
EricOber
@EricOber
May 03 2016 06:02
then paste your code
code
Stevo
@PinCove
May 03 2016 06:03
'''code'''
CamperBot
@camperbot
May 03 2016 06:03
:bulb: to format code use backticks! ``` more info
Stevo
@PinCove
May 03 2016 06:03
ive failed lol
code
EricOber
@EricOber
May 03 2016 06:04
```js
code
marcsnts
@marcsnts
May 03 2016 06:04
@PinCove you meant to do prop !== "tracks"
EricOber
@EricOber
May 03 2016 06:05
tick tick tick js
YOUR CODE
tick tick tick
the tick is next to the #1
Stevo
@PinCove
May 03 2016 06:05
yes that's my bad, but I seem to be having issues getting the .push program to work.
marcsnts
@marcsnts
May 03 2016 06:06
@PinCove and you only push when the prop given is "tracks". your .push method gives you an error because you're trying to .push into things that aren't arrays
Stevo
@PinCove
May 03 2016 06:06
I keep getting TypeError: Cannot read property 'push' of undefined
marcsnts
@marcsnts
May 03 2016 06:07
@PinCove because you cant Array.push into things that aren't arrays
Stevo
@PinCove
May 03 2016 06:07
@marcsnts so I've just not followed the directions correctly?
marcsnts
@marcsnts
May 03 2016 06:08
your code
if(prop!=="artist" && value!=="" )
collection[id][prop].push(value);
Chris Cullen
@123xylem
May 03 2016 06:08
How does this work? SUrely It only returns args and not the array?js function destroyer(arr) { var args = Array.prototype.slice.call(arguments); args.splice(0, 1); return arr.filter(function(element) { return args.indexOf(element) === -1; }); }
marcsnts
@marcsnts
May 03 2016 06:08
this if statement will enter when album is the prop and value is not NULL
and since album is not an array... you can't Array.push it
Stevo
@PinCove
May 03 2016 06:09
OH I think I understand
Darth Skywalker
@adityaparab
May 03 2016 06:10
@123xylem : arguments is not an Array it is an array like object. So the code you've shared converts that object into Array and destroys it.
prashant
@findname
May 03 2016 06:10
function rot13(str) { // LBH QVQ VG!
  var arr=[];
  arr=str.split("");
  for(i=0;i<str.length;i++)
 {    
     if(arr[i]!==" ")
   {  arr[i]=str.charCodeAt(i)-13;
    if(arr[i]<65) arr[i]=100-(65-arr[i]);
     arr[i]=String.fromCharCode(arr[i]);
   }
     }
  return arr.join("");
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
anything wrong with this code
its returning some of word incoreect
Darth Skywalker
@adityaparab
May 03 2016 06:11
for(i=0;i<str.length;i++) should be for(i=0;i<arr.length;i++)
Mateusz Szymański
@matszym
May 03 2016 06:12

@findname

i=0

You didnt create variable with var, therefore you are poluting window object

Marian Menschig
@mmenschig
May 03 2016 06:12
anyone know why this doesn't work
$(document).ready(function() {

    $.getJSON("data/quotes.json"), function(json) {
        console.log(json);
    };
});
Mateusz Szymański
@matszym
May 03 2016 06:13
This message was deleted
Darth Skywalker
@adityaparab
May 03 2016 06:13
@matszym : if i=0 isn't declared with var it gets created on the window scope. (provided "use strict" is not enabled) So that is not the problem here. There is a semantic issue.
prashant
@findname
May 03 2016 06:14
@matszym used var now still same
Mateusz Szymański
@matszym
May 03 2016 06:14
@adityaparab Thats what I said, "poluting window object"
Darth Skywalker
@adityaparab
May 03 2016 06:15
@findname : Can you try parseInt(str.charCodeAt(i))-13;
Mateusz Szymański
@matszym
May 03 2016 06:16
@adityaparab Might not be the case, charCodeAt will return integer, I was wrong
Darth Skywalker
@adityaparab
May 03 2016 06:16
@mmenschig Whats the error?
Marian Menschig
@mmenschig
May 03 2016 06:17
@adityaparab ughhhhhh.....i just discovered it. it's a missing parenthesis
prashant
@findname
May 03 2016 06:18
@adityaparab its same (out put)
Mateusz Szymański
@matszym
May 03 2016 06:19

@findname

if(arr[i]<65) arr[i]=100-(65-arr[i]);

Inserting ; after if statement prevents whole concept of if

prashant
@findname
May 03 2016 06:19
@matszym but i applied condition before that in same line
celoos
@celoos
May 03 2016 06:19
@marcsnts on the sequences for some reason it just wasn't parsing the string correctly... I took the exact same string from the prior challenge and it wouldn't parse it either. :\
prashant
@findname
May 03 2016 06:20
 if(arr[i]<65) 
       arr[i]=100-(65-arr[i]);
@matszym
Darth Skywalker
@adityaparab
May 03 2016 06:20
This message was deleted
Mateusz Szymański
@matszym
May 03 2016 06:20
@findname Yes you did. I see now. Its so criptic tho. You shoud use your white spaces
christianws
@christianws
May 03 2016 06:22
hey guys how can I post my code on here so it is contained within a black box
prashant
@findname
May 03 2016 06:23
paste inside ``` and press enter and close usiing same @CurlyWS
Darth Skywalker
@adityaparab
May 03 2016 06:23
@findname
function rot13(str) { // LBH QVQ VG!
  var arr=[];


  arr=str.split("");
  for(i=0;i<str.length;i++){    
     if(arr[i]!==" ") {
          arr[i]=str.charCodeAt(i)-13;
    }
    if(arr[i]<65){
        arr[i]=100-(65-arr[i]);
    } else {
        arr[i]=String.fromCharCode(arr[i]);
    }
   }
  return arr.join("");
}
// Change the inputs below to test
rot13("SERR PBQR PNZC")
christianws
@christianws
May 03 2016 06:24
code
AhmedA-del
@AhmedA-del
May 03 2016 06:25
function findLongestWord(str) {
  var toArray = str.split();
  var c = 0;
  for (var i = 0 ; i < toArray.length ;i++) {
    if (toArray[i] == /\s/g) {
      if (c < i - 1){
      c = i + 1;
        return c;
      }
    }
  }

}
Thomas G.
@CaptainMurphey
May 03 2016 06:25

function golfScore(par, strokes) {
// Only change code below this line
var score = strokes - par;
if(strokes===1){return "Hole-in-one!";}
else if(score<=-2){return "Eagle";}
else if(score==-1){return "Birdie";}
else if(score===0){ return "Par";}
else if(score===1){ return "Bogey";}
else if(score===2){ return "Double Bogey";}
else {

return "Go Home!";
// Only change code above this line
}
}

// Change these values to test
golfScore(5, 4);

WHOS THE MAN? IM THE MAN - GOLF SCORES SHALL BOW BEFORE MY MIGHTY CODING SKILLS!
:)

christianws
@christianws
May 03 2016 06:25
thank you how do I send these brownie points I keep seeing?
Darth Skywalker
@adityaparab
May 03 2016 06:26
@findname : Always use curly braces. Follow JS style for curly braces. Always use for(...) {
instead of
for(...)
{
.
.
.
}
Chris Cullen
@123xylem
May 03 2016 06:26
@adityaparab right... im tryin to see how the function at the end works
Thomas G.
@CaptainMurphey
May 03 2016 06:26
@CurlyWS you click the persons name like i did yours and put thanks somewhere in the message
CamperBot
@camperbot
May 03 2016 06:26
captainmurphey sends brownie points to @curlyws :sparkles: :thumbsup: :sparkles:
Chris Cullen
@123xylem
May 03 2016 06:26
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  args.splice(0, 1);
  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  });
}
CamperBot
@camperbot
May 03 2016 06:26
:cookie: 96 | @curlyws |http://www.freecodecamp.com/curlyws
christianws
@christianws
May 03 2016 06:27
@camperbot thanks!
CamperBot
@camperbot
May 03 2016 06:27
curlyws sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1647 | @camperbot |http://www.freecodecamp.com/camperbot
christianws
@christianws
May 03 2016 06:27
@findname thanks
CamperBot
@camperbot
May 03 2016 06:27
curlyws sends brownie points to @findname :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @findname |http://www.freecodecamp.com/findname
Thomas G.
@CaptainMurphey
May 03 2016 06:27
@CurlyWS camperbot doesnt want you thx, camperbot needs no thx
CamperBot
@camperbot
May 03 2016 06:27
captainmurphey sends brownie points to @curlyws :sparkles: :thumbsup: :sparkles:
:warning: captainmurphey already gave curlyws points
prashant
@findname
May 03 2016 06:28
@adityaparab oh ok thanks
CamperBot
@camperbot
May 03 2016 06:28
findname sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 157 | @adityaparab |http://www.freecodecamp.com/adityaparab
christianws
@christianws
May 03 2016 06:28
Can someone help me with the Counting Cards
var count = 0;

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

    case 2: case 3: case 4: case 5: case 6:
    card++;  
    return card; 
    break;
    case 10: case 'J': case 'Q': case 'K': case 'A':
    card--;
    break;

}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
everything is coming out null
Michael Karpinski
@karpimpski
May 03 2016 06:31
@CurlyWS I'm not sure if you can use cases like that
@CurlyWS oh. looks like they can. my bad
marcsnts
@marcsnts
May 03 2016 06:31
you can its like saying or
Michael Karpinski
@karpimpski
May 03 2016 06:32
@CurlyWS either way, it would be more efficient to use 2 if statements, less writing
marcsnts
@marcsnts
May 03 2016 06:32
@CurlyWS chain card++ and card-- to count++ count--
nah switch is less writing
christianws
@christianws
May 03 2016 06:33
I'm sorry can you explain what you mean by chaining please macsnts?
Michael Karpinski
@karpimpski
May 03 2016 06:33
@marcsnts meh, in cases like this I prefer if statements, but to each his own
marcsnts
@marcsnts
May 03 2016 06:33
change*
christianws
@christianws
May 03 2016 06:35
ahh yes of course
prashant
@findname
May 03 2016 06:39
@adityaparab you added else after if that wasnt required
AhmedA-del
@AhmedA-del
May 03 2016 06:40
function titleCase(str) {
  var toArray = str.split("");
  var firstLetter = toArray[0].toUpperCase;
  return firstLetter;

}
I'm just trying to capitalize the first letter and return it but when i run the code it says testing chllenge......
kirbyedy
@kirbyedy
May 03 2016 06:40
@AhmedA-del try to reload the page
maybe its stuck
AhmedA-del
@AhmedA-del
May 03 2016 06:41
@kirbyedy i tried a lot
kirbyedy
@kirbyedy
May 03 2016 06:41
hmmm
clear browser cache ?
devpaaji
@devpaaji
May 03 2016 06:43
@AhmedA-del what exercise is that
can you tell me
in JS
prashant
@findname
May 03 2016 06:43
function rot13(str) { // LBH QVQ VG!
  var arr=[];
  arr=str.split("");
  for(var i=0;i<str.length;i++)
 {    
     if(arr[i]!==" "){  //arr[i]=str.charCodeAt(i)-13;
    arr[i]=parseInt(str.charCodeAt(i))-13;
     if(arr[i]<65) 
       arr[i]=100-(65-arr[i]);
     arr[i]=String.fromCharCode(arr[i]);
   }
     }
  return arr.join("");
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
AhmedA-del
@AhmedA-del
May 03 2016 06:43
@devpaaji Title Case a Sentence
devpaaji
@devpaaji
May 03 2016 06:43
ok
see it is easy
i will help you
in simple tersm
function titleCase(str) {
  str = str.toLowerCase().split(' ');
  for (var i = 0; i < str.length; i++) {
    str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1).toLowerCase(); 
  }
  return str.join(' ');

 // return str.toLowerCase().split(' ').map(function(word) {
   // return (word.charAt(0).toUpperCase() + word.slice(1));
 // }).join(' ');
}
christianws
@christianws
May 03 2016 06:44

can someone help me how so I can return two variables e.g.

var card = 3;
var text = "good card";

//here is what I want to work

return card . text;

I want this to return "3 good card"

devpaaji
@devpaaji
May 03 2016 06:44
try to understand and see whats going on
marcsnts
@marcsnts
May 03 2016 06:44
cant return 2 variables
devpaaji
@devpaaji
May 03 2016 06:44
in my comments part
marcsnts
@marcsnts
May 03 2016 06:44
unless its an array
devpaaji
@devpaaji
May 03 2016 06:44
i have also included
prashant
@findname
May 03 2016 06:44
return (card, text);
devpaaji
@devpaaji
May 03 2016 06:44
another way of doing
@Ahmed-M-T makes sense
AhmedA-del
@AhmedA-del
May 03 2016 06:45
@devpaaji thanks :smile:
CamperBot
@camperbot
May 03 2016 06:45
ahmeda-del sends brownie points to @devpaaji :sparkles: :thumbsup: :sparkles:
:cookie: 128 | @devpaaji |http://www.freecodecamp.com/devpaaji
devpaaji
@devpaaji
May 03 2016 06:45
please test and write comments
as you go along
if you not able to understand
Mateusz Szymański
@matszym
May 03 2016 06:46
@findname
function rot13(str) { // LBH QVQ VG!
  var arr = str.split("");
  // arr = ['S', 'E', 'R', 'R', ' ', 'P',...]
   for(var i = 0; i < str.length; i++) {    
      if(arr[i] !== " "){  
         arr[i] = parseInt(str.charCodeAt(i), 10) - 13;
         // instead of char ther is number representation of letter - 13
         // E -> 57
         if(arr[i] < 65) 
            arr[i] = 90 - (64 - arr[i]);
            // for E, arr[i] = 90 - (65 - 57); -> 82


         arr[i] = String.fromCharCode(arr[i]);
      }
   }
  return arr.join("");
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
devpaaji
@devpaaji
May 03 2016 06:46
though I have used most in build functions
AhmedA-del
@AhmedA-del
May 03 2016 06:47
@CurlyWS you can make this variables into 1
christianws
@christianws
May 03 2016 06:47
@findname this does not work unfortunately
prashant
@findname
May 03 2016 06:48
@matszym oops it hould be 90 ; and commented section means that i need to change these
christianws
@christianws
May 03 2016 06:48
@AhmedA-del perhaps this is a better solution. I know I can already solve this problem with multiple if statements but I want my code to be more efficient
Mateusz Szymański
@matszym
May 03 2016 06:48
@CurlyWS
return card + ' ' + text;
@findname it should work, rot13("SERR PBQR PNZC"); returns FREE CODE CAMP
christianws
@christianws
May 03 2016 06:50
@matszym this doesn't work actually
@matszym actually hang on
it does work my mistake
prashant
@findname
May 03 2016 06:51
@matszym yeah it works for free code camp thanks
CamperBot
@camperbot
May 03 2016 06:51
:cookie: 28 | @matszym |http://www.freecodecamp.com/matszym
findname sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
christianws
@christianws
May 03 2016 06:51
@matszym thanks
CamperBot
@camperbot
May 03 2016 06:51
curlyws sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 29 | @matszym |http://www.freecodecamp.com/matszym
christianws
@christianws
May 03 2016 06:51
@AhmedA-del thank you
CamperBot
@camperbot
May 03 2016 06:51
curlyws sends brownie points to @ahmeda-del :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @ahmeda-del |http://www.freecodecamp.com/ahmeda-del
AhmedA-del
@AhmedA-del
May 03 2016 06:54
@devpaaji why str[i] is the variable instead of str without brackets
Steve
@smr312
May 03 2016 06:55
How would I assign a value to A then assign the contents of A to variable B?
var a;
var b = 2;
AhmedA-del
@AhmedA-del
May 03 2016 06:55
@smr312 a = b; ?
devpaaji
@devpaaji
May 03 2016 06:56
@AhmedA-del when you split it converts string to array
so ahmed becomes [a, h, m, e, d];
prashant
@findname
May 03 2016 06:56
@matszym why did you used parseInt(str.charCodeAt(i), 10);
devpaaji
@devpaaji
May 03 2016 06:56
since index position starts at 0
christianws
@christianws
May 03 2016 06:56
excellent just completed challenge thanks
prashant
@findname
May 03 2016 06:57
@matszym ,10 one part
devpaaji
@devpaaji
May 03 2016 06:57
so str[i] we use loop to iterate
first we lowercase the str
then split to convert to arrays
then use loop to title case only the first letter and lowercase others
and use join method to return the string
Mateusz Szymański
@matszym
May 03 2016 06:58

@findname

secod argument in parseInt is radix parametr - 10 means its decimal number, and should be treated as such

Steve
@smr312
May 03 2016 06:58
oooh, now i see how it was so simple
thanks
devpaaji
@devpaaji
May 03 2016 06:59
@Ahmed-M-T if sentence is " I am a front end developer"
then split will break into arrays
then str[i] will check i, am, a, front, end....
like 0,1,2,3
and uppercase the first letter
read about arrays and position
Naguib Bouchibi ⚡️
@naguib101
May 03 2016 07:01
Hi everyone ! Might be quick, does someone knows why I have to click twice on my onclick button to actually trigger it ?
I read its because of the first declaration of some vars but I can't do anything .. :-/
Mateusz Szymański
@matszym
May 03 2016 07:02
@skyrunner176 post code
AhmedA-del
@AhmedA-del
May 03 2016 07:02
@devpaaji but if i is 0 then it will be
str[0] = str[0].charAt(0).toUpperCase() + str.slice(1);
which means str[i] will have the whole string
devpaaji
@devpaaji
May 03 2016 07:03
 str = str.toLowerCase().split(' ');
can you console.log(str); to see what it is displaying
then i will show you further
The split() method is used to split a string into an array of substrings, and returns the new array.
Javier
@sh1g
May 03 2016 07:05
function sumPrimes(num) {
    var prime = [];
    var notPrime = [];
    for (var i = 0; i <= num; i++) {
        if(i <= 1){
            notPrime.push(i);
        } else if (i <= 3){
            prime.push(i);
        } else if (i % 2 === 0 || i % 3 ===0){
            notPrime.push(i);
            //If values are divisible by 5, not a prime
        } else if (i % 5 === 0){
            notPrime.push(i);
            //If values are divisible by 7, 11 or 13 not a prime
        } else if (1 % 7 === 0 || 1 % 11 === 0|| 1 % 13 === 0){
            notPrime.push(i);
        } else {
                prime.push(i);
            }
        }

    /*var sum = prime.reduce(add, 0);
    function add(a,b){
        return a + b;
    }*/
    //console.log(sum);
    console.log(prime);
    //console.log(notPrime);
}

sumPrimes(50);
why does it return 49... is it because it's a square?
devpaaji
@devpaaji
May 03 2016 07:06
so each substring has its own index position
array indexing starts with 0
here we are looping
so we are passing str[i]
which will check over each word in the array
Eldar Tinjić
@EldarT90
May 03 2016 07:07
@sh1g you are hard coding the solution
Naguib Bouchibi ⚡️
@naguib101
May 03 2016 07:07
function generate()
{
    var textLogo = document.getElementById('textLogo').value;  
    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");

    var imgObj = new Image();

    var y = 0;
    var h = 40;
    var v = 100;
    var nameDecal = 120;
    var webDecal = 134;

    var width = 130;
    var height = 95;

    ctx.clearRect(0, 0, c.width, c.height);

    ctx.moveTo(335,20);
    ctx.lineTo(335,170);

    ctx.globalCompositeOperation = "source-over";
    ctx.fillStyle = '#fff';
    ctx.fillRect(0, 0, 670, 601);

    ctx.font="bold 20px Georgia";
    ctx.fillStyle="#6495ED";
    ctx.textAlign="center"; 
    ctx.fillText("ThankYou Sponsors !", 335, 25);

    ctx.fillStyle="black";
    ctx.font="15px Georgia";

   imgObj.crossOrigin = "Anonymous";
    for (i = 0; i < logoTab.length; i++)
    {

        imgObj.src = logoTab[y];
        console.log(imgObj.src);
        console.log("logoLenght: " + logoTab.length);

        /*if (logoTab[y].lenght <= 0)
            ctx.fillText("Please select at least one logo !", 240, 300);*/
      /*  
        if (logoTab.lenght >= 7)
        {
            window.alert("Please select less than 7 logos");
        }*/
        /*if (logoTab.length == 1)
        {*/
            h = 240;
            nameDecal = 200;
            webDecal = 220;
            width = 200;
            height = 150;
      /*  }
        else if ((logoTab.length == 2) && (i == 0))
        {
            h = 150;
        }
        else if ((logoTab.length == 4) && (i == 3))
        {
            h = 240;
            v += 230;
        }
        else if (h >= 670 && (logoTab.length == 5))
        {
            h = 130;
            v += 230;
        }
        else if (h >= 670)
        {
            h = 20;
            v += 230;
        }
                */
        ctx.fillText("name", h, v + nameDecal);
        ctx.fillText("website", h, v + webDecal);
        ctx.drawImage(imgObj, h, v, width, height);                
        h += 230;
        y++;
    }

    if (textLogo != null)
    {
        ctx.fillStyle="#6495ED";
        ctx.font="bold 20px Georgia";
        ctx.textAlign="center"; 
        ctx.fillText(textLogo, 335,550);
    }

}
it just generate my canvas image
but i got to click twice for it to actually display the imgObj,
the text actually display the first time
Javier
@sh1g
May 03 2016 07:10
@EldarT90 that doesn't answer my question but thank you for input
CamperBot
@camperbot
May 03 2016 07:10
sh1g sends brownie points to @eldart90 :sparkles: :thumbsup: :sparkles:
:cookie: 331 | @eldart90 |http://www.freecodecamp.com/eldart90
Hung Truong
@hungtruong97
May 03 2016 07:11
can sb help me with this challenge?
Mateusz Szymański
@matszym
May 03 2016 07:12
@skyrunner176 I cant spot any event handler in your code, and you said you have to click 2x
Do you have codepen with full code?
Hung Truong
@hungtruong97
May 03 2016 07:13
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20if%20(value%20!%3D%3D%22%22%20%26%26%20prop%20!%3D%3D%20%22tracks%22)%20%7B%0A%20%20%20%20collection%5Bid%5D.prop%20%3D%20value%3B%0A%20%20%7D%20else%20if%20(prop%20%3D%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22)%20%7B%0A%20%20%20%20collection%5Bid%5D.prop.push(value)%3B%0A%20%20%7D%20else%20if%20(value%20%3D%3D%3D%20%22%22)%20%7B%0A%20%20%20%20delete%20collection%5Bid%5D.prop%3B%0A%20%20%7D%0A%20%20%20%20%0A%0A%20%20%20%20%0A%0A%20%20%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
Eldar Tinjić
@EldarT90
May 03 2016 07:13
@sh1g you have 1%7 etc instead of i in last row, so that whole row is scratched
Hung Truong
@hungtruong97
May 03 2016 07:13
how do you upload image to this chat?
Eldar Tinjić
@EldarT90
May 03 2016 07:15
@hungtruong97
help format
CamperBot
@camperbot
May 03 2016 07:15

: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 the code.

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

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

Hung Truong
@hungtruong97
May 03 2016 07:16
@EldarT90 thanks a lot. By the way, I figured out how to solve that challenge.
CamperBot
@camperbot
May 03 2016 07:16
hungtruong97 sends brownie points to @eldart90 :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @eldart90 |http://www.freecodecamp.com/eldart90
Mariya
@mariyadiminsky
May 03 2016 07:21
If anyone is looking to learn ES6 consider following this series :sparkles: https://medium.freecodecamp.com/learn-es6-the-dope-way-i-const-let-var-ae828580472b#.vx5xnqcrv
Blauelf
@Blauelf
May 03 2016 07:33
Should include something like case "a": answer = "apple"; break;
Alhaji Turay
@Alhaji24
May 03 2016 07:36
@Blauelf Thanks
CamperBot
@camperbot
May 03 2016 07:36
alhaji24 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1742 | @blauelf |http://www.freecodecamp.com/blauelf
buiphuking
@buiphuking
May 03 2016 07:37
\w\S* in regexp, what is that mean , guys, help me
Eldar Tinjić
@EldarT90
May 03 2016 07:37
@Blauelf why is this pushing more elements in an array than it should ?
hoooo sorry! I have resolved by myself!!!!
Zaid Hilal
@zmhnak
May 03 2016 07:43
I wana help in this exercise Counting Cards

Frank XC
@tenkdayz
May 03 2016 07:44
@Elodie950 "Not Found" not "Not found"
Zaid Hilal
@zmhnak
May 03 2016 07:44
var count = 0;

function cc(card) {
  // Only change code below this line
  var answer="";
  if(card>=2 && card<=6){
     count++;
     answer="Bet";
  }

  else if (card>=7 && card<=9)
    {
      count=count;
      answer="Hold";
    }

  else
    {
       count--;
      answer="Hold";
    }


  return count + "" +  answer;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Frank XC
@tenkdayz
May 03 2016 07:44
@Elodie950 there isnt an else statement
Zaid Hilal
@zmhnak
May 03 2016 07:44
maybe i didn't understand the semantics as well
Blauelf
@Blauelf
May 03 2016 07:45
@EldarT90 clickingColors attaches new (additional!) event handlers to the buttons each time it is called, and clickingColors is called whenever you click #play. Probably not intended that way?
Blauelf
@Blauelf
May 03 2016 07:46
@zmhnak Bet/Hold depends on count only, not at all on card, so should be decided afterwards, outside your evaluate-card-change-count structure. Also, needs a single space character between count and "Bet"/"Hold" (can be included, so " Bet"/" Hold").
Eldar Tinjić
@EldarT90
May 03 2016 07:46
@Blauelf but why? shouldnt it attach only as many clicks is made
1 click = 1 attachment
no?
Frank XC
@tenkdayz
May 03 2016 07:48
@matszym I'm used to writing it
Blauelf
@Blauelf
May 03 2016 07:49
@EldarT90 It attaches a new handler per button on each click to the play button. Clicked play twice means two handlers will act on any button click. Why not install the handlers only once?
Eldar Tinjić
@EldarT90
May 03 2016 07:50
@Blauelf well i waas hoping it would attach only once and not for every click
Blauelf
@Blauelf
May 03 2016 07:51
But it does. And you might want to clear playerArray and not keep the whole click history there.
Eldar Tinjić
@EldarT90
May 03 2016 07:51
@Blauelf im still not sure which exact line of code is making it
@Blauelf that was plan , if arrays are equal
i clear playerArray
Michael Kristiansen
@developingMichael
May 03 2016 07:51

Good morning all!
In the Validate US Telephone Numbers challange:

Why can't I match the brackets with ( in my regEx?

function telephoneCheck(str) {
  // Good luck!
  var re = /^(1?)( ?)\(?(\d{3})\(?(-?| ?)(\d{3})(-?| ?)\d{4}$/g;


  return re.test(str);
}
Eldar Tinjić
@EldarT90
May 03 2016 07:51
but if array == array is not passing even for first statement which is obviously true
Blauelf
@Blauelf
May 03 2016 07:51
@EldarT90 If you made one mistake, they cannot become equal any more.
Eldar Tinjić
@EldarT90
May 03 2016 07:52
and that is what i want
if you make mistake, you are out
shouldnt this work for first click on play
only 1 click i test it, array is the same
and still button wont turn green
Blauelf
@Blauelf
May 03 2016 07:52
array == array won't work, could be something like arr1.length==arr2.length && arr1.every((e,i)=>arr2[i]===e) for element-wise comparison.
Frank XC
@tenkdayz
May 03 2016 07:53
@EldarT90 hey what's the problem with it now?
devpaaji
@devpaaji
May 03 2016 07:53

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var multiArr = [];
  var n = Math.floor(arr.length/size);
  for(var i=0; i < n; i++) {
  multiArr.push(arr.slice(i, i+size));
} 
  return multiArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Eldar Tinjić
@EldarT90
May 03 2016 07:53
@Blauelf oh
devpaaji
@devpaaji
May 03 2016 07:53
this code is not giving desired output
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
Eldar Tinjić
@EldarT90
May 03 2016 07:54
@tenkdayz im trying to figure out some things in simon game ^^ :D but i have few mistakes atm which im trying to solve
devpaaji
@devpaaji
May 03 2016 07:54
need guidance
Frank XC
@tenkdayz
May 03 2016 07:54
@developingMichael recomend using (?: )
devpaaji
@devpaaji
May 03 2016 07:55
chunkArrayInGroups(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]]
Blauelf
@Blauelf
May 03 2016 07:55
@EldarT90 Arrays are objects, and when you compare objects, their references are compared, so unless they point to the same object, they are unequal. You have to compare what you find meaningful (e.g. the individual elements of an array)
devpaaji
@devpaaji
May 03 2016 07:55
but it is giving me [["a", "b"], ["b", "c"]];
Blauelf
@Blauelf
May 03 2016 07:56
@devpaaji Depending on your code, you might need to change your increment.
Eldar Tinjić
@EldarT90
May 03 2016 07:56
@Blauelf yeah your statement works , but im not 100% sure if i understand it; i think it means: compare every element in first array (taking account value AND index) so that element of second array at same index has same value
devpaaji
@devpaaji
May 03 2016 07:57
@Blauelf can you take a look at it

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var multiArr = [];
  var n = Math.floor(arr.length/size);
  for(var i=0; i < n; i++) {
  multiArr.push(arr.slice(i, i+size));
} 
  return multiArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Michael Kristiansen
@developingMichael
May 03 2016 07:57
@tenkdayz what does the colon after the ? mean?
negyvenketto
@negyvenketto
May 03 2016 07:57
@devpaaji it is definitely the increment
@devpaaji you are only increasing i by one
Michael Kristiansen
@developingMichael
May 03 2016 07:58
@tenkdayz oh non capturing?
negyvenketto
@negyvenketto
May 03 2016 07:58
@devpaaji so you start the first slice at zero, the second one at one, the third one at two, etc
devpaaji
@devpaaji
May 03 2016 07:58
@negyvenketto so what should be the correct way
negyvenketto
@negyvenketto
May 03 2016 07:58
@devpaaji you need to increase by "size"
Blauelf
@Blauelf
May 03 2016 07:59
@devpaaji Just use i*size instead of i in your slice expression. Like arr.slice(i*size, (i+1)*size)
I would recommend not flooring n.
Frank XC
@tenkdayz
May 03 2016 07:59
@developingMichael yes. example
(?:\(\d{3}\))
Mateusz Szymański
@matszym
May 03 2016 08:00
@developingMichael oh, in regex. Listen to him ;)
Orsini
@jrorsini
May 03 2016 08:00
Hi guys I'm tearing my hair with this one. Can someone help me out?
function rot13(str) { // LBH QVQ VG!
  var test = [];
  var random = [];
  var rot;
  for(var i = 0; i<str.length; i++){
    test.push(str.charCodeAt(i)); 
  }
  for(var j = 0; j<test.length; j++){
    rot = 0;
    if(test[j] === 79){
      rot = 0;
    }
      if(test[j] > 66 && test[j] < 78){
          rot = 13;
      }
      if(test[j] < 90 && test[j] > 76){
          rot = -13;
      }
      random.push(String.fromCharCode(test[j] + rot));
  }
  return random.join("");
  //return "O".charCodeAt(0);
  //return String.fromCharCode(79);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
It's with the ROT13 cipher
devpaaji
@devpaaji
May 03 2016 08:01
@Blauelf you mean
 multiArr.push(arr.slice(i*size));
Orsini
@jrorsini
May 03 2016 08:01
I feel like I've got to breakdown y statements for each case and I don't think it's the right or simple way to do it
Can someone, who succeeded with this. help me out here?
Blauelf
@Blauelf
May 03 2016 08:02
@devpaaji Sorry, meant
 multiArr.push(arr.slice(i*size, (i+1)*size));
Frank XC
@tenkdayz
May 03 2016 08:02
@jrorsini I'm guess rot should be added to every value in test [] correct ?
Eldar Tinjić
@EldarT90
May 03 2016 08:02
@Blauelf so which line of code exactly causes "duplicate issue" ? level() ?
Orsini
@jrorsini
May 03 2016 08:03
@tenkdayz Yes, correct
devpaaji
@devpaaji
May 03 2016 08:03
in first iteration
i*size will always be 0
if var i = 0
Blauelf
@Blauelf
May 03 2016 08:03
@jrorsini No need to test for 79. First part should be > 64 and < 78, second should be < 91 and > 77 (or equivalent expressions using different numbers and <=/>=).
Orsini
@jrorsini
May 03 2016 08:03
This message was deleted
Frank XC
@tenkdayz
May 03 2016 08:04
@jrorsini what are you doing with the spaces?
Blauelf
@Blauelf
May 03 2016 08:04
You don't have to test for spaces if you change letters only.
Orsini
@jrorsini
May 03 2016 08:04
@tenkdayz Thanks! the range wasn't good
CamperBot
@camperbot
May 03 2016 08:04
jrorsini sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:cookie: 468 | @tenkdayz |http://www.freecodecamp.com/tenkdayz
Orsini
@jrorsini
May 03 2016 08:04
Regarding the space there remain the same, I only applied a variable for the range of uppercased characters
@tenkdayz Did you do it in a different way?
Eldar Tinjić
@EldarT90
May 03 2016 08:05
@Blauelf and why 2nd step also passes? only after 3rd problems occur?
Blauelf
@Blauelf
May 03 2016 08:06
@EldarT90 Did you reset playerArray?
Goun Choe
@lenaChoe
May 03 2016 08:06

hey guys I'm having problem to open a href link.. even though i set attribute target as a _blank, codepen blocks my page! anyone knows why?

http://codepen.io/lenaChoe/pen/bpQrmN?editors=0010

Frank XC
@tenkdayz
May 03 2016 08:06
@jrorsini similar.. dont remember if it was more or less efficient than yours
Eldar Tinjić
@EldarT90
May 03 2016 08:06
@Blauelf yes
Frank XC
@tenkdayz
May 03 2016 08:07
@lenaChoe codepen blocks links
Orsini
@jrorsini
May 03 2016 08:07
@tenkdayz , Do you know how to access the solution they've made in FreeCodeCamp?
Frank XC
@tenkdayz
May 03 2016 08:07
@jrorsini help Caesars Cipher
Orsini
@jrorsini
May 03 2016 08:08
help Caesars Cipher
CamperBot
@camperbot
May 03 2016 08:08

:point_right: algorithm caesars cipher [wiki]

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

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Orsini
@jrorsini
May 03 2016 08:08
@tenkdayz Thank you
CamperBot
@camperbot
May 03 2016 08:08
:warning: jrorsini already gave tenkdayz points
jrorsini sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
Blauelf
@Blauelf
May 03 2016 08:10
@EldarT90 Do not attach another handler each time you click play.
Eldar Tinjić
@EldarT90
May 03 2016 08:10
@Blauelf and what do you mean by handler? function call?
negyvenketto
@negyvenketto
May 03 2016 08:13
@lenaChoe you don't need the quotes for the link. a.setAttribute("href", json[3][i]);
Jason Keenan
@raavin
May 03 2016 08:14
For the Caesars cipher I ended up creating 2 string variables with the alphabet and an offset alphabet. Then I used the index of the letter in an each loop to pick out the offset letter
im on my phone so it's hard to type :(
Blauelf
@Blauelf
May 03 2016 08:15
@EldarT90 .on("click",fun) or shortcut .click(fun) installs handler fun for event "click". Does not remove other handlers.
Jason Keenan
@raavin
May 03 2016 08:16
i split the strings into arrays first
Eldar Tinjić
@EldarT90
May 03 2016 08:17
@Blauelf so i should remove corelation between click and all actions? but than it wont attach anything
and it wont attach 2nd and 3rd etc values
Blauelf
@Blauelf
May 03 2016 08:18
@EldarT90 Have you tried adding the handlers only once, outside the play click handler?
Eldar Tinjić
@EldarT90
May 03 2016 08:19
@Blauelf but how can i call it without click?
and if i put it plain in js, it wont work the intended way, i think; so let me try deleting click statement
no, it does the first cycle automatically
Blauelf
@Blauelf
May 03 2016 08:20
clickingColors installs handlers only, so you can move that call out of the function. Rest of the problems is in other parts of the logic.
Eldar Tinjić
@EldarT90
May 03 2016 08:20
and you cant make it have 2nd 3rd
christianws
@christianws
May 03 2016 08:20
hi guys I'm stuck on this seemingly easy challenge
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = myStorage["car"].inside['glove box'];
Richard Andrews
@Whiplash5057
May 03 2016 08:21
guys ...do anyone of you use market.mashape.com ???
Eldar Tinjić
@EldarT90
May 03 2016 08:21
@Blauelf ok that works thanks
CamperBot
@camperbot
May 03 2016 08:21
eldart90 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1743 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
May 03 2016 08:22
@CurlyWS Maybe your are expected to use .car instead of ["car"], which should be the same? Or do a page reload, if that does not work.
Eldar Tinjić
@EldarT90
May 03 2016 08:22
@Blauelf so i wasnt that far away from solution after all ^^
christianws
@christianws
May 03 2016 08:23
@Blauelf thanks
CamperBot
@camperbot
May 03 2016 08:23
curlyws sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1744 | @blauelf |http://www.freecodecamp.com/blauelf
Darth Skywalker
@adityaparab
May 03 2016 08:24
@CurlyWS : It should work as it is. :) May be there is some different error
Blauelf
@Blauelf
May 03 2016 08:29
"work" and "pass the tests" are not necessarily equivalent, if the test author expected specific syntax. Or if the website crashed and needs a reload.
Goun Choe
@lenaChoe
May 03 2016 08:33
@tenkdayz but the link works in this project! anchor tag with href attribute works in this project http://codepen.io/lenaChoe/pen/dMKXmw?editors=1000
Steve
@smr312
May 03 2016 08:36
how do I set a remainder?
Goun Choe
@lenaChoe
May 03 2016 08:36
@tenkdayz oh!! i don't know why but suddenly link works!!! thanks anyway :(
CamperBot
@camperbot
May 03 2016 08:36
lenachoe sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:cookie: 469 | @tenkdayz |http://www.freecodecamp.com/tenkdayz
Goun Choe
@lenaChoe
May 03 2016 08:36
:)
Ankur sharma
@ankur1163
May 03 2016 08:41
i am checking out this pen
he has used two times document.ready function
why to use document.ready function twice?
Blauelf
@Blauelf
May 03 2016 08:45
First call is already included in second call, so probably not needed any more...
Ankur sharma
@ankur1163
May 03 2016 08:45
@Blauelf so if i remove the second call
everything will work fine?
Brendan Kinahan
@BKinahan
May 03 2016 08:46
@ankur1163 yup
Blauelf
@Blauelf
May 03 2016 08:47
Second document.ready includes attaching the handler to the button, but you don't need that call getQuote(); twice.
Brendan Kinahan
@BKinahan
May 03 2016 08:47
@ankur1163 it was probably just done in testing and forgotten about since it doesn't break anything, but the function does run twice when the document is ready, though you can't see the effect
Steve
@smr312
May 03 2016 08:48
How do I Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
var remainder;\
Darth Skywalker
@adityaparab
May 03 2016 08:49
var remainder = 11%3;
console.log(remainder); ---> 2 :)
Tien Manh Do
@domanhtien2011
May 03 2016 08:50
Hi guys, I have a question. I am currently doing the challenge Words Blank in JavaScript section. And I don't know what is wrong with my code:
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code  below this line
  result = "My " + myAdjective + myNoun + myVerb + myAdverb + "and he can't catch it!";  

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dragon ", "blue ", "bites ", "quickly ");
Steve
@smr312
May 03 2016 08:50
ooooooh
Ankur sharma
@ankur1163
May 03 2016 08:50
thanks @BKinahan
CamperBot
@camperbot
May 03 2016 08:50
ankur1163 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
Steve
@smr312
May 03 2016 08:50
fuck im dumb i wasnt replacing the ; with a =
CamperBot
@camperbot
May 03 2016 08:50
:star2: 1418 | @bkinahan |http://www.freecodecamp.com/bkinahan
Ankur sharma
@ankur1163
May 03 2016 08:50
thanks @Blauelf
CamperBot
@camperbot
May 03 2016 08:50
ankur1163 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1745 | @blauelf |http://www.freecodecamp.com/blauelf
Steve
@smr312
May 03 2016 08:51
thanks Aditya Parab
Ankur sharma
@ankur1163
May 03 2016 08:52
I just tried it without the second call
so i deleted
$(document).ready(function() {
  // get a random quote when page loads
  getQuote();
  $('.new-quote-now').click(getQuote);

});
but then it stopped working
Blauelf
@Blauelf
May 03 2016 08:52
@domanhtien2011 The words passed to wordBlanks do not contain spaces, so you'll have to add them in your function.
@ankur1163 $('.new-quote-now').click(getQuote); attaches the event handler to the button. Without that, it won't work.
Darth Skywalker
@adityaparab
May 03 2016 08:52

@domanhtien2011
have you tried adding spaces in between the words?

result = "My " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + " and he can't catch it!";

devpaaji
@devpaaji
May 03 2016 08:53
@domanhtien2011 here is the way
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
    var result = "";
    // Your code below this line
    result+= "Test your madlib word friends .";
    result += myNoun + " " +  myAdjective + " " + myVerb + " " + myAdverb + " ";


    // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
wordBlanks("cat", "little", "hit", "slowly")
ortonomy @xenographer hello
Tien Manh Do
@domanhtien2011
May 03 2016 08:55
thanks @Blauelf , @adityaparab , @devpaaji
CamperBot
@camperbot
May 03 2016 08:55
:cookie: 130 | @devpaaji |http://www.freecodecamp.com/devpaaji
:star2: 1746 | @blauelf |http://www.freecodecamp.com/blauelf
domanhtien2011 sends brownie points to @blauelf and @adityaparab and @devpaaji :sparkles: :thumbsup: :sparkles:
:cookie: 158 | @adityaparab |http://www.freecodecamp.com/adityaparab
Ankur sharma
@ankur1163
May 03 2016 08:57
@Blauelf then I cant add this code to first function call
do I have to call same function again
for this?
Blauelf
@Blauelf
May 03 2016 08:58
Why should you not be able to add that to first $(document).ready?
Ankur sharma
@ankur1163
May 03 2016 09:00
let me try
Blauelf
@Blauelf
May 03 2016 09:04
If the name is "isLess", then the operator is probably not === ("strictly equal"). Would be some misleading function name then.
prashant
@findname
May 03 2016 09:15
@Alhaji24 return Boolean(a < b);
Blauelf
@Blauelf
May 03 2016 09:15
Just return a < b; is enough. Comparisons already evaluate to booleans, no conversion needed.
prashant
@findname
May 03 2016 09:16
@Blauelf thanks
CamperBot
@camperbot
May 03 2016 09:16
findname sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1747 | @blauelf |http://www.freecodecamp.com/blauelf
Hung Truong
@hungtruong97
May 03 2016 09:16
I am stuck at the Profile Lookup challenge. Can anybody help me?
Blauelf
@Blauelf
May 03 2016 09:17
Show your function, please.
João Castanho
@joaocastanho
May 03 2016 09:19
hello, anyone uses guillotine?
Alhaji Turay
@Alhaji24
May 03 2016 09:21
@findname im getting a syntax error
Anand
@Anandpatel245
May 03 2016 09:34

function isLess(a, b) {
// Fix this code
return a=== b;

}

// Change these values to test
isLess(10, 15);

iam not able to solve
isLess(10,15) should return true
this statement
Stephen James
@sjames1958gm
May 03 2016 09:35
@Anandpatel245 Why would a function called isLess return a === b
Anand
@Anandpatel245
May 03 2016 09:35
as i have to use equality statement
i can do it through if and else
but i need to do it through ===
Stephen James
@sjames1958gm
May 03 2016 09:36
@Anandpatel245 Why do you have to use equality statement?