These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Apr 2016
Coy Sanders
@coymeetsworld
Apr 04 2016 00:01 UTC
var gear = 0;
Ryan Morrow
@morrowr08
Apr 04 2016 00:03 UTC
Finally got it to work.
var Bike = function() {
  var gear;
  this.setGear = function(myGear){
    gear = myGear;
  };
  this.getGear = function(){
    return gear;
  };
};
var myBike = new Bike();
myBike.setGear(4);
myBike.getGear();
on setGear I kept saying this.gear = gear; Kept coming back as undefined.
So I changed the argument I was passing in, myGear and set gear = myGear.
Don't know if this is correct way to do it or not, but it worked.
Appreciate the help @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 04 2016 00:06 UTC
hmm idk are you sure @morrowr08 ?
that shouldn't have mattered
this.setGear = function(gear){
    this.gear = gear;
  };
unless I'm missing a scope issue here
that should be fine
there's still the issue if you don't call setGear before getGear though
thats why you should initialize gear to 0
Ryan Morrow
@morrowr08
Apr 04 2016 00:08 UTC
I have no idea, I just know it finally worked and I got past that challenge, haha.
Coy Sanders
@coymeetsworld
Apr 04 2016 00:08 UTC
hmm, ok then i guess lol
Brandon Lee
@brandonlee781
Apr 04 2016 00:20 UTC

Hey everyone! I'm doing the Exact Change algorithm and this is my code so far:

function checkCashRegister(price, cash, cid) {
  var change = [], changeAmount = [], cidTotal = 0,
  returned = cash - price,
  bills = [["ONE HUNDRED",0],["TWENTY",0],["TEN",0],["FIVE",0],["ONE",0],["QUARTER",0],["DIME",0],["NICKLE",0],["PENNY",0]];
  for (var j = 0;j < cid.length;j++) {
    cidTotal += cid[j][1];
  }
  while (returned > 0) {
    if (returned - 100 >= 0 && returned <= cid[8][1]) {
      returned -= 100;
      bills[0][1] += 100;
      continue;
    } else if (returned - 20 >= 0 && returned <= cid[7][1]) {
      returned -= 20;
      bills[1][1] += 20;
      continue;
    } else if (returned - 10 >= 0 && returned <= cid[6][1]) {
      returned -= 10;
      bills[2][1] += 10;
      continue;
    } else if (returned - 5 >= 0 && returned <= cid[5][1]) {
      returned -= 5;
      bills[3][1] += 5;
      continue;
    } else if (returned - 1 >= 0 && returned <= cid[4][1]) {
      returned -= 1;
      bills[4][1] += 1;
      continue;
    } else if (returned - 0.25 >= 0 && returned <= cid[3][1]) {
      returned -= 0.25;
      bills[5][1] += 0.25;
      continue;
    } else if (returned - 0.10 >= 0 && returned <= cid[2][1]) {
      returned -= 0.10;
      bills[6][1] += 0.10;
      continue;
    } else if (returned - 0.05 >= 0 && returned <= cid[1][1]) {
      returned -= 0.05;
      bills[7][1] += 0.05;
      continue;
    } else if (returned - 0.01 >= 0 && returned <= cid[0][1]) {
      returned -= 0.01;
      bills[8][1] += 0.01;
      continue;
    } else {
      return bills;
    }
  }
  for (var i = 0;i < bills.length;i++) {
    if (bills[i][1] !== 0) {change.push(bills[i]);}
  }
  if (change.length > 0 && cidTotal === returned) {return "Closed";}
  return change;
}

checkCashRegister(19.50, 20.00, [["PENNY", 0.50], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);

It runs fine, but for some reason when it pushes pennies into my bills array it's value is 0.49000000000000027. Which obviously shouldn't happen since it's adding 0.01 50 times.

Why is it doing that?
Harsh Khandelwal
@harsh2602
Apr 04 2016 00:24 UTC

function isInteger(x) { return (x^0); }

console.log(isInteger("21.09"));

I am trying to understand the behavior of ^ operator. Why do I get return value as 21?

Moisés Man
@moigithub
Apr 04 2016 00:25 UTC
xor ?
Harsh Khandelwal
@harsh2602
Apr 04 2016 00:26 UTC
oh yeah xor makes sense... @moigithub thanks
CamperBot
@camperbot
Apr 04 2016 00:26 UTC
harsh2602 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 821 | @moigithub | http://www.freecodecamp.com/moigithub
Stephen
@balomus
Apr 04 2016 00:27 UTC
Hey everyone! Having trouble understanding what I'm doing wrong with "Profile Lookup". I feel like this should be working, but I can't seem to get any result other than "No such contact" as my return. Am I just overlooking something, or do I have it all wrong?
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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

    }

// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");
@brandonlee781 I wish I could help you, but after looking over it I don't understand why it's behaving that way either.
Moisés Man
@moigithub
Apr 04 2016 00:30 UTC
@balomus return exit the function immediatelly... soo as soon as first "firstname" dont match ur loop exit..
Stephen
@balomus
Apr 04 2016 00:31 UTC
Well even if I provide a "firstName" match and a "prop" match, it always seems to return "No such contact". That exact code returns "No such Contact" meaning to me that the first "if" statement is returning false for some reason.
Jackson Bates
@JacksonBates
Apr 04 2016 00:31 UTC
@balomus is this the problem? firstName == contacts[i][firstName]
Stephen
@balomus
Apr 04 2016 00:32 UTC
Unless I'm misunderstanding how return works.
Jackson Bates
@JacksonBates
Apr 04 2016 00:32 UTC
@balomus I'm not 100% sure, but that's my guess so far
Stephen
@balomus
Apr 04 2016 00:32 UTC
@JacksonBates Yeah I think that line is where it isn't getting past.
Just trying to understand why it isn't
I've also tried `firstName == contacts[i][0];' since the property "firstName" is in the same array position in each array.
Duncan T
@dtweedle
Apr 04 2016 00:33 UTC
@balomus Add a console.log before your first if statement. check your comparisons.
Moisés Man
@moigithub
Apr 04 2016 00:34 UTC
@balomus
if (firstName == contacts[i][firstName])
firstName is a variable...
so if i = 0, and firstName = "John"
ur code will be doing
Jackson Bates
@JacksonBates
Apr 04 2016 00:34 UTC
@balomus I'm not at a computer to tinker with it myself
Moisés Man
@moigithub
Apr 04 2016 00:35 UTC
@balomus
if ("Jonh" == contacts[0]["John"])
and Contacts elements.. dont have any object with key "Jonh"
so instead of if (firstName == contacts[i][firstName])
proabably u want if (firstName == contacts[i]["firstName"])
César
@ICesarI
Apr 04 2016 00:37 UTC
I was typing the same.
Stephen
@balomus
Apr 04 2016 00:37 UTC
@moigithub I tried that and it yields the same result, but it does give me a warning saying that dot notation would be more efficient.
And I also tried if (firstName == contacts[i].firstName);
Moisés Man
@moigithub
Apr 04 2016 00:38 UTC
@balomus u can access object values using or bracket notation.. or dot notation.. both ways should be good
and u ONLY use dot notation.. whatever follow the dot... its a "real" property/key of that object
eeflores
@eeflores
Apr 04 2016 00:39 UTC
wiki bracket
CamperBot
@camperbot
Apr 04 2016 00:39 UTC

:point_right: challenge accessing objects properties with bracket notation [wiki]

Challenge: Accessing Objects Properties with Bracket Notation

The second way to access the properties of an object is bracket notation ([]). If the property of the object you are trying to access has a space in it, you will need to use bracket notation.

Here is a sample of using bracket notation to read an object property:

var myObj = {
  "Space Name": "Kirk",
  "More Space": "Spock"
};
myObj["Space Name"]; // Kirk
myObj['More Space']; // Spock

Note that property names with spaces in them must be in quotes (single or double).
:pencil: read more about challenge accessing objects properties with bracket notation on the FCC Wiki

Moisés Man
@moigithub
Apr 04 2016 00:39 UTC
@balomus also u only need 1 for/loop
Stephen
@balomus
Apr 04 2016 00:39 UTC
Sure, I get that I should be able to use either, but something else must still be wrong with my code because it doesn't yield any other result other than "No such contact"
Duncan T
@dtweedle
Apr 04 2016 00:39 UTC
@balomus Your main problem is the logic of your if statement. I don't want to give too much away but ask yourslef. Is my if statement completing the loops? Look where your return statement is placed/
Elbert Cortez
@trip16661
Apr 04 2016 00:40 UTC
that challenge is hard D:
Moisés Man
@moigithub
Apr 04 2016 00:40 UTC
@balomus contacts is an array.. of Objects... so doing
contacts[0] will give u back the first Object
{
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
eeflores
@eeflores
Apr 04 2016 00:41 UTC
@balomus you will want to take out the "No such contact" out of the for loop
Moisés Man
@moigithub
Apr 04 2016 00:41 UTC

@balomus and . object... dont have a length property

so u CANT say for (var j = 0; j < contacts[i].length; j++)
contacts[i].length

eeflores
@eeflores
Apr 04 2016 00:42 UTC
@balomus "No such contact" should only be returned when you have completely searched the contacts array and you can't find the name
César
@ICesarI
Apr 04 2016 00:42 UTC
@trip16661, it's not that hard (:
There're better ways to do the same exercise, more JS style. Balomus was doing like C style.
Stephen
@balomus
Apr 04 2016 00:43 UTC
@ICesarI I am coming from a primarily C# background, but I am very much a novice in that as well.
Moisés Man
@moigithub
Apr 04 2016 00:43 UTC
well.. depends on ur background i guess... if u just started.. of have some previous knowledge on any programming language...
César
@ICesarI
Apr 04 2016 00:44 UTC
@balomus, I wasn't wrong then ^.^. I came from assembler and C.
Stephen
@balomus
Apr 04 2016 00:45 UTC
@Isymm @eeflores I'll try your suggestions and see if I can get something working. I'd be curious to know what @ICesarI means by a more JS style way to do the exercise.
Brandon Lee
@brandonlee781
Apr 04 2016 00:46 UTC
Can anyone tell me why when I try an add 0.01 to an array element 50 times I get 0.49000000000000027?
Stephen
@balomus
Apr 04 2016 00:46 UTC
Thanks @moigithub @Isymm @eeflores @ICesarI !
CamperBot
@camperbot
Apr 04 2016 00:46 UTC
balomus sends brownie points to @moigithub and @isymm and @eeflores and @icesari :sparkles: :thumbsup: :sparkles:
:star: 356 | @icesari | http://www.freecodecamp.com/icesari
:star: 650 | @eeflores | http://www.freecodecamp.com/eeflores
:star: 822 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 284 | @isymm | http://www.freecodecamp.com/isymm
César
@ICesarI
Apr 04 2016 00:48 UTC
@balomus, as an example, you can use forEach method.
contacts.forEach(function (OneObject) {
    console.log(OneObject.firstName) // this will show Akira, Harry, Sherlock, and so on.
});
Duncan T
@dtweedle
Apr 04 2016 00:49 UTC
@brandonlee781 what does your code look like
Brandon Lee
@brandonlee781
Apr 04 2016 00:50 UTC
function checkCashRegister(price, cash, cid) {
  var change = [], changeAmount = [], cidTotal = 0,
  returned = cash - price,
  bills = [["ONE HUNDRED",0],["TWENTY",0],["TEN",0],["FIVE",0],["ONE",0],["QUARTER",0],["DIME",0],["NICKLE",0],["PENNY",0]];
  for (var j = 0;j < cid.length;j++) {
    cidTotal += cid[j][1];
  }
  while (returned > 0) {
    if (returned - 100 >= 0 && returned <= cid[8][1]) {
      returned -= 100;
      bills[0][1] += 100;
      continue;
    } else if (returned - 20 >= 0 && returned <= cid[7][1]) {
      returned -= 20;
      bills[1][1] += 20;
      continue;
    } else if (returned - 10 >= 0 && returned <= cid[6][1]) {
      returned -= 10;
      bills[2][1] += 10;
      continue;
    } else if (returned - 5 >= 0 && returned <= cid[5][1]) {
      returned -= 5;
      bills[3][1] += 5;
      continue;
    } else if (returned - 1 >= 0 && returned <= cid[4][1]) {
      returned -= 1;
      bills[4][1] += 1;
      continue;
    } else if (returned - 0.25 >= 0 && returned <= cid[3][1]) {
      returned -= 0.25;
      bills[5][1] += 0.25;
      continue;
    } else if (returned - 0.10 >= 0 && returned <= cid[2][1]) {
      returned -= 0.10;
      bills[6][1] += 0.10;
      continue;
    } else if (returned - 0.05 >= 0 && returned <= cid[1][1]) {
      returned -= 0.05;
      bills[7][1] += 0.05;
      continue;
    } else if (returned - 0.01 >= 0 && returned <= cid[0][1]) {
      returned -= 0.01;
      bills[8][1] += 1;
      console.log(bills[8][1]);
      continue;
    } else {
      return bills;
    }
  }
  for (var i = 0;i < bills.length;i++) {
    if (bills[i][1] !== 0) {change.push(bills[i]);}
  }
  if (change.length > 0 && cidTotal === returned) {return "Closed";}
  return change;
}

checkCashRegister(19.50, 20.00, [["PENNY", 0.50], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);
That final else is just for debugging.
Duncan T
@dtweedle
Apr 04 2016 00:53 UTC
SO where in here are you adding 0.01 to the array element 50 times?
Brandon Lee
@brandonlee781
Apr 04 2016 00:57 UTC
else if (returned - 0.01 >= 0 && returned <= cid[0][1]) {
      returned -= 0.01;
      bills[8][1] += 1;
      console.log(bills[8][1]);
      continue;
Moisés Man
@moigithub
Apr 04 2016 00:57 UTC
@brandonlee781 if u check stack overflow.. there are some post about javascript floating point precision
Brandon Lee
@brandonlee781
Apr 04 2016 00:57 UTC
@moigithub I just read that actually
Moisés Man
@moigithub
Apr 04 2016 00:57 UTC
n some workarounds few did..was converting to decimal
Brandon Lee
@brandonlee781
Apr 04 2016 00:57 UTC
I might have to do something stupid like multiply everything by 100 and divide by 100
César
@ICesarI
Apr 04 2016 00:59 UTC
:/ That's a nightmare. I lost an exercise just for that. I had something like 0.5000000000001 and don't pass u.u
Norvin Burrus
@ndburrus
Apr 04 2016 01:00 UTC
Hi, I'm working on the "Stand in Line" exercise. It seems a little confusing.

Here is my code: function queue(arr, item) {
// Your code here
var array = [[arr], item];

array.push(item);
var removedItem = array.shift();

return removedItem; // Change this line
}

eeflores
@eeflores
Apr 04 2016 01:03 UTC
@ndburrus the arr function parameter is an array, the item parameter is something you add to the end of arr
@ndburrus you don't need to create an array var
Norvin Burrus
@ndburrus
Apr 04 2016 01:04 UTC
thinking...
César
@ICesarI
Apr 04 2016 01:05 UTC
@ndburrus, you can use push on arr....and shift returns the element removed.
So you can type something like this return anArray.push(something)
Norvin Burrus
@ndburrus
Apr 04 2016 01:05 UTC
ok..., let me try that... (thx)
if two (2) items ("arr" - an array, and "item" - a number) are being passed to the function "queue," wouldn't one need to use an array as a vehicle to manipulate the data?
Norvin Burrus
@ndburrus
Apr 04 2016 01:10 UTC
ok, the goal is to push item out of queue(arr, item). I would think these items would need to be in an array to use the push command.
eeflores
@eeflores
Apr 04 2016 01:11 UTC
@ndburrus no? - you can work directly with the function parameters
Norvin Burrus
@ndburrus
Apr 04 2016 01:11 UTC
queue is just a function.
devonwilson1
@devonwilson1
Apr 04 2016 01:11 UTC
can someone tell me what in the FFFFF IS WRONG WITH THIS TESTING OBJECTS FOR PROPERTIES assigment
Norvin Burrus
@ndburrus
Apr 04 2016 01:11 UTC
really.... hmmm... thinking..
eeflores
@eeflores
Apr 04 2016 01:11 UTC
@ndburrus you can call array function on the arr parameter (like arr.push();)
devonwilson1
@devonwilson1
Apr 04 2016 01:11 UTC
i did exactly what they did in the example "myObj.hasOwnProperty("gift"); // true and it does nothing
jkbfadjkasdf jol ;jklfsaj;aafsjkl'
eeflores
@eeflores
Apr 04 2016 01:12 UTC
@devonwilson1 I think you're supposed to use the parameter to the function as an argument to hasOwnProperty()
@devonwilson1 myObj.hasOwnProperty(prop)
Spazz
@Spazz
Apr 04 2016 01:13 UTC
Hey guys, This works, but I can only assume there is an easier way to accomplish this considering the other challenges were 1-3 lines each. can anybody let me know if I can simplify it?
function rot13(str) { // LBH QVQ VG!
  //65 = A
  //90 = Z
  str = str.split(" ");
  var newString = [];
  console.log(str.length);
  for(x = 0; x < str.length; x++) {
    var temp = "";
    for(i = 0; i < str[x].length; i++) {
      temp += String.fromCharCode(cipherShift(str[x][i]));
    }
    newString[x] = temp;
  }
  return newString.join(" ");
  }

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


//build function to decypher letters
function cipherShift(letter) {
  //if the "letter" is outside of the A - Z alphabet then just return what was sent. We don't want to change it.
  if(letter.charCodeAt() < 65 || letter.charCodeAt() > 90) {
    return letter.charCodeAt();
  }
  //If the "letter" is less than 13 characters away from A then we need to wrap the count around to Z and countdown.
  if(letter.charCodeAt() < 78 && letter.charCodeAt() > 64) {
    var currentLoc = letter.charCodeAt();
    var diff = 0;
    diff = 13 - (currentLoc - 65);
    return 91 - diff;
  } else {
    //The "letter" was more than 13 characaters away form A so we can safely just shift 13 characters down and still be in the alphabet.
    return letter.charCodeAt() - 13;
  }
}
devonwilson1
@devonwilson1
Apr 04 2016 01:13 UTC
i did
Norvin Burrus
@ndburrus
Apr 04 2016 01:13 UTC
i (humbly) don't think that is correct. The goal is to push on item.
devonwilson1
@devonwilson1
Apr 04 2016 01:13 UTC

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

function checkObj(checkProp) {
myObj.hasOwnProperty("git"); // true
myObj.hasOwnProperty("pet"); // true
myObj.hasOwnProperty("sleigh"); // true

return "Not Found";
}

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

eeflores
@eeflores
Apr 04 2016 01:14 UTC
@devonwilson1 example: instead of myObj.hasOwnProperty("git") use myObj.hasOwnProperty(checkProp)
devonwilson1
@devonwilson1
Apr 04 2016 01:14 UTC

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

function checkObj(checkProp) {
myObj.hasOwnProperty(checkProp); // true

return "Not Found";
}

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

eeflores
@eeflores
Apr 04 2016 01:14 UTC
@devonwilson1 also, the hasOwnProperty() function returns true or false - you'll need to test the result in an if statement
devonwilson1
@devonwilson1
Apr 04 2016 01:14 UTC
tried that too and goes straight to "not found"
César
@ICesarI
Apr 04 2016 01:15 UTC
@ndburrus, arr is per se an array. Well, is just the references to that array.
The array is made in memory, and arr saves the address.
So if you "save" the array in another var var myArray = arr you are only saving the address to that array. Besides, if you do this myArr = [arr,item] you are making a new array with two items, in index 0 arr, and in index 1 item.
devonwilson1
@devonwilson1
Apr 04 2016 01:15 UTC
WHAT??
like this

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

function checkObj(checkProp) {
if myObj.hasOwnProperty(checkProp);
return "true";

return "Not Found";
}

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

eeflores
@eeflores
Apr 04 2016 01:16 UTC
@devonwilson1 something like that - remove the semicolon at the end of myObj.hasOwnProperty(checkProp)
@devonwilson1 but the return value should be something else right?
@devonwilson1 maybe like this:
if(myObj.hasOwnProperty(checkProp)) {
  // return something
}
devonwilson1
@devonwilson1
Apr 04 2016 01:17 UTC

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp))
return "true";

// return "Not Found"

}

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

