These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Aug 2016
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:00
@xiaji1
'a = 1' -> make 'a' equal to '1'
'a === 1' -> is 'a' equal to '1'?
encount
@encount
Aug 17 2016 00:01
@xiaji1 i cant see it in your code - but im guessing if computer === rock && player === scissors { computer wins }
c0d0er
@c0d0er
Aug 17 2016 00:01
a=1 ==> a is assigned a value as 1. a===1 means what? i am not very sure if a is variable
a=1 ==> a is assigned a value as 1. a===1 means what? i am not very sure if a is variable @stonefmagiecurata @encount
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:02
@xiaji1 it's a comparison, so you can make a logic out of that
@xiaji1 can you tell me what does this bit do? if(computerChoice<0.33){computerChoice ="rock";}
c0d0er
@c0d0er
Aug 17 2016 00:05
@stonefmagiecurata the instruction: If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
@stonefmagiecurata my original quote is: if(computerChoice<0.33){computerChoice ==="rock";}
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:06
@xiaji1 the one I wrote is the correct one, can you translate that code to me pls, do you know what it does?
@xiaji1 this part especially: 'if(computerChoice<0.33)'
encount
@encount
Aug 17 2016 00:08
@xiaji1 when random number is selected - depending on its value you need to assign (=) it eith rock paper scissors ( not compare it (===)
c0d0er
@c0d0er
Aug 17 2016 00:08
var computerChoice=Math.random(); if(computerChoice<0.33)means Math.random()<0.33, it means also that computerChoice is assigned the value "<0.33" @stonefmagiecurata
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:09
@xiaji1 I'll explain it in PM
encount
@encount
Aug 17 2016 00:11
@xiaji1 computerchoice is originally assigned a random number - depending on that number you then assign it a value (thus overriding the random number)
c0d0er
@c0d0er
Aug 17 2016 00:22
@encount here computerChoice<0.66, in this code, the computerchoice is COMPARING with 0.66, not assign the value, correct?
sfmajors373
@sfmajors373
Aug 17 2016 00:22
Hi! I am working though Basic JS and am on "Accessing Objects Properties with Variables" but I'm not sure what I am supposed to do with it. Can anyone give me some advice?
encount
@encount
Aug 17 2016 00:23
@xiaji1 its asking if compchoice is less than 0.66
Norvin Burrus
@ndburrus
Aug 17 2016 00:24
@sralls how are we doing?
biodundj
@biodundj
Aug 17 2016 00:25
Hello
I need help
Norvin Burrus
@ndburrus
Aug 17 2016 00:26
@sfmajors373 ok, we need to meet this requirement: Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
hudsontaylor
@hudsontaylor
Aug 17 2016 00:26
I am having trouble with the Caesar's Cipher algorithm. When I run the following code, I get, " arr.pop is not a function." But, I know it is a function. Please help!
function rot13(str) { // LBH QVQ VG!
  var decode = "";
  for (var i = 0; i <= str.length; i++) {
    decode += str.charCodeAt(i) + " ";
  }
  var arr = decode.split(" ");
  for (var x = 0; x < 14; x++) {
    arr += parseInt(arr[x]);
  }
  arr.pop();
  arr.pop();
  return arr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
c0d0er
@c0d0er
Aug 17 2016 00:26
@stonefmagiecurata thanks!!!
CamperBot
@camperbot
Aug 17 2016 00:26
xiaji1 sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
c0d0er
@c0d0er
Aug 17 2016 00:26
@encount thanks! i got it!
CamperBot
@camperbot
Aug 17 2016 00:26
xiaji1 sends brownie points to @encount :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @encount |http://www.freecodecamp.com/encount
biodundj
@biodundj
Aug 17 2016 00:27
Am on the freeCode Camp challenge code of Javascript.
ANyone here that could help
Hello!!!
hudsontaylor
@hudsontaylor
Aug 17 2016 00:28
Yes, I can!
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:28
@hudsontaylor arr += parseInt(arr[x]);
sfmajors373
@sfmajors373
Aug 17 2016 00:29
@ndburrus Yes, but I don't know that I understand how to do that. I see the examples, but I am not sure how to apply it.
hudsontaylor
@hudsontaylor
Aug 17 2016 00:29
@stonefmagiecurata That's what I did?
Margaret
@Margaret2
Aug 17 2016 00:30
@biodundj what is the name of the challenge?
ahmed abouhay
@abohay
Aug 17 2016 00:30
function mutation(arr) {
  var arrj = arr.join("").toLowercase().split(" ");
  arrj[0].split("");
  arrj[1].split("");
  for(var i = 0 ; i < arrj[0].length ; i++ ){
      if (arrj[0][i].indexof(arrj[1]) > 0 ){
        return true;
      }
  }
      return false;
}

mutation(["hello", "hey"]);
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:30
@hudsontaylor yes, you tried to add to it, so it turned it into a string
encount
@encount
Aug 17 2016 00:30
@hudsontaylor you changed arr to a string - arr.pop works on arrays only
what @stonefmagiecurata said :)
hudsontaylor
@hudsontaylor
Aug 17 2016 00:31
Oh! What should I replace this with?
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:32
@hudsontaylor what other methods does an array have, other than pop()?
Margaret
@Margaret2
Aug 17 2016 00:33
@stonefmagiecurata Array reference > http://www.w3schools.com/jsref/jsref_obj_array.asp
hudsontaylor
@hudsontaylor
Aug 17 2016 00:33
Wait. I got it. It was just
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:33
@Margaret2 :D
hudsontaylor
@hudsontaylor
Aug 17 2016 00:34
arr[x] = parseInt(arr[x]);
Thanks guys!
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:35
@hudsontaylor :+1:
Jacob Stewart
@JacobStewart1
Aug 17 2016 00:40
can someone help me on the wikipedia viewer project Im trying to get my results be links and i cant figure it out
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:43
@JacobStewart1 do you have a pen, or code to paste?
ahmed abouhay
@abohay
Aug 17 2016 00:44
function mutation(arr) {
  var arrj = arr.join("").toLowerCase().split("");
  arrj[0].split("");
  arrj[1].split("");
  for(var i = 0 ; i < arrj[0].length ; i++ ){
      if (arrj[1].indexOf(arrj[0][i]) > 0 ){
        return true;
      }
  }
      return false;
}

mutation(["hello", "hey"]);
@stonefmagiecurata
stonefmagiecurata
@stonefmagiecurata
Aug 17 2016 00:46
@JacobStewart1 I'll take a look
Jacob Stewart
@JacobStewart1
Aug 17 2016 00:46
ok thanks @stonefmagiecurata
CamperBot
@camperbot
Aug 17 2016 00:46
jacobstewart1 sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
Joseph
@revisualize
Aug 17 2016 00:47
THERE!
Hello! I'm on the :bus:
Tyler Roberts
@teachtyler
Aug 17 2016 00:47
@revisualize short bus? ;)
Joseph
@revisualize
Aug 17 2016 00:48
:|
Tyler Roberts
@teachtyler
Aug 17 2016 00:48
tehe
Will
@williamnoon
Aug 17 2016 00:49
HI, I'm stuck on the "Wherefore art thou" challenge can someone help?
Joseph
@revisualize
Aug 17 2016 00:50
Wow.. My internet via my phone SUCKS!
@williamnoon I'm on that same challenge. Of course. I've been there for like 2 months now because I haven't really worked on it. But, that's besides the point.
@will I do know that you need to use Object.keys() to create an array of they keys in the object.
Will
@williamnoon
Aug 17 2016 00:51
Yea I've been stuck on it for the las two days myself
Joseph
@revisualize
Aug 17 2016 00:51
I should actually just do it.
Let's see here.
Okay. Here I am.. In the challenge. Finally.
Will
@williamnoon
Aug 17 2016 00:53
My function passes the first three test but fails the fourth

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var props = Object.keys(source);
var numberOfObjects = collection.length;
var j = 0;
var match=0;

while(j < numberOfObjects){
for (i=0; i<props.length; i++){
if(collection[j][props[i]] == source[props[i]]){
match++;
if(match === props.length){
arr.push(collection[j]);
match = 0;
}
}
}j++;
}

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

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

Joseph
@revisualize
Aug 17 2016 00:54

So...
Make a function that looks through an array of objects (first argument)
and returns an array of all objects that have matching property
and value pairs (second argument).

Each property and value pair of the source object has to be present in the object
from the collection if it is to be included in the returned array.

So we have:
[ { ... } , { ... } , { ... } , { ... } ]
Will
@williamnoon
Aug 17 2016 00:54
guess thats not how i'm suppose to paste code here!?
Joseph
@revisualize
Aug 17 2016 00:54
Each object has two keys?
hmm.
help format
CamperBot
@camperbot
Aug 17 2016 00:54

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Joseph
@revisualize
Aug 17 2016 00:55
Filter?
Are we supposed to filter out the non-source items?
hmm
Will
@williamnoon
Aug 17 2016 00:56
I'm using both a while and for loop
I started out with filter but couldn't iterate through both source and collection array items
Joseph
@revisualize
Aug 17 2016 00:57
Hmmm.
Moisés Man
@moigithub
Aug 17 2016 00:58
u need to reset ur match for each collection object
Joseph
@revisualize
Aug 17 2016 00:58
what is match?
Will
@williamnoon
Aug 17 2016 00:58
I thought i was doing that line 17
Joseph
@revisualize
Aug 17 2016 00:58
Oh, you have some match variable. I didn't look at your code.
Moisés Man
@moigithub
Aug 17 2016 00:58
:)
Will
@williamnoon
Aug 17 2016 00:59
@revisualize please do :)
Moisés Man
@moigithub
Aug 17 2016 00:59
right.. hard to see (line 17).. would be great if u can post formatted.. add some backticks
Will
@williamnoon
Aug 17 2016 00:59
@moigithub will do

