These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Nov 2017
elpatron17
@elpatron17
Nov 20 2017 00:40
hi guys
I nee some help
could you help me please
What is wrong with the javascript here
elpatron17
@elpatron17
Nov 20 2017 00:45
it should display the input array as a list
FlashHero
@FlashHero
Nov 20 2017 00:52
@elpatron17 why do you have the for loop there when there's only going to be one item in an array since you're just pushing the value from input
@elpatron17 are you taking one url at a time or multiple because if you're just taking one url then you don't need that for loop since you only have one item in that array
Stephen James
@sjames1958gm
Nov 20 2017 00:56
@elpatron17 When an array is converted to string it comes out as value0, value1
@elpatron17 You also have a loop where you don't use the loop variable i
Ken Haduch
@khaduch
Nov 20 2017 01:00
@elpatron17 - can you give a description of how you are expecting this to work? A sequence of steps that you are trying to perform and the expected output?
Joshua Arnett
@josha5
Nov 20 2017 02:02
@sjames1958gm Hey james ran into another bug with setTimeout >.>
Stephen James
@sjames1958gm
Nov 20 2017 02:08
yes
Joshua Arnett
@josha5
Nov 20 2017 02:09
@sjames1958gm So after my replayFlash array is greater than 2 items when the function is called its playing those items at the same time instead of one after another
var clickNum = 0;
function correctClick(buttons) {
  $(".button").on("click", function() {
     var thisClick = $(this).attr("id");
     var matchBut = buttonPressValidate[clickNum];
     if(thisClick == matchBut) {
       clickNum++;
        setTimeout(function() {
          var replay = replayFlash(buttonPress);
          setTimeout(function() {
            var highLighted = highLightSquare($(simonButtons));
          }, 1500);
        }, 1500);  
    }
  });  
}
Stephen James
@sjames1958gm
Nov 20 2017 02:10
hmm
Joshua Arnett
@josha5
Nov 20 2017 02:11
function replayFlash(butPressArr) {
  function eachColor(i) {
    var litColor = $(butPressArr[i]);
    var originalColor = litColor.css("background-color");
    var highLight = litColor.css("background-color", "#ffcccc");
    setTimeout(function() {
      litColor.css("background-color", originalColor); 
    }, 1000 * (i + 1));  
  }
  butPressArr.map(function(x, i) {
    if(x === "#greenButton") {
      greenButton.play();   
    } else if (x === "#redButton") {
        redButton.play();         
    } else if(x === "#blueButton") {
        blueButton.play();
    } else if(x === "#yellowButton") {
        yellowButton.play();
    }
    eachColor(i);
   });

}
Stephen James
@sjames1958gm
Nov 20 2017 02:13
@josha5 When is correctClick called?
Joshua Arnett
@josha5
Nov 20 2017 02:13
Only problem I can see is within my setTimeouts I've changed a couple things around in both functions but can't get it to play the replayFlash buttons one after another
Stephen James
@sjames1958gm
Nov 20 2017 02:14
You have a fixed delay in the function that calls replayFlash, but a variabl timeout in replayFlash?
Joshua Arnett
@josha5
Nov 20 2017 02:14
Its called right below the correctClick function and before the replayFlash function
Stephen James
@sjames1958gm
Nov 20 2017 02:18
You don't have any timeouts between the setting of the background colors, so they will all happen at once.
You space out turning off the hightlight.
Maybe draw a timeline of when things happen and that would help
Joshua Arnett
@josha5
Nov 20 2017 02:21
@sjames1958gm thanks yeah all these setTimeouts are starting to get confusing
CamperBot
@camperbot
Nov 20 2017 02:21
josha5 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8700 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Joshua Arnett
@josha5
Nov 20 2017 02:27
So i understand the need for setTimeout for the background colors but the closures are getting me confused
Stephen James
@sjames1958gm
Nov 20 2017 02:31
You used to have two timeouts in eachColor where the first delayed the start of each hightlight and the second just turned it off.
You need to delay the start using i and the end can be a simple value
Joshua Arnett
@josha5
Nov 20 2017 02:53
Yeah the way I had it set up was with addClass though
I don't know why I'm not getting this might need to take a break haha
Stephen James
@sjames1958gm
Nov 20 2017 02:54
Sometimes it comes to you when you aren't trying to think about it
elpatron17
@elpatron17
Nov 20 2017 11:08
hello guys
I still stuck on js
could you help me?
Markus Kiili
@Masd925
Nov 20 2017 11:15
@elpatron17 Stuck where?
that's my code @Masd925
basically Im trying to display every single input in a new line
into the forward store
Stephen James
@sjames1958gm
Nov 20 2017 11:19
@elpatron17 You might explain what it is supposed to do and what it is doing.
Your for loop which doesn't use the loop variable i and just sets the innerHTML of an element to the same thing over and over seems odd
elpatron17
@elpatron17
Nov 20 2017 11:20
it's now working
when user put input
and press forward button it should appear on the forward store
but every single input on new line
Stephen James
@sjames1958gm
Nov 20 2017 11:23
It's now working? or not working?
elpatron17
@elpatron17
Nov 20 2017 11:23
I mean the loop is working
Stephen James
@sjames1958gm
Nov 20 2017 11:23
try using .value and not innerHTML
// Clear the value and add all the entries
document.getElementById("forwardOutput").value = "";
for ( i = 0; i < displayStackArr.length; i++) {
  document.getElementById("forwardOutput").value = displayStackArr[i] + "\r\n";
}
elpatron17
@elpatron17
Nov 20 2017 11:24
when the back button is clicked is should take the last element from the array and display it on the back store
Stephen James
@sjames1958gm
Nov 20 2017 11:26
Can you explain what your back function is doing?
elpatron17
@elpatron17
Nov 20 2017 11:27
so it takes the last element from the array
and display it on the back store
but it should be deleted from the forward store
this is example
Stephen James
@sjames1958gm
Nov 20 2017 11:30
Your back function now is removing the last entry from the list (throwing it away because you don't save the value return from pop)
and then it is putting the entire list into the back output?
You will need to have both a forward list and a backward list
elpatron17
@elpatron17
Nov 20 2017 11:31
how I can save the return value
exmp.jpg
example of how it would works
Stephen James
@sjames1958gm
Nov 20 2017 11:36
@elpatron17 save it on the backward list - assign to a variable -
var last = array.pop()
array.pop doesn't take a value
I would suggest using console.log in your function to understand what each line of code is doing.
elpatron17
@elpatron17
Nov 20 2017 11:38
I know what each line is doing
just stuck on how to display them in a new row
because "\n" is not working
Stephen James
@sjames1958gm
Nov 20 2017 11:44
Don't use innerHTML if you want newline to work
Tiago Correia
@tiagocorreiaalmeida
Nov 20 2017 11:44
@Masd925 I atually searched beyonce-yoga and atually im surprised with what I found
elpatron17
@elpatron17
Nov 20 2017 11:45
I changed it
Markus Kiili
@Masd925
Nov 20 2017 11:47
@tiagocorreiaalmeida I read about it in local newspaper.
is there a difference between var last and var backward?
elpatron17
@elpatron17
Nov 20 2017 12:08
@sjames1958gm
tundeiness
@tundeiness
Nov 20 2017 12:44
hi folks. I have a concern that needs to be addressed. I don't know if it's only me, but I think codepen does not behave like a normal browser. I mean I have had to alter somethings in codepen and when I get to real browsers it's not what I viewd exactly in codepen. Anyone with heads up on how to go about this?
Stephen James
@sjames1958gm
Nov 20 2017 12:44
@elpatron17
If you click back - it is supposed to remove the last value from front and move it to back?
Are you supposed to keep a list of value moved to back?
Stephen James
@sjames1958gm
Nov 20 2017 12:49
@tundeiness One thing I know of is that codepen runs your code in an iframe and the functions in the js are not visible to the HTML.
elpatron17
@elpatron17
Nov 20 2017 12:51
yes I am supposed to keep a list of value moved back
I have keep a list of forward stack aswell
Stephen James
@sjames1958gm
Nov 20 2017 12:51
@elpatron17 So you need a forward array and a backward array
tundeiness
@tundeiness
Nov 20 2017 12:51
@sjames1958gm yeah...but I need a solution right now...it's so frustrating
I made few changes
Seth
@sethdcd
Nov 20 2017 12:55
hi all,
i have an array called barn that i am pushing objects into. each object has three properties and i essentially want to iterate through all the data and return an empty array if any value is falsy, would this do the trick?
    barn.filter(function(val) {
        if ( !val.names || !val.types || !val.breeds ) {
            return emptyBarn;
        }
    });
Stephen James
@sjames1958gm
Nov 20 2017 12:56
@elpatron17
Not sure why you are popping twice (that will remove two values)
You aren't creating a backwards stack like you have forward
@sethdcd You want to remove entries that have falsy properties?
Seth
@sethdcd
Nov 20 2017 12:58
@sjames1958gm no i actually just need to detect if there are any falsy property values and if so return an empty array
@sjames1958gm i know i could achieve this with a loop, but im trying to be fancy with filter (if thats even the right method)
elpatron17
@elpatron17
Nov 20 2017 12:59
oo yeah my bad @sjames1958gm
so do I need a new array?
Stephen James
@sjames1958gm
Nov 20 2017 12:59
@sethdcd filter is really for removing specific entries from an array.
@elpatron17 If you want to store back and front stacks you do
Seth
@sethdcd
Nov 20 2017 12:59
@sjames1958gm oh i see, what method would you recommend?
Stephen James
@sjames1958gm
Nov 20 2017 13:00
@sethdcd You could use reduce.
array.reduce(function(acc, c) { 
   if ( !val.names || !val.types || !val.breeds ) {
      return [];
   }
   return acc;
}, array);
Seth
@sethdcd
Nov 20 2017 13:01
ah sweet thanks @sjames1958gm !
CamperBot
@camperbot
Nov 20 2017 13:01
sethdcd sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8701 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
elpatron17
@elpatron17
Nov 20 2017 13:02
Thanks @sjames1958gm
CamperBot
@camperbot
Nov 20 2017 13:02
elpatron17 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8702 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
elpatron17
@elpatron17
Nov 20 2017 13:03
is it storing in the same way as the forward array?
Stephen James
@sjames1958gm
Nov 20 2017 13:04
@elpatron17 Similar, I am not sure the order of the values in the backward array.
elpatron17
@elpatron17
Nov 20 2017 13:04
the last item popped from the forward is first in the back store
Stephen James
@sjames1958gm
Nov 20 2017 13:10
Then instead of .push you should use .unshift
elpatron17
@elpatron17
Nov 20 2017 13:14
did the function back is still the same?
Stephen James
@sjames1958gm
Nov 20 2017 13:16
@elpatron17
The back function should
  • remove value from front stack
  • add value to back stack
  • write front stack to page
  • write back static to page
elpatron17
@elpatron17
Nov 20 2017 13:17
yeah
how I can do this :worried:
it display the whole array now
Stephen James
@sjames1958gm
Nov 20 2017 13:21

@elpatron17 This code is wrong for front and back.
You have a for loop but you don't use i

for ( i = 0; i < displayStackArr.length; i++) {
document.getElementById("forwardOutput").value = displayStackArr + "\n";
}

See how this code outputs each value separately with the "\n" between each?

document.getElementById("forwardOutput").value = ""
for ( i = 0; i < displayStackArr.length; i++) {
document.getElementById("forwardOutput").value += displayStackArr[i] + "\n";
}
elpatron17
@elpatron17
Nov 20 2017 13:24
the second code does't work properly
Moisés Man
@moigithub
Nov 20 2017 13:25
and would be better if u store the element reference first on a variable...
so it dont repeteadly access/find in the dom
Henry
@GitHub-Henry
Nov 20 2017 13:25
Anyone using FF Dev Edition, thoughts about it would be appreciated.
that works 50%
so the thing I should do is to delete the last element from the forward store
when the back button is clicked
Moisés Man
@moigithub
Nov 20 2017 13:30
pop dont use any values
mdn.io/pop
and its removing.. but ur code not "refreshing" the "forward values" on the box
elpatron17
@elpatron17
Nov 20 2017 13:33
yes
and how I can refresh it
Moisés Man
@moigithub
Nov 20 2017 13:33
(almost) same way u doing on forward function
Stephen James
@sjames1958gm
Nov 20 2017 13:35
I would write a function that takes an array and an id and refreshes the box.
Then you can call this whenever needed
function updateBox(id, array) {
   var e = document.getElementById(id);
   e.value = ""
   for ( i = 0; i < array.length; i++) {
      e.value += array[i] + "\n";
   }
}
elpatron17
@elpatron17
Nov 20 2017 13:36
@moigithub I've tried but without any success
Stephen James
@sjames1958gm
Nov 20 2017 13:36
updateBox("forwardOutput", displayStackArr);
updateBox("backStore", backStackArr);
elpatron17
@elpatron17
Nov 20 2017 13:36
@sjames1958gm thanks man
CamperBot
@camperbot
Nov 20 2017 13:36
elpatron17 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
elpatron17
@elpatron17
Nov 20 2017 14:07
@sjames1958gm not working :(
Stephen James
@sjames1958gm
Nov 20 2017 14:26
@elpatron17 What does your latest code look like?
Are you using console.log to see what the variables look like during operation?
elpatron17
@elpatron17
Nov 20 2017 14:34
@sjames1958gm I'm not using console.log
Stephen James
@sjames1958gm
Nov 20 2017 14:34
@elpatron17 You should be to debug your code.
elpatron17
@elpatron17
Nov 20 2017 14:38
okay
@sjames1958gm thanks!
CamperBot
@camperbot
Nov 20 2017 14:38
elpatron17 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8703 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Nov 20 2017 14:39
@elpatron17 :+1:
Sohel-ASM
@Sohel-ASM
Nov 20 2017 16:40
will someone plz help me to figure out what's wrong with this code?
```

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

// Only change code below this line

var gloveBoxContents = myStorage.car["glove box"];

Blauelf
@Blauelf
Nov 20 2017 16:41
myStorage.car has two properties, "inside" and "outside".
Sohel-ASM
@Sohel-ASM
Nov 20 2017 16:41
@Blauelf Thank you. haven't noticed that.
CamperBot
@camperbot
Nov 20 2017 16:41
sohel-asm sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4655 | @blauelf |http://www.freecodecamp.org/blauelf
Markus Kiili
@Masd925
Nov 20 2017 16:43
@Sohel-ASM By indenting the code properly, you will see the object structure better.
Sohel-ASM
@Sohel-ASM
Nov 20 2017 16:45
It's from the exercise, I just wrote the last line. Thank you though. I'll remember that.
intcreate
@intcreate
Nov 20 2017 18:12
Anyone know how I can refactor this?
    // Reset option after new option chosen
    $('#state-filter').change(function(){
         $('#price-filter option:first').prop('selected', 'selected');
         $('#bathroom-filter option:first').prop('selected', 'selected');
         $('#bedroom-filter option:first').prop('selected', 'selected');
    });

    $('#price-filter').change(function(){
        $('#bathroom-filter option:first').prop('selected', 'selected');
        $('#bedroom-filter option:first').prop('selected', 'selected');
    });

    $('#bedroom-filter').change(function(){
        $('#price-filter option:first').prop('selected', 'selected');
        $('#bathroom-filter option:first').prop('selected', 'selected');
    });

    $('#bathroom-filter').change(function(){
        $('#price-filter option:first').prop('selected', 'selected');
        $('#bedroom-filter option:first').prop('selected', 'selected');
    });
Kaz Baig
@kbaig
Nov 20 2017 18:17
@intcreate Could you describe what the interaction is here? It seems to be some functionality with checkboxes but might be helpful to get a better idea
intcreate
@intcreate
Nov 20 2017 18:22
Its 4 filters for a house website
Christopher McCormack
@cmccormack
Nov 20 2017 18:25
@intcreate the last three are exactly the same so you could just use a class selector instead and just do it one time
Jason Luboff
@JLuboff
Nov 20 2017 18:26
@cmccormack They're slightly different
Christopher McCormack
@cmccormack
Nov 20 2017 18:26
oh yeah
my bad
Jason Luboff
@JLuboff
Nov 20 2017 18:27
I was thinking the same thing but... nah. I mean, he could create a function..but.. you're still going to have a wall of text (I think)
Tiago Correia
@tiagocorreiaalmeida
Nov 20 2017 18:35
the book app its quite long jesus :D
Jason Luboff
@JLuboff
Nov 20 2017 18:35
Yup. It's the longest code of any of my apps
Kaz Baig
@kbaig
Nov 20 2017 18:47
@intcreate I'd try to find a way to add/remove classes so that you only have one selector for each callback
Pieter Stokkink
@forkerino
Nov 20 2017 18:50
@intcreate only thing I would do is create a helper function which would reset the correct things (i.e. the things passed in as argument). So that inside the .change I could write something like reset('price', 'bedroom')
Jason Luboff
@JLuboff
Nov 20 2017 18:51
@forkerino :wave:
Pieter Stokkink
@forkerino
Nov 20 2017 18:51
:metal:
Jason Luboff
@JLuboff
Nov 20 2017 18:52
Whats up?
Pieter Stokkink
@forkerino
Nov 20 2017 18:52
very rainy day here, winter is coming.
Jason Luboff
@JLuboff
Nov 20 2017 18:53
:joy:
Heat wave incoming here... and :baby: incoming tomorrow night (inducing)
Pieter Stokkink
@forkerino
Nov 20 2017 18:54
oooh, nice
Kaz Baig
@kbaig
Nov 20 2017 18:54
Does 11 C count as a heatwave?
(~52F)
Jason Luboff
@JLuboff
Nov 20 2017 18:54
Ya nice to know a date finally
@kbaig if its hotter than normal? Sure
It's supposed to be 90* F here on Wednesday..
Kaz Baig
@kbaig
Nov 20 2017 18:55
It's still slightly below freezing in the mornings and night, ie when I'm outside sooo
Pieter Stokkink
@forkerino
Nov 20 2017 18:58
phew, 90 fahrenheit?!? Is that normal in November?
Here we are around 13 C, which is kinda warm for the time of year
Jason Luboff
@JLuboff
Nov 20 2017 18:59
Not really. I'm guessing we're getting East winds though, thats usually what brings a hot front like that.
Pieter Stokkink
@forkerino
Nov 20 2017 18:59
haven't seen any frost yet
Jason Luboff
@JLuboff
Nov 20 2017 18:59
We've been highs of 70-75 lately. Lows are in the 50's
Henry
@GitHub-Henry
Nov 20 2017 19:20
anyone tried FF Dev Edition would appreciate input about it
Henry
@GitHub-Henry
Nov 20 2017 19:28
just installed it, wow, tools for CSS Grid, and a built in tutorial on how to use it, so far , i like it
Christopher McCormack
@cmccormack
Nov 20 2017 19:31
very nice
haven't checked it out yet
Brad
@bradtaniguchi
Nov 20 2017 19:36
@GitHub-Henry I like it, mainly it takes up less ram than chrome. I was on Opera cuse it got to a point I couldn't handle it
I need to use it more though I've only scratched the surface, so its hard to tell
Henry
@GitHub-Henry
Nov 20 2017 19:38
@bradtaniguchi I just started with CSS Grid. I immediately thought some tooling was missing for it, looks like the folks at FF thought the same thing. I'm sure other browsers will catch up in this area, eventually...
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:03
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i ++) {
    if (firstName == contacts[i].firstName && prop == contacts[i].prop) {
      return contacts[i][prop];
    } else {
      return "No such property";
    }
  }
  return "No such contact";
Will someone please help me understand what I am doing wrong here?
It's from the "Profile Lookup" exercise?
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i ++) {
    if (firstName == contacts[i].firstName && prop == contacts[i].prop) {
      return contacts[i][prop];
    } else {
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
Kaz Baig
@kbaig
Nov 20 2017 20:04
@Sohel-ASM can you link it
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:05
@kbaig sure, just a sec
Kaz Baig
@kbaig
Nov 20 2017 20:08
@Sohel-ASM Two issues here I think
One is to do with your if/else
Your loop never makes it past the first iteration
Do you see why?
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:08
@kbaig not really
Kaz Baig
@kbaig
Nov 20 2017 20:09
Well in the event that the if statement doesn't pass, it's going to use the else statement, which has a return
So you're exiting the function before you can move on to the next iteration
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:12
@kbaig What should I do to solve it then?
Kaz Baig
@kbaig
Nov 20 2017 20:13
You only want to return 'no such property' if the contact exists right
So maybe you should instead be checking for just the contact first
You also only want to bother checking for the prop only if the contact exists
So maybe have that if statement within the firstname checking if statement
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:14
@kbaig so you are saying to separate the both && condition to two different if statement?
Kaz Baig
@kbaig
Nov 20 2017 20:15
@Sohel-ASM IMO that's the cleanest way. Because the if/else of whether the property exists or not only matters if you found the contact
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:15
@kbaig first if statement for checking the name, and then another nested if statement for checking the prop?
Kaz Baig
@kbaig
Nov 20 2017 20:15
Ye
The problem pretty much directs you to do it that way too
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:16
Alright, let me try it then, hopefully it will work, if it doesn't I 'll get back to you. Thank you though.
Kaz Baig
@kbaig
Nov 20 2017 20:16
@Sohel-ASM np. As I said, I think there's actually 2 issues so you'll still have a problem
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:18
@kbaig
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (firstName == contacts[i].firstName ) {
      if (prop == contacts[i].prop) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }
  }
// Only change code above this line
}
@kbaig still not working. what's the another issue?
Kaz Baig
@kbaig
Nov 20 2017 20:19
You're not checking to see if the contact has the prop, you're trying to match the value of the prop with the prop's name
so if have a contact named Kaz and I want his hobby's name
And in my object a contact with name Kaz and hobby Coding exists
Your code is checking to see if ('hobby' === 'Coding')
not if('hobby' exists)
Actually no that's not it either
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:21
@kbaig but when hobby exists, I am returning the value of the hobby.
Kaz Baig
@kbaig
Nov 20 2017 20:21
No that's not what's happening
And I'm also wrong about something else
In if (prop == contacts[i].prop)
contacts[i].prop is looking for a property called prop
which no contact is going to have
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:22
shall it be like
if (prop == contacts[i][prop]) ?
Kaz Baig
@kbaig
Nov 20 2017 20:23
well yes and no
that does use the value that was passed in
So if prop is 'hobby', it will look at contacts[i].hobby
but you don't want to look at the value in the hobby property
You want to check if hobby exists in the first place
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:27
@kbaig but say I am trying to look up the "prop" argument matches with any property, if yes, then return the value of that property. Hence, I am doing this
Kaz Baig
@kbaig
Nov 20 2017 20:27
@Sohel-ASM You don't want to compare what is in the prop, only that the prop exists in the first place
look for a contact. if the contact has the prop, return the value of that contact's prop. if it doesn't say no such property. if contact doesn't exist, say no such contact
You're only looking to check if the prop exists for the contact
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:30

@kbaig I understand what you are saying, that I should check if the prop exist or not, if it exist, return its value, if not then "No such property". But I am also trying understand if

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

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

works, then why

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

won't work?

Kaz Baig
@kbaig
Nov 20 2017 20:33
because one is to check if the person's first name is a certain value and the other is to check if the property exists
two different things
Henry
@GitHub-Henry
Nov 20 2017 20:36
if anyone is interested, here's a snapshot of FF Dev Edition, CSS Grid layout tool in action, cool stuff...
image.png
Kaz Baig
@kbaig
Nov 20 2017 20:37
@GitHub-Henry That's sick, thanks for sharing
CamperBot
@camperbot
Nov 20 2017 20:37
kbaig sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 491 | @github-henry |http://www.freecodecamp.org/github-henry
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:38
@kbaig so, if the "prop" argument matches with a property name, doesn't it imply that the property exist, like as the "firstName" argument?
Kaz Baig
@kbaig
Nov 20 2017 20:39
@Sohel-ASM Yes but you're not currently comparing with the property name. You're comparing with the value within the property
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:41
@kbaig what the codes will be look like if I want to compare the "prop" argument, with a property name of the contacts object?
Kaz Baig
@kbaig
Nov 20 2017 20:42
@Sohel-ASM check out the linkI sent you
That's what it's for
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:44
@kbaig okay, Thank you so much, for trying hard to put some knowledge in my hollow skull. I gotta eat and sleep good, but with issue like this, I can't do that either.
CamperBot
@camperbot
Nov 20 2017 20:44
sohel-asm sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @kbaig |http://www.freecodecamp.org/kbaig
Kaz Baig
@kbaig
Nov 20 2017 20:44
@Sohel-ASM haha np take a break
Kaz Baig
@kbaig
Nov 20 2017 20:54
@Sohel-ASM whenever you're back, fyi you can use the in operator instead of Object.hasOwnProperty https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in
Sohel-ASM
@Sohel-ASM
Nov 20 2017 20:54
@kbaig Thank you.
CamperBot
@camperbot
Nov 20 2017 20:54
sohel-asm sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
api offline
JBallin
@JBallin
Nov 20 2017 21:36
what does it mean to "decorate an object"
"To use this method, you have to create an object, decorate it and then return it from the constructor function."
is it just adding key value pairs after the object is created?
Kaz Baig
@kbaig
Nov 20 2017 21:42
@JBallin What is this for?
@JBallin http://www.dofactory.com/javascript/decorator-design-pattern looks like it's just an alternative design pattern to classes and subclasses
I guess it's the difference between working top down and bottom up
Pieter Stokkink
@forkerino
Nov 20 2017 21:59
@JBallin yes, it just means that you add properties or methods to an object.
Margaret Greaney
@greaneym
Nov 20 2017 22:50
hello, trying again to get some help with getting the game working on codepen.io. I have it working locally on my laptop but can't figure out why it does not work on codepen. I narrowed it down to hexi.js . I have a pixi.js assets test working on codepen.io but hexi is giving me an error that does not make sense. Any help appreciated. Here is the link to the pen,https://codepen.io/greaney/pen/vWdzwg
By the way hexi.js does not have any cdn that I can find, so am using rawgit. Is that a problem as far as anyone knows?
JBallin
@JBallin
Nov 20 2017 23:12
thanks @forkerino
CamperBot
@camperbot
Nov 20 2017 23:12
jballin sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2953 | @forkerino |http://www.freecodecamp.org/forkerino