Hsin Chih Wang
@hsinwang5
Apr 04 2016 01:17 UTC
@Spazz I couldn't come up with a way to shorten the cipherShift part either...it's just long
devonwilson1
@devonwilson1
Apr 04 2016 01:17 UTC
that returns true but doesn't work
eeflores
@eeflores
Apr 04 2016 01:18 UTC
@devonwilson1 the return value when hasOwnProperty is true is the value of the property myObj[checkProp]
Spazz
@Spazz
Apr 04 2016 01:18 UTC
@hsinwang5 ok cool. I just wasn't sure if there was a built in function or something I was missing that made it easier.
devonwilson1
@devonwilson1
Apr 04 2016 01:18 UTC
it supposed to return the objects property not true or flase
Hsin Chih Wang
@hsinwang5
Apr 04 2016 01:19 UTC
@Spazz You can combine some function calls like I did but that almost makes the lines super long to read and it's basically the same functionality
Mike Patrick
@MMPatrick
Apr 04 2016 01:20 UTC
Hey all, I can't figure out what I'm doing wrong on this Return Largest Numbers in Arrays challenge. It keeps giving me TypeError: Cannot set property '0' of undefined. Should I just paste all of the code?
Justin
@daemedeor
Apr 04 2016 01:20 UTC
@MMPatrick if you could
Mike Patrick
@MMPatrick
Apr 04 2016 01:20 UTC
function largestOfFour(arr) {
  var sumArr;
  for (var i = 0; i < arr.length; i++) {
    arr[i].sort(function(a,b) {
      return a - b;
    });
    sumArr[i] = arr[i][0];
  }
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Justin
@daemedeor
Apr 04 2016 01:21 UTC
@MMPatrick you should do three backticks on top and three on bottom
eeflores
@eeflores
Apr 04 2016 01:21 UTC
@MMPatrick add a return to the end of the function?
devonwilson1
@devonwilson1
Apr 04 2016 01:21 UTC
hello?
anyone there lol
harpoon747
@harpoon747
Apr 04 2016 01:21 UTC
Can someone please help with the code, it fails for the given condition below
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(num>3)
    return str.slice(0, num -3) + "...";
  else
    return str.slice(0, num) + "...";

}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2);
Justin
@daemedeor
Apr 04 2016 01:21 UTC
@eeflores that’ll be a problem but not related to what the problem is
eeflores
@eeflores
Apr 04 2016 01:22 UTC
@devonwilson1 did you figure it out?
Justin
@daemedeor
Apr 04 2016 01:22 UTC
@MMPatrick you need to initialize sumArr with sumArr= []
devonwilson1
@devonwilson1
Apr 04 2016 01:22 UTC
no? lol
eeflores
@eeflores
Apr 04 2016 01:22 UTC
@devonwilson1 what have you got for code now?
devonwilson1
@devonwilson1
Apr 04 2016 01:22 UTC
i need it to return the myobj properties values not true or flase

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp))

// return "Not Found"

}

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

Mike Patrick
@MMPatrick
Apr 04 2016 01:23 UTC
@daemedeor that was it! Thanks a lot :D
CamperBot
@camperbot
Apr 04 2016 01:23 UTC
mmpatrick sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 171 | @daemedeor | http://www.freecodecamp.com/daemedeor
eeflores
@eeflores
Apr 04 2016 01:23 UTC
@devonwilson1 the if statement isn't returning anything at the moment
@devonwilson1 you can have the return "Not Found" att the end of the function
devonwilson1
@devonwilson1
Apr 04 2016 01:24 UTC
i just deleted the if statement because i don't need a true or false i need the strings to entered to return its value
so if i put in gift i need checkObj to return "PONY"
eeflores
@eeflores
Apr 04 2016 01:25 UTC
@devonwilson1 you'll need the if statement to test the hasOwnProperty() function
@devonwilson1 something like this:
if(myObj.hasOwnProperty(checkProp)) {
  // return something
}
return "Not Found";
Spazz
@Spazz
Apr 04 2016 01:26 UTC
@devonwilson1 If it does exist, then inside your if statement you can return myObj[property] to return the value of the property. if it doesn't exist then you need to return not found.
César
@ICesarI
Apr 04 2016 01:28 UTC

@devonwilson1

return condition ? myObject[property] : "Not Found";  // return the value if exist.

This is a way, using ternary.

Hsin Chih Wang
@hsinwang5
Apr 04 2016 01:28 UTC
@harpoon747 You forgot to include a condition for when num is longer than the string length
devonwilson1
@devonwilson1
Apr 04 2016 01:29 UTC

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

function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkProp)) {
// return myObj[property]
}

// return "Not Found"

}

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

doesn't do anything
eeflores
@eeflores
Apr 04 2016 01:30 UTC
@devonwilson1 ok now try it by uncommenting out the return values ... what happens?
Spazz
@Spazz
Apr 04 2016 01:30 UTC
@devonwilson1 you have your returns commented out. "property" should correspond to your function so you should use checkProp instead.
devonwilson1
@devonwilson1
Apr 04 2016 01:31 UTC

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

if(myObj.hasOwnProperty(checkProp)) {
// return myObj[checkProp]
}

// return "Not Found"

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

doesn't work
andreyorlov33
@andreyorlov33
Apr 04 2016 01:32 UTC
SEEK AND DESTROY
Hello campers !! I have been stuck on the Seek and Destroy challenge for a few days... I came up with my own solution that works ...
BUT during my research process i've noticed that many had the following solution ..... I do not understand how part of it works and i would greatly appreciate it if some one could clarify ...
function destroyer(arr) { 
  args = Array.prototype .slice.call(arguments,1);  // Used to convert the arguments object into an array and extract the destroyer arguments... this case 2 and 3.. this is understood
  function remove(x) { return args.indexOf(x) === -1; } 
/*
What i do not understand is how the above line of code woks... in my solution i use for loops to iterate through the arrays and filter function to filter out the Nulls...
I do not understand how this line of code does the exact same thing in one line...  PLEASE EXPLAIN!!!!
*/
  return arguments[0].filter(remove);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Spazz
@Spazz
Apr 04 2016 01:33 UTC
// return myObj[checkProp]. The "//" is commenting out the return. with the comments there you are in essence saying this.
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

 if(myObj.hasOwnProperty(checkProp)) {

}

checkObj("gift");
@devonwilson1 you need to remove the "//" so it looks like this
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

 if(myObj.hasOwnProperty(checkProp)) {
    return myObj[checkProp]
 }
    return "Not Found"

// Test your code by modifying these values
checkObj("gift");
@devonwilson1 and add semicolons to the end of the returns
Spazz
@Spazz
Apr 04 2016 01:39 UTC
@andreyorlov33 .filter works as a loop and loops through every item in the array. if the index is -1 then it means it did not exist against the test data and will automatically remove it.
andreyorlov33
@andreyorlov33
Apr 04 2016 01:40 UTC
@Spazz Oh ok got it!!! thanks you!
CamperBot
@camperbot
Apr 04 2016 01:40 UTC
andreyorlov33 sends brownie points to @spazz :sparkles: :thumbsup: :sparkles:
:star: 266 | @spazz | http://www.freecodecamp.com/spazz
César
@ICesarI
Apr 04 2016 01:42 UTC
@devonwilson1, JS doesn't execute anyting in comments, so when you have a text after this // the interpreter skip it even if it'is javascript. Anyway, where is your function? The code you copied hadn't the function checkObj.
ZctrapCoding
@ZctrapCoding
Apr 04 2016 01:56 UTC
Why isnt this working?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  myNoun = "clown";
  myAdjective = "strechy";
  myVerb = "squated";
  myAdverb = "slowly";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Justin
@daemedeor
Apr 04 2016 01:57 UTC
@ZctrapCoding because you’re not changing result?
ZctrapCoding
@ZctrapCoding
Apr 04 2016 01:57 UTC
... i... umm... i dont know what to say....
Elbert Cortez
@trip16661
Apr 04 2016 01:58 UTC
@ZctrapCoding you are just changing myNoun and everthing else
but result is empy
empty
and you are changing the arguments but
in that excersice they want you
to grup the arguments
and make a sentence
ZctrapCoding
@ZctrapCoding
Apr 04 2016 01:59 UTC
yeah i dont know what to say to that... its so obvious...
Elbert Cortez
@trip16661
Apr 04 2016 01:59 UTC
Hope it helped xD
ZctrapCoding
@ZctrapCoding
Apr 04 2016 02:00 UTC
i guess my brain thought i was supposed to do something else somehow like color it in html or something with those evem though you would do .addClass brain fart moment
Elbert Cortez
@trip16661
Apr 04 2016 02:03 UTC
@ZctrapCoding ahahaha it's okay it's like me yesterday, asking for help and finding out the answer
as i was formulating the question
Patrick Black
@Mortiferr
Apr 04 2016 02:11 UTC
Hey
What maths would I use to make the sum of this array:
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
});
singleVal = array;
ZctrapCoding
@ZctrapCoding
Apr 04 2016 02:12 UTC
... i made a sentence what am i doing wrong!
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  myNoun = "clown";
  myAdjective = "strechy";
  myVerb = "squated";
  myAdverb = "slowly";
  result = "Once the was a " + myNoun +" and he was really "+ myAdjective +" and once he " + myVerb + " but he did very " + myAdverb + ".";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Spazz
@Spazz
Apr 04 2016 02:15 UTC
@ZctrapCoding you are setting each noun, verb, etc... before result. get rid of those otherwise your sentence will always say clown, stretchy, squated, slowly.
ZctrapCoding
@ZctrapCoding
Apr 04 2016 02:16 UTC
oh Now i get what i was supposed to do thx @Spazz
CamperBot
@camperbot
Apr 04 2016 02:16 UTC
zctrapcoding sends brownie points to @spazz :sparkles: :thumbsup: :sparkles:
:star: 274 | @spazz | http://www.freecodecamp.com/spazz
Patrick Black
@Mortiferr
Apr 04 2016 02:17 UTC
@Spazz any ideas on mine?
Mine is just printing the array
[4,5,6,7,8]
bitgrower
@bitgrower
Apr 04 2016 02:17 UTC
yeah, because you're setting singleVal to array
Patrick Black
@Mortiferr
Apr 04 2016 02:18 UTC
oh
wow
im smart
Spazz
@Spazz
Apr 04 2016 02:18 UTC
^ what he said. not sure what challenge you are doing though so not sure what you are wanting it to do.
Patrick Black
@Mortiferr
Apr 04 2016 02:18 UTC
lol just had to assign it to array not singleval
thanks @bitgrower and @Spazz
CamperBot
@camperbot
Apr 04 2016 02:18 UTC
mortiferr sends brownie points to @bitgrower and @spazz :sparkles: :thumbsup: :sparkles:
:star: 960 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 275 | @spazz | http://www.freecodecamp.com/spazz
Stephen KH Chan
@channerism
Apr 04 2016 02:20 UTC
thanks @leftynaut for your help with Checkpoint: Counting Cards
CamperBot
@camperbot
Apr 04 2016 02:20 UTC
channerism sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 466 | @leftynaut | http://www.freecodecamp.com/leftynaut
Kent
@kenthub
Apr 04 2016 02:30 UTC
Anyone on here that can help with Bonfire? Problem "Title Case a Sentence". My code is returning everything to lower case instead of capitalizing the first letter of each word.
function titleCase(str) {
  // Convert to lowercase
  // Convert to array;
  var newString = str.toLowerCase().split(' '); 

  for(var i = 0; i < newString.length; i++){ 
    // Select first element in each array
    if(newString[i].charAt(0)){

      var upperCase = newString[i].charAt(0).toUpperCase();
      var update = newString[i].replace(newString[i].charAt(0), upperCase);
     }
    return newString.join(' ');
  }
}