```function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var props = Object.keys(source);
var numberOfObjects = collection.length;
var j = 0;
var match=0;

while(j < numberOfObjects){
for (i=0; i<props.length; i++){
if(collection[j][props[i]] == source[props[i]]){
match++;
if(match === props.length){
arr.push(collection[j]);
match = 0;
}
}
}j++;
}

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

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

mzedlach
@mzedlach
Aug 17 2016 01:00
Hello eveyone :)
Moisés Man
@moigithub
Aug 17 2016 01:00
bacticks must be on its OWN line.. shift enter to add new lines if needed
u can edit ur post
also backticks at the end
hola @mzedlach
mzedlach
@mzedlach
Aug 17 2016 01:01
@revisualize I did get it! The message was burried amongst a bunch of cookies, hahah
Joseph
@revisualize
Aug 17 2016 01:01
@mzedlach Hello.
Awesome.
mzedlach
@mzedlach
Aug 17 2016 01:01
@revisualize You're still here! :)
Joseph
@revisualize
Aug 17 2016 01:01
I am.
mzedlach
@mzedlach
Aug 17 2016 01:01
I am stuck again!
lol
Joseph
@revisualize
Aug 17 2016 01:01
Oh
What now?
:P
Record Collection? Or Profile Lookup?
mzedlach
@mzedlach
Aug 17 2016 01:02
How do you get different emojis?
Moisés Man
@moigithub
Aug 17 2016 01:02
emoji-cheat-sheet.com
Will
@williamnoon
Aug 17 2016 01:02
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var props = Object.keys(source);
  var numberOfObjects = collection.length;
  var j = 0;
  var match=0;

  while(j < numberOfObjects){
  for (i=0; i<props.length; i++){
  if(collection[j][props[i]] == source[props[i]]){
  match++;
    if(match === props.length){
      arr.push(collection[j]);
      match = 0;
     }
    }
   }j++;
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
mzedlach
@mzedlach
Aug 17 2016 01:02
Neat!
I'm not that far along... Had to go dog walk and clean up :)
Will
@williamnoon
Aug 17 2016 01:03
@moigithub how do I send brownie points ;)
Joseph
@revisualize
Aug 17 2016 01:03
help brownie
CamperBot
@camperbot
Aug 17 2016 01:03

:point_right: brownie points [wiki]

Brownie Points

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are two ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.

:pencil: read more about brownie points on the FCC Wiki

Joseph
@revisualize
Aug 17 2016 01:03
@mzedlach How can we help?
Moisés Man
@moigithub
Aug 17 2016 01:04
u write thanks @someName @williamnoon
CamperBot
@camperbot
Aug 17 2016 01:04
moigithub sends brownie points to @somename and @williamnoon :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @williamnoon |http://www.freecodecamp.com/williamnoon
:warning: could not find receiver for somename
mzedlach
@mzedlach
Aug 17 2016 01:04
"Accessing Nested Objects"
Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name.

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

// Only change code below this line

var gloveBoxContents = myStorage.car.inside.["glove box"]; // Change this line
I know it's my syntax
But I don't know what...
Joseph
@revisualize
Aug 17 2016 01:04
@mzedlach Great!
@mzedlach Let me get you some code.
Uno momento.
This bus is bouncing.
mzedlach
@mzedlach
Aug 17 2016 01:05
LOL! Bus?! As in, public transit?
Joseph
@revisualize
Aug 17 2016 01:05
@mzedlach
var arr = [["a1"], ["b2","c2"], ["d3","e3","f3"], ["g4","h4","i4","k4"]];
// Do you understand that this is an array of arrays?
Yes. Public Transit.
mzedlach
@mzedlach
Aug 17 2016 01:05
Yes :) That array makes sense :)
Joseph
@revisualize
Aug 17 2016 01:05
Great.
@mzedlach Do you understand that your object is a bunch of objects?
Moisés Man
@moigithub
Aug 17 2016 01:06
@williamnoon move the inner if outside the for loop
if(match === props.length){
      arr.push(collection[j]);
      match = 0;
     }
mzedlach
@mzedlach
Aug 17 2016 01:06
Right, it's sort of like a list within a list.
Joseph
@revisualize
Aug 17 2016 01:06
OH! :busstop:
Yes.
So, you just call the object from the parent object.
mzedlach
@mzedlach
Aug 17 2016 01:07
@revisualize Hmmm, you lost me there.
@mzedlach Am I not doing that by going through the pathway?
@revisualize var gloveBoxContents = myStorage.car.inside.["glove box"];
Kareem A. Henry
@NiteOwler
Aug 17 2016 01:07
Hello World!
CamperBot
@camperbot
Aug 17 2016 01:07

welcome to FreeCodeCamp @NiteOwler!

mzedlach
@mzedlach
Aug 17 2016 01:07
Hello @NiteOwler !!!
Margaret
@Margaret2
Aug 17 2016 01:08
@NiteOwler nice username!
Kareem A. Henry
@NiteOwler
Aug 17 2016 01:08
Just join
hudsontaylor
@hudsontaylor
Aug 17 2016 01:08
I am trying to update the "data-text" attribute for a tweet button. It is not working , though... Here is my code:
Kareem A. Henry
@NiteOwler
Aug 17 2016 01:08
Yeap no sleep!
Joseph
@revisualize
Aug 17 2016 01:08
@mzedlach i will be home in 3min. One second.
Kareem A. Henry
@NiteOwler
Aug 17 2016 01:08
@Margaret2 Thanks
CamperBot
@camperbot
Aug 17 2016 01:08
niteowler sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @margaret2 |http://www.freecodecamp.com/margaret2
Joseph
@revisualize
Aug 17 2016 01:08
But, that is the idea.
mzedlach
@mzedlach
Aug 17 2016 01:09
@revisualize Run! Run home! :stuck_out_tongue:
Joseph
@revisualize
Aug 17 2016 01:09
Actually, thay should be correct.?
Will
@williamnoon
Aug 17 2016 01:09
@moigithub tried that now only two test pass
ahmed abouhay
@abohay
Aug 17 2016 01:10
@revisualize @mzedlach
function mutation(arr) {
  var arrj = arr.join("").toLowerCase().split("");
  arrj[0].split("");
  arrj[1].split("");
  for(var i = 0 ; i < arrj[0].length ; i++ ){
      if (arrj[1].indexOf(arrj[0][i]) > 0 ){
        return true;
      }
  }
      return false;
}

mutation(["hello", "hey"]);
mzedlach
@mzedlach
Aug 17 2016 01:10
@revisualize var gloveBoxContents = myStorage.car.inside.["glove box"];
I feel like a bracket or semi colon is not right.
@abohay Question?
Joseph
@revisualize
Aug 17 2016 01:10
OH! The dot!
hudsontaylor
@hudsontaylor
Aug 17 2016 01:10

I am trying to update the "data-text" attribute for a tweet button. It is not working , though... Here is my code:

<a href="https://twitter.com/share" class="twitter-share-button" data-text="" data-hashtags="quotes" data-show-count="false">Tweet</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

$(".twitter-share-button").attr("data-text", "You");

Note that I am using codepen.io. Thanks!

Joseph
@revisualize
Aug 17 2016 01:10
You have a dot before the [
mzedlach
@mzedlach
Aug 17 2016 01:10
@revisualize OH JEEZE!!! THE ONE AFTER INSIDE?!
Joseph
@revisualize
Aug 17 2016 01:11
Yes.
mzedlach
@mzedlach
Aug 17 2016 01:11
@revisualize :sob:
Will
@williamnoon
Aug 17 2016 01:11
welcome @NiteOwler
mzedlach
@mzedlach
Aug 17 2016 01:11
@revisualize Thank you!
CamperBot
@camperbot
Aug 17 2016 01:11
mzedlach sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1654 | @revisualize |http://www.freecodecamp.com/revisualize
zidna110
@zidna110
Aug 17 2016 01:11
hi
Joseph
@revisualize
Aug 17 2016 01:12
From my phone even.
Moisés Man
@moigithub
Aug 17 2016 01:12
@williamnoon which test fail ?
Will
@williamnoon
Aug 17 2016 01:12
@revisualize good catch lol I totally didn't see that
@moigithub third and fourth
mzedlach
@mzedlach
Aug 17 2016 01:13
It feels a little less satisfying when you get that pop-up of passing all tests after sitting on a problem that has that kind of resolution. Haha ^^
Moisés Man
@moigithub
Aug 17 2016 01:14
@williamnoon can u post plz ?
Will
@williamnoon
Aug 17 2016 01:15
my code ??? @moigithub
Joseph
@revisualize
Aug 17 2016 01:15
@mzedlach At least you learned.
:)
Now. Can you come clean my place so I don't end up on "Hoarders: Before They Were Stars"?
mzedlach
@mzedlach
Aug 17 2016 01:16
@revisualize Hahahah!
I have to "schedule" time during the day to actually clean my place.... otherwise I live amongst piles.
Moisés Man
@moigithub
Aug 17 2016 01:16
@williamnoon the test
like
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
mzedlach
@mzedlach
Aug 17 2016 01:16
Is there an app to this thing? How were you doing this on your phone?
@revisualize
Hans Aranzalez
@haranzalez
Aug 17 2016 01:17
Need help with the record collection exercise in the javascript section!!!
Please!!
Joseph
@revisualize
Aug 17 2016 01:17
@mzedlach There is a Gitter.im phone client.
Brandon
@Brandons42
Aug 17 2016 01:17
I do it on my phone sometimes just using the website.
Joseph
@revisualize
Aug 17 2016 01:18
@haranzalez What is your current function? Note: We do NOT want to see the object. Just the function.
Hans Aranzalez
@haranzalez
Aug 17 2016 01:18
If value is empty (""), delete the given prop property from the album.
Joseph
@revisualize
Aug 17 2016 01:18
@haranzalez How do you delete a property?
var myObj = {
   delete_me: "Delete This"
}
Will
@williamnoon
Aug 17 2016 01:19
Oh ok one sec @moigithub
Hans Aranzalez
@haranzalez
Aug 17 2016 01:19
im creating a conditional statement to check if value is empty and then I delete collection[id][prop];
Joseph
@revisualize
Aug 17 2016 01:19
@haranzalez GREAT!
Hans Aranzalez
@haranzalez
Aug 17 2016 01:19
but it doestn work
for some reason is not taking it
Joseph
@revisualize
Aug 17 2016 01:19
@haranzalez Talk is cheap. Show me the code. Torvalds, Linus (2000-08-25).
Will
@williamnoon
Aug 17 2016 01:19
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 }) should return [{ "a": 1, "b": 2 }, { "a": 1, "b": 2, "c": 2 }].
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 }) should return [{ "a": 1, "b": 2, "c": 2 }].
Hans Aranzalez
@haranzalez
Aug 17 2016 01:20
how do I share the code?
sorry Im new here
Joseph
@revisualize
Aug 17 2016 01:20
help format
CamperBot
@camperbot
Aug 17 2016 01:20

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

mzedlach
@mzedlach
Aug 17 2016 01:20
Does FCC by any chance have a book that is based on the lessons? I mean, right now I'm just copy and pasting everything into a word doc, which I plan to print out, and then have as reference & write my own notes in. But I have this weird gut feeling that this must have been done before...
Joseph
@revisualize
Aug 17 2016 01:20
@haranzalez We don't need the object. We just need the function.
Tyler Roberts
@teachtyler
Aug 17 2016 01:20
@haranzalez @revisualize what about checking myObj[0].length and if it's 0 you shift() it
Joseph
@revisualize
Aug 17 2016 01:20
@teachtyler No.
@teachtyler I have no idea what you're doing. I'm just going to say.. No.
Tyler Roberts
@teachtyler
Aug 17 2016 01:21
:(
Brandon
@Brandons42
Aug 17 2016 01:21
Use the hasOwnProperty method.
Tyler Roberts
@teachtyler
Aug 17 2016 01:22
i guess i misunderstood the deleteThis question
Joseph
@revisualize
Aug 17 2016 01:22
@mzedlach There isn't a book. What are you putting in your "book"?
mzedlach
@mzedlach
Aug 17 2016 01:23
@revisualize Pretty much the explanations to each lesson... and, if I have trouble with it, sometimes the sample exercise.
Brandon
@Brandons42
Aug 17 2016 01:23
@revisualize How am I supposed to change binary into English? challenge: Binary Agents
Hans Aranzalez
@haranzalez
Aug 17 2016 01:23
function updateRecords(id, prop, value) {
  if(value === "")
    {
      collection[id][prop] = "";
    }
  else if(prop == "tracks" && value !== null && collection[id].hasOwnProperty("tracks") === false)
    {
      collection[id][prop] = [];
      collection[id][prop].push(value);

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

  return collection;

}
Joseph
@revisualize
Aug 17 2016 01:23

@teachtyler Are you talking about this question that I asked @haranzalez ?
How do you delete a property?

var myObj = {
   delete_me: "Delete This"
}

delete myObj["delete_me"];

Hans Aranzalez
@haranzalez
Aug 17 2016 01:24
I just sent my code
Joseph
@revisualize
Aug 17 2016 01:24
@haranzalez You're not even doing what you said.

@haranzalez

im creating a conditional statement to check if value is empty and then I delete collection[id][prop];

Hans Aranzalez
@haranzalez
Aug 17 2016 01:24
sorry I was trying it like that too
but it didnt work
I did that too
it doesnt work
Joseph
@revisualize
Aug 17 2016 01:25
You're telling me that:
delete collection[id][prop];
Doesn't work?
Hans Aranzalez
@haranzalez
Aug 17 2016 01:25
yea
Brandon
@Brandons42
Aug 17 2016 01:25
Also, @haranzalez turn "track" into "tracks" in your last else if.
Joseph
@revisualize
Aug 17 2016 01:25
:cow::shit:
@haranzalez I call :cow2: :shit:
Jacob Stewart
@JacobStewart1
Aug 17 2016 01:26
can someone help me get my wikipedia viewer results have links
Joseph
@revisualize
Aug 17 2016 01:27
@haranzalez In fact! I can prove it.
Tyler Roberts
@teachtyler
Aug 17 2016 01:27
@JacobStewart1 what do you mean by have links. Search function?
Jacob Stewart
@JacobStewart1
Aug 17 2016 01:27
@teachtyler like where you can click them to go to te wikipedia page
Joseph
@revisualize
Aug 17 2016 01:27
@haranzalez I just took your code. Changed that one line and solved the challenge.
blob
Tyler Roberts
@teachtyler
Aug 17 2016 01:29
@JacobStewart1 so you want to search an article and it show a link before taking you to the page?
same with random article i'm assuming
Joseph
@revisualize
Aug 17 2016 01:29
@haranzalez Also, @Brandons42 is correct. You do need to fix: else if(prop !== "track")
Jacob Stewart
@JacobStewart1
Aug 17 2016 01:30
well whe you type in what you want to search it results under the search box and i want those words to be links to there wikipedia pages @teachtyler
Joseph
@revisualize
Aug 17 2016 01:30
@mzedlach I kind of do that with comments in my code.
mzedlach
@mzedlach
Aug 17 2016 01:31
"Record Collection" Please tell me if I'm interpreting this correctly.... The task is to: alter the current data with the input data OR add the data if it is not there. Is that correct?
llamatarianism
@llamatarianism
Aug 17 2016 01:31
@mzedlach yes
or delete the data if value is blank
mzedlach
@mzedlach
Aug 17 2016 01:32
Okay! cool :) Thank you!
Tyler Roberts
@teachtyler
Aug 17 2016 01:33
@JacobStewart1 since you're already using jquery, you would want to create a <div id="my-link"> </div> and then change the inner html with $('#my-link').html('<a href="http://www.google.com">Google</a>');
mzedlach
@mzedlach
Aug 17 2016 01:34
@revisualize These are the notes you were talking about?
Jacob Stewart
@JacobStewart1
Aug 17 2016 01:34
ok thanks @teachtyler
CamperBot
@camperbot
Aug 17 2016 01:34
jacobstewart1 sends brownie points to @teachtyler :sparkles: :thumbsup: :sparkles:
:cookie: 34 | @teachtyler |http://www.freecodecamp.com/teachtyler
Tyler Roberts
@teachtyler
Aug 17 2016 01:34
@JacobStewart1 instead of hard coding google you'd put the results in there as variables
Joseph
@revisualize
Aug 17 2016 01:34
@mzedlach Not really, Those are just the instructions of that lesson. In comment form.
@mzedlach But, kind of. I do have some lessons where I did kind of do that.
Kent Saeteurn
@sansae
Aug 17 2016 01:36
Hi all, I'm working on the "Wherefore Art Thou" challenge here: https://www.freecodecamp.com/challenges/wherefore-art-thou; I'm currently stuck and am having trouble figuring out how to test for multiple key:value pairs in the source argument. At the moment, I have the code working for source args that have only one key-value pair. Can anyone give me a hint as to the next step I can take? It took me two weeks to figure out how to test for the first two cases. My brain is fried. Here is my fiddle: https://jsfiddle.net/r53mrxga/; please excuse all my notes
sentedelviento
@sentedelviento
Aug 17 2016 01:37
Hey, for other people who have viewed the example Pomodoro Clock, does an alarm go off? 'cause the specs make it seem like that should happen but I don't hear any sound
mzedlach
@mzedlach
Aug 17 2016 01:37
Oh man... I really don't feel like doing this... hahahha. I did too much python today and switching syntax is just, well, I feel like it made me hit the wall much faster
c0d0er
@c0d0er
Aug 17 2016 01:43
var userChoice = prompt("Do you choose rock, paper, scissors or rope?");

var computerChoice = Math.random();
if (computerChoice < 0.26) {
    computerChoice = "rock";
} else if(computerChoice < 0.51) {
    computerChoice = "paper";
} else if(computerChoice<0.76){
    computerChoice = "scissors";
} else{computerChoice="rope"}

console.log("Computer: " + computerChoice);

var compare= function(choice1, choice2){
    if(choice1===choice2){return "The result is a tie!"}

    else if(choice1 === "rock"){if(choice2 === "scissors"){return "rock wins";}else if(choice2 === "paper"){return "paper wins";}
       else{return "rope wins";}}

    else if(choice1 === "paper"){if(choice2 === "rock"){return "paper wins";}else if(choice2==="scissors"){return "scissors wins"}
       else{return "rope wins";}}

    else if(choice1 === "scissors"){if(choice2 === "rock"){return "rock wins";}else if(choice2==="paper"){return "scissors wins";}
       else{return "scissors wins";}}

    else if(choice1==="rope"){if(choice2 === "rock"){return "rope wins";}else if(choice2==="paper"){return "rope wins";}
       else{return "scissors wins";}}

   else if(choice1!=="rock"||"paper"||"scissors"||"rope"){return "Please choose one option from the following options: rock, paper, scissors or rope"}
    };
    compare(userChoice, computerChoice)

    //if both players make the same choice, the game returns a tie. What if the game didn't end there but instead asked both players for new choices?

    if(compare(userChoice, computerChoice)==="The result is a tie!"){compare(userChoice, computerChoice)}
this is my code, the last challenge is : if both players make the same choice, the game returns a tie. What if the game didn't end there but instead asked both players for new choices? but my code cannot pass this challenge, can anybody help me to figure out?
Angel J Piscola
@Redmega
Aug 17 2016 01:44
Mate, you need to rethink your logic. Too many nested if statements, thats a nightmare for my brain to parse
Simple answer without looking at your code is as long as the result is a tie throw it in a loop
That was directed at @xiaji1
@sansae You loop through the collection but you don't loop through the properties of each object. So you only check the first property of each.
c0d0er
@c0d0er
Aug 17 2016 01:47
if(compare(userChoice, computerChoice)==="The result is a tie!"){compare(userChoice, computerChoice)} this code cannot pass the challenge "if both players make the same choice, the game returns a tie. What if the game didn't end there but instead asked both players for new choices?" all the other works fine @Redmega
revisualize @revisualize is afk. Youtube.
Will
@williamnoon
Aug 17 2016 01:48
@sansae I'm working on the same challenge and I'm stuck myself
Angel J Piscola
@Redmega
Aug 17 2016 01:48
@xiaji1 Let me ask you something, the prompt says to get new choices, right? Does your compare() ask them for new choices, or only evaluate the choices theyve already given? ;)
And yes, it works, but man is it ugly, and if you come back and look at this in a month (or even a week) chances are you'll get lost. Code maintainability and readability are important to incorporate into your programming, especially if you plan on using your coding skills in the workplace where you'll have many people looking at and coding on the same project.
Justin Woodward
@jwoo92
Aug 17 2016 01:49

Hey - Is anyone in here currently working on the ticTacToe project that would like to 'pair program' over gitter chat with me in regards to the MiniMax algorithm?

Let me know by commenting back to me on here or privately. Thanks!

c0d0er
@c0d0er
Aug 17 2016 01:51
@Redmega :smile: in this code, could you show me how to make better, this is what i can think the best solution
Moisés Man
@moigithub
Aug 17 2016 01:51
@williamnoon did u moved the inner if outside the loop?
Angel J Piscola
@Redmega
Aug 17 2016 01:52
@xiaji1 Not going to write your program for you, bud. Your issue is you're only re-evaluating their choices if its a tie, you're not asking them for new choices. That should get you in the right direction. If not then maybe someone else can weight in.
Will
@williamnoon
Aug 17 2016 01:52
@moigithub I did that didn't work
Moisés Man
@moigithub
Aug 17 2016 01:53
u also need t move the match reset outside that if
else it only will reset when match = prop length
@williamnoon
jinjuujii
@jinjuujii
Aug 17 2016 01:53
"firstline \n secondline" string doesn't yield 2 lines? can anybody give me a clue? i tried looking at w3schools and from whative been reading.. it should work
Angel J Piscola
@Redmega
Aug 17 2016 01:54
@jinjuujii Whats the context? It will create two lines in the console but not in html
Will
@williamnoon
Aug 17 2016 01:55
ahhhhh got it @moigithub
Moisés Man
@moigithub
Aug 17 2016 01:55
post ur code exactly how u did.. add backticks to proper format on this chat... like this >> `code`
@jinjuujii
:+1: @williamnoon
Will
@williamnoon
Aug 17 2016 01:55
@moigithub :+1:
c0d0er
@c0d0er
Aug 17 2016 01:55
@Redmega i am not asking about the solution of asking for new choices, but asking you how could make my is else statement code looks better
Will
@williamnoon
Aug 17 2016 01:56
how do I give brownie points
Moisés Man
@moigithub
Aug 17 2016 01:56
thanks @williamnoon
CamperBot
@camperbot
Aug 17 2016 01:56
moigithub sends brownie points to @williamnoon :sparkles: :thumbsup: :sparkles:
:warning: moigithub already gave williamnoon points
jinjuujii
@jinjuujii
Aug 17 2016 01:56
i'm doing exercise 137 on FCC
Moisés Man
@moigithub
Aug 17 2016 01:56
like that :)
jinjuujii
@jinjuujii
Aug 17 2016 01:56
var myStr = "FirstLine \n \Secondline\ \r ThirdLine"; // Change this line
is my code
Will
@williamnoon
Aug 17 2016 01:57
:+1: @moigithub
Moisés Man
@moigithub
Aug 17 2016 01:57
@jinjuujii remove extra spaces
also Line with uppercase L.. on Second
Will
@williamnoon
Aug 17 2016 01:58
@moigithub thanks a lot more importantly than it working i get why it wasn't working so appreciate you
CamperBot
@camperbot
Aug 17 2016 01:58
williamnoon sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1918 | @moigithub |http://www.freecodecamp.com/moigithub
jinjuujii
@jinjuujii
Aug 17 2016 01:59
@moigithub thank you
CamperBot
@camperbot
Aug 17 2016 01:59
jinjuujii sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1919 | @moigithub |http://www.freecodecamp.com/moigithub
Josh A
@ai3gtmc
Aug 17 2016 01:59
Hello
Moisés Man
@moigithub
Aug 17 2016 01:59
Hola @ai3gtmc
Josh A
@ai3gtmc
Aug 17 2016 02:00
I'm running into a bif of trouble with the Record Collection
this part "After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element." confuses me
Raymundo Manuel Alvarez
@Raymundo-Alvarez
Aug 17 2016 02:00

Can anyone help me on this exercise. It's on "Assignment with a returned value"

var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line

var processed = processArg (7);

That is my solution but for some reason I do not full fill the requirement of "You should assign processArg to "processed."

Moisés Man
@moigithub
Aug 17 2016 02:01
@ai3gtmc probably u resetting the array ?
u should create the array ONLY when tracks dont exist
if u post ur code.. easier to check....
Josh A
@ai3gtmc
Aug 17 2016 02:02

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

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



  return collection;
}
Moisés Man
@moigithub
Aug 17 2016 02:03
@Raymundo-Alvarez looks correct.. try removing the space before (7)
c0d0er
@c0d0er
Aug 17 2016 02:03
@Redmega thanks
CamperBot
@camperbot
Aug 17 2016 02:03
xiaji1 sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 58 | @redmega |http://www.freecodecamp.com/redmega
Raymundo Manuel Alvarez
@Raymundo-Alvarez
Aug 17 2016 02:04
@moigithub Hahaha! Yup. That was my issue. Thanx so much!
CamperBot
@camperbot
Aug 17 2016 02:04
raymundo-alvarez sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1920 | @moigithub |http://www.freecodecamp.com/moigithub
Angel J Piscola
@Redmega
Aug 17 2016 02:05
@xiaji1 Ah, my bad, I misunderstood
@xiaji1 You can do it a few ways. First I'd try and look at the different outcomes not as conditions to evaluate, but as data to compare. Then you can make an object which contains the winning combinations, and compare from there. Though from the looks of it that might be a bit complicated for your skill level
So I'd settle for you properly indenting your if statements ;)
mzedlach
@mzedlach
Aug 17 2016 02:06
Is there a way to test run your text without simply hitting the "Run Tests" button? I mean, so that you could see what you get as output in various stages of writing code?
Moisés Man
@moigithub
Aug 17 2016 02:07

@ai3gtmc tracks property is array type
so.. when prop is track.. u can do array operations like push
... when prop !="tracks" mean its NOT an array .. so u cant push

if (prop != "tracks" && value !== "") {
    collection[id][prop].push(value); <<--is wrong

when collection do not have tracks property... mean there are no array .. so u cant push... u need to create tracks as array

else if (prop == "tracks" && collection[id][prop] === undefined) {
   collection[id][prop].push([{}]);  /// this is wrong
    collection[id][prop].push([value]);   // no brackets need here

when prop is tracks.. u need to ADD value to it.. ( use push to add to the end of the array)

 } else if (prop == "tracks" && value !== "") {
    collection[id][prop] = [value];  // <-- u overwriting all previous values, not adding
Angel J Piscola
@Redmega
Aug 17 2016 02:07
@xiaji1 Something simple you can do is have compare return -1,0,or 1 to represent a loss, tie, or win. That way instead of returning all those strings and evaluating hte string you get out, you can just check for the value of a single nu,ber
c0d0er
@c0d0er
Aug 17 2016 02:08
@Redmega thanks, this is a easier way for me right now
CamperBot
@camperbot
Aug 17 2016 02:08
xiaji1 sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:warning: xiaji1 already gave redmega points
llamatarianism
@llamatarianism
Aug 17 2016 02:08
@mzedlach you could use some other website
like repl.it or jsfiddle
Angel J Piscola
@Redmega
Aug 17 2016 02:08
jsfiddle is one of my favorites
mzedlach
@mzedlach
Aug 17 2016 02:09
Thank you @llamatarianism
CamperBot
@camperbot
Aug 17 2016 02:09
mzedlach sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1209 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
mzedlach
@mzedlach
Aug 17 2016 02:10
@Redmega Why is it better than others?
Josh A
@ai3gtmc
Aug 17 2016 02:10
@moigithub I'll check that out. thank you.
CamperBot
@camperbot
Aug 17 2016 02:10
ai3gtmc sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Angel J Piscola
@Redmega
Aug 17 2016 02:10
@mzedlach Can't say tbh. Its similar to codepen and all. It just happens to be the first one that comes to my mind.
CamperBot
@camperbot
Aug 17 2016 02:10
:star2: 1921 | @moigithub |http://www.freecodecamp.com/moigithub
mzedlach
@mzedlach
Aug 17 2016 02:11
:+1:
Angel J Piscola
@Redmega
Aug 17 2016 02:11
Although repl.it looks good for pure javascript. jsfiddle is more if you need to interact with html/css
David Halls
@DavidHalls
Aug 17 2016 02:16
anyone working on no repeats please?
coffeebeanzz
@coffeebeanzz
Aug 17 2016 02:16
JSBin is good too. I use it for my JS practice
Thomas Mullen
@t-mullen
Aug 17 2016 02:17
How to iterate through all possible on/off permutations of an array?
I know I can iterate through binary numbers and use them to control the array, but is there a more elegant solution that doesn't touch strings?
Angel J Piscola
@Redmega
Aug 17 2016 02:18
all possible on/off permutations of an array? Mind giving context?
Thomas Mullen
@t-mullen
Aug 17 2016 02:22
I guess they're called binary permutations? I think I found an answer.
Josh A
@ai3gtmc
Aug 17 2016 02:23
@moigithub I got it! thanks!
CamperBot
@camperbot
Aug 17 2016 02:23
ai3gtmc sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: ai3gtmc already gave moigithub points
Angel J Piscola
@Redmega
Aug 17 2016 02:25
@RationalCoding Well there you go... Glad I could help... lmao xD
Thomas Mullen
@t-mullen
Aug 17 2016 02:27
Haha thanks :p
Justin Woodward
@jwoo92
Aug 17 2016 02:28

Hey - Is anyone in here currently working on the ticTacToe project that would like to 'pair program' over gitter chat with me in regards to the MiniMax algorithm?

Let me know by commenting back to me on here or privately. Thanks!

David Halls
@DavidHalls
Aug 17 2016 02:33
help no repeats please
CamperBot
@camperbot
Aug 17 2016 02:33

:point_right: algorithm no repeats please [wiki]

Algorithm No Repeats Please

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

:checkered_flag: Problem Explanation:

This task requires us to return the number of total permutations of the provided string that don't have repeated consecutive letters. It is to be assumed that all characters in the provided string are each unique. For example, aab should return 2 because it has 6 total permutations (aab, aab, aba, aba, baa, baa), but only 2 of them (aba and aba) don't have the same letter (in this case a) repeating.

To achieve that, we'll have to look at each possible permutation of a string. There are several ways to do that. A common interview question is building a function that collects all permutations of a string. There are several tutorials available on the internet on how to do that.

Potential Methods Used As Solution

Recursive Method

This task can be daunting even after watching a tutorial. To write a recursive solution, you will want to send each new use of the function three 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.
  3. An idea of what characters (more specifically positions) from the original string have yet to be used.

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

Angel J Piscola
@Redmega
Aug 17 2016 02:43
Maybe I need a fresh eye... I'm on the palindrome, this should solve it but its saying that palindrome("1 eye for of 1 eye.") should return false...
Scratch that, misread the requirements!
Stephen James
@sjames1958gm
Aug 17 2016 02:43
@Redmega If you only removed the spaces and left the numbers and letters that should return false
Angel J Piscola
@Redmega
Aug 17 2016 02:44
Yeah, I had been removing numbers too. Misread 'alphanumeric' as 'alphabetic'
I really should sleep
Stephen James
@sjames1958gm
Aug 17 2016 02:44
@Redmega :+1:
Alexander Køpke
@alexanderkopke
Aug 17 2016 02:44
also the dot should be removed
Angel J Piscola
@Redmega
Aug 17 2016 02:47
/[^a-z\d]/ was my regex, so that took care of it
Man i love ES6
SPOILER
Whoops, didnt mean to post the whole thing
Justin Woodward
@jwoo92
Aug 17 2016 02:54
Is anyone familiar with the MiniMax JavaScript algorithm?
Amandeep Saxena
@AmandeepSaxena
Aug 17 2016 03:29
hey!!frnds...is anyone here help me out wid javascript..
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:31
```
'''
CamperBot
@camperbot
Aug 17 2016 03:31
:bulb: to format code use backticks! ``` more info
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:32
function updateRecords(id, prop, value) {

  selectedRecord = collection[id];

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

  return collection;
}
Hi guys, I am stuck with the Record Collection
Could anyone give me some suggestion please ^^
Amandeep Saxena
@AmandeepSaxena
Aug 17 2016 03:33
function convertToF(celsius) 
{
  var fahrenheit;
  // Only change code below this line

  fahrenheit = celsius(9/5)+32;
  // Only change code above this line
  return fahrenheit;
}

// Change the inputs below to test your code
convertToF(0);
any idea?
Chris Lacaille
@ChrisL108
Aug 17 2016 03:34
This message was deleted
I've tried adding different CDN's w/ the same result
Well actually jQuery is working.. idk why its telling me that sorry
llamatarianism
@llamatarianism
Aug 17 2016 03:43
@AmandeepSaxena celsius(9/5) is wrong
you're calling celsius like a function, but it's not a function, it's a number
you need to multiply it by 9/5
Angel J Piscola
@Redmega
Aug 17 2016 03:46
@AmandeepSaxena You typed it how you'd write it. Javascript doesn't know thatx(y)multiplies x times y, it only knows that () is how you call a function
@kn1ghtdave What's the error?
Joseph
@revisualize
Aug 17 2016 03:46
What everyone else said.
@AmandeepSaxena When you do celsius(9/5) javascript thinks you're making a function call.
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:47
@Redmega ```
```
function updateRecords(id, prop, value) {

  selectedRecord = collection[id];

 if(!selectedRecord.hasOwnProperty('tracks')){
   selectedRecord[prop] = [];
   selectedRecord[prop].push(value);
 } else if (selectedRecord.hasOwnProperty('tracks')){
   selectedRecord[prop].push(value);
 } else if (!selectedRecord[prop].hasOwnProperty(value)){
   delete selectedRecord[prop];
 }

  return collection;
}
Angel J Piscola
@Redmega
Aug 17 2016 03:48
You just showed me your code again, you didn't point out or tell us the error :)
Joseph
@revisualize
Aug 17 2016 03:48
@kn1ghtdave What is with the selectedRecord
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:48
@Redmega I am stuck at the part to check if the input value is empty, if it is empty, I should delete the prop
Joseph
@revisualize
Aug 17 2016 03:49
@kn1ghtdave I want to understand this:
collection[id];
vs
selectedRecord
console.log("selectedRecord".length) ... 14
console.log("collection[id]".length) ... 14
So.. What's the point?
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:50
@revisualize Hi! I just set the selected id to a variable called selectedRecord. just for easier interpretation
Joseph
@revisualize
Aug 17 2016 03:50
Well, I'm trying to help you but, I'm not "interpretation"ing it any easier.
@kn1ghtdave Also,
} else if (!selectedRecord[prop].hasOwnProperty(value)){
Has [prop] twice then.
And it isn't even the correct evaluation.
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:51
@revisualize Well I can just remove it and replace it with collection[id]
Joseph
@revisualize
Aug 17 2016 03:51
@kn1ghtdave // If value is blank, delete that property from the album.
@kn1ghtdave Almost all of your if Conditions are Incorrect.
@kn1ghtdave For this:
If value is blank, delete that property from the album.
You have written:
if (!collection[id][prop].hasOwnProperty(value)){
Which isn't even close.
...
kn1ghtdave
@kn1ghtdave
Aug 17 2016 03:54
@revisualize Ok cool, let me try this out. Thank you!
CamperBot
@camperbot
Aug 17 2016 03:54
kn1ghtdave sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1655 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 17 2016 03:54
If I was to do..
If name is Joseph return awesome.
I would write:
if (name == "Joseph") {
   return "AWESOME";
}
pixelisart
@pixelisart
Aug 17 2016 03:55
if (name === "Joseph") {
return "AWESOME";
}
shouldn't it be three equals?
Joseph
@revisualize
Aug 17 2016 03:56
There doesn't need to be.
@pixelisart What is the difference between == and === ???
Note: That's an actual interview question as well. So, maybe you should learn it.
doraani
@doraani
Aug 17 2016 03:58
Any suggestion on how to make a button that can not be clicked again until the onclick event finish?
http://codepen.io/doraani/pen/xOQrzV
pixelisart
@pixelisart
Aug 17 2016 03:58
I think the difference is that == returns true. The other returns false.
right?
Angel J Piscola
@Redmega
Aug 17 2016 03:59
@pixelisart The functional difference, not the difference in your specific case
That is a really important thing to learn, actually.\
Joseph
@revisualize
Aug 17 2016 04:00
@pixelisart Depends on the evaluation.
Angel J Piscola
@Redmega
Aug 17 2016 04:00
But to your point @revisualize More often than not its recommended to use ===. Most JSlints or code scanners will tell you that's best practice
Joseph
@revisualize
Aug 17 2016 04:00
It is best practice.
Angel J Piscola
@Redmega
Aug 17 2016 04:00
@pixelisart See if you can see the difference here:
Joseph
@revisualize
Aug 17 2016 04:00
I don't disagree.
Angel J Piscola
@Redmega
Aug 17 2016 04:01
1=="1" -> true
1==="1" -> false
Joseph
@revisualize
Aug 17 2016 04:02
0 == false; // true
0 === false; // false
Angel J Piscola
@Redmega
Aug 17 2016 04:02
@revisualize Hehe
Angel J Piscola
@Redmega
Aug 17 2016 04:03
Joseph's example also ties in to "Truthiness"
kn1ghtdave
@kn1ghtdave
Aug 17 2016 04:04
@Redmega Hey I did it! I think the instruction was a bit confusing ...
Thank you!
CamperBot
@camperbot
Aug 17 2016 04:04
kn1ghtdave sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 70 | @redmega |http://www.freecodecamp.com/redmega
pahosler
@pahosler
Aug 17 2016 04:04
@doranni pseudo code
while activity true button disable
This message was deleted
This message was deleted
kn1ghtdave
@kn1ghtdave
Aug 17 2016 04:05
@revisualize Hey I did it! I think the instruction was a bit confusing ...
Thank you!
CamperBot
@camperbot
Aug 17 2016 04:05
kn1ghtdave sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: kn1ghtdave already gave revisualize points
Angel J Piscola
@Redmega
Aug 17 2016 04:05
@kn1ghtdave Wasn't me who gave you the help, but thanks for the brownies! Thank @revisualize so he gets some ;)
CamperBot
@camperbot
Aug 17 2016 04:05
redmega sends brownie points to @kn1ghtdave and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for kn1ghtdave
:star2: 1656 | @revisualize |http://www.freecodecamp.com/revisualize
Angel J Piscola
@Redmega
Aug 17 2016 04:05
Well, I gave you some brownies for him then
@pahosler Four backticks
Joseph
@revisualize
Aug 17 2016 04:06
@kn1ghtdave No problem. You can tell how often people come in here for help on that lesson that I created a Gist for it.
ahmed abouhay
@abohay
Aug 17 2016 04:07
function mutation(arr) {
  var arrj = arr.join("").toLowerCase().split("");
  arrj[1].split("");
  var blh = arrj[0];
  for(var i = 0 ; i < arrj[0].length ; i++ ){
      if (arrj[1][i].indexOf(blh) > 0 ){
        return true;
      }
  }
      return false;
}

mutation(["hello", "hey"]);
pahosler
@pahosler
Aug 17 2016 04:07
@Redmega nope it's three backticks, I was posting from irc so I guess it translated differently
ahmed abouhay
@abohay
Aug 17 2016 04:08
please any one could help @revisualize @Redmega @kn1ghtdave @pahosler @pixelisart mutation challenge
function mutation(arr) {
  var arrj = arr.join("").toLowerCase().split("");
  arrj[1].split("");
  var blh = arrj[0];
  for(var i = 0 ; i < arrj[0].length ; i++ ){
      if (arrj[1][i].indexOf(blh) > 0 ){
        return true;
      }
  }
      return false;
}

mutation(["hello", "hey"]);
Angel J Piscola
@Redmega
Aug 17 2016 04:08
This message was deleted
Oh hey look at that
Ive always just used 4 by habit, I guess
pahosler
@pahosler
Aug 17 2016 04:09
@Redmega I see what it did, it sent them as individual lines, that's why the markdown didn't catch it
still it's only three
or 1 to do :point_left:
Angel J Piscola
@Redmega
Aug 17 2016 04:12
My god, I think I Just gave my self cancer
arr.map((a,i) => {if(!x[y]){x[y]=[];}x[y].push(a);if(x[y].length===size){y++;}});
pahosler
@pahosler
Aug 17 2016 04:13
@abohay that's not how you get args
Angel J Piscola
@Redmega
Aug 17 2016 04:13
@abohay Haven't done that one yet, sorry
pahosler
@pahosler
Aug 17 2016 04:13
help arguments
CamperBot
@camperbot
Aug 17 2016 04:13

:point_right: algorithm arguments optional [wiki]

Algorithm Arguments Optional

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

:pencil: read more about algorithm arguments optional on the FCC Wiki

pahosler
@pahosler
Aug 17 2016 04:13
not the right one sigh
try that link @abohay
for a neat little short cut you can use var args = [...arguments]; but please read mdn so you understand what's happening
erickstm87
@erickstm87
Aug 17 2016 04:16
Could someone help me with record collector javascript? It passes when I pass it through a js compiler but isn't working in freecodecamp's console.

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

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

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

Joseph
@revisualize
Aug 17 2016 04:21
@erickstm87 How do you test if an object has a property?
Kent Saeteurn
@sansae
Aug 17 2016 04:23
@Redmega Thank you for the response Angel. That makes sense. I'll jump through the steps of my code and see what I can fix.
CamperBot
@camperbot
Aug 17 2016 04:23
sansae sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 73 | @redmega |http://www.freecodecamp.com/redmega
Angel J Piscola
@Redmega
Aug 17 2016 04:24
@sansae Np... (Awkwardly scrolls up to figure out how he helped)
erickstm87
@erickstm87
Aug 17 2016 04:24
@revisualize sorry if i've misunderstood the question. But does the last 'else if' statement not cover that?
ahmed abouhay
@abohay
Aug 17 2016 04:25
@pahosler the argument arr is array itself
Kent Saeteurn
@sansae
Aug 17 2016 04:25
@Redmega lol... sorry, i should have made it clear what I was referring to. I forgot I sent my original message a while ago. It seems that perhaps using a "for (var x in collection)" somewhere in my code will do the trick
Angel J Piscola
@Redmega
Aug 17 2016 04:26
@sansae Ah. got it. I think. Good luck!
pahosler
@pahosler
Aug 17 2016 04:27
@abohay oh sorry, I was looking at it wrong, been working too long today...
erickstm87
@erickstm87
Aug 17 2016 04:27
@revisualize also this statement should test for that as well correct? 'else if(prop === "tracks" && collection[id][prop] !== 'tracks' ){
collection[id][prop] = [];
collection[id][prop].push(value);
}'
Kent Saeteurn
@sansae
Aug 17 2016 04:28
@Redmega the problem i needed help with was the "Wherefore are Thou" challenge. There is a collection (an array of objects) and a source (one object for which to check if it exists in arr of objects);
i'll see what i can do
thank you again
Angel J Piscola
@Redmega
Aug 17 2016 04:28
@sansae Oh, right. I'm trying to work through these required modules so I've been quite distracted. I remember now. Yeah, good luck!
You werent looping through the props, only the collections, right?
ahmed abouhay
@abohay
Aug 17 2016 04:29
@pahosler no problem ... idon't know why i'm wrong
function mutation(arr) {
  var arrj = arr.join("").toLowerCase().split("");
  arrj[1].split("");
  var blh = arrj[0];
  for(var i = 0 ; i < arrj[0].length ; i++ ){
      if (arrj[1][i].indexOf(blh) > 0 ){
        return true;
      }
  }
      return false;
}

mutation(["hello", "hey"]);
Justin Woodward
@jwoo92
Aug 17 2016 04:31
Does anyone know of a good resource that will help you initially understand the MiniMax algorithm and its ability to be used in the ticTacToe game?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:31
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%20%20%0A%20%20%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%0A%20%20for(var%20x%3D0%3Bx%3Ccontacts.length%3Bx%2B%2B)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20if(firstName%3D%3Dcontacts%5Bx%5D.firstName)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20check%3Dcontacts%5Bx%5D.hasOwnProperty(prop)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(check)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20return%20contacts%5Bx%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%0A%20%20%20%20%7D%0A%20%20%0A%20%20%0A%20%20%0A%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
guys please help me mpdify
the code
im not getting 1 objective
im nt gettg hw to write it for that
Joseph
@revisualize
Aug 17 2016 04:31
@erickstm87 How do you test if an object has a property?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:31
some hints would be appreciated
pahosler
@pahosler
Aug 17 2016 04:31
@abohay I'll paste it in repl so I can see what it's doing, it looks basically correct
Kent Saeteurn
@sansae
Aug 17 2016 04:34
@Redmega well, i thought i was looping through the collection; to be more specific, i thought i was looping through the collection AND its properties, but I guess I wasn't? the code I have works for the first two test cases, so technically, I am looping through the props in collection, otherwise I don't think it would work. the problem is that when the source argument has more than one key:value pair, the code doesn't work. my fiddle is here: https://jsfiddle.net/r53mrxga/; i think what's happening is that my code isn't taking into account the second key:pair value in the source argument. i don't know. like i said previously, my brain is fried. it took me about 2 weeks just to get the first two test cases working
lol
i think i need a break
pahosler
@pahosler
Aug 17 2016 04:36
@abohay
 var arrj = arr.join("").toLowerCase().split("");
  arrj[1].split("");
  var blh = arrj[0];
  console.log(arrj[1],blh); // <--- add this to your code and see the results...
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:36
hw would i write that condition
erickstm87
@erickstm87
Aug 17 2016 04:38
@revisualize ok I think it's something like 'if(collection[id][prop]) {}'
Thanks
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:38
guys
can someone please help me
just needed a suggestion ive got the problem corect
Justin Clark
@jeclark9063
Aug 17 2016 04:40
When your output is red dots, what does that actually means?
Josh Hernandez
@Lag-lan
Aug 17 2016 04:40
@swapnildaddikar bro write the code here
Angel J Piscola
@Redmega
Aug 17 2016 04:41
@pahosler Any way to make this smaller? I'm too tired for this...
function slasher(r, n) {
  r.splice(0,n);return r;
}
Not sure if this is smaller...
function slasher(r, n) {
 return r.splice(n,r.length);
}
Nope, its not
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:42

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

function lookUpProfile(firstName, prop){

myCount=0;
// Only change code below this line

for(var x=0;x<contacts.length;x++)
{

  if(firstName==contacts[x].firstName)
    {
      var check=contacts[x].hasOwnProperty(prop);
      if (check)
        {
      return contacts[x][prop];

    }
      else 
        {
          return "No such property";
        }


    }

  if(firstName!=contacts[x].firstName)
    {

      myCount+=1;
    }

}

if(myCount==contacts.length)
{
return "No such contact";
}

// Only change code above this line
}

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

https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%20%20%0A%20%20myCount%3D0%3B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%0A%20%20for(var%20x%3D0%3Bx%3Ccontacts.length%3Bx%2B%2B)%0A%20%20%20%20%7B%0A%20%20%20%20%20%0A%20%20%0A%20%20%20%20%20%20if(firstName%3D%3Dcontacts%5Bx%5D.firstName)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20check%3Dcontacts%5Bx%5D.hasOwnProperty(prop)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(check)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20return%20contacts%5Bx%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20if(firstName!%3Dcontacts%5Bx%5D.firstName)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20myCount%2B%3D1%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%0A%20%20%20%20%7D%0A%20%20%0A%20%20if(myCount%3D%3Dcontacts.length)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%7D%0A%20%20%0A%20%20%0A%20%20%0A%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
sorry
check this link
@Lag-lan
Joseph
@revisualize
Aug 17 2016 04:43
@erickstm87 How do you"Testing Objects for Properties"???
friscodisco
@friscodisco
Aug 17 2016 04:44
@swapnildaddikar you are only failing one test...the test is: "Bob", "number" should return "No such contact" so you need to add "no such contact" for that test case to pass and it is missing from your code as it is in the link.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:44
ive added that
wait
Joseph
@revisualize
Aug 17 2016 04:44
@swapnildaddikar You keep posting huge blocks of code and huge links. Is there any way you can not do that? We do NOT need to see the object.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:45
instead of criticizing can u help out on the real problem ? @revisualize
Joseph
@revisualize
Aug 17 2016 04:45
@swapnildaddikar Sure. Here.
Link again.
39 lines of text plus a comment.
Angel J Piscola
@Redmega
Aug 17 2016 04:46
@swapnildaddikar He wasn't criticizing, he was trying to maintain order in the chat. I agree, the insanely long links made following the chat hard
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:46
like i said ive got my problem correct
i needed some optimization
Joseph
@revisualize
Aug 17 2016 04:46
@swapnildaddikar Okay. You want to "optimize" your code.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:47
There is a key word in the if firstName does not corrospond to ANY contacts in the contact list.
yes
Joseph
@revisualize
Aug 17 2016 04:47

@swapnildaddikar

function lookUpProfile(firstName, prop){           // Basic function with two params
   for (var i = 0; i < contacts.length; i++) {     // you know a basic for loop through the contacts array.
        if (firstName === contacts[i].firstName) { // if the contact i has a firstName that matches my firstName param
            return contacts[i].hasOwnProperty(prop) ? contacts[i][prop] : "No such property"; // true
        }  // Ternary: if (contacts[i].hasOwnProperty(prop)) { return that contacts prop value } 
    }      // else ... return that it doesn't have the property
    return "No such contact"; // after the loop is completed. That means the contact wasn't found. 
}                             // because the function would have *HALTED* with the first return statement.

Optimized.

Kent Saeteurn
@sansae
Aug 17 2016 04:47
@swapnildaddikar Joseph Tracy make a great point; instead of being defensive, you should accept his suggestion; most people use jsfiddle.net or other similar sandboxes to share their code; they simply paste a link so that others can go and check out the code;
Joseph
@revisualize
Aug 17 2016 04:48
@swapnildaddikar Anything else I can do for you?
Kent Saeteurn
@sansae
Aug 17 2016 04:48
it's also easier for them to help you debug your code
Joseph
@revisualize
Aug 17 2016 04:48
If you read the description text of this room:
Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:49
alright thanks
and sorry for the rude behaviour
Kent Saeteurn
@sansae
Aug 17 2016 04:50
@revisualize i had no idea about gist (noob here); thank you
CamperBot
@camperbot
Aug 17 2016 04:50
sansae sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1657 | @revisualize |http://www.freecodecamp.com/revisualize
Kent Saeteurn
@sansae
Aug 17 2016 04:50
i usually use jsfiddle.net; i figured it would be easier for folks to help me
Joseph
@revisualize
Aug 17 2016 04:51
@sansae Gist is great because it ties directly in with Github and as you progress in your developer career. You want to keep a log of some code.
Angel J Piscola
@Redmega
Aug 17 2016 04:51
^
Jack
@jh0l
Aug 17 2016 04:51
@sansae u can also use a combination of Gist and RawGit to host images, svg any other file etc as an alternative to imgur or google drive too!
Joseph
@revisualize
Aug 17 2016 04:51
@sansae I also recommend taking your FreeCodeCamp challenge answers and making a github repo with the way you solved the problem in a .js file
Jack
@jh0l
Aug 17 2016 04:52
or paying for a Codepen Pro account
Joseph
@revisualize
Aug 17 2016 04:52
Codepen works too but, that is more for "full" static websites.
Kent Saeteurn
@sansae
Aug 17 2016 04:52
@Jhollond well... i guess i don't quite see the benefit of getting a pro acct with codepen; especially considering i'm still a novice; i have nothing significant to share
Jack
@jh0l
Aug 17 2016 04:53
ye that's what I meant lol
Joseph
@revisualize
Aug 17 2016 04:53
about @sansae
CamperBot
@camperbot
Aug 17 2016 04:53
:cookie: 287 | @sansae |http://www.freecodecamp.com/sansae
Joseph
@revisualize
Aug 17 2016 04:54
@sansae You've done more FreeCodeCamp projects than I have. ... That seems like a lot to share.
Angel J Piscola
@Redmega
Aug 17 2016 04:54
You're already closer to your cert than me @sansae
Justin Clark
@jeclark9063
Aug 17 2016 04:54
Can anyone tell me if there a cleaner way to approach this algorithm? I got it working but was just curious to see others implementation
function rot13(str) { // LBH QVQ VG!
  var temp = [];
  var fin = "";

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

  if (str.charCodeAt(i) < 65 || str.charCodeAt(i) > 90)
    temp[i] = str.charCodeAt(i);
  else if (str.charCodeAt(i) - 13 < 65)
    temp [i] = str.charCodeAt(i) - 13 + 26;

  else
    temp [i] = str.charCodeAt(i) - 13;
  }


  for (var j = 0; j < temp.length; j++){
   fin += String.fromCharCode(temp[j]);
  }
  return fin;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Angel J Piscola
@Redmega
Aug 17 2016 04:54
I'm being lazy with my portfolio
Joseph
@revisualize
Aug 17 2016 04:54
Anyhow!
I need to get to bed. :zzz:
Angel J Piscola
@Redmega
Aug 17 2016 04:55
G"night
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:55
@revisualize wait help me with this
can u see now?
Josh Hernandez
@Lag-lan
Aug 17 2016 04:55
:zzz:
Joseph
@revisualize
Aug 17 2016 04:55
@swapnildaddikar Didn't I already?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:56
that return statement after the loop has be confused
Joseph
@revisualize
Aug 17 2016 04:56
@swapnildaddikar Did you read the comment?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:56
yes
i even tried it out
Joseph
@revisualize
Aug 17 2016 04:56
@swapnildaddikar What do return statements do?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:56
this code is working
return and break that loop
to the caller
Markus Kiili
@Masd925
Aug 17 2016 04:57
@jeclark9063 You could use .map() and do the transformation with one remainder operation.
Joseph
@revisualize
Aug 17 2016 04:57
@swapnildaddikar Great.
@swapnildaddikar So, what do you need help with?
@swapnildaddikar Do you want me to refactor your code?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:57
yes so could u see my code?
Chris Cullen
@123xylem
Aug 17 2016 04:58
$("#plus").click(function() {
  var curr=  $("#display").text(values).parseInt();
  var num=   $(".digit").text(values).parseInt();
  add(function(num,curr){
     $("#display").text(curr+num)
  })
Am i on the right lines for a + button here? It takes displayed numbers (parseINted) and adds them to next inputted number... I need a way to make the next inputted number end at = press though....
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:58
if u see ive used a myCount varaible
my question is
Joseph
@revisualize
Aug 17 2016 04:58
@swapnildaddikar I see that. It isn't needed.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:58
if i use your logic of return statement
where shoud i place it
ya
exactly
so i needed ur help with optmization
its nt needed
i tried placing the return statement
as per your commands
Angel J Piscola
@Redmega
Aug 17 2016 04:59
If you wanted to optimize your code you should post in /CodeReview
This is for help with coding issues :)
Joseph
@revisualize
Aug 17 2016 04:59
@swapnildaddikar Give me a second. I'm going to refactor your code for you.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 04:59
alright thanks a lot
this is a coding issue
Jaren Escueta
@jarenescueta731
Aug 17 2016 04:59
@123xylem you could add a separate event handler for the equals press
Chris Cullen
@123xylem
Aug 17 2016 05:00
so make = a function with 4 if statements?
if + = does this if - = does that?
Angel J Piscola
@Redmega
Aug 17 2016 05:01
@swapnildaddikar Thought your code was working already
Joseph
@revisualize
Aug 17 2016 05:01
@swapnildaddikar It isn't a coding issue. But, whatever. I'm still working through this.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:01
yes and joseph told me to change it .. i changed and got an error
Angel J Piscola
@Redmega
Aug 17 2016 05:01
So revert, submit, and you're done
Joseph
@revisualize
Aug 17 2016 05:01
@swapnildaddikar That's because you're doing it differently.
Angel J Piscola
@Redmega
Aug 17 2016 05:01
Or if you're not happy with it then post it in code review
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:02
im asking for a suggestion who suggsed me
if u cant help whats the point in arguing ?
Angel J Piscola
@Redmega
Aug 17 2016 05:02
@swapnildaddikar Ok fair enough
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:02
he told me something... i couldnt get it so im asking him again
idk why creating such an issue
Angel J Piscola
@Redmega
Aug 17 2016 05:03
I seem to be playing code golf with myself tonight.. Can anyone think of a shorter way to do this?
function mutation(r) {
  var a=r[0].toLowerCase().split(''),b=r[1].toLowerCase().split('');
  for(var i=b.length-1;i>=0;i--){
    if(a.indexOf(b[i])>-1){
      b.splice(i,1);
    }
  }
  return b.length===0;
}

mutation(["hello", "hey"]);
Besides space saved from making it a 1 liner
Maybe regex?
Kent Saeteurn
@sansae
Aug 17 2016 05:05
@sansae u can also use a combination of Gist and RawGit to host images, svg any other file etc as an alternative to imgur or google drive too! @Jhollond thanks for the tip; if ever i need gist, i'm sure i'll come around to it; gist and rawgit are foreign to me at this point; you could tell me that they both a type of fruit and i'd probably believe you, lol
CamperBot
@camperbot
Aug 17 2016 05:05
sansae sends brownie points to @jhollond :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @jhollond |http://www.freecodecamp.com/jhollond
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:06
@Redmega i didnt mean no disrespect ... sorry for rude behavior
Markus Kiili
@Masd925
Aug 17 2016 05:06
@Redmega
function mutation(arr) {
  return arr[1].toLowerCase().split("").every(function(val, index){
    return arr[0].toLowerCase().indexOf(val)>-1;
  });
}
Angel J Piscola
@Redmega
Aug 17 2016 05:06
@swapnildaddikar No problem dude, I was being a bit confrontational too
Jack
@jh0l
Aug 17 2016 05:06
@sansae ya I only found out about it through this article
Angel J Piscola
@Redmega
Aug 17 2016 05:06
@Masd925 Niiiice
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:06
i hope its cool ... sorry from my side .. have a nice day
Liew Xun
@damakuno
Aug 17 2016 05:08
11037
3154
322
Angel J Piscola
@Redmega
Aug 17 2016 05:08
@Masd925 So using es6 I can get it to
/* jshint esversion:6 */
function mutation(r) {
  return r[1].toLowerCase().split("").every((v) => {
    return r[0].toLowerCase().indexOf(v)>-1;
  });
}
Joseph
@revisualize
Aug 17 2016 05:10
@swapnildaddikar
You here?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:10
yes @revisualize
Joseph
@revisualize
Aug 17 2016 05:10
@swapnildaddikar https://repl.it/CnxH
Markus Kiili
@Masd925
Aug 17 2016 05:10
@Redmega Yes, I have no idea how to get shorter than that.
Joseph
@revisualize
Aug 17 2016 05:11

IF Anyone wants to see how I refactor code:

https://repl.it/CnxH .. Not it is the answer to Profile Lookup ... So, if you haven't completed it.. Don't look.

swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:12
thanks a lot :) @revisualize
CamperBot
@camperbot
Aug 17 2016 05:12
swapnildaddikar sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1658 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 17 2016 05:13
@swapnildaddikar Does everything make sense?
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:13
yes sir
Angel J Piscola
@Redmega
Aug 17 2016 05:13
@Masd925 I shaved two more characters by using ~ (example: return ~r[0].toLowerCase().indexOf(v);
Joseph
@revisualize
Aug 17 2016 05:14
@swapnildaddikar It is a process of looking at your code and understanding everything about it that let's you break it down like I did.
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:16
@revisualize thank you very much u helped me a lot
CamperBot
@camperbot
Aug 17 2016 05:16
swapnildaddikar sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: swapnildaddikar already gave revisualize points
Geo Galagaran
@geeofree
Aug 17 2016 05:16
yow guys anyone done with the DNA Pairing challenge?
Jaren Escueta
@jarenescueta731
Aug 17 2016 05:16
@da7thsin what's ur prob?
Joseph
@revisualize
Aug 17 2016 05:16
@swapnildaddikar Good luck. I hope it helped you learn.
Geo Galagaran
@geeofree
Aug 17 2016 05:16
@jarenescueta731 nothing really. I just wanted to pair codes is all haha
swapnildaddikar
@swapnildaddikar
Aug 17 2016 05:17
yes it did @revisualize
Geo Galagaran
@geeofree
Aug 17 2016 05:17
Anyone have anything shorter than what I did?
function pairElement(str) {
  return str.split('').map(function(val){
    if(val == "A"){
      return (val += "T").split('');
    }
    else if(val == "T"){
      return (val += "A").split('');
    }
    else if(val == "G"){
      return (val += "C").split('');
    }
    else if(val == "C"){
      return (val += "G").split('');
    }
  });
}

pairElement("GCG");
Joseph
@revisualize
Aug 17 2016 05:17
@da7thsin I think I do. But, I'm not sure. I really did pretty much hard code everything like you did.
Markus Kiili
@Masd925
Aug 17 2016 05:17
@da7thsin This is one popular way
function pair(str){
  var pairs = {A:'T', T: 'A', C: 'G', G: 'C'};
  return Array.prototype.map.call(str, function(val){
    return [val,pairs[val]];
  });
}
NixonRichard
@NixonRichard
Aug 17 2016 05:17
hi there
Geo Galagaran
@geeofree
Aug 17 2016 05:18
@Masd925 I've seen call. But what does that do exactly?
NixonRichard
@NixonRichard
Aug 17 2016 05:18
im so desperate
Geo Galagaran
@geeofree
Aug 17 2016 05:18
@revisualize its ok :p haha
Markus Kiili
@Masd925
Aug 17 2016 05:18
@da7thsin There it does the same as if you split the string and use .map().
Angel J Piscola
@Redmega
Aug 17 2016 05:18
@NixonRichard Whats up?
Geo Galagaran
@geeofree
Aug 17 2016 05:19
@Masd925 ok! Thank you!
CamperBot
@camperbot
Aug 17 2016 05:19
da7thsin sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2302 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 17 2016 05:19
@da7thsin Call method sets the calling object to be an array-like string wrapper. So with call you can use array methods on array-like objects (needs to have numeric property keys and length property).
NixonRichard
@NixonRichard
Aug 17 2016 05:19
my pen doesnt work TT @Redmega
Angel J Piscola
@Redmega
Aug 17 2016 05:20
I keep doing these... I really should go to sleep...
/* jshint esversion:6 */

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr.filter((a)=>{
    return a;
  });
}
@NixonRichard Haven't done that one yet, sorry
NixonRichard
@NixonRichard
Aug 17 2016 05:21
nevermind
Markus Kiili
@Masd925
Aug 17 2016 05:21
@Redmega bouncer=a=>a.filter(x=>x);
Angel J Piscola
@Redmega
Aug 17 2016 05:22
@Masd925 You clearly have more ecmafu than i do
@Masd925 thanks
CamperBot
@camperbot
Aug 17 2016 05:22
redmega sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2303 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 17 2016 05:23
@Redmega I have a gist of my one-liners to FCC challenges if you like to see things stuffed into one line.
Angel J Piscola
@Redmega
Aug 17 2016 05:23
Its my very favorite thing in the world
Joseph
@revisualize
Aug 17 2016 05:23
Or you could just use Boolean like the lesson suggests
Markus Kiili
@Masd925
Aug 17 2016 05:23
@Redmega :)
Angel J Piscola
@Redmega
Aug 17 2016 05:23
Because in my work I'm forced to use Java 1.5
@revisualize True but wheres the fun in that
;)
Joseph
@revisualize
Aug 17 2016 05:23
const bouncer = (arr) => arr.filter(Boolean);
Angel J Piscola
@Redmega
Aug 17 2016 05:23
o
Joseph
@revisualize
Aug 17 2016 05:24
:muscle:
Angel J Piscola
@Redmega
Aug 17 2016 05:24
I spoke too soon :laughing:
Markus Kiili
@Masd925
Aug 17 2016 05:24
@revisualize But @Redmega will fall into sleep reading that looong word Boolean ;)
Kent Saeteurn
@sansae
Aug 17 2016 05:24
@Redmega lol, it took me forever to figure that silly problem out; i wrote like 50 lines of code before i learned how to use Boolean objects to test my cases; it turns out though that that bouncer problem required just a few lines of code using .filter (a method that I still don't understand how to use AT ALL); good luck
Joseph
@revisualize
Aug 17 2016 05:25
Did I just give away an answer?
Angel J Piscola
@Redmega
Aug 17 2016 05:25
@sansae Truth be told it can be done by using filter and comparing to false. We're just messing around with golf
Adrian Kopytko
@adriankopytko
Aug 17 2016 05:25
Hello, can someone make a code review for me? Just JS, I made a wikipedia viewer.
Joseph
@revisualize
Aug 17 2016 05:26
Ain't I supposed to be in bed?
Angel J Piscola
@Redmega
Aug 17 2016 05:26
filter() just applies a function to each element in the array, and keeps it based on the boolean value of the return of that function
Joseph
@revisualize
Aug 17 2016 05:26
:zzz: ... :sailboat: ... :zzz: ... :sailboat: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :dolphin: :whale2: :sunrise: ... :zzz:
Markus Kiili
@Masd925
Aug 17 2016 05:26
@Redmega https://gist.github.com/Masd925/8b1a9b1d37c322827dcd
Angel J Piscola
@Redmega
Aug 17 2016 05:26
@revisualize Sorry but @Masd925 wins, btw. x=>x is shorter than Boolean
By a whole 3 bytes
Joseph
@revisualize
Aug 17 2016 05:27
Whatever.
I'm OUT!
Angel J Piscola
@Redmega
Aug 17 2016 05:27
Lol
Night
Kent Saeteurn
@sansae
Aug 17 2016 05:28
@revisualize have a great night!
coffeebeanzz
@coffeebeanzz
Aug 17 2016 05:28
Sweet dreams @revisualize
Angel J Piscola
@Redmega
Aug 17 2016 05:28
@Masd925 Thanks, I bookmarked it for reference, though I doubt I'd be able to come up with anything as short as yours
CamperBot
@camperbot
Aug 17 2016 05:28
redmega sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: redmega already gave masd925 points
Jaren Escueta
@jarenescueta731
Aug 17 2016 05:28
@revisualize good night you beautiful human
Kent Saeteurn
@sansae
Aug 17 2016 05:28
@Redmega lol, yeah; i ended up avoiding the usage of .filter. I just used an if (true === Boolean) statement inside a for loop
Angel J Piscola
@Redmega
Aug 17 2016 05:29
@sansae In the end your code was probably more human-readable to the average programmer. That's pretty important too
NixonRichard
@NixonRichard
Aug 17 2016 05:29
what s going on ?
sagar manghnani
@sagarmanghnani
Aug 17 2016 05:33
hey guys i need some help on profile lookup problem
Kent Saeteurn
@sansae
Aug 17 2016 05:33
@Redmega thank you, but in the end, i feel like i rely waaaay too much on for loops and if statements; for every problem i do, my gut is like... "dude, use a for loop and a bunch of if statements" lol; what ends up happening is i don't learn how to use other methods that javascript provides; in other words, i feel i'm quite limited in that sense; i hear that being able to write efficient code is very important; my code is extremely unefficient
CamperBot
@camperbot
Aug 17 2016 05:33
sansae sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 77 | @redmega |http://www.freecodecamp.com/redmega
Chris Cullen
@123xylem
Aug 17 2016 05:33
http://codepen.io/123xylem/pen/bZkAKd?editors=1010
Why is my clearAll button not clearing my data. When I reinput a number all previous numbers are remembered
Kent Saeteurn
@sansae
Aug 17 2016 05:33
@Redmega anyway, it was nice chatting with you; and thank you for the help
CamperBot
@camperbot
Aug 17 2016 05:33
sansae sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:warning: sansae already gave redmega points
Kent Saeteurn
@sansae
Aug 17 2016 05:33
although i can't remember what you helped me with; have a great night redmega
Angel J Piscola
@Redmega
Aug 17 2016 05:34
@sansae Haha, good night
Adrian Kopytko
@adriankopytko
Aug 17 2016 05:34
It's my JS wikipedia viewer. Can someone take a look and appreciate it? Thanks!
var config = {};

$(document).ready(function() {
  var btn = config.btn || $('#searchBtn');
  btn.on('click', wikipediaModule.btnListener);
});

var wikipediaModule = (function() {
  'use strict';

  var WIKIPEDIA_API_REQUEST = 'https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=';
  var QUERY_ITEM_1 = config.query_item_1 || '<a href="https://en.wikipedia.org/?curid=';
  var QUERY_ITEM_2 = config.query_item_2 || '"><div class="query-item"><h2 class="query-item-title">';
  var QUERY_ITEM_3 = config.query_item_3 || '</h2><p class="query-item-info">';
  var QUERY_ITEM_4 = config.query_item_4 || '</p></div></a>';

  var userInputValue;

  var request = function(api, title) {
    return (api + title);
  };

  var getWikiQuery = function() {
    $.ajax({
      url: request(WIKIPEDIA_API_REQUEST, userInputValue),
      dataType: 'jsonp',
      success: function (data) {
        var results = data.query.pages;

        $.each(results, function(key, value) {
          addQueryItem(value.title, value.pageid, value.extract);
        });
      }
    });
  };

  var btnListener = function () {
    var input = config.userInput || $('#input');
    userInputValue = input.val();
    getWikiQuery();
  };

  var addQueryItem = function(title, pageid, extract) {
    var query = config.query || $('#query');
    query.append(QUERY_ITEM_1 + pageid + QUERY_ITEM_2 + title + QUERY_ITEM_3 + extract + QUERY_ITEM_4);
  };

  return {
    btnListener: btnListener
  };
})();
sagar manghnani
@sagarmanghnani
Aug 17 2016 05:35

i don't know what i am doing wrong please help
here is the code

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

NixonRichard
@NixonRichard
Aug 17 2016 05:36
help me with this code thx alot
CamperBot
@camperbot
Aug 17 2016 05:36
no wiki entry for: me with this code thx alot
NixonRichard
@NixonRichard
Aug 17 2016 05:37
$.getJSON(url,

     function (json) {
    $("#results").html( JSON.stringify(json));
    var html = '';
  json.forEach(function(val) {
  var keys = Object.keys(json.query.search[0].snippet);
  html += "<div class='resultA result result-extract'>";
  keys.forEach(function(key) {
    html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
  });
  html += "</div><br>";

  });
      $('#results').html(html);      
    });
});
@camperbot tooNoisy
Mostafa Khalid Raihan
@run-time-error
Aug 17 2016 05:38
Hello i need help regarding random quote generator.
I am trying to get json from quotesondesign.com
query is
$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
$("body").append(a[0].content + "<p>— " + a[0].title + "</p>")
});
here filter[orderby]=rand should fetch some random quote right ? but every time it fetches the same quote
http://codepen.io/root09/pen/RRdAVE?editors=0010
llamatarianism
@llamatarianism
Aug 17 2016 05:41
here filter[orderby]=rand should fetch some random quote right ?
This message was deleted
This message was deleted
oh wait sorry I misread
my point kinda stands though.
I'd just generate a random number and hit the API with that
Angel J Piscola
@Redmega
Aug 17 2016 05:44
@Masd925 my destroyer is shorter than yours! (ignoring the jshint comment)
/* jshint esversion:6 */
function destroyer(arr) {
  var r = [].splice.call(arguments,1);
  return arguments[0].filter((x)=>{return !~r.indexOf(x);});
}
Just barely
llamatarianism
@llamatarianism
Aug 17 2016 05:44
@Redmega !~ ew
Angel J Piscola
@Redmega
Aug 17 2016 05:44
SHh! ITS BEAUTIFUL
llamatarianism
@llamatarianism
Aug 17 2016 05:44
also if we're using ES6 stuff and we only care about conciseness
Angel J Piscola
@Redmega
Aug 17 2016 05:45
More elegant than >-1 :P
llamatarianism
@llamatarianism
Aug 17 2016 05:45
you can make it significantly shorter
Angel J Piscola
@Redmega
Aug 17 2016 05:45
OH, I know
This is just what I could come up with off the top of my head
llamatarianism
@llamatarianism
Aug 17 2016 05:45
destroyer=(a,...r)=>a.filter(x=>!~r.indexOf(x));
Markus Kiili
@Masd925
Aug 17 2016 05:45
@Redmega My solution avoids browser optimization problems connected with slicing arguments, so it has different goals than your solution.
Angel J Piscola
@Redmega
Aug 17 2016 05:46
@Masd925 I didn't slice, I spliced ;)
llamatarianism
@llamatarianism
Aug 17 2016 05:46
anyway
without going completely overboard on the golf
Angel J Piscola
@Redmega
Aug 17 2016 05:46
@llamatarianism Lambdas are beautiful things
llamatarianism
@llamatarianism
Aug 17 2016 05:46
you can make some improvements to that without changing the semantics
function destroyer(arr, ...args) {
  return arr.filter(x => !args.includes(x));
}
Angel J Piscola
@Redmega
Aug 17 2016 05:48
@llamatarianism I'm a noob at golf and the es6 stuff. You're opening my eyes here.
I need to spend longer trolling the MDN, I forgot about includes()
llamatarianism
@llamatarianism
Aug 17 2016 05:49
!r.includes actually isn't shorter than !~r.indexOf
so for once
it's fine to use the clearer version in code golf
arif hussain
@arifhussain0
Aug 17 2016 05:49
hello need help
llamatarianism
@llamatarianism
Aug 17 2016 05:50
@arifhussain0 :wave:
Angel J Piscola
@Redmega
Aug 17 2016 05:50
includes reads cleaner though
arif hussain
@arifhussain0
Aug 17 2016 05:50
it says translatePigLatin("glove") should return "oveglay".
sagar manghnani
@sagarmanghnani
Aug 17 2016 05:50

guys need some help on profile lookup problem don't know what i am doing wrong

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

Angel J Piscola
@Redmega
Aug 17 2016 05:50
Oh thas what you said isnt it
llamatarianism
@llamatarianism
Aug 17 2016 05:50
@arifhussain0 yes
arif hussain
@arifhussain0
Aug 17 2016 05:50
shouldn't it return "lovegay"
Angel J Piscola
@Redmega
Aug 17 2016 05:50
@sagarmanghnani Put three backticks before and after your code to format it. ```
llamatarianism
@llamatarianism
Aug 17 2016 05:50
nope
Travis Terrell
@travterrell
Aug 17 2016 05:50
Does anyone know how to solve the Manipulating Complex Objects challenge?
llamatarianism
@llamatarianism
Aug 17 2016 05:50
you take off all the consonants at the start
("gl")
and put them at the end
("ovegl")
then you add "ay"
Travis Terrell
@travterrell
Aug 17 2016 05:51
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
arif hussain
@arifhussain0
Aug 17 2016 05:51
i thought i am supposed to take just the first consonent
Travis Terrell
@travterrell
Aug 17 2016 05:51
How do you add another album to this complex array?
llamatarianism
@llamatarianism
Aug 17 2016 05:51
@arifhussain0 no, you take all the consonants up until there's a vowel
arif hussain
@arifhussain0
Aug 17 2016 05:51
thanks :)
llamatarianism
@llamatarianism
Aug 17 2016 05:51
for example
"throw" should be "owthray"
@travterrell the same way you add anything else to an array
Markus Kiili
@Masd925
Aug 17 2016 05:52
@travterrell You have to access the property value that has the array and push to it.
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 05:52
Hey guys can anyone explain to me what i'm doing wrong:
llamatarianism
@llamatarianism
Aug 17 2016 05:52
just put a comma after the last element
and put something in there
between the square brackets
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 05:52

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

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

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

sagar manghnani
@sagarmanghnani
Aug 17 2016 05:52
function lookUpProfile(firstName, prop){ // Only change code below this line var status; for(var i = 0;i<4;i++) { if(contacts[i].firstName === firstName) { if(contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } else { status = "No such property"; } } else { status = "No such contact"; } } return status; // Only change code above this line }
Angel J Piscola
@Redmega
Aug 17 2016 05:52
@travterrell try .push()
@tonyjrkamanga Need the backticks after your code too
llamatarianism
@llamatarianism
Aug 17 2016 05:52
@tonyjrkamanga myObj.checkProp is myObj["checkProp"]
it's different to myObj[checkProp]
if you're trying to access a property using a variable, you have to use bracket notation
Travis Terrell
@travterrell
Aug 17 2016 05:53
I will try your suggestions. Thanks
Blauelf
@Blauelf
Aug 17 2016 05:53
@sagarmanghnani Triple backticks need their own lines. Add line breaks with Shift+Return.
And don't set status to "No such contact" inside the loop. One way would be to return the property value or "No such property" from within the loop, as those values will immediately be determined, but return "No such contact" only after the loop.
Other way would be to initialize status to "No such contact", and replace it by property value or "No such property" on name match (but never do something on name mismatch in the loop)
sagar manghnani
@sagarmanghnani
Aug 17 2016 05:55

```function lookUpProfile(firstName, prop){

// Only change code below this line

var status;

for(var i = 0;i<4;i++)

{

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

    {

      if(contacts[i].hasOwnProperty(prop))

        {

          return contacts[i][prop];

        }

      else

        {

          status = "No such property";

        }

    }

  else

    {

      status = "No such contact";

    }

}

return status;

// Only change code above this line

}```

lazy_bunny
@lazyCoder036
Aug 17 2016 05:56
Hi need help with truncate problem javascript
can any one help
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 05:56
js
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
no idea what im doing wrong
Blauelf
@Blauelf
Aug 17 2016 05:57
@sagarmanghnani Triple backticks need their own lines. Add line breaks with Shift+Return.
lazy_bunny
@lazyCoder036
Aug 17 2016 05:57

function truncateString(str, num) {
    // Clear out that junk in your trunk
    if(str.length > num){
        str = str.slice(0,num);
        console.log(str);
        if(num > 3){
            str = str.slice(0,-3) + "...";
            return str;
        }
        else{
            return str + "..."
        }
    }
    else{
        return str;
    }
}

console.log(truncateString("Absolutely Longer", 2));
Angel J Piscola
@Redmega
Aug 17 2016 05:57
@tonyjrkamanga try myObj[checkProp]
lazy_bunny
@lazyCoder036
Aug 17 2016 05:57
can any one please optimize this code
its bulky and ugly as hell :/
Blauelf
@Blauelf
Aug 17 2016 05:57
@tonyjrkamanga Change from dot notation to bracket notation, as you were told. myObj.checkProp is same as myObj["checkProp"].
lazy_bunny
@lazyCoder036
Aug 17 2016 05:58
anyone :worried:
Blauelf
@Blauelf
Aug 17 2016 05:59
@mitul036 you could have an if-elseif-else with three return statements, or two to three assignments and one return. The flat structure looks a bit cleaner.
sagar manghnani
@sagarmanghnani
Aug 17 2016 05:59
@Blauelf thanks for the help
CamperBot
@camperbot
Aug 17 2016 05:59
sagarmanghnani sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2371 | @blauelf |http://www.freecodecamp.com/blauelf
lazy_bunny
@lazyCoder036
Aug 17 2016 06:00
@Blauelf thanks
CamperBot
@camperbot
Aug 17 2016 06:00
mitul036 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2372 | @blauelf |http://www.freecodecamp.com/blauelf
Chris Cullen
@123xylem
Aug 17 2016 06:00

$("#equals").click(function() {
var answer= values.replace(\s)/g, "").split("");
  console.log(answer);  $("#display").text(values);
});
trying to get an array of my calc in total without spaces. ANy idea why its not working?
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 06:00
@Redmega @mitul036 @Blauelf return myObj["checkProp"]; gives me warning of myObj["checkProp"] is better with dot notation and still doesnt give desired result
Angel J Piscola
@Redmega
Aug 17 2016 06:01
@tonyjrkamanga Think of what the value of checkProp is, and think of what you're asking for when you use "checkProp"
Blauelf
@Blauelf
Aug 17 2016 06:01
@mitul036
function truncateString(str, num) {
  if (str.length <= num) {
    return str;
  } else if (num > 3) {
    return str.slice(0, num - 3) + "...";
  } else {
    return str.slice(0, num) + "...";
  }
}
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 06:01
@tonyjrkamanga myObj[checkProp] works thanks for the help
CamperBot
@camperbot
Aug 17 2016 06:01
sorry tonyjrkamanga, you can't send brownie points to yourself! :sparkles: :sparkles:
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 06:01
@Redmega myObj[checkProp] works thanks for the help
CamperBot
@camperbot
Aug 17 2016 06:01
tonyjrkamanga sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 79 | @redmega |http://www.freecodecamp.com/redmega
Angel J Piscola
@Redmega
Aug 17 2016 06:02
@tonyjrkamanga There you go :D
lazy_bunny
@lazyCoder036
Aug 17 2016 06:02
@tonyjrkamanga I am very new to this, but can you give one suggestion, when ever you work with object always use [] notation
it will be less confusing
jamesmillerho
@jamesmillerho
Aug 17 2016 06:02
@mitul036
compact code
function truncateString(str, num) {
  return num>=4 ?str.length > num ?str.slice(0, num-3) + "..." :str 
  :str.slice(0, num) + "...";
}
Angel J Piscola
@Redmega
Aug 17 2016 06:02
@llamatarianism Any faster way to sort numerically?
/* jshint esversion:6 */
function getIndexToIns(arr, num) {
  arr.push(num);
  return arr.sort((x,y) => x-y).indexOf(num);
}
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 06:02
@mitul036 thanks for the suggestion
CamperBot
@camperbot
Aug 17 2016 06:02
tonyjrkamanga sends brownie points to @mitul036 :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @mitul036 |http://www.freecodecamp.com/mitul036
Blauelf
@Blauelf
Aug 17 2016 06:02
@tonyjrkamanga Those two, dot without quotation marks and bracket with quotation marks, were the same, we wanted to show you that you were using a static property name where you wanted to use a variable instead.
lazy_bunny
@lazyCoder036
Aug 17 2016 06:02
@jamesmillerho your code is terny as hell
llamatarianism
@llamatarianism
Aug 17 2016 06:02
@Redmega nah not really
jamesmillerho
@jamesmillerho
Aug 17 2016 06:03
@mitul036 lol
Angel J Piscola
@Redmega
Aug 17 2016 06:03
@mitul036 Basically playing code golf ;)
Tony Kamanga Jr
@tonyjrkamanga
Aug 17 2016 06:03
@Blauelf oooh alright i get it
lazy_bunny
@lazyCoder036
Aug 17 2016 06:03
@jamesmillerho it will decade to write a code like that :P
Blauelf
@Blauelf
Aug 17 2016 06:03
@mitul036 That way it would be console["log"]("Hello, World!"); ;)
llamatarianism
@llamatarianism
Aug 17 2016 06:03
I'm fine with nested ternaries, as long as they're like this:
Markus Kiili
@Masd925
Aug 17 2016 06:04
@mitul036 You can always use bracket notation but some people prefer using the dot notation when it works, because it makes object property access look different from array element access. Perhaps makes code easier to read.
llamatarianism
@llamatarianism
Aug 17 2016 06:04
condition ? thing : 
condition ? thing : 
condition ? thing : 
            thing;
^ I'd still never write that, but at least I can tell what it's doing reasonably easily at a glance
whereas ternaries like this:
Angel J Piscola
@Redmega
Aug 17 2016 06:05
I just found a great bookmark for es6: https://github.com/DrkSephy/es6-cheatsheet
sagar manghnani
@sagarmanghnani
Aug 17 2016 06:05
@Blauelf with your help my code worked but i still can't find the reason where i was in logic. please explain
llamatarianism
@llamatarianism
Aug 17 2016 06:05
condition ? 
  (condition ?
    (condition ? thing : thing)
   : thing)
: thing
lazy_bunny
@lazyCoder036
Aug 17 2016 06:05
@Masd925 absolutely agree with you. But I am code noob and it was really confusing when I try to pass variable as object properties name.
llamatarianism
@llamatarianism
Aug 17 2016 06:05
^ is gross
lazy_bunny
@lazyCoder036
Aug 17 2016 06:05
to me bracket notation always work
I prefer @Blauelf code
it simple to read and easy to understand
from my point of view
Angel J Piscola
@Redmega
Aug 17 2016 06:06
tbh tho es6 belongs mainly in the backend until browser support is up there.
Blauelf
@Blauelf
Aug 17 2016 06:07

@Redmega Faster would be not sorting, like

/* jshint esversion:6 */
function getIndexToIns(arr, num) {
  return arr.reduce((counter,elem) => counter + (elem < num), 0);
}

(or an equivalent for-loop, this counts the elements less than num, order does not matter)

Angel J Piscola
@Redmega
Aug 17 2016 06:07
I wouldnt use it on any production site in the browse
@Blauelf Still wrapping my head around reduce, which is why i tend to avoid it
pahosler
@pahosler
Aug 17 2016 06:08
once reduce clicks with you you will think it's awesome!
lot
Angel J Piscola
@Redmega
Aug 17 2016 06:08
Yeah I'm always hearing praises about map reduce and how efficient and great it is
Just have to spend more time with it i guess
pahosler
@pahosler
Aug 17 2016 06:08
lots of reasons to use it instead of for loops
Blauelf
@Blauelf
Aug 17 2016 06:08
@sagarmanghnani When your first contact had a matching name, but not the property, you would set status to "No such property". On the next contact, with non-matching name, you would replace it with "No such contact", which is obviously wrong.
pahosler
@pahosler
Aug 17 2016 06:09
there is an article in the fcc wiki, I read that and BAM! I just got it
llamatarianism
@llamatarianism
Aug 17 2016 06:10
@Redmega it's not really any more efficient
depends how you use it
if you're doing this:
Blauelf
@Blauelf
Aug 17 2016 06:11
For-loop is still faster:
function getIndexToIns(arr, num) {
  var counter = 0;
  for (var i = 0, len = arr.length; i < len; i++) {
    counter += (arr[i] < num);
  }
  return counter;
}
llamatarianism
@llamatarianism
Aug 17 2016 06:11
var newArr = [];
for (let item of arr) {
  newArr.push(fun(item));
}
sagar manghnani
@sagarmanghnani
Aug 17 2016 06:11
@Blauelf i understood, thanks again
CamperBot
@camperbot
Aug 17 2016 06:11
sagarmanghnani sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: sagarmanghnani already gave blauelf points
llamatarianism
@llamatarianism
Aug 17 2016 06:11
then using map won't be more efficient, but it'll be way less gross
if you're doing this:
Angel J Piscola
@Redmega
Aug 17 2016 06:12
@llamatarianism This is the first time I'm seeing for (let item of arr)
llamatarianism
@llamatarianism
Aug 17 2016 06:12
for (let i = 0; i < arr.length; i++) {
  arr[i] = fun(arr[i]);
}
then doing arr = arr.map(fun) will only take up extra space
and give the GC more stuff to do
pahosler
@pahosler
Aug 17 2016 06:12
let is sorta newish
Angel J Piscola
@Redmega
Aug 17 2016 06:12
I know about let
llamatarianism
@llamatarianism
Aug 17 2016 06:12
@Redmega for of is like for in in sensible languages
pahosler
@pahosler
Aug 17 2016 06:12
ES6... correct?
Angel J Piscola
@Redmega
Aug 17 2016 06:12
Yeah, I just found it on MDN @llamatarianism
llamatarianism
@llamatarianism
Aug 17 2016 06:13
new_list = []
for item in list:
    new_list.append(fun(item))
^ equivalent python
Angel J Piscola
@Redmega
Aug 17 2016 06:13
It always boggled me that for in gave me index
I mean, I get why. It enumerates the properties
But, I didn't get why
pahosler
@pahosler
Aug 17 2016 06:13
you can do for in in js too
Blauelf
@Blauelf
Aug 17 2016 06:13
@Redmega for-in is not made for arrays, but for object properties, that's why.
Angel J Piscola
@Redmega
Aug 17 2016 06:14
@Blauelf Yeah, I learned that eventually. Hence the past tense ;)
llamatarianism
@llamatarianism
Aug 17 2016 06:15
but yeah
the thing about map and filter is they create entirely new arrays
Blauelf
@Blauelf
Aug 17 2016 06:15
@Redmega Oh, right, simple past, not present perfect.
llamatarianism
@llamatarianism
Aug 17 2016 06:15
which means they take up a lot of space
functional languages solve this by offering lazily evaluated versions
Angel J Piscola
@Redmega
Aug 17 2016 06:15
Yeah
llamatarianism
@llamatarianism
Aug 17 2016 06:15
that just use a thunk that computes all the filtering and mapping and flattening in one pass
not JS though
because JS is not a functional programming language
FIGHT ME
Angel J Piscola
@Redmega
Aug 17 2016 06:16
Lol
llamatarianism
@llamatarianism
Aug 17 2016 06:16
const xs = [];
xs.push(5);
muh const
arif hussain
@arifhussain0
Aug 17 2016 06:16
can i do arr[1].push() to make 1D array into 2D ??
Angel J Piscola
@Redmega
Aug 17 2016 06:16
Rxjs seeks to make it functional
Blauelf
@Blauelf
Aug 17 2016 06:16
@llamatarianism In many cases I actually prefer a new copy when mutable structures are involved.
Angel J Piscola
@Redmega
Aug 17 2016 06:16
only if arr[1] is already a []
@arifhussain0
Surbhi Oberoi
@surbhioberoi
Aug 17 2016 06:17
i have a bug in jquery code, can someone help?
llamatarianism
@llamatarianism
Aug 17 2016 06:17
@Blauelf I like getting new copies too
arif hussain
@arifhussain0
Aug 17 2016 06:17
arr is initially 1D array
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:17
function reverseString(str) {
 var reverseString =str.split('').reverse().join('');
}

reverseString("hello");
llamatarianism
@llamatarianism
Aug 17 2016 06:17
I just don't like it when those new copies are eagerly evaluated
arif hussain
@arifhussain0
Aug 17 2016 06:17
@Redmega
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:17
why it didn,t worke?
work
Angel J Piscola
@Redmega
Aug 17 2016 06:17
@Jonhnwhantcoding what does the function return?
Blauelf
@Blauelf
Aug 17 2016 06:17
This message was deleted
Angel J Piscola
@Redmega
Aug 17 2016 06:17
@Blauelf Wanted him to say "undefined" :(
Anyway...
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:18
dine guys thanks
done
:D
Angel J Piscola
@Redmega
Aug 17 2016 06:18

It's too late for caesars cipher...

Sadly I'll probably forget a lot of the knowledge y'all are dropping by tomorrow... I've been slacking on my FCC, works been keeping me busy. Hopefully I'll complete my portfolio at some point...

I have work in... Wow, 6 hours. Oh boy.
Good night everyone
llamatarianism
@llamatarianism
Aug 17 2016 06:20
@Redmega :wave:
pahosler
@pahosler
Aug 17 2016 06:21
l8r
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:28
function factorialize(num) {
  var z = 0;
  for (n = 2; n <= num; n++) {
    z = z *n;
return num;
  }
}

factorialize(5);
why it didn,t work?
arif hussain
@arifhussain0
Aug 17 2016 06:29
because z=0
Tien
@TienDo1011
Aug 17 2016 06:29
Anyone has problem with "No repeats please"?, i believe my code is correct but the test still say it's wrong
Aditya
@ezioda004
Aug 17 2016 06:29
@Jonhnwhantcoding because youre multiplying 0 everytime with n.
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:29
function factorialize(num) {
  var z = 1;
  for (n = 2; n <= num; n++) {
    z = z *n;
return num;
  }
}

factorialize(5);
Tien
@TienDo1011
Aug 17 2016 06:30
This message was deleted
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:30
it didn,t work
Markus Kiili
@Masd925
Aug 17 2016 06:30
@Jonhnwhantcoding Maybe return something else?
arif hussain
@arifhussain0
Aug 17 2016 06:31
@Jonhnwhantcoding return z
Tien
@TienDo1011
Aug 17 2016 06:31
var result = [];
var finalResult = [];

function permAlone(str) {
  var strArr = str.split("");
  generate(strArr.length, strArr);
  for(var i = 0; i < result.length; i ++) {
    if(!(/([a-z])\1/).test(result[i])) {
      finalResult.push(result[i]);
    }
  }
  return finalResult.length;
}

function generate(n, arr) {
  if(n == 1) {
    var arrResult = arr.join("");
    result.push(arrResult);
    return;
  }
    for(var i = 0; i < n; i++) {
      generate(n - 1, arr);
      if(n % 2 === 0) {
        swap(arr, i, n - 1);
      } else {
        swap(arr, 0, n - 1);
      }
    }
}

function swap(arr, idxA, idxB) {
  var tmp = arr[idxA];
  arr[idxA] = arr[idxB];
  arr[idxB] = tmp;
}

permAlone('aab');
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:32
@arifhussain0 didn,t work
Markus Kiili
@Masd925
Aug 17 2016 06:32
@TienDo1011 Global variables mess up FCC tests.
Tien
@TienDo1011
Aug 17 2016 06:32
ok i see, let me change it
arif hussain
@arifhussain0
Aug 17 2016 06:32
@Masd925 can i make a 1D array a 2D array by arr[i].push() in for loop
for the DNA exercise??
Markus Kiili
@Masd925
Aug 17 2016 06:33
@arifhussain0 You can push arrays to an array, thus making arrays elements arrays.
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:33
function factorialize(num) {
  var z = 1;
  for (var n = 2; n <= num; n++) {
    z  = z *n;
return num ;
  }
}

factorialize(5);
Markus Kiili
@Masd925
Aug 17 2016 06:34
@Jonhnwhantcoding Don't return num.
llamatarianism
@llamatarianism
Aug 17 2016 06:34
@TienDo1011 try doing permAlone('aab') multiple times in a row
the result gets bigger every time because you're using global variables
Joni petriashvili
@Jonhnwhantcoding
Aug 17 2016 06:34
function factorialize(num) {
  var z = 1;
  for (var n = 2; n <= num; n++) {
    z  = z *n;
return z ;
  }
}

factorialize(5);
llamatarianism
@llamatarianism
Aug 17 2016 06:34
@Jonhnwhantcoding if you return inside the loop
the loop will end
Tien
@TienDo1011
Aug 17 2016 06:36
@llamatarianism: Let me try to change that, i just need to push global variable into the permAlone function, right?
llamatarianism
@llamatarianism
Aug 17 2016 06:36
@TienDo1011 yeah. make it local, so that it gets reset every time you run the function
Markus Kiili
@Masd925
Aug 17 2016 06:38
@TienDo1011 You can always make a wrapper function that has the variables and calls the other functions.
Tien
@TienDo1011
Aug 17 2016 06:40

function permAlone(str) {
  var result = [];
  var finalResult = [];
  var strArr = str.split("");
  generate(strArr.length, strArr, result);
  for(var i = 0; i < result.length; i ++) {
    if(!(/([a-z])\1/).test(result[i])) {
      finalResult.push(result[i]);
    }
  }
  return finalResult.length;
}

function generate(n, arr, result) {
  if(n == 1) {
    var arrResult = arr.join("");
    result = result.push(arrResult);
    return;
  }
    for(var i = 0; i < n; i++) {
      generate(n - 1, arr);
      if(n % 2 === 0) {
        swap(arr, i, n - 1);
      } else {
        swap(arr, 0, n - 1);
      }
    }
}

function swap(arr, idxA, idxB) {
  var tmp = arr[idxA];
  arr[idxA] = arr[idxB];
  arr[idxB] = tmp;
}

permAlone('aab');
I got the push function not defined error
jamesmillerho
@jamesmillerho
Aug 17 2016 06:40
@TienDo1011 put generate and swap in permAlone
Tien
@TienDo1011
Aug 17 2016 06:40
Hjx
@jamesmillerho: But it wont look clean, how do i put it outside and still can use it?
Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:44
@llamatarianism I do it the llama way ;P
condn
  ? true
  : false
llamatarianism
@llamatarianism
Aug 17 2016 06:44
@abhisekp eugh
well I suppose I can't complain too hard about JS being ugly
most JS is ugly.
Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:45
:expressionless:
Markus Kiili
@Masd925
Aug 17 2016 06:47
@TienDo1011 If you wan't to make it pretty, you need to use some math, I think.
lazy_bunny
@lazyCoder036
Aug 17 2016 06:47
can any one please give a cleaner version of this code :D

function chunkArrayInGroups(arr, size) {
    var holder =[];
    for(var i = 0, j = 0; i < arr.length/size ; i++ , j= j + size)
    {
        holder[i] = arr.slice(j,j+size);
    }
    return holder;
}

console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2));
is it possible to execute this code with out the for loop
???
Markus Kiili
@Masd925
Aug 17 2016 06:49
@mitul036
function chunkArrayInGroups(arr, size) {
  var result = [];
  for (var i=0; i<arr.length; i+=size) {
    result.push(arr.slice(i,i+size));
  }
  return result;
}
kn1ghtdave
@kn1ghtdave
Aug 17 2016 06:49
```
for ( var i = 0; i < contacts.length; i++ ){

    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
          return contacts[i][prop]; 
        } else if (!contacts[i].hasOwnProperty(firstName)){
          return "No such contact";
        } 
   }
Markus Kiili
@Masd925
Aug 17 2016 06:49
@mitul036 You can also use while loop, reduce, or recursion.
jamesmillerho
@jamesmillerho
Aug 17 2016 06:50
@mitul036
function chunkArrayInGroups(arr, size) {
  return arr.length?[arr.splice(0,size)].concat(chunk(arr,size)):[];
}
// written by: blauelf
arif hussain
@arifhussain0
Aug 17 2016 06:50

function fearNotLetter(str) {
for (var i=0;i<str.length-1;i++)
{
if(1+str.charCodeAt(i)!==str.charCodeAt(i+1))
{
return String.fromCharCode(str.charCodeAt(i)+1);
}
}
return "undefined";

}

fearNotLetter("yz");

lazy_bunny
@lazyCoder036
Aug 17 2016 06:50
@Masd925 I am familiar with while loop. What is reduce and recusion
kn1ghtdave
@kn1ghtdave
Aug 17 2016 06:50

Hi guys, I was trying to check the firstName in the contact list. However, it keeps returning No such contact...

Any help please?

Jae
@jhshim1990
Aug 17 2016 06:50
Hello can someone help me
I'm on Javascript word blank and have the code as below
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun = "dog";
myAdjective = "big";
myVerb = "ran";
myAdverb = "quickly";
result = "My " + myNoun + " was a " + myAdjective + " animal that " + myVerb + " very " + myAdverb +".";
// Your code above this line
return result;
}
// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
lazy_bunny
@lazyCoder036
Aug 17 2016 06:51
@jamesmillerho damn :/
jamesmillerho
@jamesmillerho
Aug 17 2016 06:51
chunk should be chunkArrayInGroups - I changed the function name
llamatarianism
@llamatarianism
Aug 17 2016 06:51
@abhisekp :point_up: see what @jamesmillerho just posted?
Jae
@jhshim1990
Aug 17 2016 06:51
I don't understand the last question asking to change to wordblanks to cat litte hit etc
llamatarianism
@llamatarianism
Aug 17 2016 06:51
a prime example of JS being ugly.
arif hussain
@arifhussain0
Aug 17 2016 06:51

function fearNotLetter(str) {
for (var i=0;i<str.length-1;i++)
{
if(1+str.charCodeAt(i)!==str.charCodeAt(i+1))
{
return String.fromCharCode(str.charCodeAt(i)+1);
}
}
return "undefined";

}

fearNotLetter("yz");

why this fails test here although it returns undefined as per the requirements??
@Masd925 @llamatarianism

jamesmillerho
@jamesmillerho
Aug 17 2016 06:51
@llamatarianism how
lazy_bunny
@lazyCoder036
Aug 17 2016 06:52
@jamesmillerho to understand your code I need to go to the MOON :P
Markus Kiili
@Masd925
Aug 17 2016 06:52
@mitul036 Reduce is the most general array iterator. You could use it to solve that problem. Recursive solution would most likely chop off the first slice and then call the same function again.
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 17 2016 06:52
I agree it's ugly :3
llamatarianism
@llamatarianism
Aug 17 2016 06:52
chunk _ [] = []
chunk n xs = take n xs : chunk n (drop n xs)
a very rare example
of haskell being pretty
Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:52
lol... pretty LOLOLOL
lazy_bunny
@lazyCoder036
Aug 17 2016 06:53
@Masd925 any reference
llamatarianism
@llamatarianism
Aug 17 2016 06:53
yep
much prettier than the equivalent JS
arif hussain
@arifhussain0
Aug 17 2016 06:53
problem solved :)
Markus Kiili
@Masd925
Aug 17 2016 06:54
@mitul036 You have to look what FCC has and google some more. MDN is a trusty source.
llamatarianism
@llamatarianism
Aug 17 2016 06:54
even the equivalent ocaml looks better, and ocaml is the grandaddy of ugly.
let rec chunk n = function
| [] -> []
| xs -> List.take n xs :: chunk n (List.drop n xs);;
lazy_bunny
@lazyCoder036
Aug 17 2016 06:54
@Masd925 found one :D
@Masd925 thanks :D
CamperBot
@camperbot
Aug 17 2016 06:54
mitul036 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2304 | @masd925 |http://www.freecodecamp.com/masd925
jamesmillerho
@jamesmillerho
Aug 17 2016 06:55
what is the prettiest language?
Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:56
i guess the Llama likes assembly
Adriana
@Adrianacmy
Aug 17 2016 06:56
Hi, anybody can help with Profile Lookup

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var x in contacts){
if( x[firstName] === firstName && x[prop] !== ""){
arr = [];
for (var y = 0; y < x[prop].length; y++){
arr.push(x[prop][y]);
}
return arr;

}else if(firstName !== x.firstName) {
  return "No such contact";

}else if(!x.hasOwnProperty(prop)){
  return "No such property";
}

}

// Only change code above this line
}

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

llamatarianism
@llamatarianism
Aug 17 2016 06:56
I dunno
what you find pretty depends on you
Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:56
you like assembly i know
llamatarianism
@llamatarianism
Aug 17 2016 06:57
plus there are plenty of pretty things in ugly languages
perl has some pretty stuff in it
@abhisekp looks better than JS
Adriana
@Adrianacmy
Aug 17 2016 06:58
anybody can help me check the codes above?
Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:58
:expressionless: :exclamation:
explain format
CamperBot
@camperbot
Aug 17 2016 06:58

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Abhisek Pattnaik
@abhisekp
Aug 17 2016 06:58
@VenusGrape :point_up: August 17, 2016 12:28 PM
lazy_bunny
@lazyCoder036
Aug 17 2016 06:59
@VenusGrape type this "```" and then paste your code.
press ctrl + enter to submit your code
Adriana
@Adrianacmy
Aug 17 2016 07:00
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var x in contacts){
    if( x[firstName] === firstName && x[prop] !== ""){
      arr = [];
      for (var y = 0; y < x[prop].length; y++){
        arr.push(x[prop][y]);  
      }
      return arr;

    }else if(firstName !== x.firstName) {
      return "No such contact";

    }else if(!x.hasOwnProperty(prop)){
      return "No such property";
    }

  }



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Thanks
lazy_bunny
@lazyCoder036
Aug 17 2016 07:01
instead of x.firstName use x[firstName]
@VenusGrape console both x.firstName and x[firstName] and you will get the idea.
jamesmillerho
@jamesmillerho
Aug 17 2016 07:02
@VenusGrape
else if(firstName !== x.firstName) {
return "No such contact";
  1. it is contacts[x].firstName
  2. if contacts1.firstName === firstName, but contact[0].firstName !== firstName, it returns "No such contact" and stops the function
llamatarianism
@llamatarianism
Aug 17 2016 07:04
@VenusGrape that's not how for in works
lazy_bunny
@lazyCoder036
Aug 17 2016 07:04
@jamesmillerho even though I think contacts[x].firstname will not work
llamatarianism
@llamatarianism
Aug 17 2016 07:04
for in iterates through the keys of an object
jamesmillerho
@jamesmillerho
Aug 17 2016 07:04
it works
llamatarianism
@llamatarianism
Aug 17 2016 07:04
so for in on an array iterates through the indices in an array.
for (var i in arr) is almost the same as for (var i = 0; i < arr.length; i++)
Tien
@TienDo1011
Aug 17 2016 07:09
@Masd925 @llamatarianism Thanks guys, Let's me see what i can do with it
CamperBot
@camperbot
Aug 17 2016 07:09
tiendo1011 sends brownie points to @masd925 and @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1210 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:star2: 2305 | @masd925 |http://www.freecodecamp.com/masd925
Amandeep Saxena
@AmandeepSaxena
Aug 17 2016 07:10
can anyone plss tell wats wrong here..??

var myStr = "I am a \"double quoted\" string inside \" double quotes\" ." ; // Change this line
error am getting: Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
Benjam Wondafrash
@BenjamWondafrash
Aug 17 2016 07:12
@AmandeepSaxena You have extra space in two places.
@AmandeepSaxena between inside double and right before dot at the end.
labeebahmad414
@labeebahmad414
Aug 17 2016 07:14

Why does following:

"ab".match(/(ab)/);

returns this:

["ab", "ab"]

Though "ab" appears once in the string "ab" , why has "ab" appeared twice in the array?

llamatarianism
@llamatarianism
Aug 17 2016 07:15
@labeebahmad414 "ab" is the entire string
"ab" is also the first captured group
try this:
"blahblahABXYblahblah".match(/(AB)XY/);
wait sorry I remembered wrong
"ab" is the entire string that was matched.
try it now that I've edited it.
Chris C.
@chrisamsterdam1986
Aug 17 2016 07:18
Hello all, I'm having quite a complex problem with some JS that I'm trying to figure out. Does anyone have the time to help me out?
Mateusz Szymański
@matszym
Aug 17 2016 07:19
@chrisamsterdam1986 Hey, I'll try. What is the problem?
Chris C.
@chrisamsterdam1986
Aug 17 2016 07:19
Hey @matszym , thanks!
CamperBot
@camperbot
Aug 17 2016 07:19
chrisamsterdam1986 sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 143 | @matszym |http://www.freecodecamp.com/matszym
Chris C.
@chrisamsterdam1986
Aug 17 2016 07:19
So, this is my website: www.happiness-design.com
As you can see, I'm a pretty good designer, however, my JS skills are lacking
So I hope you can help me out with the following
As soon as you hover over the title, it removes the text and writes: view project. As soon as you move away again, it will rewrite the text '100 day challenge'
However ... as s