titleCase("I'm a little tea pot");
CamperBot
@camperbot
Apr 04 2016 02:30 UTC
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Trilok reddy
@Trilokreddy007
Apr 04 2016 02:34 UTC
has anyone solved record collection problem in json
Norvin Burrus
@ndburrus
Apr 04 2016 02:37 UTC
i have a question on the "Stand in Line" exercise. A function "queue" is being used to function as a queue. I think the goal is to utilize an array within the function to insert (push) in the last input element (the input elements are "arr" - an array, and "item" - a number). In addition, the first element of the inputted array needs to be removed ("shift"ed). I've tried: a) using an array (within the function "queue"), and b) using "push" & "shift" on the function "queue" itself. Neither method works.
devonwilson1
@devonwilson1
Apr 04 2016 02:38 UTC
@Spazz
still don't work
Norvin Burrus
@ndburrus
Apr 04 2016 02:39 UTC
I also tried dabbling with the queue structure, but that didn't work either. That subject wasn't discussed (introduced), but I thought it was worth a try.
I'll have to come back to that one...
Elbert Cortez
@trip16661
Apr 04 2016 02:41 UTC
im not sure if i remember
the challenge
Dustin
@Key-Banger
Apr 04 2016 02:41 UTC
@ndburrus can you post your code?
Norvin Burrus
@ndburrus
Apr 04 2016 02:41 UTC
moment...
Elbert Cortez
@trip16661
Apr 04 2016 02:41 UTC
This message was deleted
help format
CamperBot
@camperbot
Apr 04 2016 02:41 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Norvin Burrus
@ndburrus
Apr 04 2016 02:44 UTC

function queue(arr, item) {
// Your code here
var removedItem = queue.shift([arr[0]]);

return removedItem; // Change this line
}

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

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

i erased it....
but basically the function (1st line is given)
(1st line) is given
Elbert Cortez
@trip16661
Apr 04 2016 02:45 UTC
@kenthub is because you are returning newString but you are not changing newString in the if statement or the loop
@kenthub so you are returning the line 4 only
Dustin
@Key-Banger
Apr 04 2016 02:46 UTC
@ndburrus the "arr" argument is the array so to shift all you need is arr.shift()
devonwilson1
@devonwilson1
Apr 04 2016 02:46 UTC

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

if(myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}

return "Not Found";

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

Elbert Cortez
@trip16661
Apr 04 2016 02:46 UTC
@ndburrus ```js (then you click sfit enter) and then you put your code inside
between the closing ```
Norvin Burrus
@ndburrus
Apr 04 2016 02:46 UTC
@Key-Banger ok, ty, ill try that
Elbert Cortez
@trip16661
Apr 04 2016 02:47 UTC
help format
CamperBot
@camperbot
Apr 04 2016 02:47 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Norvin Burrus
@ndburrus
Apr 04 2016 02:47 UTC
@trip16661 ok, thx... i'll use the code formatting...
CamperBot
@camperbot
Apr 04 2016 02:47 UTC
ndburrus sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 279 | @trip16661 | http://www.freecodecamp.com/trip16661
Dustin
@Key-Banger
Apr 04 2016 02:48 UTC
@ndburrus @ndburrus alternately to push you can arr.push(item)
Elbert Cortez
@trip16661
Apr 04 2016 02:48 UTC
help bracket notation
CamperBot
@camperbot
Apr 04 2016 02:48 UTC

:point_right: challenge accessing objects properties with bracket notation [wiki]

Challenge: Accessing Objects Properties with Bracket Notation

The second way to access the properties of an object is bracket notation ([]). If the property of the object you are trying to access has a space in it, you will need to use bracket notation.

Here is a sample of using bracket notation to read an object property:

var myObj = {
  "Space Name": "Kirk",
  "More Space": "Spock"
};
myObj["Space Name"]; // Kirk
myObj['More Space']; // Spock

Note that property names with spaces in them must be in quotes (single or double).
:pencil: read more about challenge accessing objects properties with bracket notation on the FCC Wiki

Elbert Cortez
@trip16661
Apr 04 2016 02:49 UTC
@devonwilson1 read it
devonwilson1
@devonwilson1
Apr 04 2016 02:49 UTC
which one
Norvin Burrus
@ndburrus
Apr 04 2016 02:49 UTC
@Key-Banger ... alright thx.
CamperBot
@camperbot
Apr 04 2016 02:49 UTC
ndburrus sends brownie points to @key-banger :sparkles: :thumbsup: :sparkles:
:star: 370 | @key-banger | http://www.freecodecamp.com/key-banger
Elbert Cortez
@trip16661
Apr 04 2016 02:49 UTC
what i just made the bot to look for
Norvin Burrus
@ndburrus
Apr 04 2016 02:49 UTC
be back in a cpl mins
devonwilson1
@devonwilson1
Apr 04 2016 02:50 UTC
i put this and didn't work ill do again and show you
Elbert Cortez
@trip16661
Apr 04 2016 02:51 UTC
else is missing i think too
if else
if this is like this do this
else do that
Eric Murta
@murtinha
Apr 04 2016 02:51 UTC
Guys, on challenge smalest common multiple, my logic is working fine for number untill 12, if a put 13 there my loop becomes infinite...
Elbert Cortez
@trip16661
Apr 04 2016 02:51 UTC
but i think you are just retuning it
Eric Murta
@murtinha
Apr 04 2016 02:52 UTC
function smallestCommons(arr) {
  var check=0;
  var x=0;
  var value=Math.max(arr[0],arr[1]);
  var maxval=Math.max(arr[0],arr[1]);
  var cond=(Math.max(arr[0],arr[1])-(Math.min(arr[0],arr[1])))+1;

  while(x===0){
      check=0; 
    for(i=Math.min(arr[0],arr[1]);i<=maxval;i++){
      if((value%i)===0){
        check++;

      }
    }

    if(check==cond){
      x=1;       
    }
    else{
      value++;
    }

    }

  return value;
}


smallestCommons([1,12]);
Elbert Cortez
@trip16661
Apr 04 2016 02:52 UTC
anyway post your code in the format next time @devonwilson1
devonwilson1
@devonwilson1
Apr 04 2016 02:53 UTC
what do you mean format?
Elbert Cortez
@trip16661
Apr 04 2016 02:53 UTC
help format
CamperBot
@camperbot
Apr 04 2016 02:53 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

devonwilson1
@devonwilson1
Apr 04 2016 02:54 UTC
myObj has no space so should i use dot notation?
Elbert Cortez
@trip16661
Apr 04 2016 02:54 UTC
so it's in a box so peoplecan read it easily
@devonwilson1 I think the major problem is that you are just returning something after returning the result of the if
try with
devonwilson1
@devonwilson1
Apr 04 2016 02:55 UTC
try with an if statement?
Elbert Cortez
@trip16661
Apr 04 2016 02:55 UTC
else { return bla bla lba
this is what you posted
if(myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
return "Not Found";
Dustin
@Key-Banger
Apr 04 2016 02:55 UTC
@murtinha I'm headed there next. Wish I could help. Looks fun.... :wink:
Kent
@kenthub
Apr 04 2016 02:56 UTC
@trip16661 I finally went to wiki page after 3 days of being stuck on this. They have a solution similar to mine so i'm trying to work off it. Thanks for that heads up though!
CamperBot
@camperbot
Apr 04 2016 02:56 UTC
kenthub sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 280 | @trip16661 | http://www.freecodecamp.com/trip16661
Eric Murta
@murtinha
Apr 04 2016 02:56 UTC
@Key-Banger yeah man! yesterday I was struggling a lot with the primo one hahaha
Elbert Cortez
@trip16661
Apr 04 2016 02:56 UTC
i think you are over writing your previous return so instead of returning
Dustin
@Key-Banger
Apr 04 2016 02:57 UTC
@devonwilson1 @trip16661 I think the else is implied. What is the challenge?
@murtinha For sure. I finished it and didn't start the next one because I was wiped.
Elbert Cortez
@trip16661
Apr 04 2016 02:58 UTC
@Key-Banger im not sure though as far as i can see it looks okay
but aint an expert xD
Elbert Cortez
@trip16661
Apr 04 2016 03:02 UTC
This message was deleted
devonwilson1
@devonwilson1
Apr 04 2016 03:04 UTC
i tried what you just wrote
it didn't work
cannelflow
@cannelflow
Apr 04 2016 03:05 UTC
@devonwilson1 there is a function reset the code and try again
Elbert Cortez
@trip16661
Apr 04 2016 03:05 UTC
ye
i just found out now
the re should be a function in the code
so checkObj can be used
devonwilson1
@devonwilson1
Apr 04 2016 03:07 UTC
omg okay so am i just using check Obj with dot or bracket notation?
Dustin
@Key-Banger
Apr 04 2016 03:07 UTC
@devonwilson1 without giving you the answer. Check this out:
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty(property)) {
     return Object[property];
     }
  return "Not Found";

}

// Test your code by modifying these values
checkObj("gift");
cannelflow
@cannelflow
Apr 04 2016 03:07 UTC
@devonwilson1 []
var myObj = {
  gift: "pony",
  pet: "kitten",<===how you will get this value ???
  bed: "sleigh"
};
@devonwilson1
Elbert Cortez
@trip16661
Apr 04 2016 03:09 UTC
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty(checkProp)){
    return myObj[checkProp];
  }else{
  return "Not Found";  
  }

}

// Test your code by modifying these values
checkObj("gift");
i just did it
Dustin
@Key-Banger
Apr 04 2016 03:10 UTC
without giving the answer away...
bitgrower
@bitgrower
Apr 04 2016 03:11 UTC
@devonwilson1 ... when you are using a variable to contain the property name, you need to use bracket notation ... dot notation is only used when you actually reference the property name by name ...
devonwilson1
@devonwilson1
Apr 04 2016 03:11 UTC
@bitgrower thank you
CamperBot
@camperbot
Apr 04 2016 03:11 UTC
devonwilson1 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
devonwilson1
@devonwilson1
Apr 04 2016 03:11 UTC
@trip16661 thank you
CamperBot
@camperbot
Apr 04 2016 03:11 UTC
devonwilson1 sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 961 | @bitgrower | http://www.freecodecamp.com/bitgrower
devonwilson1
@devonwilson1
Apr 04 2016 03:11 UTC
@cannelflow thank you
CamperBot
@camperbot
Apr 04 2016 03:11 UTC
:star: 281 | @trip16661 | http://www.freecodecamp.com/trip16661
devonwilson1
@devonwilson1
Apr 04 2016 03:11 UTC
@Key-Banger thank you
@Key-Banger thank you
CamperBot
@camperbot
Apr 04 2016 03:12 UTC
devonwilson1 sends brownie points to @key-banger :sparkles: :thumbsup: :sparkles:
Elbert Cortez
@trip16661
Apr 04 2016 03:12 UTC
the reason it didn't work before it cuz you deleted the function
CamperBot
@camperbot
Apr 04 2016 03:12 UTC
:star: 371 | @key-banger | http://www.freecodecamp.com/key-banger
devonwilson1
@devonwilson1
Apr 04 2016 03:12 UTC
that what i though
Elbert Cortez
@trip16661
Apr 04 2016 03:12 UTC
be sure you never delete what's in there
bitgrower
@bitgrower
Apr 04 2016 03:12 UTC
^^^ good advice!
Elbert Cortez
@trip16661
Apr 04 2016 03:12 UTC
unless asked otherwise
andreyorlov33
@andreyorlov33
Apr 04 2016 03:18 UTC
This message was deleted
Eric Murta
@murtinha
Apr 04 2016 03:18 UTC
@murtinha
Guys, on challenge smalest common multiple, my logic is working fine for number untill 12, if a put 13 there my loop becomes infinite...
function smallestCommons(arr) {
  var check=0;
  var x=0;
  var value=Math.max(arr[0],arr[1]);
  var maxval=Math.max(arr[0],arr[1]);
  var cond=(Math.max(arr[0],arr[1])-(Math.min(arr[0],arr[1])))+1;

  while(x===0){
      check=0; 
    for(i=Math.min(arr[0],arr[1]);i<=maxval;i++){
      if((value%i)===0){
        check++;

      }
    }

    if(check==cond){
      x=1;       
    }
    else{
      value++;
    }

    }

  return value;
}


smallestCommons([1,12]);
Ryan Morrow
@morrowr08
Apr 04 2016 03:30 UTC
Has anyone worked on the "Reverse a String" challenge?
I'm getting the right output, just not allowing me to move onto next challenge.
function reverseString(str) {
  return str;
}
reverseString("hello")
  .split("")
  .reverse(function(b,a){
    return b-a;
  })
  .join("");
Darrel Adams
@dadams-510
Apr 04 2016 03:33 UTC
What is the best way to unnest arrays within Javascript?
Dustin
@Key-Banger
Apr 04 2016 03:36 UTC
@morrowr08 you wrote your function logic in the wrong section.
Ryan Morrow
@morrowr08
Apr 04 2016 03:37 UTC

@dadams-510

var array = ["element1","element2","element3"];

If that's your array. Then you can do this.

array = new Array();

OR

array = [];
@Key-Banger So I need to write the login on the function itself? Haha, I'm dumb.
Dustin
@Key-Banger
Apr 04 2016 03:41 UTC
@morrowr08 yea, all of it goes inside the function. The reverseString("Howdy"); is calling the reverseString function.
Ryan Morrow
@morrowr08
Apr 04 2016 03:41 UTC
Thanks @Key-Banger that worked, I had the write logic, just needed it to be on the function rather than the string I was trying to reverse.
CamperBot
@camperbot
Apr 04 2016 03:41 UTC
morrowr08 sends brownie points to @key-banger :sparkles: :thumbsup: :sparkles:
:star: 372 | @key-banger | http://www.freecodecamp.com/key-banger
Dustin
@Key-Banger
Apr 04 2016 03:42 UTC
@morrowr08 no problem. Its the little things ha ha ha.
qeurago
@qeurago
Apr 04 2016 03:46 UTC
how do i post my code in here? just copy paste or do i need to do something special with it?
Elbert Cortez
@trip16661
Apr 04 2016 03:47 UTC
help format
CamperBot
@camperbot
Apr 04 2016 03:47 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

bitgrower
@bitgrower
Apr 04 2016 03:48 UTC
@qeurago ...
  1. start with one line, with nothing else on it but this: ```js
  2. paste your code in
  3. add one line after (if it hasn't been added for you, with nothing else on it but this: ```
qeurago
@qeurago
Apr 04 2016 03:48 UTC
function truncateString(str, num) {
  if (str.length > num) {
    str = str.slice(0, num-3);
    str += "...";
  }
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
this code isn't working
Ewe Lin Loo
@elloo
Apr 04 2016 03:50 UTC

Hey guys, am I misunderstanding something about incrementing numbers?

var myVar = 87;

// Only change code below this line
myVar = myVar++;

myVar should equal 88, right?

Oh nevermind, just solved it lol
Ryan Morrow
@morrowr08
Apr 04 2016 03:50 UTC
@elloo you can just do myVar++
(y)
Ewe Lin Loo
@elloo
Apr 04 2016 03:50 UTC
Yup that was the problem, thanks @morrowr08
CamperBot
@camperbot
Apr 04 2016 03:50 UTC
elloo sends brownie points to @morrowr08 :sparkles: :thumbsup: :sparkles:
:star: 30 | @morrowr08 | http://www.freecodecamp.com/morrowr08
Ryan Morrow
@morrowr08
Apr 04 2016 03:52 UTC

Same goes for decrementing by one, --
You can also do shorthand if you wanted to add more than 1.

myVar += 30;

that's the same as

myVar = myVar + 30;
Dustin
@Key-Banger
Apr 04 2016 03:55 UTC
@qeurago your looking for > should be <.
qeurago
@qeurago
Apr 04 2016 03:55 UTC
@Key-Banger no, the string truncates if it is longer than the num
Dustin
@Key-Banger
Apr 04 2016 03:56 UTC
@qeurago sorry read wrong. I'll look again.
@qeurago you cant go -3 on a string that is only 2 long.
qeurago
@qeurago
Apr 04 2016 04:00 UTC
@Key-Banger ok but after i wrote the code and it didn't work i literally copy pasted 2 other peoples code in to the exercise and they both didn't work, so something must be wrong with the exercise
Matt Green
@mattxgreen
Apr 04 2016 04:04 UTC
@qeurago try this:
function truncate(str, num) {
  // Clear out that junk in your trunk
  if(str.length > num){
    return (num>3) ? str.slice(0,num-3) +"..." : str.slice(0,num) +"...";
  }
  return str;
}
I KNOW that should work
qeurago
@qeurago
Apr 04 2016 04:05 UTC
@mattxgreen it gives the right outputs when i put in the parameters but it won't pass the exercise
Dustin
@Key-Banger
Apr 04 2016 04:06 UTC
@qeurago They changed the function names. Copy and past wont work if you copy everything. The function should be truncateString
qeurago
@qeurago
Apr 04 2016 04:08 UTC
what does the question mark mean? and the colon @mattxgreen
Matt Green
@mattxgreen
Apr 04 2016 04:08 UTC
@qeurago it's a ternary statement
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 04:09 UTC
hi

// 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 update(id, prop, value) {

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

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

if (collection[id].value==="")
delete collection[id].prop;

return collection;
}

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

stuck here
Dylan
@dhcodes
Apr 04 2016 04:11 UTC
@qeurago check out this for a brief explanation on ternary operators: http://eloquentjavascript.net/01_values.html#p_EWJu4coIAh
they confuse me too
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 04:11 UTC
can anyone help?
Brandon Lee
@brandonlee781
Apr 04 2016 04:14 UTC
@sudeepnarkar First of all it looks like your missing curly braces on your if statements.
Second, because they are three seperate if statements the code will test each one individually regardless of if one passes or not. If else statements are tried top-down until one passes. @sudeepnarkar
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 04:21 UTC
I got it
Thanks for the help
Sometimes I get confused between the dot and bracket notation

// 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 update(id, prop, value) {

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

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

if(value==="")
delete collection[id][prop];

return collection;
}

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

Fixed it
andreyorlov33
@andreyorlov33
Apr 04 2016 04:22 UTC
Why do i keep getting a TypeError: args.sort is not a function
function getIndexToIns(arr, num) {

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

function compareNumbers(a, b) {
  return a - b;
}
  args.sort(compareNumbers); 

  return args;

 }

getIndexToIns([40, 60], 50);
AudioGen
@AudioGen
Apr 04 2016 04:23 UTC
@andreyorlov33 you didn't mention the callback function for the sort method
Actually I might be off on that, because I see you got the compareNumbers function
Ryan Morrow
@morrowr08
Apr 04 2016 04:27 UTC
Has anyone completed the "Factorialize a Number" challenge yet? If so, wold you be able to help guide me in the right direction?
Elbert Cortez
@trip16661
Apr 04 2016 04:27 UTC
This message was deleted
Dustin
@Key-Banger
Apr 04 2016 04:30 UTC
@andreyorlov33 .sort is a method. Your calling it as a function.
Brandon Lee
@brandonlee781
Apr 04 2016 04:32 UTC
@sudeepnarkar No you didn't. You're still missing curly braces. If statements are:
if (some condition to be met) {
    whatever happens when the condition is true;
}
AudioGen
@AudioGen
Apr 04 2016 04:32 UTC
@morrowr08 I used recursion for that challenge, are you familiar with that?
Ryan Morrow
@morrowr08
Apr 04 2016 04:33 UTC
@AudioGen No, not particulary.
Brandon Lee
@brandonlee781
Apr 04 2016 04:37 UTC
@andreyorlov33 I'm only slightly guessing here, but it might be because .sort() is a method for arrays, but args is a string. The .join() method returns a string.
bitgrower
@bitgrower
Apr 04 2016 04:37 UTC
while recursion is not necessarily the best solution in terms of time & space efficiency, it does lead to some elegant solutions ... creating a factorial algorithm is probably one of the easiest & cleanest ways of learning about recursion ...
AudioGen
@AudioGen
Apr 04 2016 04:37 UTC
@morrowr08 you recall the function inside the function but alter it in some way, in this exercise it allows you multiply all the positive integers. it kind of substitutes for a loop for that particular exercise.
bitgrower
@bitgrower
Apr 04 2016 04:37 UTC
@morrowr08 ^^^ (my comment about recursion)
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 04:40 UTC

@brandonlee781 Hi. You do not need curly braces if you have just a single statement to execute if the condition is met. For instance,
if (true)
j=0;

is a valid statement

Ryan Morrow
@morrowr08
Apr 04 2016 04:40 UTC
@bitgrower and @AudioGen Appreciate the input, I will have to do some research to try and better understand.
Brandon Lee
@brandonlee781
Apr 04 2016 04:41 UTC
@sudeepnarkar Huh, okay.
bitgrower
@bitgrower
Apr 04 2016 04:42 UTC

the article which helped me with recursion is one I found on the ibm site ... because what i was interested in is not knowing what recursion is (I already knew that) ... but how best to go about coding it ... basically, you start with the end in mind ...

recursion is the technique of calling the same function from within the function, over and over again ... so, the first thing you need to know is: when to stop and return ... so that's the part of the code that needs to be executed first in your recursive function ...

Sudeep Narkar
@sudeepnarkar
Apr 04 2016 04:43 UTC
@brandonlee781 :)
Ryan Morrow
@morrowr08
Apr 04 2016 04:46 UTC

I looked up to research more on it, and came across some code, unfortunately. Completely different from how I was attempting to approach it, I was trying to make an array of numbers decrementing from the number passed into the function. Then take that array and multiply them together.

The code I came across was this:

function factorialize(num) {
  if (num < 0) {
        return -1;
    }
    else if (num === 0) {
        return 1;
    }
    var tmp = num;
    while (num-- > 2) {
        tmp *= num;
    }
    return tmp;
}
buonarfcc
@buonarfcc
Apr 04 2016 04:47 UTC
any one can provide a hint with Counting Cards?
Ryan Morrow
@morrowr08
Apr 04 2016 04:49 UTC

Another example on the site I visited was this:

function factorialize(num) {
    if (num < 0) {
        return -1;
    }
    else if (num === 0) {
        return 1;
    }
    else {
        return (num * factorialize(num - 1));
    }
}

This one makes more sense to what you were explaining, calling the function again while inside the function.

AudioGen
@AudioGen
Apr 04 2016 04:50 UTC
@morrowr08 Yep
Ryan Morrow
@morrowr08
Apr 04 2016 04:52 UTC
@AudioGen @bitgrower Thanks for the help.
CamperBot
@camperbot
Apr 04 2016 04:52 UTC
morrowr08 sends brownie points to @audiogen and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 962 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 338 | @audiogen | http://www.freecodecamp.com/audiogen
bitgrower
@bitgrower
Apr 04 2016 04:55 UTC
@buonarfcc -- use a case statement ... at least that's what I did ... it may not be the shortest solution ... but it's fairly understandable ...
César
@ICesarI
Apr 04 2016 05:05 UTC
@morrowr08, yeah, that is called recursive programming. I made mine the same way (:
Matt Reynolds
@mareynolds
Apr 04 2016 05:07 UTC
I keep getting a "-1" value when running this formula: "arr[1].indexOf(secondWord)". I want it to loop through each letter of the second word in an array, but it gives me -1 every time so it isn't finding anything when I know the letter I'm looking for is there, so it should return "true". Any suggestions? Here's my full code block:
function mutation(arr) {
  var check = false;
  for (var secondWord = 0; secondWord < arr[1].length; secondWord++) // check each letter of second word to see if that letter is found anywhere within the first word
  {
    for (var firstWord = 0; firstWord < 9; firstWord++)
    {
      if (arr[1].indexOf(secondWord) == arr[0].indexOf(firstWord))
      {
        console.log("Letter #" + secondWord + " matches \"" + arr[0].indexOf(firstWord) + "\".");
        check = true;
        break;
      } else {
        console.log("Did not find an \"" + arr[1].indexOf(secondWord) + "\".");
        check = false;
      } 
    }
  }
  return check;
}

mutation(["hello", "hey"]);
Markus Kiili
@Masd925
Apr 04 2016 05:14 UTC
@acctg4code You only need one loop through the second string characters. Inside loop check with indexOf if the character is found on the first string. If not, return false. After loop, return true.
buonarfcc
@buonarfcc
Apr 04 2016 05:36 UTC

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

case 1: 
  console.log("alpha");
  break;
case 2: 
  console.log("beta");
  break;
case 3: 
  console.log("gamma");
  break;

case 4: 
  console.log("delta");

// Only change code above this line
return answer;

           }
                }

// Change this value to test
myTest(1); The following are the error I got:

myTest(1) should have a value of "alpha"
myTest(2) should have a value of "beta"
myTest(3) should have a value of "gamma"
myTest(4) should have a value of "delta"
any enlightenment would be great ;)
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 05:41 UTC
@buonarfcc answer="alpha"
and likewise
because you are returning answer
buonarfcc
@buonarfcc
Apr 04 2016 05:48 UTC
Many thanks sudeepnarkar:)
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 05:51 UTC
@buonarfcc Did it work?
Trilok reddy
@Trilokreddy007
Apr 04 2016 06:03 UTC
@sudeepnarkar can you help me in correcting my code her :nesting loops in json
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 06:04 UTC
@Trilokreddy007 checking
Trilok reddy
@Trilokreddy007
Apr 04 2016 06:04 UTC

Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0;i < arr.length;i++) {
for(var j=0; j < arr[i].length;j++)
};
product *= arr[i][j];

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

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

TypeError: Cannot read property '1' of undefined

multiplyAll([[1],[2],[3]]); should return 6
multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);) should return 54

Sudeep Narkar
@sudeepnarkar
Apr 04 2016 06:08 UTC

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

}
}

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

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

check your for loop closing braces
You have closed the for loop brace before product *= arr[i][j];
which is causing th eproblem
*the problem
Trilok reddy
@Trilokreddy007
Apr 04 2016 06:10 UTC
@sudeepnarkar Thanking u so much sudeep
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 06:13 UTC
@Trilokreddy007 No problem :)
unnzowy
@unnzowy
Apr 04 2016 06:17 UTC
Hello, im doing profile lookup and i'm having problem with first if
function lookUp(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++) {
if(contacts[i].firstName == firstName && contacts[i][prop]) {
return contacts[i][prop];
} else if (contacts[i].firstName !== firstName) {
return "No such contact";
} else {
return "No such property";
}
}
how should i check if property exists in an object, this part seems to not working - first if " && contacts[i][prop]) "
unnzowy
@unnzowy
Apr 04 2016 06:26 UTC
hasOwnProperty[prop]; doesnt do the job or im doing apparently something wrong
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 06:28 UTC
@unnzowy checking
James Bond
@Dman89
Apr 04 2016 06:28 UTC
my function isnt working
to randomize movement
can someone look at it
i just want it to display x in the boxs on the "o" button click
Jovan Curayag
@curayagjovan
Apr 04 2016 06:29 UTC

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

// Your code above this line
return result;
}

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

how to answer?
Frank XC
@tenkdayz
Apr 04 2016 06:30 UTC
@Dman89 randomized cell selection? you mean?
James Bond
@Dman89
Apr 04 2016 06:30 UTC
myNoun + myAdjective + "loves to " + myVerb + Myadverb
something like that
@tenkdayz yes sir
unnzowy
@unnzowy
Apr 04 2016 06:31 UTC
@curayagjovan yeahm do return myNoun + myAdjective + "loves to " + myVerb + Myadverb; ..
in proper way of your words :)
James Bond
@Dman89
Apr 04 2016 06:31 UTC
hahaha
Jovan Curayag
@curayagjovan
Apr 04 2016 06:31 UTC
oh thank you @Dman89 and @unnzowy
CamperBot
@camperbot
Apr 04 2016 06:31 UTC
curayagjovan sends brownie points to @dman89 and @unnzowy :sparkles: :thumbsup: :sparkles:
:star: 229 | @unnzowy | http://www.freecodecamp.com/unnzowy
:star: 355 | @dman89 | http://www.freecodecamp.com/dman89
James Bond
@Dman89
Apr 04 2016 06:32 UTC
@tenkdayz are you looking?
np @curayagjovan
Frank XC
@tenkdayz
Apr 04 2016 06:33 UTC
@Dman89 I think if you use jquery it'll be simpler
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 06:33 UTC
@unnzowy I do not see what is wrong
Frank XC
@tenkdayz
Apr 04 2016 06:33 UTC
wait.. sorry I'm not used to codepen
unnzowy
@unnzowy
Apr 04 2016 06:34 UTC
@sudeepnarkar yeah, im kinda not know whats wrong too, other than that it doesnt want to workin Profile Lookup lesson
is there a way i can link you whole code to check?
Sudeep Narkar
@sudeepnarkar
Apr 04 2016 06:35 UTC
The output seems correct
Even I am stuck
You can open up an issue in github
James Bond
@Dman89
Apr 04 2016 06:35 UTC
@tenkdayz how would I?
Frank XC
@tenkdayz
Apr 04 2016 06:37 UTC
could you add comments to see.. I'm not used to codepen.
HunterHelms
@HunterHelms
Apr 04 2016 06:37 UTC
i am stuck on changing the value of a and b
James Bond
@Dman89
Apr 04 2016 06:38 UTC
@tenkdayz added comments

function randomize() {    
    var random = open[Math.floor(Math.random() * open.length)];
   document.getElementById(random).innerHTML = "x";
};


$("#O").on("click", function() {
    win = "o";
    randomize();
    checkWinState();
    $("#X").removeClass("active");
    $("#O").addClass("active");
  })
@tenkdayz
i need it to run once, and everytime
Frank XC
@tenkdayz
Apr 04 2016 06:40 UTC
do something like.
Jovan Curayag
@curayagjovan
Apr 04 2016 06:42 UTC

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

var sample = ("My "+myNoun+" is "+ myAdjective + " and loves to " + myVerb +" very "+ myAdverb);
// Your code above this line
return result;
}

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

whats wrong?
James Bond
@Dman89
Apr 04 2016 06:42 UTC
return sample
not result
work?
@curayagjovan look above
Jovan Curayag
@curayagjovan
Apr 04 2016 06:45 UTC
@Dman89 Thank you! it worked!
CamperBot
@camperbot
Apr 04 2016 06:45 UTC
curayagjovan sends brownie points to @dman89 :sparkles: :thumbsup: :sparkles:
:warning: curayagjovan already gave dman89 points
Frank XC
@tenkdayz
Apr 04 2016 06:45 UTC
var cells = [0,1,2,3,4,5,6,7,8,9];
var rand = Math.floor(Math.random()*8.99);
delete cells[rand];
var tempArr = cells.sort().pop();
cells = tempArr;
var iaSelection = cells[rand];
i had something like that @Dman89
you also have to
delete cells[playerSelection];
....
V Arun Kumar
@arunvkumr
Apr 04 2016 06:48 UTC
@unnzowy read about hasOwnProperty();or you can see if it is property in object is defined or not.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
Frank XC
@tenkdayz
Apr 04 2016 06:48 UTC
actually that's one too many numbers inside the cells array.. hehe
James Bond
@Dman89
Apr 04 2016 06:49 UTC
@tenkdayz thank you
CamperBot
@camperbot
Apr 04 2016 06:49 UTC
dman89 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 349 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Olawale Akinseye
@brainyfarm
Apr 04 2016 06:49 UTC
wiki map the debris
CamperBot
@camperbot
Apr 04 2016 06:49 UTC

:point_right: algorithm map the debris [wiki]

Problem Explanation:

The first thing to do is to get familiar with what the program is for, for this I would suggest you check the Wikipedia link as that is very important and from where you can also get the formula for the conversion. The hardest part are finding the formula, implementing it and for some modifying objects by the key. However, something that is not very clear is the fact that your program has to be able to check for any number of objects in the array which is what is tested on the second part.

:pencil: read more about algorithm map the debris on the FCC Wiki

V Arun Kumar
@arunvkumr
Apr 04 2016 06:50 UTC
@unnzowy and your code will not work, because no such contact breaks the loop. to say that no such contact you should have checked for all the entries but your code just checks for one and returns no such contact.
James Bond
@Dman89
Apr 04 2016 06:50 UTC
@tenkdayz what do you mean about delete player selection
@tenkdayz ok i see it now, thank you for your time
CamperBot
@camperbot
Apr 04 2016 06:51 UTC
dman89 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:warning: dman89 already gave tenkdayz points
Frank XC
@tenkdayz
Apr 04 2016 06:52 UTC
@Dman89 if you use that method I showed you . otherwise the AI will try to pick cells that arent available. .. but I think you already have something to prevent that.
Riful
@timburrows
Apr 04 2016 06:53 UTC
Could someone give me a hint to what reg expression pattern i should use to solve the palindrome bonfire?
This is what I've got:
function palindrome(str) {
  var expression = /\W/g;

  var newStr = str.replace(expression, '');
  newStr = newStr.toLowerCase();

  var split = newStr.split('');
  split = split.reverse();
  split = split.join('');

  if (split == newStr) {
    return true;
  }

  return newStr;
}



palindrome("0_0 (: /-\ :) 0-0");
Frank XC
@tenkdayz
Apr 04 2016 06:54 UTC
if you use delete the value you delete will be undefined so you have to pop it... slice it not pop it.
Riful
@timburrows
Apr 04 2016 06:54 UTC
btw it's returning newStr just so I can see the output.
Frank XC
@tenkdayz
Apr 04 2016 06:55 UTC
or splice.. whichever
V Arun Kumar
@arunvkumr
Apr 04 2016 06:55 UTC
@RifuI \W expression removes everything except alphabets, numbers and underscore. you also have to add underscore to make it work.
Riful
@timburrows
Apr 04 2016 06:56 UTC
I don't follow
James Bond
@Dman89
Apr 04 2016 06:57 UTC
@tenkdayz ok makes sense
Riful
@timburrows
Apr 04 2016 06:57 UTC
It says to remove all non-alphanumeric characters, but then the last test has / : ) an d_
V Arun Kumar
@arunvkumr
Apr 04 2016 06:58 UTC
@RifuI add underscore in your regexp.. that will make it work.
@RifuI yes it does remove non-alphanumeric but not underscore.. in your output it returns something like 0_000. so you have to specify in you regexp to remove underscore.
\W is same as [^A-Za-z0-9_] <- see the underscore.
Riful
@timburrows
Apr 04 2016 07:02 UTC
I see
Ghost
@ghost~56a18e6ae610378809bd9384
Apr 04 2016 07:03 UTC

Anyone know How can I send a PDF to PDFObject from File API?

So I'm trying to use file select (or file API) to select file from desktop and send it to an embedded PDF viewer in my HTML Doc. I've tried a lot of different ways with my limited knowledge to push the file from the file-api to the PDFObject and nothing seems to work. I'm not sure if it's not able to do this or if I'm just doing it wrong in many different ways.

I can post code here if anyone thinks they can help

Riful
@timburrows
Apr 04 2016 07:04 UTC
Oh..
So your not supposed to match the symbols to check if they are palindrome
I got confused.. because "0_0 (: /-\ :) 0-0" is a palindrome pattern
buonarfcc
@buonarfcc
Apr 04 2016 07:07 UTC

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

switch (val){
case 'a': answer ="apple"; break;
case 'b': answer ="bird"; break;
case 'c': answer ="cat"; break;
default: answer = "stuff";

// Only change code above this line
return answer;
}
}
// Change this value to test
myTest(a);
I got referenceError: a is not defined? Thank you.

V Arun Kumar
@arunvkumr
Apr 04 2016 07:09 UTC
@buonarfcc remove val = ''; inside the function it's changing the val to empty string.
and pass with quotes like, myTest('a');
buonarfcc
@buonarfcc
Apr 04 2016 07:11 UTC
sound feasible arunkumrv , great & txs.
V Arun Kumar
@arunvkumr
Apr 04 2016 07:12 UTC
@buonarfcc you're welcome. :grinning:
rahulkavi
@rahulkavi
Apr 04 2016 07:21 UTC
Hi someone help me in Roman Numeral Converter challenge..
Jackson
@jacksonbrim
Apr 04 2016 07:30 UTC
Would anyone mind helping me with chunky monkey? I have been staring at this for a while now.
Jackson Bates
@JacksonBates
Apr 04 2016 07:31 UTC
Ok, I'm struggling with getting a random quote from an api (still). I'm using $.ajax to use the POST method to request a quote from an api, but it's throwing this error No 'Access-Control-Allow-Origin' header is present on the requested resource. Stackoverflow solutions to this problem all seem to be server-side solutions, not something I can do from my end...did anyone successfully overcome this hurdle?
@jacksonbrim jacksons gotta stick together...what are you stuck with?
Jackson
@jacksonbrim
Apr 04 2016 07:33 UTC
I'm trying to post the code
Not having much luck with that either.
@JacksonBates I'm on the Chunky Monkey bonfire.
This message was deleted
kirbyedy
@kirbyedy
Apr 04 2016 07:34 UTC
@JacksonBates why POST ?
Jackson Bates
@JacksonBates
Apr 04 2016 07:34 UTC
@jacksonbrim to post code use three backticks ` on the top line, then press shift+enter, paste the code, press shift+enter and put three more backticks on the last line.
Jackson
@jacksonbrim
Apr 04 2016 07:35 UTC
This message was deleted
CamperBot
@camperbot
Apr 04 2016 07:35 UTC
:bulb: to format code use backticks! ``` more info
Jackson
@jacksonbrim
Apr 04 2016 07:35 UTC
Ahh shoot
@kirbyedy What do you mean why POST?
Jackson Bates
@JacksonBates
Apr 04 2016 07:35 UTC
@kirbyedy The api I'm using has no GET method, and the other one I was using does have a get method, but it doesn't generate a random quote.
Ythalo Rossy Saldanha Lira
@ythalorossy
Apr 04 2016 07:36 UTC
kirbyedy
@kirbyedy
Apr 04 2016 07:36 UTC
@JacksonBates yes but POST means you are sending data, not getting it
you have to use GET eventually
Jackson
@jacksonbrim
Apr 04 2016 07:36 UTC
Oh shoot. That was to the other Jackson. haha
This message was deleted
CamperBot
@camperbot
Apr 04 2016 07:36 UTC
:bulb: to format code use backticks! ``` more info
Jackson Bates
@JacksonBates
Apr 04 2016 07:36 UTC
@ythalorossy I appreciate the offer, but I'd rather small hints to overcome the challenge at hand, not the whole solution :)
kirbyedy
@kirbyedy
Apr 04 2016 07:37 UTC
@jacksonbrim yes :D
@JacksonBates which api you are using ?
Jackson Bates
@JacksonBates
Apr 04 2016 07:37 UTC
Jackson
@jacksonbrim
Apr 04 2016 07:38 UTC
This message was deleted
CamperBot
@camperbot
Apr 04 2016 07:38 UTC
:bulb: to format code use backticks! ``` more info
Jackson Bates
@JacksonBates
Apr 04 2016 07:38 UTC
@kirbyedy I tried this one too (with GET): http://quotesondesign.com/the-api/
Jackson
@jacksonbrim
Apr 04 2016 07:38 UTC
My goodness. I'm having the worst time right now. :smile:
This message was deleted
Ythalo Rossy Saldanha Lira
@ythalorossy
Apr 04 2016 07:39 UTC
@JacksonBates Ajax request outside your domain needs permission in taget domain
Jackson
@jacksonbrim
Apr 04 2016 07:39 UTC
Somebody help me post this code please.
Ythalo Rossy Saldanha Lira
@ythalorossy
Apr 04 2016 07:40 UTC
``` use this
Jackson
@jacksonbrim
Apr 04 2016 07:40 UTC
I have been doing that.
'''
CamperBot
@camperbot
Apr 04 2016 07:40 UTC
:bulb: to format code use backticks! ``` more info
Ythalo Rossy Saldanha Lira
@ythalorossy
Apr 04 2016 07:40 UTC
``` + shift + enter
Jackson Bates
@JacksonBates
Apr 04 2016 07:40 UTC
@ythalorossy yeah, i figured that - but another camper did successfuly use this api, with POST... I should go back and look him up, I guess :)
@jacksonbrim ' is not `
kirbyedy
@kirbyedy
Apr 04 2016 07:41 UTC
@JacksonBates if you open this page: http://api.forismatic.com/api/jsonp/
and then the source code you will see the correct api call
Ythalo Rossy Saldanha Lira
@ythalorossy
Apr 04 2016 07:41 UTC

Jackson Bates
@JacksonBates
Apr 04 2016 07:41 UTC
@jacksonbrim if your kbd layout is like mine, backtick is under the esc key
Jackson
@jacksonbrim
Apr 04 2016 07:42 UTC
Yeah, I found it. Thanks.
Just realized it was different.
This message was deleted
This message was deleted
Ok, well that has the tick marks... :worried:
Jackson Bates
@JacksonBates
Apr 04 2016 07:44 UTC
@kirbyedy ok, I've found the api call in the source...I'll fiddle with it for a while and see if I have any luck. Thanks for the pointers.
CamperBot
@camperbot
Apr 04 2016 07:44 UTC
jacksonbates sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 794 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Jackson
@jacksonbrim
Apr 04 2016 07:45 UTC
Woohoo.... I got it.
Sheesh.
HunterHelms
@HunterHelms
Apr 04 2016 07:45 UTC
can anybody help with the celsius converter?
kirbyedy
@kirbyedy
Apr 04 2016 07:46 UTC
whats your code @HunterHelms
Jackson Bates
@JacksonBates
Apr 04 2016 07:47 UTC
@jacksonbrim ok, so what's the issue you're having with it at the moment? What is it returning or does the error console show?
@jacksonbrim oh, your code disappeared while I was reading it :)
Jackson
@jacksonbrim
Apr 04 2016 07:48 UTC
@JacksonBates yeah, I deleted it because it was old code. The gitter im took over my whole page and I had to refresh.
Olawale Akinseye
@brainyfarm
Apr 04 2016 07:48 UTC
wiki no repeat
CamperBot
@camperbot
Apr 04 2016 07:48 UTC

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

Jackson
@jacksonbrim
Apr 04 2016 07:48 UTC
Copy and pasted what was in there and I realized that it wasn't from the attempt that I was having trouble with. I'll start from scratch again.
Olawale Akinseye
@brainyfarm
Apr 04 2016 07:49 UTC
wiki map the
CamperBot
@camperbot
Apr 04 2016 07:49 UTC

:point_right: algorithm map the debris [wiki]

Problem Explanation:

The first thing to do is to get familiar with what the program is for, for this I would suggest you check the Wikipedia link as that is very important and from where you can also get the formula for the conversion. The hardest part are finding the formula, implementing it and for some modifying objects by the key. However, something that is not very clear is the fact that your program has to be able to check for any number of objects in the array which is what is tested on the second part.

:pencil: read more about algorithm map the debris on the FCC Wiki

HunterHelms
@HunterHelms
Apr 04 2016 07:49 UTC
@kirbyedy i dont even know when to start
kirbyedy
@kirbyedy
Apr 04 2016 07:50 UTC
@HunterHelms try to find the mathematical formula on google how the conversion is done
Jackson
@jacksonbrim
Apr 04 2016 07:53 UTC
Ok, I'm back.
```js
Ok, so when I type in the tick marks to post the code, it doesn't allow me to use the enter key
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  var result = [];
  for (var i = 0,c = 0; i < arr.length; i += size, c++){
    for (var j = 0; j < size; j++){
      newArr[c,j] = arr[j+(c*i)];
    }
  }
  return newArr;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Ythalo Rossy Saldanha Lira
@ythalorossy
Apr 04 2016 07:55 UTC
shift + enter
Jackson
@jacksonbrim
Apr 04 2016 07:55 UTC
It wasn't working when I did that. :/
Buut, I can just post it and then edit it here.
So in the above code, my output is just one array, of ["c","d"]
HunterHelms
@HunterHelms
Apr 04 2016 07:56 UTC
@kirbyedy got the equation still lost
kirbyedy
@kirbyedy
Apr 04 2016 07:57 UTC
what is it
HunterHelms
@HunterHelms
Apr 04 2016 07:58 UTC
c*9/5, plus 32
kirbyedy
@kirbyedy
Apr 04 2016 07:58 UTC
cool
Markus Kiili
@Masd925
Apr 04 2016 07:58 UTC
@jacksonbrim You could use .slice() inside the loop to produce arrays that you can push into result array.
kirbyedy
@kirbyedy
Apr 04 2016 07:58 UTC
now you have to assign this formula to your "fahrenheit", where this C in your code will be the celsius from the brackets in the task
Jackson
@jacksonbrim
Apr 04 2016 07:59 UTC
@Masd925 huh.. I thought that was only for strings
Jackson Bates
@JacksonBates
Apr 04 2016 07:59 UTC
@jacksonbrim as @Masd925 says, I was gonna suggest looking at .push() and .slice()
Jackson
@jacksonbrim
Apr 04 2016 08:00 UTC
Yeah, but .push() keeps giving me errors saying that it's not a function when I try to do stuff like newArray[c,j].push()
Thomas Hennes
@jaxxeh
Apr 04 2016 08:01 UTC
@jacksonbrim I'm not even sure the [a,b] notation is correct in JS, it should be [a][b] for a 2-dimensional array
HunterHelms
@HunterHelms
Apr 04 2016 08:01 UTC
@kirbyedy yeah im still lost. haha
kirbyedy
@kirbyedy
Apr 04 2016 08:02 UTC
@HunterHelms fahrenheit = your formula
Jackson
@jacksonbrim
Apr 04 2016 08:02 UTC
No, I don't think so, @jaxxeh, because that throws an error when I do that.
Jackson Bates
@JacksonBates
Apr 04 2016 08:02 UTC
@jacksonbrim newArray[whatever] would try to push it to a string within the array...just try newArray.push()
Thomas Hennes
@jaxxeh
Apr 04 2016 08:03 UTC
@jacksonbrim but yeah, like @JacksonBates and @Masd925 said, have a look at push() and slice() and you won't even have to worry about indices
Jackson Bates
@JacksonBates
Apr 04 2016 08:03 UTC
@jacksonbrim anyway, goodluck I gotta go. I'll check in later :)
Jackson
@jacksonbrim
Apr 04 2016 08:03 UTC
Alright, cool.
Push, just won't work for me.
I get this when I use push
      newArr[c][j] = newArr[c][j].push(arr[j+(c*i)]);
      newArr[c][j] = newArr[c][j].push(arr[j+(c*i)]);
Type Error: Cannot read property '0' of undefined
Thomas Hennes
@jaxxeh
Apr 04 2016 08:05 UTC
@jacksonbrim for starters, the return value of push() isn't an array, it's the new length of the array you've pushed on ;)
@jacksonbrim I know it's counter-intuitive, but that's how it works
Jackson
@jacksonbrim
Apr 04 2016 08:06 UTC
@jaxxeh I'm sorry, could you explain that in another way?
push() should push objects into arrays.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:06 UTC
@jacksonbrim lets say you have a brand new array var myArray = [];
Jackson
@jacksonbrim
Apr 04 2016 08:06 UTC
@jaxxeh yes
@jaxxeh Yes? ...
Thomas Hennes
@jaxxeh
Apr 04 2016 08:07 UTC
@jacksonbrim then if you do var x = myArray.push(1); you'll find that x = 1 because it's the size of myArray after you pushed one element onto it
@jacksonbrim so the return value of push is NOT the updated array
@jacksonbrim the array is modified 'in place' and what is returned is its updated size
Jackson
@jacksonbrim
Apr 04 2016 08:09 UTC
myArray.push(1) will push 1 into myArray.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:09 UTC
@jacksonbrim the other thing is, push always adds elements at the end of the array, so passing an index is useless
@jacksonbrim yes
@jacksonbrim so if you check the value of myArray it will be [1]
Jackson
@jacksonbrim
Apr 04 2016 08:10 UTC
But, I need arrays within arrays.
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  for (var i = 0,c = 0; i < arr.length; i += size, c++){
    for (var j = 0; j < size; j++){
      newArr[c].push(arr[j+(c*i)]);
    }
  }
  return newArr;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Thomas Hennes
@jaxxeh
Apr 04 2016 08:11 UTC
@jacksonbrim yes but you can do this : myArray.push([a, b]);
Jackson
@jacksonbrim
Apr 04 2016 08:11 UTC
Ahhh.... ok. Let me try this.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:11 UTC
@jacksonbrim and then myArray will be [[a, b]]
@jacksonbrim so pretty much what you want to do there, is initialize an empty array, and then slice the original array into sub arrays that you will successively push into your new array
Jackson
@jacksonbrim
Apr 04 2016 08:16 UTC
@jaxxeh That doesn't work the way I thought it would.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:16 UTC
show me
Jackson
@jacksonbrim
Apr 04 2016 08:17 UTC
No, I just looked at it again and thought it through. It can't work that way.
The array has to be iterated over and each object filed away one at a time.
So, doing .push([a,b]) won't work because the program won't hold up for all other problems.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:18 UTC
@jacksonbrim the original array has to be iterated over, yes, but how is that a problem?
Jackson
@jacksonbrim
Apr 04 2016 08:19 UTC
Because I need to be able to stick arr[0] into array[0][0] and then arr[1] into array[0][1] and so on.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:19 UTC
@jacksonbrim no no, let go of the indices, just get them out of your mind
@jacksonbrim what you have to do, is slice the original array into arrays of size x, and push those into your new array
Jackson
@jacksonbrim
Apr 04 2016 08:20 UTC
I just don't see how it can work any other way. I have to so that I can use varying sizes.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:20 UTC
@jacksonbrim and then you're done
Jackson
@jacksonbrim
Apr 04 2016 08:20 UTC
Oh wow.
That was too simple.
Sheesh, thanks @jaxxeh
CamperBot
@camperbot
Apr 04 2016 08:20 UTC
jacksonbrim sends brownie points to @jaxxeh :sparkles: :thumbsup: :sparkles:
:star: 307 | @jaxxeh | http://www.freecodecamp.com/jaxxeh
Thomas Hennes
@jaxxeh
Apr 04 2016 08:20 UTC
@jacksonbrim always look for simple stuff when coding ;)
Jackson
@jacksonbrim
Apr 04 2016 08:23 UTC
Yeah, I was thinking that splice was for strings only. That's why I missed it.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:24 UTC
you're not the only one getting confused mate, happens to me every day :D
Jackson
@jacksonbrim
Apr 04 2016 08:26 UTC
@jaxxeh well it seems I'm not quite out of the rough yet...
Now this has stumped me.
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  var otherArr = [];
  for (var i = 0; i < arr.length; i += size){
    newArr.push(arr.splice(i,i+size));
  }
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
I changed it. and it's only returning [['a','b']]
Thomas Hennes
@jaxxeh
Apr 04 2016 08:26 UTC
oh, wrong function name, it's slice(), splice() is different
Jackson
@jacksonbrim
Apr 04 2016 08:27 UTC
Ahh, danggit. I keep doing that splice slice thing.
Thanks for catching it.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:27 UTC
and i believe after that you're good ;)
Jackson
@jacksonbrim
Apr 04 2016 08:27 UTC
Yeah, golden!
Thomas Hennes
@jaxxeh
Apr 04 2016 08:27 UTC
grats bud
Jackson
@jacksonbrim
Apr 04 2016 08:28 UTC
Merci, beaucoup!
Thomas Hennes
@jaxxeh
Apr 04 2016 08:28 UTC
hehehe welcome
Adam
@AdamDrover
Apr 04 2016 08:37 UTC

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

function lookUp(firstName, prop){

// Only change code above this line
var answer = "";

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

Any ideas why this only works for 2 of the 5 required?
Thomas Hennes
@jaxxeh
Apr 04 2016 08:40 UTC
@AdamDrover because your correct answer might be overriden by a later iteration?
Adam
@AdamDrover
Apr 04 2016 08:44 UTC
Ah, I see. But how do I get around this? I'm a bit lost I think..
I'm setting all my properties to that from the last iteration.
Not purposely, of course.
Thomas Hennes
@jaxxeh
Apr 04 2016 08:45 UTC
@AdamDrover sometimes a for() loop isn't the best answer ;) think about what other type of loops you might use
@AdamDrover especially one that stops looping after a condition is met
Adam
@AdamDrover
Apr 04 2016 08:47 UTC
I guess we're referring to a while() loop then?
Thomas Hennes
@jaxxeh
Apr 04 2016 08:47 UTC
@AdamDrover I guess we are yes :D
Adam
@AdamDrover
Apr 04 2016 08:47 UTC
@jaxxeh Thanks! I think I've got it :+1:
CamperBot
@camperbot
Apr 04 2016 08:47 UTC
adamdrover sends brownie points to @jaxxeh :sparkles: :thumbsup: :sparkles:
:star: 308 | @jaxxeh | http://www.freecodecamp.com/jaxxeh
Reza Farshbaf
@grfarshbaf
Apr 04 2016 09:00 UTC
Dudes, please comment on my code for "where do I belong to" challenge
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  return arr.sort(function(a,b){
    return a - b;
  }).indexOf(num);
}
Islam Ibakaev
@dagman
Apr 04 2016 09:06 UTC
hey guys why just state doesn't get updated? http://codepen.io/dagman/pen/yOzemP?editors=0011
kirbyedy
@kirbyedy
Apr 04 2016 09:07 UTC
@dagman Uncaught TypeError: this.setState is not a function
Daniel Lau
@BluesBleu
Apr 04 2016 09:08 UTC
Hi, I need help implementing a way to remove entire duplicates, so
array = [1,1,2,2,3,4,4,5] would turn into array = [3,5], anything with more than 1 copy should be removed. How would I go about this? It's driving me crazy.
herbertdellama
@herbertdellama
Apr 04 2016 09:10 UTC
@BluesBleu do you want the solution or do you want someone to guide you through it?
Saturnino Abril
@saturninoabril
Apr 04 2016 09:11 UTC
@grfarshbaf all test passed, coding is elegant. great!
Daniel Lau
@BluesBleu
Apr 04 2016 09:11 UTC
the solution! i've just about tried every method I know of
There must be something i'm missing at this point
Markus Kiili
@Masd925
Apr 04 2016 09:12 UTC
@BluesBleu You could use .filter(), .indexOf() and .lastIndexOf().
When indexOf and lastIndexOf are equal, element is unique.
Daniel Lau
@BluesBleu
Apr 04 2016 09:13 UTC
I would need to remove that unique element
herbertdellama
@herbertdellama
Apr 04 2016 09:14 UTC
@BluesBleu well. I completed that task on another computer so I can't give yo my solution. but here's someone else's http://wulkan.me/bonfire-seek-and-destroy/
Markus Kiili
@Masd925
Apr 04 2016 09:15 UTC
@BluesBleu I thought that you remove duplicates and keep singles.
Daniel Lau
@BluesBleu
Apr 04 2016 09:16 UTC
This is actually for Symmetric Difference
but i think you're onto something about index of and lastindexof
if it's unique, i can just push it onto another array
and i'll have my solution
Markus Kiili
@Masd925
Apr 04 2016 09:16 UTC
@BluesBleu You can do it with filter and arr.indexOf(val)===arr.lastIndexOf(val).
herbertdellama
@herbertdellama
Apr 04 2016 09:17 UTC
@BluesBleu oh I haven't reached advanced algos yet soz
Robert Uivarosi
@URobert
Apr 04 2016 09:17 UTC
@BluesBleu for uniques
function unique(arr) {
  var result = [];
  $.each(arr, function(i, e) {
    if ($.inArray(e, result) == -1) result.push(e);
  });
  return result;
}

var array = [1,1,2,2,3,4,4,5] 
console.log(unique(array));
Markus Kiili
@Masd925
Apr 04 2016 09:19 UTC
@URobert Why not just:
function removeDoubles (arr) {
  return arr.filter(function(val){
      return arr.indexOf(val)===arr.lastIndexOf(val);
  });  
}
Robert Uivarosi
@URobert
Apr 04 2016 09:19 UTC
@Masd925 that is neater :+1:
Daniel Lau
@BluesBleu
Apr 04 2016 09:20 UTC
So in the filter, the function's condition being true/false will dictate the type of value that will be kept?
So in this case, because the value is unique, it will return true
and the filter will keep that value in the array?
Markus Kiili
@Masd925
Apr 04 2016 09:22 UTC
@BluesBleu Filter automatically iterates through the array and passes each element to the callback function you provide. If the return value is true (or truthy) the value is put to the result array (new array returned).
Daniel Lau
@BluesBleu
Apr 04 2016 09:23 UTC
Thanks for all your help!
Saturnino Abril
@saturninoabril
Apr 04 2016 09:24 UTC
@BluesBleu one way to determine unique value from array is to compare lastIndexOf to (current) index from .filter() function
  var unique = function(arr) {
    return arr.filter(function(val, index) { 
      return arr.lastIndexOf(val) === index; 
    });
  };
Latela
@Latela
Apr 04 2016 09:25 UTC
"Convert celsius to fahrenheit" - I don't quite get it from the beginning. Some tips?
Christian
@christianbrill
Apr 04 2016 09:28 UTC

Hey guys, I'm working on chapter 209 and it's the counting cards function. Now this is what is presented to me:

var count = 0;

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

return "Change Me";
// 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');

and I have no clue what to do here. This is the task to do:

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.

Yet I don't know how to even begin. I tried some switch statements and if/else statement but all I've started showed up as wrong. xD

Can someone lend a helping hand or point me in the right direction? Help is greatly appreciated!

Markus Kiili
@Masd925
Apr 04 2016 09:28 UTC
@saturninoabril He is trying to remove those that are not single. Your code keeps one of each number. It does what you said, but he is not asking for it.
Craig Banach
@CraigBanach
Apr 04 2016 09:29 UTC
@Alnilam90 Sure, post your code formatted
help format
CamperBot
@camperbot
Apr 04 2016 09:29 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

kirbyedy
@kirbyedy
Apr 04 2016 09:29 UTC
@Latela search for the mathematical formula how the celsius is converted to fahrenheit
Latela
@Latela
Apr 04 2016 09:30 UTC
9/5+32
Christian
@christianbrill
Apr 04 2016 09:30 UTC
var count = 0;

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


  return "Change Me";
  // 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');

The question is this one:

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.

kirbyedy
@kirbyedy
Apr 04 2016 09:31 UTC
@Latela yea, so now your fahrenheit = that formula
and add the celsius
Craig Banach
@CraigBanach
Apr 04 2016 09:31 UTC

@Alnilam90 Ok, try and implement this: It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table)

For the card values 2-6.

Latela
@Latela
Apr 04 2016 09:32 UTC
I think it's assing problem then. It does not take my var seriously :X
kirbyedy
@kirbyedy
Apr 04 2016 09:33 UTC
@Latela paste your code here
Christian
@christianbrill
Apr 04 2016 09:33 UTC
@CraigBanach do I start with a switch statement?
var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
  }

  return "Change Me";
  // 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');
something like this?
Craig Banach
@CraigBanach
Apr 04 2016 09:34 UTC
@Alnilam90 There are many ways to do it, a switch is one.
@Alnilam90 So now you need to change the count variable if you get 2-6
Saturnino Abril
@saturninoabril
Apr 04 2016 09:34 UTC
@Masd925 ok, but I thought he's trying to look for unique function,
@BluesBleu anyway, is this for Symmetric Difference? If yes, then you could solve it as well using unique function as I suggested.
Latela
@Latela
Apr 04 2016 09:35 UTC

function convert(celsius) {
// Only change code below this line
var fahrenheit="celsius+9/5+32";
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

Markus Kiili
@Masd925
Apr 04 2016 09:36 UTC
@saturninoabril Yes, there are many ways to solve it. I think he is first leaving just the unique values to each array and after concat removing those that are not single. So he needs both functions.
Coryphaeus
@cvdeby
Apr 04 2016 09:38 UTC
@Alnilam90 For checking I used array of ['K', 'A', '...'] and indexOf property, for another values (card >= 2 && card <=5) is enough. You can use switch or if else expression. But if else works a little bit faster than switch.
@Alnilam90 So, how @CraigBanach said - There are so many ways to do it:smile:
Christian
@christianbrill
Apr 04 2016 09:42 UTC
@cvdeby @CraigBanach ohhhhhhhhhhhhh, I think I just got it
I had totally forgotten about arrays
RodrigoGM13
@RodrigoGM13
Apr 04 2016 09:42 UTC
Hey people. How is every one?
Christian
@christianbrill
Apr 04 2016 09:42 UTC
now it's working. haha thank you, @cvdeby and @CraigBanach
CamperBot
@camperbot
Apr 04 2016 09:42 UTC
alnilam90 sends brownie points to @cvdeby and @craigbanach :sparkles: :thumbsup: :sparkles:
Andrew McKeever
@andmckvr13
Apr 04 2016 09:42 UTC
function palindrome(str) {
  // Good luck!
  var lower;
  var palindrome;
  lower = str.toLowerCase();
  lower.replace(/[\W_]/gi, lower);
  palindrome = str.split('').reverse().join('');

   return lower == palindrome;


}



palindrome("Not a PLAindrome");
CamperBot
@camperbot
Apr 04 2016 09:42 UTC
:star: 396 | @craigbanach | http://www.freecodecamp.com/craigbanach
:star: 270 | @cvdeby | http://www.freecodecamp.com/cvdeby
Andrew McKeever
@andmckvr13
Apr 04 2016 09:43 UTC
any thoughts on why this isn't working?
Craig Banach
@CraigBanach
Apr 04 2016 09:44 UTC
@andmckvr13 Your palindrome variable is never lowercase, while lower always is.
Thomas Hennes
@jaxxeh
Apr 04 2016 09:44 UTC
@andmckvr13 you're replacing underscores and non-digits & letters with whatever's in string 'lower'
your second parameter in replace should just be an empty string
Coryphaeus
@cvdeby
Apr 04 2016 09:45 UTC
@andmckvr13 And use replace parameter in palindrome variable too.
Andrew McKeever
@andmckvr13
Apr 04 2016 09:45 UTC
@CraigBanach @jaxxeh thanks for the help
CamperBot
@camperbot
Apr 04 2016 09:45 UTC
andmckvr13 sends brownie points to @craigbanach and @jaxxeh :sparkles: :thumbsup: :sparkles:
Saturnino Abril
@saturninoabril
Apr 04 2016 09:45 UTC
@Masd925 @BluesBleu it makes sense, I agree.
CamperBot
@camperbot
Apr 04 2016 09:46 UTC
:star: 397 | @craigbanach | http://www.freecodecamp.com/craigbanach
:star: 309 | @jaxxeh | http://www.freecodecamp.com/jaxxeh
RodrigoGM13
@RodrigoGM13
Apr 04 2016 09:47 UTC
Hey! Can anyone explain a little bit @andmckvr13 's solution. I did it in a very complicated way, I think.
Thomas Hennes
@jaxxeh
Apr 04 2016 09:47 UTC
@andmckvr13 oh and it would be simpler to just do palindrome = lower.split('')...
Coryphaeus
@cvdeby
Apr 04 2016 09:47 UTC
This message was deleted
@jaxxeh I'm sry)
Thomas Hennes
@jaxxeh
Apr 04 2016 09:48 UTC
@RodrigoGM13 he's turning the input string into lowercase, then removing anything except letters and digits, then comparing the resulting string to its reverse
@RodrigoGM13 he has to use split & join to reverse the string because reverse only works on arrays, not on actual String objects
RodrigoGM13
@RodrigoGM13
Apr 04 2016 09:50 UTC
@jaxxeh I see. Thank you. Cool. I delated every simbol one by one. It worked at the end haha but that solution makes more sense.
CamperBot
@camperbot
Apr 04 2016 09:50 UTC
rodrigogm13 sends brownie points to @jaxxeh :sparkles: :thumbsup: :sparkles:
:star: 310 | @jaxxeh | http://www.freecodecamp.com/jaxxeh
Latela
@Latela
Apr 04 2016 09:50 UTC
"Convert celsius to fahrenheit" any tips besides the already given formula there?
Thomas Hennes
@jaxxeh
Apr 04 2016 09:51 UTC
@RodrigoGM13 yeah, RegEx can be a little scary to get into, but they're great if you use them wisely ;)
Andrew McKeever
@andmckvr13
Apr 04 2016 09:51 UTC
function palindrome(str) {
  // Good luck!
  var lower;
  var palindrome;
  lower = str.toLowerCase();
  lower.replace(/[\W_]/gi, "");
  palindrome = lower.split('').reverse().join('');

   return lower == palindrome;

}

palindrome("Not a PLAindrome");
so I'm still not getting it to work
Coryphaeus
@cvdeby
Apr 04 2016 09:52 UTC
@andmckvr13 Add the same replace function into the palindrome variable.
Markus Kiili
@Masd925
Apr 04 2016 09:52 UTC
@andmckvr13 Strings are immutable.
Bruce Young
@mutantspore
Apr 04 2016 09:53 UTC
@andmckvr13 and it wil have to be lowercase also
Thomas Hennes
@jaxxeh
Apr 04 2016 09:53 UTC
@andmckvr13 you have to do lower = lower.replace(..)
@andmckvr13 just like @Masd925 said, strings are immutable
Andrew McKeever
@andmckvr13
Apr 04 2016 09:54 UTC
thanks @jaxxeh @cvdeby
CamperBot
@camperbot
Apr 04 2016 09:54 UTC
andmckvr13 sends brownie points to @jaxxeh and @cvdeby :sparkles: :thumbsup: :sparkles:
:warning: andmckvr13 already gave jaxxeh points
:star: 271 | @cvdeby | http://www.freecodecamp.com/cvdeby
Andrew McKeever
@andmckvr13
Apr 04 2016 09:54 UTC
got it now
Latela
@Latela
Apr 04 2016 09:55 UTC
"Convert celsius to fahrenheit" problems any1?
Coryphaeus
@cvdeby
Apr 04 2016 09:55 UTC

For good understanding create another function clear()

function clear (str) {
  return str.toLowerCase().replace(/[\W_]/gi, "");
}

and use it so

lower = clear(lower);
palindrome = clear(palindrome).split("")...;
Andrew McKeever
@andmckvr13
Apr 04 2016 09:55 UTC
@Masd925 can you explain a bit more about immutable? I'm still a big confused
you have to always declare the variable then?
Thomas Hennes
@jaxxeh
Apr 04 2016 09:56 UTC
@andmckvr13 once created, a string cannot be modified
Coryphaeus
@cvdeby
Apr 04 2016 09:57 UTC
@andmckvr13 Immutable means that it doesn't work var str = "Cap"; str[0] = "M"; Only full string can be changed.
Andrew McKeever
@andmckvr13
Apr 04 2016 09:57 UTC
okay so if I want to change the string I have to declare a variable to be equal to the string and changes I want to make to the string
Thomas Hennes
@jaxxeh
Apr 04 2016 09:57 UTC
@andmckvr13 exactly
Andrew McKeever
@andmckvr13
Apr 04 2016 09:58 UTC
haha it amazes me how I can spend hours trying to figure out something so simple
Markus Kiili
@Masd925
Apr 04 2016 09:58 UTC
@andmckvr13 There are no methods that change string content. All string methods return a new string and the original stays intact. Therefore you must assign the result somewhere.
Bruce Young
@mutantspore
Apr 04 2016 09:59 UTC
for amusement … here is my solution
function palindrome(str) {

  str = str.toLowerCase().replace(/[^a-z1-9]/g,'');

return str == str.split('').reverse().join('');
}

palindrome("eye");
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 09:59 UTC

Stuck here a bit. i have json = {"quote":"Carpe diem. Seize the day, boys. Make your lives extraordinary.","author":"Dead Poets Society","category":"Movies"}

How do i access the quote? Tried this:
```
console.log(json[quote])
console_runner-ba402f0….js:1 undefined
undefined
console.log(json["quote"])
console_runner-ba402f0….js:1 undefined
undefined

Thomas Hennes
@jaxxeh
Apr 04 2016 09:59 UTC
@Latela remove the string around the formula that converts celsius into fahrenheit
@Latela the quotes I mean >< damn this immutable talk confused my brain :D
@mutantspore so you're removing zeroes? why?
Coryphaeus
@cvdeby
Apr 04 2016 10:01 UTC
@rithvikvibhu json.quote and json["quote"] should work;
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:01 UTC
I get undifined @cvdeby
Thomas Hennes
@jaxxeh
Apr 04 2016 10:02 UTC
poor zeroes, so much hate
must be all that division by thing
Bruce Young
@mutantspore
Apr 04 2016 10:02 UTC
@jaxxeh 1-9
Thomas Hennes
@jaxxeh
Apr 04 2016 10:03 UTC
yeah?
Bruce Young
@mutantspore
Apr 04 2016 10:03 UTC
but i guess it says alph-numberic lol
Coryphaeus
@cvdeby
Apr 04 2016 10:03 UTC
@rithvikvibhu What console.log(json) returns?
Thomas Hennes
@jaxxeh
Apr 04 2016 10:03 UTC
but zero is not in the 1-9 range, why not 0-9?
Saturnino Abril
@saturninoabril
Apr 04 2016 10:04 UTC

@latela just change:

var fahrenheit="celsius+9/5+32";

to

var fahrenheit = celsius*(9/5) + 32;
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:05 UTC
@cvdeby it returns the json {"quote":"Carpe diem. Seize the day, boys. Make your lives extraordinary.","author":"Dead Poets Society","category":"Movies"}
Bruce Young
@mutantspore
Apr 04 2016 10:05 UTC
@jaxxeh lol ok it passed anyway but i’ll change it
Thomas Hennes
@jaxxeh
Apr 04 2016 10:05 UTC
@mutantspore just teasing you, really :P
Bruce Young
@mutantspore
Apr 04 2016 10:06 UTC
@jaxxeh it’s 6am.. not been to sleep. :(
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:06 UTC
@cvdeby Check it out here: http://codepen.io/rithvikvibhu/pen/dMVxZj
Bruce Young
@mutantspore
Apr 04 2016 10:08 UTC
@rithvikvibhu data.quote
@rithvikvibhu $("#quote").html(data.quote);
Coryphaeus
@cvdeby
Apr 04 2016 10:09 UTC
@rithvikvibhu data - is a string, not an object.
alpox
@alpox
Apr 04 2016 10:09 UTC
@rithvikvibhu Your mistake is here: datatype: 'json', it must be: dataType: 'json', (big T) otherwise you get a STRING back instead of the data OBJECT
Thomas Hennes
@jaxxeh
Apr 04 2016 10:10 UTC
@rithvikvibhu you might have to do a data = JSON.parse(json), then do what @mutantspore said
Bruce Young
@mutantspore
Apr 04 2016 10:10 UTC
and it’s dataType
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:12 UTC
@mutantspore what did you change?
Bruce Young
@mutantspore
Apr 04 2016 10:12 UTC
@rithvikvibhu now you need a check your button to see if you need to call it again
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:12 UTC
I cant find any dataType
Bruce Young
@mutantspore
Apr 04 2016 10:13 UTC
dataType: 'json’,
in the $.ajax
Coryphaeus
@cvdeby
Apr 04 2016 10:13 UTC
@rithvikvibhu row 5
alpox
@alpox
Apr 04 2016 10:13 UTC
@rithvikvibhu In your code you wrote datatype: 'json', instead of dataType: 'json',
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:13 UTC
Ah
Got it working, Thanks @cvdeby @mutantspore @alpox !
CamperBot
@camperbot
Apr 04 2016 10:13 UTC
rithvikvibhu sends brownie points to @cvdeby and @mutantspore and @alpox :sparkles: :thumbsup: :sparkles:
:star: 1361 | @mutantspore | http://www.freecodecamp.com/mutantspore
:star: 475 | @alpox | http://www.freecodecamp.com/alpox
:star: 272 | @cvdeby | http://www.freecodecamp.com/cvdeby
Bruce Young
@mutantspore
Apr 04 2016 10:13 UTC
$("#quote").html(data.quote); and $("#quote").html(data.author);
Rithvik Vibhu
@rithvikvibhu
Apr 04 2016 10:14 UTC
Thats on my list
alpox
@alpox
Apr 04 2016 10:14 UTC
@mutantspore That would override the quote with the author
Bruce Young
@mutantspore
Apr 04 2016 10:14 UTC
well the second one wil need it’s own id
yes i just did a quick cut/paste
Deepak Yadav
@ydeepk
Apr 04 2016 10:22 UTC
Please some body help me understand stand in line challange
Reza Farshbaf
@grfarshbaf
Apr 04 2016 10:23 UTC
Please rate my code for Caesars Cipher
function rot13(str) { // LBH QVQ VG!
  var input  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var output = "NOPQRSTUVWXYZABCDEFGHIJKLM";
  var result = [];
  str = str.split('');
  result = str.map(function(item){
    if (input.indexOf(item) !== -1){
      return output[input.indexOf(item)];
    } else {
      return item;
    }
  });
  return result.join('');
}
Deepak Yadav
@ydeepk
Apr 04 2016 10:24 UTC
We add an element at the end of an array using arrayName.push(arrayValue); right?
Reza Farshbaf
@grfarshbaf
Apr 04 2016 10:24 UTC
@ydeepk Yes
Craig Banach
@CraigBanach
Apr 04 2016 10:24 UTC

@grfarshbaf

Readabilty= 3/5
Ease of understanding = 2/5
Performance = ?

Deepak Yadav
@ydeepk
Apr 04 2016 10:24 UTC
and pop from front using arrayName.pop(); right?
Craig Banach
@CraigBanach
Apr 04 2016 10:25 UTC
@ydeepk pop removes from highest index
Deepak Yadav
@ydeepk
Apr 04 2016 10:25 UTC
@grfarshbaf i can not resolve stand in line probblem. i belive i have written correct code.
Craig Banach
@CraigBanach
Apr 04 2016 10:25 UTC
you "pop the top off"
so to speak
Deepak Yadav
@ydeepk
Apr 04 2016 10:26 UTC
@CraigBanach so how do ipop from bottom?
Craig Banach
@CraigBanach
Apr 04 2016 10:26 UTC
@ydeepk either shift or unshift, can't remember
Reza Farshbaf
@grfarshbaf
Apr 04 2016 10:26 UTC
@ydeepk use shift method
@CraigBanach any idea how to improve the codce?
Deepak Yadav
@ydeepk
Apr 04 2016 10:26 UTC
@grfarshbaf & @CraigBanach thanks i got it...
CamperBot
@camperbot
Apr 04 2016 10:26 UTC
ydeepk sends brownie points to @grfarshbaf and @craigbanach :sparkles: :thumbsup: :sparkles:
:star: 399 | @craigbanach | http://www.freecodecamp.com/craigbanach
:star: 267 | @grfarshbaf | http://www.freecodecamp.com/grfarshbaf
Craig Banach
@CraigBanach
Apr 04 2016 10:27 UTC
@grfarshbaf Instead of using two strings, use the character code. Do you know what ASCII code is?
and comments
Bruce Young
@mutantspore
Apr 04 2016 10:27 UTC

@grfarshbaf I worked with the helpful hints provided

String.charCodeAt()
String.fromCharCode()

and did this
function rot13(encodedStr) {
  var codeArr = encodedStr.split("");  // String to Array
  var decodedArr = []; // Your Result goes here
  // Only change code below this line

  codeArr.forEach( function (v,i){
    var temp = v.charCodeAt();

    if (temp >= 65 && temp <= 90) { 
      temp += 13;
    if (temp > 90) {
      temp -= 26;
       }
    }
    decodedArr[i] = String.fromCharCode(temp); 
  });

  // Only change code above this line
  return decodedArr.join(""); // Array to String
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
you seem to have changed code that was “above the line”
Craig Banach
@CraigBanach
Apr 04 2016 10:33 UTC
@mutantspore Did that code pass the tests?
Bruce Young
@mutantspore
Apr 04 2016 10:33 UTC
wel I wouldn’t post it if it didn't
yes
Reza Farshbaf
@grfarshbaf
Apr 04 2016 10:34 UTC
I tried the lookup table method. @mutantspore
Craig Banach
@CraigBanach
Apr 04 2016 10:34 UTC
@mutantspore It shouldn't, any uppercase character in the second half of the alphabet will be converted to lowercase, they must not check for that
Reza Farshbaf
@grfarshbaf
Apr 04 2016 10:34 UTC
@mutantspore thank you for the hint BTW.
CamperBot
@camperbot
Apr 04 2016 10:34 UTC
grfarshbaf sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1362 | @mutantspore | http://www.freecodecamp.com/mutantspore
Chris Goode
@goodeee
Apr 04 2016 10:35 UTC
ass
Bruce Young
@mutantspore
Apr 04 2016 10:36 UTC
@CraigBanach why
Craig Banach
@CraigBanach
Apr 04 2016 10:36 UTC
@mutantspore why what?
Olawale Akinseye
@brainyfarm
Apr 04 2016 10:36 UTC
wiki no repeat
CamperBot
@camperbot
Apr 04 2016 10:36 UTC

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

Craig Banach
@CraigBanach
Apr 04 2016 10:36 UTC
@mutantspore Oh no, I'm wrong, can't count
Bruce Young
@mutantspore
Apr 04 2016 10:36 UTC
why would it convert to lowercase..
:)
Prateek Vasisht
@vaspv
Apr 04 2016 11:10 UTC
Hi I am doing the wikipedia viewer project and have encountered a strange problem. I'm reusing the code from weather station api and have just put in basic code that displays URL on press of button. The strange this is that it works with weather url but not with a valid wikipedia url

function getwik() {
var sterm = "36.8485";
//sterm = document.getElementById("mysearch").value;
var myurl = "http://api.openweathermap.org/data/2.5/weather?lat="+sterm+"&lon=174.7633&appid=e0f6d168a225045972c6933b7097d418";

$.getJSON(myurl, function(json) {

$("#mysnippet").text(myurl);

})
}

when I use wikipedia url which is valid, the code does not work. it is getting stuck somewhere in teh sub function?
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:16 UTC
What URL do you use @vaspv ?
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:16 UTC
@vaspv
You might be having Cross Origin request issue.
Share your code for the Wikipedia viewer.
Besides @vaspv
$("#mysnippet").text(myurl); would put your url into that field and not your json response.
Prateek Vasisht
@vaspv
Apr 04 2016 11:20 UTC
@brainyfarm @marcusnielsen I am using the following for wikipedia which is correctly formed and works: "https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=" + sterm + "&srwhat=text&srprop=sectiontitle%7Csnippet&srlimit=5"
yes, re the mysnippet, this is a paragraph field and I am just pre-testing that if my URL displays then at least i am not having a nested function problem
I have a codepen - should I just send link?
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:21 UTC
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:22 UTC
Snippet would be great
best is to find some kind of error or network request
why does everyone use codepen? why not just go with github and code like we do when working?
in real code editors I mean
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:24 UTC
@marcusnielsen
codepen is recommended for the front end challenges.
Prateek Vasisht
@vaspv
Apr 04 2016 11:24 UTC
oh don't know - codepen was showing in the intro lessons so stuck with that
ah ok embedded the pen
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:24 UTC
@brainyfarm ah, ok, that makes a bit of sense. Thank you.
CamperBot
@camperbot
Apr 04 2016 11:24 UTC
marcusnielsen sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1756 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Prateek Vasisht
@vaspv
Apr 04 2016 11:25 UTC
in the javascript section, if the URL is replaced with weather api, then the click fucntion works
Trilok reddy
@Trilokreddy007
Apr 04 2016 11:26 UTC
can any one help me with solving profile Lookup
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:26 UTC
@vaspv https://crossorigin.me/http://en.wikipedia.org/data/2.5/weather?lat=36.8485&lon=174.7633&appid=e0f6d168a225045972c6933b7097d418 that looks wrong
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:26 UTC
Sure @Trilokreddy007 .
Prateek Vasisht
@vaspv
Apr 04 2016 11:26 UTC
ok changed now to
it is coming up now and even when I enter it in browser it is showing the json feed
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:27 UTC
@vaspv
That should work now.
Prateek Vasisht
@vaspv
Apr 04 2016 11:27 UTC
yes great @brainyfarm :clap:
Trilok reddy
@Trilokreddy007
Apr 04 2016 11:27 UTC
@brainyfarm this is my code can u correct it
Prateek Vasisht
@vaspv
Apr 04 2016 11:27 UTC
@marcusnielsen :clap:
Trilok reddy
@Trilokreddy007
Apr 04 2016 11:27 UTC

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

function lookUp(firstName, prop){
// Only change code below this line
if(lookUp.hasOwnProperty(firstName,Prop)){
lookUp(contacts)[firstName];
return lookUp(contacts[firstName]);

}

// Only change code above this line
}

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

Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:28 UTC
@vaspv if you write “thank you” you give some creds too ppl for helping ;-)
CamperBot
@camperbot
Apr 04 2016 11:28 UTC
marcusnielsen sends brownie points to @vaspv :sparkles: :thumbsup: :sparkles:
:star: 277 | @vaspv | http://www.freecodecamp.com/vaspv
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:28 UTC
Well done on getting it to work
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:30 UTC
@Trilokreddy007
You need to loop through the object and you are not using the .hasOwnProperty() properly.
Trilok reddy
@Trilokreddy007
Apr 04 2016 11:32 UTC
@brainyfarm i guess this is correct code lookup.hasOwnProperty(firsName)
Prateek Vasisht
@vaspv
Apr 04 2016 11:34 UTC
@marcusnielsen thanks now for the next part which is to loop through it to get the articles!
CamperBot
@camperbot
Apr 04 2016 11:34 UTC
vaspv sends brownie points to @marcusnielsen :sparkles: :thumbsup: :sparkles:
:star: 51 | @marcusnielsen | http://www.freecodecamp.com/marcusnielsen
Prateek Vasisht
@vaspv
Apr 04 2016 11:35 UTC
@brainyfarm @marcusnielsen thank you
CamperBot
@camperbot
Apr 04 2016 11:35 UTC
vaspv sends brownie points to @brainyfarm and @marcusnielsen :sparkles: :thumbsup: :sparkles:
:warning: vaspv already gave marcusnielsen points
:star: 1757 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Alex N.
@N0bl3
Apr 04 2016 11:36 UTC
Hi guys! What do you think about using promises in the browser? Im stuck because i want to use async all the time and doesnt know a propoer way to do it . Like in Simon project where i want my User to wait until all answers are displayed...
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:37 UTC
No @Trilokreddy007
You need a for loop to loop through individual objects in the array and test if the item at the current iteration is the object you are looking for.
This message was deleted
Alex N.
@N0bl3
Apr 04 2016 11:40 UTC
@brainyfarm i don't want to use this as i don"t understand how to do it myself.
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:41 UTC
Could you share your codepen link @N0bl3 ?
Prosvia
@Prosvia
Apr 04 2016 11:41 UTC
var one = 1;
function test(one) {
    one = 2;
}
  test1();
return one;
//return 1 instead of 2;

var one = 1;
function test() {
    one = 2;
}
  test2();
return one;

//returns 2 correctly
So let me get this straight. The test1 function does not return 2 because it creates its own personal, local variable named "one", yes? But the second returns two because it accesses the global variable and edits that? Is that correct?
Alex N.
@N0bl3
Apr 04 2016 11:41 UTC
@brainyfarm You know the Simon Game? Well at each successful step, the game displays the new serie of answers. The game shouldnt allow the user to play during this time
@brainyfarm the displayAllAnswers() should tell me about if they have all been displayed or not.
BTW if you would enjoy to give me some hints in programming design here i would be glad to hear you haha
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:43 UTC
@Prosvia
You are calling the wrong function names and your return value should also be inside your function.
Prosvia
@Prosvia
Apr 04 2016 11:44 UTC
Oh I accidentally mislabeled them.
var one = 1;
function test(one) {
    one = 2;
}
  test(one);
return one;
This still returns one, however
1
And this returns two
Markus Kiili
@Masd925
Apr 04 2016 11:45 UTC
@Prosvia Your functions don't return anything but the second one modifies the global variable.
Prosvia
@Prosvia
Apr 04 2016 11:45 UTC
var one = 1;
function test() {
    one = 2;
}
  test();
return one;
Yup
@Masd925 Yup
@Masd925 And the first doesn't modify the global variable because it creates its own variable right
Alex N.
@N0bl3
Apr 04 2016 11:46 UTC
@brainyfarm if you want to reload your browser, im adding some comments for clarity's sake ;;)
Markus Kiili
@Masd925
Apr 04 2016 11:47 UTC
@Prosvia Correct.
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:47 UTC

@N0bl3
The way I approached mine:

I used an array to keep each level challenge and then another array to keep track of user input then I compare as user clicks if it matches.

Prosvia
@Prosvia
Apr 04 2016 11:48 UTC
@Masd925 So here's my problem I want to plug a bunch of variables into the function and I want the function to modify the global variables, but I don't know the global variable names ...
Like,
 function test (globalVar1, globalVar2, globalVar3){
modify globalVar1;
modify globalVar2;
modify globalVar3; 
}
Alex N.
@N0bl3
Apr 04 2016 11:51 UTC
@brainyfarm Yes i don't have a problem with this haha :D
Prosvia
@Prosvia
Apr 04 2016 11:51 UTC
You get the what I'm getting at with this pseudocode?
Alex N.
@N0bl3
Apr 04 2016 11:52 UTC
@brainyfarm however i found the solution for the fake async i want : Ill use a setTimeout with a wisely and dynamically set value which will re enable my buttons after the display method :)
hey peeps
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:53 UTC
As long as it works @N0bl3 :P
Aestellar
@Aestellar
Apr 04 2016 11:53 UTC
@Prosvia You cannot modify global vars in function without you know theirs name, if only these global variables are not objects.
how do i paste the code im working on in here?
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:53 UTC
explain format
CamperBot
@camperbot
Apr 04 2016 11:53 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Olawale Akinseye
@brainyfarm
Apr 04 2016 11:53 UTC
@KindredBay :point_up:

'''
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj['Montana']; // Change this Line
var player = testObj[16]; // Change this Line
'''

CamperBot
@camperbot
Apr 04 2016 11:54 UTC
:bulb: to format code use backticks! ``` more info
well that didnt work
'''rgd'''
CamperBot
@camperbot
Apr 04 2016 11:55 UTC
:bulb: to format code use backticks! ``` more info

```// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj['Montana']; // Change this Line
var player = testObj[16]; // Change this Line
```

Prosvia
@Prosvia
Apr 04 2016 11:55 UTC
@Aestellar Well, that's horrible. Especially when coming from C. Okay. Thanks.
CamperBot
@camperbot
Apr 04 2016 11:55 UTC
prosvia sends brownie points to @aestellar :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Apr 04 2016 11:55 UTC
@Prosvia With primitive values that doesn't work, because values are copied to the parameters. As @Aestellar pointed out, with objects it works, because function parameter holds a reference to the object.
CamperBot
@camperbot
Apr 04 2016 11:55 UTC
:star: 172 | @aestellar | http://www.freecodecamp.com/aestellar
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:56 UTC
@KindredBay
playerNumber should be an integer.

@brainyfarm yes however i cannot access the variable itself in the object using bracket notation

well i dont know how to

Prosvia
@Prosvia
Apr 04 2016 11:56 UTC
@Masd925 Okay, thanks. Ugggh, I want my pointers! Javascriiiiiiiiiipt!
@Masd925 Thanks.
CamperBot
@camperbot
Apr 04 2016 11:57 UTC
prosvia sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1292 | @masd925 | http://www.freecodecamp.com/masd925
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:57 UTC
You should access the object in the next line.
@KindredBay
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:57 UTC
@Prosvia You can get the pointers the same way by putting them on an object.
Vivek
@vivek28111992
Apr 04 2016 11:57 UTC
@KindredBay just do this var player = testObj[playerNumber];
Aestellar
@Aestellar
Apr 04 2016 11:58 UTC
@Prosvia But you can create use return value and assing it to global function. ''' js globalVar1 = modify(globalVar1) '''
CamperBot
@camperbot
Apr 04 2016 11:58 UTC
:bulb: to format code use backticks! ``` more info
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:58 UTC
Vivek
@vivek28111992
Apr 04 2016 11:58 UTC
@brainyfarm oh, sorry
Coryphaeus
@cvdeby
Apr 04 2016 11:58 UTC
This message was deleted
Prosvia
@Prosvia
Apr 04 2016 11:58 UTC
@marcusnielsen Duly noted. Thanks!
CamperBot
@camperbot
Apr 04 2016 11:58 UTC
prosvia sends brownie points to @marcusnielsen :sparkles: :thumbsup: :sparkles:
:star: 52 | @marcusnielsen | http://www.freecodecamp.com/marcusnielsen
Prosvia
@Prosvia
Apr 04 2016 11:58 UTC
@Aestellar Oooh! Alright! Thanks!
CamperBot
@camperbot
Apr 04 2016 11:58 UTC
prosvia sends brownie points to @aestellar :sparkles: :thumbsup: :sparkles:
:warning: prosvia already gave aestellar points
Marcus Nielsen
@marcusnielsen
Apr 04 2016 11:59 UTC
@Prosvia
function foo(varsToModify) {
  varsToModify.myVar = 5
}
Vivek
@vivek28111992
Apr 04 2016 11:59 UTC
@brainyfarm I edited now
Olawale Akinseye
@brainyfarm
Apr 04 2016 11:59 UTC
@cvdeby
Don't share solutions.
Coryphaeus
@cvdeby
Apr 04 2016 11:59 UTC
@brainyfarm Ok.
@cvdeby @brainyfarm thanks guys
CamperBot
@camperbot
Apr 04 2016 12:00 UTC
kindredbay sends brownie points to @cvdeby and @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1758 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Coryphaeus
@cvdeby
Apr 04 2016 12:00 UTC
@KindredBay Put your number into variable. Put that variable into bracket notation.
CamperBot
@camperbot
Apr 04 2016 12:00 UTC
:star: 276 | @cvdeby | http://www.freecodecamp.com/cvdeby
@cvdeby its weird how they wanted me to do it, thats what got me confused >.<
Aestellar
@Aestellar
Apr 04 2016 12:01 UTC
@marcusnielsen It will not change global variables. It will change only their copy in temporal object varsToModify.
Coryphaeus
@cvdeby
Apr 04 2016 12:01 UTC
@KindredBay I think it's helpful and extends your skill)
Prosvia
@Prosvia
Apr 04 2016 12:02 UTC
@marcusnielsen Oh my! I
@marcusnielsen This certainly solved my problem and I learned more about javascript! Thanks!
CamperBot
@camperbot
Apr 04 2016 12:03 UTC
prosvia sends brownie points to @marcusnielsen :sparkles: :thumbsup: :sparkles:
Prosvia
@Prosvia
Apr 04 2016 12:03 UTC
Thanks everyone!
CamperBot
@camperbot
Apr 04 2016 12:03 UTC
:warning: prosvia already gave marcusnielsen points
E YG
@laed37
Apr 04 2016 12:03 UTC
Hello I have a question about 'testing objects with properties', I am having a difficult time resolving the return
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

}

// Test your code by modifying these values
checkObj("gift");
Craig Banach
@CraigBanach
Apr 04 2016 12:04 UTC
@laed37 if statements should be formatted as follows:
if (condition) {
//code
} else {
//code
}
Blauelf
@Blauelf
Apr 04 2016 12:04 UTC
You are returning value of property "checkProp", you want to return value of property "gift" or whatever value variable checkProp has. So you have to use bracket notation here to use checkProp as a key for your key-value pairs in myObj.
@CraigBanach Missing some ) after condition ;) Thanks for fixing :)
Marcus Nielsen
@marcusnielsen
Apr 04 2016 12:05 UTC

@Prosvia for extra nerdness delux: http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language

JavaScript references are kinda hard, and go by the name of “call-by-sharing”.

Aestellar
@Aestellar
Apr 04 2016 12:05 UTC
@laed37 return myObj.checkProp; === return myObj['checkProp']
Coryphaeus
@cvdeby
Apr 04 2016 12:06 UTC
This message was deleted
@laed37
if (condition)
return ;
return ;
// Works the same with
if (condition) {
  return ;
} else {
  return ;
}
Alex N.
@N0bl3
Apr 04 2016 12:08 UTC
@brainyfarm thanks tho ;)
CamperBot
@camperbot
Apr 04 2016 12:08 UTC
n0bl3 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1759 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Alex N.
@N0bl3
Apr 04 2016 12:10 UTC
@laed37 you need to return the property not the function checkProp :)
Blauelf
@Blauelf
Apr 04 2016 12:11 UTC
checkProp is no function. And myObj.checkProp does not even exist.
E YG
@laed37
Apr 04 2016 12:11 UTC
thanks @N0bl3 @Aestellar @Blauelf ! i was confused, i thought we could access properties using either dot operator or bracket notation? why do I have to use bracket notation here
CamperBot
@camperbot
Apr 04 2016 12:11 UTC
laed37 sends brownie points to @n0bl3 and @aestellar and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1510 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 233 | @n0bl3 | http://www.freecodecamp.com/n0bl3
:star: 173 | @aestellar | http://www.freecodecamp.com/aestellar
Vivek
@vivek28111992
Apr 04 2016 12:12 UTC
checkProp is just a parameter passed in function
Alex N.
@N0bl3
Apr 04 2016 12:14 UTC
myObj.checkProp is a named property (doesnt exist here in your object) so it isnot dynamic like x = 2;
myObj[checkProp] is dynamic like x = Math.random(); if you want a comparison*
Coryphaeus
@cvdeby
Apr 04 2016 12:14 UTC
@laed37 How will you get property which name is "gift gift"? Only with bracket notation.
Vivek
@vivek28111992
Apr 04 2016 12:14 UTC
@Blauelf we cannot get the value of key using dot notation, right?We must use bracket notation.Then what can we access using both dot and bracket notation?
Blauelf
@Blauelf
Apr 04 2016 12:14 UTC
@laed37 You can use dot notation only if it is a predefined name, and the name follows some rules that also apply to regular variables (starts with letter, $ or _, might also contain numbers in other positions, but for example no spaces). Then, someObj.someProp is equivalent to someObj["someProp"], but very different from someObj[someProp]
Alex N.
@N0bl3
Apr 04 2016 12:15 UTC
@laed37 so you can call with any prop in brackets burt not in dot see my answer just upsid this one :)
Blauelf sais it all :)
E YG
@laed37
Apr 04 2016 12:19 UTC
I understand now, thank you very much all~
Bharat
@BharatKalluri
Apr 04 2016 12:27 UTC
Hello Folks! Just a small clarification needed.. what does "'tracks' should not be set" Mean?? btw tracks is a property of json object..
does it mean it should be set to undefined?
Ronnie
@ronniemcg
Apr 04 2016 12:28 UTC
thanks @leftynaut for your help with Checkpoint: Counting Cards
CamperBot
@camperbot
Apr 04 2016 12:28 UTC
ronniemcg sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 467 | @leftynaut | http://www.freecodecamp.com/leftynaut
Blauelf
@Blauelf
Apr 04 2016 12:29 UTC
@Bharat-Kalluri Post your code, please (the relevant parts). I can only guess what that test case description means.
Bharat
@BharatKalluri
Apr 04 2016 12:29 UTC
'''
'''
CamperBot
@camperbot
Apr 04 2016 12:29 UTC
:bulb: to format code use backticks! ``` more info
Wint3rNuk3
@Wint3rNuk3
Apr 04 2016 12:29 UTC
Hi there, I need some help please, I have a jquery .click() inside document.ready() that does work on "hard written" html but not on dynamic function generated elements... how is that ?
Bharat
@BharatKalluri
Apr 04 2016 12:29 UTC
Blauelf
@Blauelf
Apr 04 2016 12:30 UTC
No pastebin for me.
Bharat
@BharatKalluri
Apr 04 2016 12:30 UTC
@Blauelf there is the link, I do not know how to format code..
Blauelf
@Blauelf
Apr 04 2016 12:30 UTC
@Wint3rNuk3 click() or do you use it as a shortcut for on("click",...)?
No pastebin for me, so I cannot access that code.
ALMY91
@ALMY91
Apr 04 2016 12:31 UTC
hey guys !
Blauelf
@Blauelf
Apr 04 2016 12:31 UTC
@Bharat-Kalluri Have you tried following @camperbot 's link?
Wint3rNuk3
@Wint3rNuk3
Apr 04 2016 12:32 UTC
$(".clickable-row").click(function() {
    window.open($(this).data("href"));
    //alert($(this).data("href"));
  });
ALMY91
@ALMY91
Apr 04 2016 12:32 UTC
im on the Gold Code challenge on front-end development javascript
Golf*
Blauelf
@Blauelf
Apr 04 2016 12:32 UTC
@Wint3rNuk3 This attaches the function to all elements of that class. But at the time you run that line. Elements added later won't get the listener.
ALMY91
@ALMY91
Apr 04 2016 12:32 UTC
wondering what does par means in layman terms?
Bharat
@BharatKalluri
Apr 04 2016 12:33 UTC

'''js
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}

return collection;
}

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

'''

CamperBot
@camperbot
Apr 04 2016 12:33 UTC
:bulb: to format code use backticks! ``` more info
Bharat
@BharatKalluri
Apr 04 2016 12:33 UTC
ok... got it wrong again :-( That is a chunk of the code @Blauelf
Blauelf
@Blauelf
Apr 04 2016 12:34 UTC
@Bharat-Kalluri You should delete a property if value is empty string. And try to find the backticks on your keyboard...
Wint3rNuk3
@Wint3rNuk3
Apr 04 2016 12:34 UTC
@Blauelf ok so what you are saying is that it's likely that it tries to attach the function BEFORE elements actually are created ?
Bharat
@BharatKalluri
Apr 04 2016 12:36 UTC
worked flawlessly @Blauelf , Thanks :-)
CamperBot