These are chat archives for FreeCodeCamp/HelpJavaScript

28th
May 2016
Norvin Burrus
@ndburrus
May 28 2016 00:00
@StephenMansfield MDN, Array.prototype.push(), {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push } The push() method adds one or more elements to the end of an array and returns the new length of the array. so, yes, it looks like that is what is happening... (along with the return of the resulting array length...)
Juwdohr
@Juwdohr
May 28 2016 00:01
This message was deleted
Stephen Mansfield
@StephenMansfield
May 28 2016 00:01
@ndburrus thanks
CamperBot
@camperbot
May 28 2016 00:01
stephenmansfield sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 436 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 28 2016 00:01
@StephenMansfield :)
Kevin Min
@placidmoon1
May 28 2016 00:04
Can anybody see my (bad) Random Quote Project and give their opinion on it?
http://codepen.io/placidmoon1/full/KMKzaX/
Stephen Mansfield
@StephenMansfield
May 28 2016 00:06
@ndburrus hey man can you take a look at my code, it won't pass any of the test cases but when I manually enter the test cases it spits out the right answer
var thirdArry= [];
function chunkArrayInGroups(arr, size) {
  for (var i = -1; i<(arr.length)/size;i++){
      var newArry = [];

      newArry = arr.splice(0,size);
      thirdArry.push(newArry);
      console.log(arr, thirdArry);

  }

  return thirdArry;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
Norvin Burrus
@ndburrus
May 28 2016 00:07
@StephenMansfield was the code posted earlier? oh, i see it..
Stephen Mansfield
@StephenMansfield
May 28 2016 00:07
right there, try running it with the console.log
its doing something crazy and creating way more arrays than I need
but still spits out the right answer
ThaleSelaht
@ThaleSelaht
May 28 2016 00:10
u declared the i variable but aren't using it to iterate
Norvin Burrus
@ndburrus
May 28 2016 00:10
@StephenMansfield var i = -1 ? minus one?
llamatarianism
@llamatarianism
May 28 2016 00:10
@StephenMansfield thirdArray is a global variable that doesn't get reset between each test
make it a local variable inside the function.
function chunkArrayInGroups(arr, size) {
  var thirdArray = [];
  // rest of the code
  return thirdArray;
}
Stephen Mansfield
@StephenMansfield
May 28 2016 00:11
thanks @llamatarianism
CamperBot
@camperbot
May 28 2016 00:11
:cookie: 657 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
stephenmansfield sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
ThaleSelaht
@ThaleSelaht
May 28 2016 00:13
@StephenMansfield u set ur splice function first param to 0
Norvin Burrus
@ndburrus
May 28 2016 00:13
This message was deleted
Stephen Mansfield
@StephenMansfield
May 28 2016 00:13
@ThaleSelaht but that is the index of where I start
I want to be starting from the begining, correct?
and I guess now it at least passes some cases, but not all of them
thanks @ThaleSelaht @ndburrus
CamperBot
@camperbot
May 28 2016 00:14
stephenmansfield sends brownie points to @thaleselaht and @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: stephenmansfield already gave ndburrus points
:warning: stephenmansfield already gave thaleselaht points
ThaleSelaht
@ThaleSelaht
May 28 2016 00:16
@StephenMansfield yes you do, but it can't be a constant
that says it removes elements from the origanal array
what happens when that happens?
Norvin Burrus
@ndburrus
May 28 2016 00:17
@StephenMansfield line 13: var = SyntaxError: Unexpected token = Expected an identifier and instead saw '=' . Missing ; before statement
Stephen Mansfield
@StephenMansfield
May 28 2016 00:18
does index position 2 become 0, or is index 0 and index 1 just ""??
@ndburrus I am not getting any of the same errors you are
ThaleSelaht
@ThaleSelaht
May 28 2016 00:19
@StephenMansfield hum, I'm confused right now hahahaah
Bobby McDonald
@BobbyMcWho
May 28 2016 00:19
These algos are so boring :((
Norvin Burrus
@ndburrus
May 28 2016 00:20
@StephenMansfield ok, let me look at the challenge, sorry.. need all the code
ThaleSelaht
@ThaleSelaht
May 28 2016 00:20
@StephenMansfield u are using splice instead of slice
Stephen Mansfield
@StephenMansfield
May 28 2016 00:20
@ndburrus no worries man
ThaleSelaht
@ThaleSelaht
May 28 2016 00:21
@StephenMansfield i got it know
Stephen Mansfield
@StephenMansfield
May 28 2016 00:21
ive got it working for all but the last 2
@ThaleSelaht yea slice doesnt remove, it just copies
tried it with slice but couldnt figure it out
ThaleSelaht
@ThaleSelaht
May 28 2016 00:21
@StephenMansfield exactly, I was confused cuz I use slice to solve it
Stephen Mansfield
@StephenMansfield
May 28 2016 00:21
ahhh
Aryan
@aryandua
May 28 2016 00:22
@BobbyMcWho no algorithms are ever boring
Bobby McDonald
@BobbyMcWho
May 28 2016 00:22
boooooring :) I like the projects
Aryan
@aryandua
May 28 2016 00:22
@BobbyMcWho projects are uses of algos
Moisés Man
@moigithub
May 28 2016 00:23
@StephenMansfield i variable keeps increasing..and arr.length gets evaluated everytime (arr decreasing)
soo it iterate less times than it should..
Norvin Burrus
@ndburrus
May 28 2016 00:23
@StephenMansfield is the loop counter variable (i) supposed to be minus one? or should it be zero?
Moisés Man
@moigithub
May 28 2016 00:23
@StephenMansfield u can create another variable outside.. to store the arr.length...
that would solve...
Stephen Mansfield
@StephenMansfield
May 28 2016 00:24
yea ive changed it a bit now, @ndburrus and that solved another case
@moigithub ok let me try that
Norvin Burrus
@ndburrus
May 28 2016 00:25
@StephenMansfield ok...
Stephen Mansfield
@StephenMansfield
May 28 2016 00:26
@moigithub thanks alot man that solved it!
CamperBot
@camperbot
May 28 2016 00:26
stephenmansfield sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1262 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
May 28 2016 00:26
:+1:
Stephen Mansfield
@StephenMansfield
May 28 2016 00:26
in case anyone who was helping me cares
function chunkArrayInGroups(arr, size) {
  var thirdArry= [];
  var arrLength = arr.length;
  for (var i = 0; i<(arrLength)/size;i++){
      var newArry = [];
      console.log(arr[0],arr[1]);
      newArry = arr.splice(0,size);
      console.log(arr[0],arr[1]);

      thirdArry.push(newArry);
      //console.log(arr, thirdArry);

  }

  return thirdArry;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3);
ThaleSelaht
@ThaleSelaht
May 28 2016 00:27
This message was deleted
@StephenMansfield first of all there's a type error in i<(arrLength)
@StephenMansfield nvm
Stephen Mansfield
@StephenMansfield
May 28 2016 00:28
@ndburrus changing it -1 solved 3 cases before, then I added 1 to arr.length and that solved 4, but i was just dancing around the solution doing that, @moigithub suggestion of making it a var was what I needed
Norvin Burrus
@ndburrus
May 28 2016 00:29
@StephenMansfield ...alright...
Stephen Mansfield
@StephenMansfield
May 28 2016 00:29
thanks for the help man, sorry if I confused you
ThaleSelaht
@ThaleSelaht
May 28 2016 00:29
@StephenMansfield why don't u add size to i everytime the loop iterares?
@StephenMansfield iterates*
Stephen Mansfield
@StephenMansfield
May 28 2016 00:30
yea, I could see that working
Norvin Burrus
@ndburrus
May 28 2016 00:31
@StephenMansfield i haven't worked on that one yet, but wanted to take a look.. practice.... :+1:
Felix Rodriguez
@felixrodriguez12
May 28 2016 00:31

I need help with the Profile Lookup exercise. The following code produces "No such contact": ```JS

//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){
// Only change code below this line
if (firstName === contacts[firstName])
{
if (prop === contacts[firstName][prop])
{
return contacts[firstName][prop];
}
else if (prop !== contacts[firstName][prop] )
{
return "No such property";
}
}
else if (firstName !== contacts.firstName)
{
return "No such contact";
}

else
return "Error!";

// Only change code above this line
}

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

Stephen Mansfield
@StephenMansfield
May 28 2016 00:32
//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){
// Only change code below this line
if (firstName === contacts[firstName])
{
if (prop === contacts[firstName][prop])
{
return contacts[firstName][prop];
}
else if (prop !== contacts[firstName][prop] )
{
return "No such property";
}
}
else if (firstName !== contacts.firstName)
{
return "No such contact";
}
else
return "Error!";
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
easier to look at like that @felixrodriguez12 :smiley:
Felix Rodriguez
@felixrodriguez12
May 28 2016 00:32
I tried entering JS and but it didn't display.
Stephen Mansfield
@StephenMansfield
May 28 2016 00:33
no worries mate
marcelpirata
@marcelpirata
May 28 2016 00:33
Hey guys which is the right one? var myArray = [1,2,3];
var myData = 1; or var myArray = [1,2,3];
var myData = [0]; ?
ThaleSelaht
@ThaleSelaht
May 28 2016 00:34
This message was deleted
Norvin Burrus
@ndburrus
May 28 2016 00:34
@felixrodriguez12 do you need to iterate (ie evaluate for conditions) through all the records ? :)
NewtonXu
@NewtonXu
May 28 2016 00:34

  $("#toggle").on("click", function(){
    var tempdis = $("u").html();
    console.log(tempdis);
    if(tempdis == "C")
      {
        var temp = $("b").html();
        console.log(temp);
        //convert temp C->F
        temp= (temp-32)*5/9;
        $("b").html(temp);
        $("u").html("F");

      }
    else{
      var temp = $("b").html();
      //convert temp F->C
      temp = (temp*9/5)+32;
      $("b").html(temp);
      $("u").html("C");
    }
  });
Felix Rodriguez
@felixrodriguez12
May 28 2016 00:34
I need to lookup profiles. The JSON is giving me trouble.
@ndburrus
NewtonXu
@NewtonXu
May 28 2016 00:34
this function is non responsive, any clue why?
marcelpirata
@marcelpirata
May 28 2016 00:34
Hey guys which is the right one? var myArray = [1,2,3];
var myData = [1]; or var myArray = [1,2,3];
var myData = [0]; ?
NewtonXu
@NewtonXu
May 28 2016 00:35
when i click the button nothing happens
Norvin Burrus
@ndburrus
May 28 2016 00:35
@marcelpirata it looks like all four of those are valid statements
Stephen Mansfield
@StephenMansfield
May 28 2016 00:36
@felixrodriguez12 my code used a for loop
Norvin Burrus
@ndburrus
May 28 2016 00:37
This message was deleted
Stephen Mansfield
@StephenMansfield
May 28 2016 00:38
@felixrodriguez12 also this part is bugging me
```
(prop === contacts[firstName][prop]
but I am not sure why
marcelpirata
@marcelpirata
May 28 2016 00:38
@NewtonXu so, it is [0] right?
NewtonXu
@NewtonXu
May 28 2016 00:39
@marcelpirata sorry im not sure what you mean
Norvin Burrus
@ndburrus
May 28 2016 00:39
@marcelpirata
code:
var myArray = [1,2,3];
console.log(myArray);
var myData = 1; 
console.log(myData);
var myArray = [1,2,3];
console.log(myArray);
var myData = [0];
console.log(myData);
----------------------
output:
[ 1, 2, 3 ]
1
[ 1, 2, 3 ]
[ 0 ]
@StephenMansfield ...am i missing something - i don't see a for loop...
PK
@arcticfries
May 28 2016 00:41
hi all.. I am back and stuck on one of the way points.. Code is below
var myArray = [];

// Only change code below this line.


var myArray = [];
for (var i = 0; i < 5; i++) {
  myArray.push(i);
}

// Only change code above this line.

if(typeof(myArray) !== "undefined"){(function(){return myArray;})();}
any suggestions on what I am doing wrong? I can't seem to find the answer on it
Its for help on Iterate with JavaScript For Loops
marcelpirata
@marcelpirata
May 28 2016 00:43
it asked me to create a variable called myData and set it to equal the first value of myArray. var myArray = [1,2,3]; @NewtonXu @ndburrus
PK
@arcticfries
May 28 2016 00:43
@ChrisHoenack pretty neat but a bit confusing... don't know how many one needs to find etc.
Chris Hoenack
@ChrisHoenack
May 28 2016 00:43
It should say at the top there are currently x mines
ThaleSelaht
@ThaleSelaht
May 28 2016 00:43
@felixrodriguez12 dude u are missing called hasOwnProp(), it'll help you solve it
PK
@arcticfries
May 28 2016 00:44
@ChrisHoenack hmm.. let m check again
Chris Hoenack
@ChrisHoenack
May 28 2016 00:44
and how many flags you have left
The text is hard to read
marcelpirata
@marcelpirata
May 28 2016 00:44
@NewtonXu @ndburrus which I believe would be var myData = [0]; what you guys think?
Chris Hoenack
@ChrisHoenack
May 28 2016 00:44
Also I haven't checked it for other browsers
Just using chrome
Oh make sure you lose on purpose to see what happens =)
Norvin Burrus
@ndburrus
May 28 2016 00:45
@arcticfries ...zero in on this piece of code var i = 0; i < 5 :)
PK
@arcticfries
May 28 2016 00:45
I am on using Chrome.. the red looks off and hard to read.. the game itself is fun though.. it seems to be confusing as once you click ones.. it shows as if you may have already done it .
@ndburrus hmmm but the request is for between 0 and 5 no?
Chris Hoenack
@ChrisHoenack
May 28 2016 00:46
Yeah I need to fix that
PK
@arcticfries
May 28 2016 00:46
@ChrisHoenack good work though still!..
@ndburrus sorry not sure how to fix it:(
Norvin Burrus
@ndburrus
May 28 2016 00:46
short break here...
marcelpirata
@marcelpirata
May 28 2016 00:46
@ndburrus did you see it?
PK
@arcticfries
May 28 2016 00:47
@ndburrus k
Chris Hoenack
@ChrisHoenack
May 28 2016 00:50
@arcticfries K it's sloppy but I fixed the problems you were talking abot
about
CamperBot
@camperbot
May 28 2016 00:50
you need to ask about @someone!
PK
@arcticfries
May 28 2016 00:50
@ChrisHoenack awesome!
@ChrisHoenack yours is way better than I will make I am sure! lol
Chris Hoenack
@ChrisHoenack
May 28 2016 00:53
@arcticfries Hey does right click work for placing flags? What browser are you on?
@arcticfries Thanks for the encouraging words
CamperBot
@camperbot
May 28 2016 00:53
chrishoenack sends brownie points to @arcticfries :sparkles: :thumbsup: :sparkles:
:cookie: 237 | @arcticfries |http://www.freecodecamp.com/arcticfries
PK
@arcticfries
May 28 2016 00:54
@ChrisHoenack let me check
@ChrisHoenack looks good.. much better!.. nice work
Chris Hoenack
@ChrisHoenack
May 28 2016 00:55
Thanks!
Emily Hittle
@emilyliza
May 28 2016 00:55
This message was deleted
PK
@arcticfries
May 28 2016 00:55
ok not sure what I need to get done on mine.. anyone with suggestions, greatly appreciate it..
Emily Hittle
@emilyliza
May 28 2016 00:57
This message was deleted
PK
@arcticfries
May 28 2016 00:58
@ChrisHoenack yup.. right click works.. I am using Chrmoe
oops Chrome
Sudeep Narkar
@sudeepnarkar
May 28 2016 00:59
Hi guys
Need some help in record collection bonfire
CamperBot
@camperbot
May 28 2016 00:59
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
PK
@arcticfries
May 28 2016 00:59
@sudeepnarkar hi
Sudeep Narkar
@sudeepnarkar
May 28 2016 00:59
@arcticfries Hi
jocago
@jocago
May 28 2016 01:04
Does anyone know how to reset an exercise from outside of the exercise? Whatever mistake I made is causing the page to lock up so that I cannot even hit the reset button.
Norvin Burrus
@ndburrus
May 28 2016 01:06
@jocago i believe an infinite loop will do that...
buiphuking
@buiphuking
May 28 2016 01:07
when you code a project like pomodoro clock, ie there any easy way to know why your code doesn't working??????? help me guys, i'm stuck .
DwayneCode
@DwayneCode
May 28 2016 01:09
@jocago try clearing your cookies
Norvin Burrus
@ndburrus
May 28 2016 01:09
@sudeepnarkar can you post your code?
@arcticfries were you able to resolve the challenge?
jocago
@jocago
May 28 2016 01:10
Thanks. I realized the history was in my cache or cookies, not on the server. I cleared history for the past hour and I'm good to go.
Norvin Burrus
@ndburrus
May 28 2016 01:11
@marcelpirata are you all set?
Péter Kovács
@petecz
May 28 2016 01:12
hey, any angular guru here?
Ziming Wang
@tinyCosmos
May 28 2016 01:12

Guys, newbie is dying here lol. Please help.

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".

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

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

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

It returns nothing..why?

jocago
@jocago
May 28 2016 01:12
Yes, thanks. I will stop trying to be clever and follow the instructions.
ThaleSelaht
@ThaleSelaht
May 28 2016 01:12
@peteczz one day I believe I would be able to say "FUCK YEAH" to ur question hahahha
Norvin Burrus
@ndburrus
May 28 2016 01:13
@kevinziming what is the challenge name?
Sudeep Narkar
@sudeepnarkar
May 28 2016 01:13
@kevinziming Hi. Use bracket notation when using a variable to access object property
Ziming Wang
@tinyCosmos
May 28 2016 01:13
@ndburrus Testing Objects for Properties
ThaleSelaht
@ThaleSelaht
May 28 2016 01:14
@kevinziming checkProp isn't a property of myObj
Sudeep Narkar
@sudeepnarkar
May 28 2016 01:14
return myObj[checkProp] @kevinziming
Péter Kovács
@petecz
May 28 2016 01:14
@ThaleSelaht can i still bother you with a question? :sparkles:
ThaleSelaht
@ThaleSelaht
May 28 2016 01:14
@peteczz Shoot
Péter Kovács
@petecz
May 28 2016 01:15
@ThaleSelaht http://codepen.io/peteczz/pen/vKBMWv
why is my weather.pos is an empty object?
Ziming Wang
@tinyCosmos
May 28 2016 01:15
@sudeepnarkar thanks it worked, but why the dot operator didn't ?
CamperBot
@camperbot
May 28 2016 01:15
kevinziming sends brownie points to @sudeepnarkar :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @sudeepnarkar |http://www.freecodecamp.com/sudeepnarkar
Norvin Burrus
@ndburrus
May 28 2016 01:15
@kevinziming ok, to return the property's value (value pair), we are using the key. since the key is a variable, we need to use bracket (as opposed to dot) notation.... ths may be helpful: MDN, Property accessors, {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors }
Ziming Wang
@tinyCosmos
May 28 2016 01:16
@ndburrus ooooooooh, you guys are genius.
Sudeep Narkar
@sudeepnarkar
May 28 2016 01:16
@kevinziming Because . operator is used when directly referring to the name of the object property.
Norvin Burrus
@ndburrus
May 28 2016 01:17
@kevinziming great work... :sparkles:
Sudeep Narkar
@sudeepnarkar
May 28 2016 01:17
If you want to use a variable then you need to use bracket notation
ThaleSelaht
@ThaleSelaht
May 28 2016 01:17
@peteczz I'm taking a look at iyt
@peteczz it*
Norvin Burrus
@ndburrus
May 28 2016 01:20
@arcticfries did you solve it? :)
ThaleSelaht
@ThaleSelaht
May 28 2016 01:20
@peteczz dude, looks like u are using deprecated methods look at ur console output
@peteczz "getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details."
Péter Kovács
@petecz
May 28 2016 01:21
@ThaleSelaht yeah thats not an issue, look at the codepen in another view with https://
@ThaleSelaht geolocation needs https
ThaleSelaht
@ThaleSelaht
May 28 2016 01:21
@peteczz i see
Chau Tung Lam Nguyen
@nctl144
May 28 2016 01:22

function fearNotLetter(str) {
  var arr = str.split("");
  for(var i=0; i<arr.length; i++){

    if(arr[i].charCodeAt() !== (arr[i+1].charCodeAt()-1)){
      return String.fromCharCode((arr[i].charCodeAt()+1));

   }else{
     return undefined;
   }
  }

}

fearNotLetter("abce");
can anyone help me with this?
it just executes the function within the else statement
jowright
@jowright
May 28 2016 01:24

I understand

```why are the comma and period not replaced? I have tried many different variations with the g flag and / / one tutorial had ", ", "" it worked for him but not me.
function palindrome(str) {
str= str.toLowerCase();

if (str=== "race car"){
str= str.replace("race car", "racecar");
} else if (str === "0_0 (: /-\ :) 0-0"){
str= str.replace("0_0 (: /-\ :) 0-0", "0000");

} else if (str=== "never odd or even"){
str= str.replace("never odd or even", "neveroddoreven");

}else if (str=== "A man, a plan, a canal. Panama"){
str= str.replace("A man\, a plan\, a canal. Panama", "amanaplanacanalpanama");
} // ",","" does not work either.

var copy= str.split("").reverse().join("");
if (copy== str){
return true;
} //else {
//return false;
// }

return str;

}

palindrome("A man, a plan, a canal. Panama");

ThaleSelaht
@ThaleSelaht
May 28 2016 01:24
@jowright noooooooooooooooooooooooo, u are hardcoding it dude
@peteczz dude I'm stucked too
jowright
@jowright
May 28 2016 01:26
I understand but I am trying to learn and understand. I have already passed this test but want to learn because someone else told me that I am trying to understand. I really want to do it right so I have been on this for a while.
Péter Kovács
@petecz
May 28 2016 01:26
@ThaleSelaht yeah... i think the issue is with lines 21/23 but not sure, and how to resolve it
@jowright and test ur regular expressions at http://regexr.com/
@jowright Yeah I know, I'm here to help ya
jowright
@jowright
May 28 2016 01:33
ok thanks I will test it and keep trying.
Adrian Kopytko
@adriankopytko
May 28 2016 01:36
Hello
//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){
// Only change code below this line

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

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

      for(var j = 0; j < contacts[i].length; j++) {
        if(contacts[i][j] === prop) {
          return contacts[i][j];
        }
      }

      return "No such property";
    }
  }

  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
and "Kristian", "lastName" should return "Vos" "Sherlock", "likes" should return ["Intriguing Cases", "Violin"] "Harry","likes" should return an array "Bob", "number" should return "No such contact" "Akira", "address" should return "No such property" errors
Can someone help me? :(
I guess it's the problem with second for
Norvin Burrus
@ndburrus
May 28 2016 01:38
@Shimizo check/review this statement for(var j = 0; j < contacts[i].length; j++) { once you evaluate for firstName, you take the next step and check for prop, can't you? hint: is there a need for a subsequent iteration (ie for loop)? ...make sense? :)
ThaleSelaht
@ThaleSelaht
May 28 2016 01:38
@Shimizo hasOwProperty() method can help you
@Shimizo and what @ndburrus said
Adrian Kopytko
@adriankopytko
May 28 2016 01:45
@ndburrus @ThaleSelaht So... I should check if contacts[i][prop] hasOwnProperty, and then return contacts[i][prop] or 'no such property'?
instead of for lop?
ThaleSelaht
@ThaleSelaht
May 28 2016 01:46
@Shimizo the correct syntax is contacts[i].hasOwnProperty(prop)
@Shimizo and yes you should
Norvin Burrus
@ndburrus
May 28 2016 01:46
@Shimizo yes... btw, there are a couple of ways the check for prop. hasOwnProperty() i one of them. one can also use bracket notation for the check :)
Adrian Kopytko
@adriankopytko
May 28 2016 01:47
@ThaleSelaht Oh yeah, I forgot
@ThaleSelaht @ndburrus Thank you!
CamperBot
@camperbot
May 28 2016 01:47
shimizo sends brownie points to @thaleselaht and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
:cookie: 437 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 28 2016 01:47
@Shimizo you're welcome!!! ....have you adjusted (& tested) the code? :sparkles:
Adrian Kopytko
@adriankopytko
May 28 2016 01:49
@ndburrus Yeah, I did it it works ;)
Norvin Burrus
@ndburrus
May 28 2016 01:49
@Shimizo most excellent! :+1: nice job.... :)
ThaleSelaht
@ThaleSelaht
May 28 2016 01:50
@Shimizo well done
piesha
@piesha
May 28 2016 01:52
Hey guys, the challenge is "Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable."
rphares
@rphares
May 28 2016 01:52
ty @revisualize
CamperBot
@camperbot
May 28 2016 01:52
rphares sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1175 | @revisualize |http://www.freecodecamp.com/revisualize
piesha
@piesha
May 28 2016 01:52
I have the table, but I am not sure how to tie it into phoneticLookup(val)
Norvin Burrus
@ndburrus
May 28 2016 01:53
@piesha what is the challenge name?
Péter Kovács
@petecz
May 28 2016 01:53
@ThaleSelaht damn, I solved it... so stupid, thanks for you input and your time!
CamperBot
@camperbot
May 28 2016 01:53
peteczz sends brownie points to @thaleselaht :sparkles: :thumbsup: :sparkles:
:cookie: 221 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
piesha
@piesha
May 28 2016 01:53
Using Objects for Lookups
I feel like I am supposed to use an indice
like lookup[alpha]
Norvin Burrus
@ndburrus
May 28 2016 01:54
@piesha can you post your code? that's almost right... hint: use the function variable. that is what is being passed into the function....
piesha
@piesha
May 28 2016 01:54
All I have is the table
var lookup = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank",
I don't know how to access it in a suitable manner :/
Jesse Neumann
@Jesse989
May 28 2016 01:55
can anyone look at this and let me know why it wont work? I am getting so frustrated... https://codepen.io/Jesse989/pen/XKWdxO?editors=1111
Norvin Burrus
@ndburrus
May 28 2016 01:56
@piesha take another look at the example code: alpha[2]; // "Y" alpha[24]; // "C" see how they access the table/object to get at a desired value? they use the object name, and also the property (that points to the desired value/s)
ThaleSelaht
@ThaleSelaht
May 28 2016 01:56
@peteczz anytime mate
piesha
@piesha
May 28 2016 01:57
@norvin, I get the example code. I just don't know how to tie it into the function..
Moisés Man
@moigithub
May 28 2016 01:59
@Jesse989 wrong library.. u added jquery-ui
u need jquery
Norvin Burrus
@ndburrus
May 28 2016 01:59
@piesha ok, we need to get a value (or result). per the instructions, result will be our variable. we can assign a value (or answer) to result. your question is what to assign to result, i believe. alright, we need to reference the object (by name), and also use the property we need.... the property we need, in this case, is the variable passed into the function. getting clearer?
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:00
function updateRecords(id, prop, value) 
{
  if (value!=="" && collection[id][prop] !=="tracks")
   {
     collection[id][prop]=value;
   } 
  if(collection[id][prop]==="tracks" && value!==" ")
    {
      collection[id][tracks].push(value);   
    }
  if(value==="")
   {
     delete collection[id][prop]; 
   }
  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "second");
Stephen Mansfield
@StephenMansfield
May 28 2016 02:00
hey guys I got a questions for ya, its not about a problem per say but more of a syntax. why is the .toLowerCase().split(") from arryOne correct but the split("").toLowerCase(); not correct??
function mutation(arr) {
  var arryOne = arr[0].toLowerCase().split("");
  var arryTwo = arr[1].split("").toLowerCase();
  var boolAns = true;
  for (var i = 0; i<arr[1].length;i++){

    if (-1 === arryOne.indexOf(arryTwo[i])){
      boolAns = false;


    }


  }



  return boolAns;
}

mutation(["hello", "hey"]);
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:00
Can anyone see what is wrong here?
piesha
@piesha
May 28 2016 02:00
phoneticLookup("charlie"); should give us "Chicago"
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:01
This is record collection bonfire
Moisés Man
@moigithub
May 28 2016 02:01
@StephenMansfield toLowerCase is a String method... not an array method
if u make split first.. u converting the str into an arrray
Joseph
@revisualize
May 28 2016 02:02
@sudeepnarkar I can.
marcelpirata
@marcelpirata
May 28 2016 02:02
@ndburrus I think it was a bug... here is the assignment: Access Array Data with Indexes
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:02
@revisualize Thanks
CamperBot
@camperbot
May 28 2016 02:02
sudeepnarkar sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
May 28 2016 02:02
@sudeepnarkar check/review this snippet value!==" "
CamperBot
@camperbot
May 28 2016 02:02
:star2: 1177 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 28 2016 02:03
// Write a function which takes:
//  an id, a property (prop), and a value.
function updateRecords(id, prop, value) {
// If value is non-blank (value !== "") 
// and prop is not "tracks" 
// then update or set the value for the prop.
    // Your code here

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

// If value is blank, 
// delete that prop.
    // Your code here

// Always return the entire collection object.
  return collection;
}
@sudeepnarkar your if evaluations are all messed up.
piesha
@piesha
May 28 2016 02:03
@ndburrus I needed result = lookup[val];
:D
That was the missing piece on how to pass it up
Moisés Man
@moigithub
May 28 2016 02:04
@sudeepnarkar u have an space on value!==" "<-- remove space
also tracks is a property of ur object.. not a variable.. so need quotes or use dot notation
Norvin Burrus
@ndburrus
May 28 2016 02:04
@piesha yes.... nice job.... :)
DC
@dctor
May 28 2016 02:04
what's the right way to put these two replace statements into 1?
  remove = lowerCase.replace(/\W+/g,"");
  remove2 = remove.replace(/[_-]+/g,"");
Stephen Mansfield
@StephenMansfield
May 28 2016 02:04
@moigithub ok... so i should think of the . notation as a new line then. Like whatever the .function is doing it completes it full before evaluating the next .whateverfunction... is that correct?
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:04
@revisualize // If the prop is "tracks" and value is non-blank,
// push the value onto the end of the tracks array.
// Your code here
is giving me a problem
rest are fine.
Jesus
@ItsHaysus
May 28 2016 02:06
Hey guys
Can you take a look at my Tribute page?
Stephen Mansfield
@StephenMansfield
May 28 2016 02:06
@ItsHaysus sure
Moisés Man
@moigithub
May 28 2016 02:06
@StephenMansfield the output of 1 function.. serves as input to the next function u chaining
piesha
@piesha
May 28 2016 02:06
thanks @ndburrus I know you were trying. Appreciate you helping around here :)
CamperBot
@camperbot
May 28 2016 02:06
piesha sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 438 | @ndburrus |http://www.freecodecamp.com/ndburrus
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:06
// Only change code below this line
function updateRecords(id, prop, value) 
{
  if (value!=="" && collection[id][prop] !=="tracks")
   {
     collection[id][prop]=value;
   } 
  if(collection[id][prop]==="tracks" && value!=="")
    {
      collection[id].tracks.push(value);   
    }
  if(value==="")
   {
     delete collection[id][prop]; 
   }
  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "second");
@moigithub I tried.
Still nothing
Stephen Mansfield
@StephenMansfield
May 28 2016 02:07
@ItsHaysus looks really good man, the only thing is with codepen you dont need to do the style header
Moisés Man
@moigithub
May 28 2016 02:07
@sudeepnarkar u only need to check if the variable prop is tracks (or not)
not the whole thing, re-read the instructions :)
Stephen Mansfield
@StephenMansfield
May 28 2016 02:07
@ItsHaysus I mean you can, but the whole point is to put it in the css box, so that way you arnt scrolling back and forth
Norvin Burrus
@ndburrus
May 28 2016 02:07
@piesha ...was my explanation confusing? tough to follow? just curious... i can try and improve...
Stephen Mansfield
@StephenMansfield
May 28 2016 02:08
you can line up whatever you are targeting with the css that targets and look at them at the same time
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:08
@moigithub Yes. I tried removing the condition and just checking if it is tracks.
Still nothing
Moisés Man
@moigithub
May 28 2016 02:09
how? repost code...
if(collection[id][prop]==="tracks" wrong..
u only need to check prop variable not collection etce etc
@sudeepnarkar
Norvin Burrus
@ndburrus
May 28 2016 02:09
@sudeepnarkar how's it going?
Arin
@arinarjani
May 28 2016 02:09
Hello all
I am having trouble with the Profile Lookup challenge. Here is my code:
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:10
@moigithub @ndburrus
```
Norvin Burrus
@ndburrus
May 28 2016 02:10
@arinarjani hi, can you post your code?
Arin
@arinarjani
May 28 2016 02:10

//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){
// Only change code below this line
//.hasOwnProperty(propname)
var contacts_length = contacts.length;
for ( var i = 0; i < contacts_length; i++ ) {
if ( contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) ) {
return contacts[i][prop];
} else if ( contacts[i].firstName !== firstName ) {
return "No such contact";
} else if ( contacts[i].hasOwnProperty(prop) === false ) {
return "No such property";
}
}
// Only change code above this line
}

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

Sudeep Narkar
@sudeepnarkar
May 28 2016 02:10
function updateRecords(id, prop, value) 
{
  if (value!=="" && collection[id][prop] !=="tracks")
   {
     collection[id][prop]=value;
   } 
  if(collection[id][prop]==="tracks")
    {
      collection[id].tracks.push(value);   
    }
  if(value==="")
   {
     delete collection[id][prop]; 
   }
  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "second");
@ndburrus @moigithub Ps chcek
*check
Moisés Man
@moigithub
May 28 2016 02:10
@sudeepnarkar u still have the same thing.. on ur IF condition.. plz re-read :point_up: May 27, 2016 9:09 PM :point_up: May 27, 2016 9:07 PM
Arin
@arinarjani
May 28 2016 02:10
How do you post code in the nice window like @sudeepnarkar
DC
@dctor
May 28 2016 02:10
hey all, i'd like to find out the way to combine these 2 replace() statements into 1...any idea?
  remove = lowerCase.replace(/\W+/g,"");
  remove2 = remove.replace(/[_-]+/g,"");
Stephen Mansfield
@StephenMansfield
May 28 2016 02:10
explain format
CamperBot
@camperbot
May 28 2016 02:10

: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

Stephen Mansfield
@StephenMansfield
May 28 2016 02:11
@arinarjani check that out
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:11
explain format
CamperBot
@camperbot
May 28 2016 02:11

: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
May 28 2016 02:11
@sudeepnarkar You're doing it wrong.
@sudeepnarkar Your if evaluations have NOTHING to do with the collection.
Don't PM ME!
Stephen Mansfield
@StephenMansfield
May 28 2016 02:12
@arinarjani nicer looking code
```
//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){
// Only change code below this line
  //.hasOwnProperty(propname)
  var contacts_length = contacts.length;
  for ( var i = 0; i < contacts_length; i++ ) {
    if ( contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) ) {
      return contacts[i][prop];
    } else if ( contacts[i].firstName !== firstName ) {
      return "No such contact";
    } else if ( contacts[i].hasOwnProperty(prop) === false ) {
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Joseph
@revisualize
May 28 2016 02:12
@StephenMansfield That loop doesn't loop.
Moisés Man
@moigithub
May 28 2016 02:13
returning too soon @StephenMansfield
Sudeep Narkar
@sudeepnarkar
May 28 2016 02:13
@revisualize Thanks! I got it
CamperBot
@camperbot
May 28 2016 02:13
sudeepnarkar sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: sudeepnarkar already gave revisualize points
Stephen Mansfield
@StephenMansfield
May 28 2016 02:13
actually thats @arinarjani code
Joseph
@revisualize
May 28 2016 02:13
Okay.
Stephen Mansfield
@StephenMansfield
May 28 2016 02:13
was just formatting it so i could look at it
Joseph
@revisualize
May 28 2016 02:13
@arinarjani Your for loop isn't looping!
Stephen Mansfield
@StephenMansfield
May 28 2016 02:14
@arinarjani yea! what @revisualize said!
Norvin Burrus
@ndburrus
May 28 2016 02:14
@sudeepnarkar there is a double condition for if prop == tracks.... the code only has one...
Arin
@arinarjani
May 28 2016 02:14
So it is the loop that is screwing everything up
Joseph
@revisualize
May 28 2016 02:14
@arinarjani No.
@arinarjani It is your logic
@arinarjani Well, technically it is the if, else if, else if ... all having return statements
@arinarjani Let's say I had a deck of cards. I would shuffle them... Then I would randomly burn a large chunk of them.
Then let's say I handed you the stack. And asked.. Is the Jack of Diamonds in that stack?
You'd first have to "loop" through the stack if card === Jack of Diamonds .. return yes...
but... If the jack wasn't in there.. You'd still have to "loop" ALL the way through the random number of cards before you could return ... No
Arin
@arinarjani
May 28 2016 02:19
@revisualize Say I test: lookUpProfile( "Harry", "likes"), you are saying that it stops the loop if i = 0 because of the return statement
?
Manisha Reddy
@myeramareddy
May 28 2016 02:20
Just finished the quote machine challenge and have a JS question. I have something like this and it works, but href prop doesn’t get updated if I put the statement outside the getJSON, but still inside loadNewQuote method, WHY?
function loadNewQuote() {
  $.getJSON(MAIN_URL, function(a) {
    $("#quote").text(a.quoteText)
    $("#author").html(a.quoteAuthor)
    var tQ = tweetURL+a.quoteText+' - '+a.quoteAuthor+' @myeramareddy';
    $("#tweetMe").prop('href', tQ);
  });
}
Arin
@arinarjani
May 28 2016 02:21
@revisualize Shared session?
Joseph
@revisualize
May 28 2016 02:21
@arinarjani What?
@arinarjani Put in your code and Visualize Execution
Arin
@arinarjani
May 28 2016 02:22
Oh, visualize execution
Joseph
@revisualize
May 28 2016 02:23
This salad that I'm eating is so amazing.
Arin
@arinarjani
May 28 2016 02:23
@revisualize I have never used that site before, so I was not sure why you sent me the link, but after looking around I figured out why. Now I will look at the visualization
Joseph
@revisualize
May 28 2016 02:23
:D
Moisés Man
@moigithub
May 28 2016 02:24
@myeramareddy cuz is asynchronous
javascript dont wait, it continue executing
if u put outside.. it will first run ur getJSON.. then ur prop(href)..
and when data from getJSON is ready will execute the callback n update ur html
@myeramareddy u dont have control of ur getJSON ,, server can reply back in 1 second.. or take 1 hour to reply....
Su Young (Kevin) Choi
@kchoi1011
May 28 2016 02:25
can someone help me explain why this code would not run properly?
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)===true){
return myObj.checkProp;
}
else {
return "Not Found";
}
}
Joseph
@revisualize
May 28 2016 02:25
@kchoi1011 dot notation is a string literal.
var name = "Joseph";
var myObj.name; 
// is the same as
var myObj["name"];
// you want
var myObj[name];
Moisés Man
@moigithub
May 28 2016 02:26
@kchoi1011 checkProp is a variable.... u CANT use dot notation
Arin
@arinarjani
May 28 2016 02:26
@revisualize I see that it stops looping after the first return statement, so I will figure out how to minimize my return statements. Is my logic in the if...else if....else if right?
Moisés Man
@moigithub
May 28 2016 02:27
@arinarjani that return should NOT be there
Joseph
@revisualize
May 28 2016 02:27
@arinarjani Just move it outside of the loop.
Moisés Man
@moigithub
May 28 2016 02:28
@arinarjani if u have 10 pockets,, and every pocket have money...
how many pockets u need to check to know how much total money u got ?
Arin
@arinarjani
May 28 2016 02:28
@moigithub I get the idea, I just thought the return statements did not stop a loop
Moisés Man
@moigithub
May 28 2016 02:28
sooo u cant say "no contact" after check the first one...
return exit the function immediatelly
Arin
@arinarjani
May 28 2016 02:31
Thank you @moigithub @revisualize @StephenMansfield
CamperBot
@camperbot
May 28 2016 02:31
arinarjani sends brownie points to @moigithub and @revisualize and @stephenmansfield :sparkles: :thumbsup: :sparkles:
:star2: 1263 | @moigithub |http://www.freecodecamp.com/moigithub
:cookie: 287 | @stephenmansfield |http://www.freecodecamp.com/stephenmansfield
:star2: 1178 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 28 2016 02:31
@arinarjani The RETURN statement HALTs the whole Function.
Arin
@arinarjani
May 28 2016 02:31
I will see how to work it out now that I know the problem.
@revisualize If I say var result;. result can be anything right? It can be an int, float, array, bool, etc?
Joshua Abu
@Absolutestunna
May 28 2016 02:35
I have a security related question. I'm trying to implement a authentication/authorization solution for an admin console and I want to hide elements from a list on the page until the users have been authenticated. but I feel like putting a hide on the html element and "unhiding" it after authentication is confirmed isn't the best idea. Can't a user see the hidden elements in the console although the hidden elements aren't rendered on the screen initially?
Diego Mayer
@Chrono79
May 28 2016 02:35
var result; is undefined
Emily C.
@dreamthink
May 28 2016 02:36
This message was deleted
Arin
@arinarjani
May 28 2016 02:36
I mean, I write var result; Then later on I say result = array, or result = string. Is that legal?
Emily C.
@dreamthink
May 28 2016 02:36
Hello, I am stuck on "Selecting from many options with Switch Statements". Why is this not working?
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  case '1':
    answer = "alpha";
    break;
  case '2':
    answer = "beta";
    break;
  case '3':
    answer = "gamma";
    break;
  case '4':
    answer = "delta";
    break; 

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

// Change this value to test
caseInSwitch(3);
Diego Mayer
@Chrono79
May 28 2016 02:37
@arinarjani yes, not the best practice, but yes
Arin
@arinarjani
May 28 2016 02:37
@dreamthink take the '' off
Nick LaBelle
@dogwaddle
May 28 2016 02:38
@dreamthink so it is just the numbers
Arin
@arinarjani
May 28 2016 02:38
@Chrono79 Thank you. I get confused with JS and C++. I am not okay in both, but in C++ you have to say int num; or string name. Always declare a type. JS is a lot more forgiving
CamperBot
@camperbot
May 28 2016 02:38
arinarjani sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 910 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 28 2016 02:38
@dreamthink write switch(...) { }
Jim Strickland
@JStrick999
May 28 2016 02:39

Help, I am stuck on the Seek and Destroy. ```

function destroyer(arr) {
// Remove all the values
//console.log("whole array " +arr);
//console.log(arr[0] + " first part");
//console.log(arr[0,0]);
//console.log(arr[0,1]);
//console.log(arr[0,2]);
//console.log(arr[0,3]);
//console.log(arr[0,4]);
//console.log(arr[0,5]);
//console.log(arr[0,6]); // undefined
//console.log(arr[1]);
//console.log(arr[2]);
//console.log(arr[3]);
//console.log(arr[4]);
//console.log(arr[5]);
//console.log(arr[6]); // undefined

//console.log(arr[1,0]);
//console.log(arr[1,1]);
//console.log(arr[1,3]);

//console.log(arr[0,1]);
//console.log(arr[1,0]);
//console.log(arr[1,1]);
//console.log(arr[1,1,2]);
//console.log(arr[1,1,3]);
//console.log(arr[1,1,4]);
//console.log(arr[6]);
//console.log(argument[6]);
//console.log(arr[0[2]]);
//var pos = arr.indexOf("16");
//console.log(pos);
//pos = arr.index("17");
//console.log(pos);
//console.log(arr[0],0);
//console.log("The end");
//console.log(arguments[2]); // last item
//console.log(arguments[1]); // second to last item
var filteredArray = arr.filter(arguments[1]);
//for (var i = 1; i < 3; i++ )
// {
// filteredArray = arr.filter(arguments[i]);
// }
console.log("after filtering " + filteredArray);
return arr;
}

//destroyer([1, 2, 3, 1, 2, 3], 2, 3);
destroyer(["10","11","12","13","14","15"],"16","17");
//console.log(arguments[1]);
```

CamperBot
@camperbot
May 28 2016 02:39
no wiki entry for: i am stuck on the seek and destroy function destroyerarr remove all the values consolelogwhole array arr consolelogarr0 first part consolelogarr00 consolelogarr01 consolelogarr02 consolelogarr03 consolelogarr04 consolelogarr05 consolelogarr06 undefined consolelogarr1 consolelogarr2 consolelogarr3 consolelogarr4 consolelogarr5 consolelogarr6 undefined consolelogarr10 consolelogarr11 consolelogarr13 consolelogarr01 consolelogarr10 consolelogarr11 consolelogarr112 consolelogarr113 consolelogarr114 consolelogarr6 consolelogargument6 consolelogarr02 var pos arrindexof16 consolelogpos pos arrindex17 consolelogpos consolelogarr00 consolelogthe end consolelogarguments2 last item consolelogarguments1 second to last item var filteredarray arrfilterarguments1 for var i 1 i 3 i filteredarray arrfilterargumentsi consolelogafter filtering filteredarray return arrdestroyer1 2 3 1 2 3 2 3destroyer1011121314151617consolelogarguments1
Jim Strickland
@JStrick999
May 28 2016 02:39

function destroyer(arr) {
  // Remove all the values
  //console.log("whole array " +arr);
  //console.log(arr[0] + " first part");
  //console.log(arr[0,0]);
  //console.log(arr[0,1]);
  //console.log(arr[0,2]);
  //console.log(arr[0,3]);
  //console.log(arr[0,4]);
  //console.log(arr[0,5]);
  //console.log(arr[0,6]); // undefined
  //console.log(arr[1]);
  //console.log(arr[2]);
  //console.log(arr[3]);
  //console.log(arr[4]);
  //console.log(arr[5]);
  //console.log(arr[6]); // undefined

  //console.log(arr[1,0]);
  //console.log(arr[1,1]);
  //console.log(arr[1,3]);

  //console.log(arr[0,1]);
  //console.log(arr[1,0]);
  //console.log(arr[1,1]);
  //console.log(arr[1,1,2]);
  //console.log(arr[1,1,3]);
  //console.log(arr[1,1,4]);  
  //console.log(arr[6]);
  //console.log(argument[6]);
  //console.log(arr[0[2]]);
  //var pos = arr.indexOf("16");
  //console.log(pos);
  //pos = arr.index("17");
  //console.log(pos);
  //console.log(arr[0],0);
  //console.log("The end");
  //console.log(arguments[2]); // last item
  //console.log(arguments[1]); // second to last item
  var filteredArray = arr.filter(arguments[1]);
  //for (var i = 1; i < 3; i++ )
   // {
    //  filteredArray = arr.filter(arguments[i]);
   // }
  console.log("after filtering " + filteredArray);
  return arr;
}

//destroyer([1, 2, 3, 1, 2, 3], 2, 3);
destroyer(["10","11","12","13","14","15"],"16","17");
//console.log(arguments[1]);
Arin
@arinarjani
May 28 2016 02:40
@dreamthink oh yes, sorry about not stating you have to write switch ( test ) { case 1: do something; break; }...
Diego Mayer
@Chrono79
May 28 2016 02:40
@arinarjani that's right, it's dynamically typed
Arin
@arinarjani
May 28 2016 02:40
just okay in both not "not okay" lol
Ken Truong
@kjjtruong
May 28 2016 02:41

hey everyone I FINALLY solved the Where Art Thou challenge. However, I feel like my solution is not very efficient and that I went the long way around. Just wondering if someone could review and let me know where I could improve.

Challenge - "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."

help where art thou
CamperBot
@camperbot
May 28 2016 02:41

:point_right: algorithm where art thou [wiki]

Algorithm Where Art Thou

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about algorithm where art thou on the FCC Wiki

Ken Truong
@kjjtruong
May 28 2016 02:41

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];

  // Only change code below this line

  //store keys and length of second argument in array
  var sourceKeys = Object.keys(source);
  var sourceKeysLength = sourceKeys.length;

  //iterate over array of objects (first argument)
  for(var i = 0; i < collection.length; i++) {

    //iterate and check each object if sourceKeys value exists
    if(sourceKeysLength > 1) {
      for(var j = sourceKeysLength-1; j >= 0; j--) {
        if(collection[i].hasOwnProperty(sourceKeys[j-1]) && collection[i].hasOwnProperty(sourceKeys[j])){
          if(collection[i][sourceKeys[j]] == source[sourceKeys[j]]) {
            arr.push(collection[i]);
          }
        }
      }
    } else {
      for(var k = sourceKeysLength-1; k >= 0; k--) {
        if(collection[i].hasOwnProperty(sourceKeys[k])){
          if(collection[i][sourceKeys[k]] == source[sourceKeys[k]]) {
            arr.push(collection[i]);
          }
        }
      }
    }

  }

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


whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Joseph
@revisualize
May 28 2016 02:43
@arinarjani
function stuff() {
   for (stuff) {
      if (stuff) {
          return true stuff
      }
   }
   return didn't find stuff
}
Emily C.
@dreamthink
May 28 2016 02:43
@arinarjani @Chrono79 @dogwaddle thanks!
CamperBot
@camperbot
May 28 2016 02:43
dreamthink sends brownie points to @arinarjani and @chrono79 and @dogwaddle :sparkles: :thumbsup: :sparkles:
:cookie: 235 | @arinarjani |http://www.freecodecamp.com/arinarjani
:cookie: 294 | @dogwaddle |http://www.freecodecamp.com/dogwaddle
:cookie: 911 | @chrono79 |http://www.freecodecamp.com/chrono79
Manisha Reddy
@myeramareddy
May 28 2016 02:43
@moigithub Thank you!
CamperBot
@camperbot
May 28 2016 02:43
myeramareddy sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1264 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
May 28 2016 02:44
@kjjtruong try reducing the 2 inner loops, after all, you're using those loops to transverse only one array
Ken Truong
@kjjtruong
May 28 2016 02:49
@Chrono79 yea i just noticed that lol

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];

  // Only change code below this line

  //store keys and length of second argument in array
  var sourceKeys = Object.keys(source);
  var sourceKeysLength = sourceKeys.length;

  //iterate over array of objects (first argument)
  for(var i = 0; i < collection.length; i++) {

    //iterate and check each object if sourceKeys value exists

      for(var j = sourceKeysLength-1; j >= 0; j--) {
        if(sourceKeysLength > 1) {
          if(collection[i].hasOwnProperty(sourceKeys[j-1]) && collection[i].hasOwnProperty(sourceKeys[j])){
            if(collection[i][sourceKeys[j]] == source[sourceKeys[j]]) {
              arr.push(collection[i]);
            }
          }
        } else {
          if(collection[i].hasOwnProperty(sourceKeys[j])){
            if(collection[i][sourceKeys[j]] == source[sourceKeys[j]]) {
              arr.push(collection[i]);
            }
          }
        }
      } 

   }

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


whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
```
Diego Mayer
@Chrono79
May 28 2016 02:51
@kjjtruong you can reduce the if/else too
for example, I used a count var and incremented it everytime collection[i].hasOwnProperty(sourceKeys[j]) && collection[i][sourceKeys[j]] === source[sourceKeys[j]]
if the count matched sourceKeys.length I did the push
Chris Cullen
@123xylem
May 28 2016 02:58
http://codepen.io/123xylem/pen/xOKZyy?editors=1111 Can you say why my divs have these weird borders on them?
Diego Mayer
@Chrono79
May 28 2016 03:00
@123xylem they are several nested divs
Chris Cullen
@123xylem
May 28 2016 03:01
hm
SO a nested div makes these weird borders
Sudeep Narkar
@sudeepnarkar
May 28 2016 03:03
function lookUpProfile(firstName, prop){
// Only change code below this line

var i;
 for(i=0;i<contacts.length;i++)
   {
     if(contacts[i][firstName]===firstName && contacts[i].hasOwnProperty(prop))
     {
       return contacts[i][prop];
     }
   }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Hi All
Chris Cullen
@123xylem
May 28 2016 03:03
I can probably work out how to change this style but Do you know why the last div isnt being wrapped? @Chrono79
Sudeep Narkar
@sudeepnarkar
May 28 2016 03:03
function lookUpProfile(firstName, prop){
// Only change code below this line

var i;
 for(i=0;i<contacts.length;i++)
   {
     if(contacts[i][firstName]===firstName && contacts[i].hasOwnProperty(prop))
     {
       return contacts[i][prop];
     }
   }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Diego Mayer
@Chrono79
May 28 2016 03:04
@123xylem looking at it
Sudeep Narkar
@sudeepnarkar
May 28 2016 03:04
can anyone see what is wrong with the code?
This is profile lookup
David Halls
@DavidHalls
May 28 2016 03:06
@dreamthink i dont know if you have an answer yet, but your switch statement is incorrect
Diego Mayer
@Chrono79
May 28 2016 03:07
@123xylem everytime you execute this line: $("li").wrap("<div class='streamOutput'></div>"); you add a div wrapping <li>
That's why the first <li> ends up with 5 divs
the last one isn't wrapped because is appended after the wrapping
David Halls
@DavidHalls
May 28 2016 03:07
@ndburrus im good, how are you
Norvin Burrus
@ndburrus
May 28 2016 03:09
@Byzgig good also.... :+1:
Chris Cullen
@123xylem
May 28 2016 03:10
@Chrono79 Makes sense considering the number of lines the div have at the bottom.
I guess I have to make a loop to keep changing the div so it doesnt nest 1 div?
Sudeep Narkar
@sudeepnarkar
May 28 2016 03:10
how to access an array of objects?
David Halls
@DavidHalls
May 28 2016 03:10
@sudeepnarkar
Diego Mayer
@Chrono79
May 28 2016 03:11
@123xylem why don't you append the li and the div in the same line?
David Halls
@DavidHalls
May 28 2016 03:11

@sudeepnarkar
function lookUpProfile(firstName, prop){
// Only change code below this line

var i;
for(i=0;i<contacts.length;i++)
{
if(contacts[i][firstName]===firstName && contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
} // Only change code above this line } // Change these values to test your function lookUpProfile("Akira", "likes")
}
}

Norvin Burrus
@ndburrus
May 28 2016 03:11
@sudeepnarkar review/check the statement: if(contacts[i][firstName] firstName is an actual property name (ie not a variable), so it can be referenced with dot notation.
DC
@dctor
May 28 2016 03:11
@Chrono79 this loop only returns the 1st value...what is wrong?
  for (i=0; i <=str.split(" ").length; i++) {
    return str.split(" ")[i].length;
  }
Chris Cullen
@123xylem
May 28 2016 03:11
@Chrono79 that way each new LI has its own wrap instead of make 5 li and wrap them 1 2 3 4 5 times?
Diego Mayer
@Chrono79
May 28 2016 03:12
@dctor it's returning in the first line inside the loop, so, no loop
Sudeep Narkar
@sudeepnarkar
May 28 2016 03:12
@ndburrus Thanks
CamperBot
@camperbot
May 28 2016 03:12
sudeepnarkar sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 439 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 28 2016 03:13
@sudeepnarkar you're welcome... :sparkles:
DC
@dctor
May 28 2016 03:13
@Chrono79 how to make it a loop?
Diego Mayer
@Chrono79
May 28 2016 03:13
@123xylem first, ul and divs it's not the right way of doing it, it's ul > li > whatever you want inside li
Taylor Williams
@Twilliams6006
May 28 2016 03:14
I'm trying to pass a variable for the url parameter for $.getJSON and it doesn't seem to work is this not possible?
Ken Truong
@kjjtruong
May 28 2016 03:14
@Chrono79 hmm maybe i'm not picturing this correctly or i'm confusing myself. Wouldn't that only work if sourceKeys.length was only 1. As in wouldn't that only be testing for one item in the array at a time? How would you test for the second array item in sourceKeys?
Diego Mayer
@Chrono79
May 28 2016 03:14
@dctor not returning in the first line, that's for sure, don't know what you want to do
Chris Cullen
@123xylem
May 28 2016 03:15
@Chrono79 I dont understand what u mean there... BUT your idea has got me to fix this !! so thanks!
CamperBot
@camperbot
May 28 2016 03:15
123xylem sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 912 | @chrono79 |http://www.freecodecamp.com/chrono79
Chris Cullen
@123xylem
May 28 2016 03:15
@Chrono79 I added div into the append section and took the wrap function out!
Ken Truong
@kjjtruong
May 28 2016 03:15
@Chrono79 do you have an example? maybe i can visualize it better then
DC
@dctor
May 28 2016 03:15
@Chrono79 i want it to loop thru each element in an array and finding the length for each
Jim Strickland
@JStrick999
May 28 2016 03:16
I am stuck on Seek and Destroy.
```
Diego Mayer
@Chrono79
May 28 2016 03:16
@dctor you can store that length in another array
Jim Strickland
@JStrick999
May 28 2016 03:16
function destroyer(arr) {
  // Remove all the values

  //console.log("whole array " +arr);
  console.log(arr[0] + " first part");
  var modArray = arguments[0]-arguments[1]-arguments[2];
  console.log(modArray);
  return modArray;

}
var filtered = [[1, 2, 3, 1, 2, 3], 2, 3].filter(destroyer);
console.log(filtered);
Joseph
@revisualize
May 28 2016 03:17
@JStrick999 Good LUCK! :D
DC
@dctor
May 28 2016 03:18
@Chrono79 that's what i am trying to do - loop thru up to the length of the input sentence. then finding the length for each word and put them in an array. but the loop ins't working..
Diego Mayer
@Chrono79
May 28 2016 03:18
@123xylem good, but read this: http://www.w3schools.com/html/html_lists.asp you'll see that the children of <ul> are <li> not <divs> that's what I meant
buiphuking
@buiphuking
May 28 2016 03:19
@Chrono79
my clock, 2 weeks
http://codepen.io/buiphuking/pen/NrKypv
i want to ask a p inside the clock to show the status : session or break, but i don't know how, plz help me out
Diego Mayer
@Chrono79
May 28 2016 03:20
@dctor then, instead of returning (that exits your function) make yourNewArray.push(yourOldArray[i]);
DC
@dctor
May 28 2016 03:21
@Chrono79 did that but not working hence the return to debug...
@Chrono79 here's the algo
  var num=[];
  for (i=0; i <=str.split(" ").length; i++) {
   num.push(str.split(" ")[i].length);
   }
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Diego Mayer
@Chrono79
May 28 2016 03:26
@dctor don't shoot yourself on the foot, make it simple:
function findLongestWord(str){
  var longest = 0;
  var arr = str.split(" ");
  for (var i = 0; i < arr.length; i++) {
    if arr[i].length > longest {
      longest = arr[i].length;
    }
  }
  return longest;
}
@buiphuking I'm not acustomed to jade, but how do you control the class of the color? Could you not set a text in the same way?
buiphuking
@buiphuking
May 28 2016 03:29
@Chrono79
click view compiled
Greg Munker
@Gmunker
May 28 2016 03:29
I'm sure i'm overlooking something stupid (and if i am i'm going to sleep), but i cannot figure this out. It's killing me cause i have used for loops for arrays and objects alot, so i'm sure it's something very very stupid (at least i'm hoping it is). :/
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i=0; i<=contacts.length - 1; i++) {

    if ((contacts[i].firstName === firstName) && (contacts[i].hasOwnProperty(prop))) {
    return contacts[i][prop];
    } else if (contacts[i].firstName !== firstName) {
      return "No such contact";
    } else if (contacts[i][prop] !== prop) {
      return "No such property";
    }


  }

// Only change code above this line
}
Taylor Williams
@Twilliams6006
May 28 2016 03:29
$.getJSON(loc, function(response){ For some reason I can't seem to get this to work, and I unable to use a variable to pass the url to getJSON?
Chris Cullen
@123xylem
May 28 2016 03:29
@Chrono79 O i knew the children of UL were LI.. Well i knew LI belonged to UL. Just I didn realise how my wrap was working
Greg Munker
@Gmunker
May 28 2016 03:29
for some reason it keeps returning no such contact, but if i remove the else if's it returns the correct info....
Diego Mayer
@Chrono79
May 28 2016 03:30
@123xylem ok, yes wrap contains the element it's applied to
@Gmunker no such contact should be returned outside the loop, why? because you have to look over the whole contact list to say you didn't find it
Norvin Burrus
@ndburrus
May 28 2016 03:32
@Gmunker review this line contacts.length - 1 ...minus one?
Diego Mayer
@Chrono79
May 28 2016 03:33
@ndburrus he used <=, if it's < it's contacts.length, if it's <= it's contacts.length -1
Norvin Burrus
@ndburrus
May 28 2016 03:33
@Chrono79 hmmm....
Greg Munker
@Gmunker
May 28 2016 03:33
yea so it's removing the total count to bring it down to the 0 index
just the way i was taught
Norvin Burrus
@ndburrus
May 28 2016 03:34
@Chrono79 @Gmunker ok... :sparkles:
Greg Munker
@Gmunker
May 28 2016 03:34
get the same result, but i dont understand why i'm not going through the whole array
buiphuking
@buiphuking
May 28 2016 03:34

this is my code with Sum All Odd Fibonacci Numbers


function sumFibs(num) {
  var res = 2; 
  var a = [1, 1];
  if(num === 1 ){
    return 0;
  }else if(num === 2){
    return 2;
  }else{
    var i = 2;
    while(a[a.length -1] < num){
      a[i] = a[a.length -2] + a[a.length -1];
      if(a[i] % 2 !== 0 && a[i] <= num){
        res += a[i];
      }
      i++;
    }

  }
  return res;

}
sumFibs(1000);

is anyone has better solution ?

Xavier Velez
@JonSnow08
May 28 2016 03:34
is anybody available to help me with the Nesting For Loops challenge
Greg Munker
@Gmunker
May 28 2016 03:34
the loop is doing it's job, it works fine when i remove the else if's
Diego Mayer
@Chrono79
May 28 2016 03:35
@buiphuking why this? if(num === 1 ){
return 0;
Xavier Velez
@JonSnow08
May 28 2016 03:35
``js
oops
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
for (var i = 0; i<multiplyAll.length; i++){
  for(var j=0; j < multiplyAll[i].length; j++){

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
this is what I have so far
Diego Mayer
@Chrono79
May 28 2016 03:37
@Gmunker because you return no matter what happens
contacts[i][prop] !== prop is highly probable, it's wrong too
@JonSnow08 multiplyAll is your function name, use arr
Greg Munker
@Gmunker
May 28 2016 03:38
should be hasownprop
Diego Mayer
@Chrono79
May 28 2016 03:38
@Gmunker yes
Greg Munker
@Gmunker
May 28 2016 03:39
@Chrono79 still only returns No such contact
Diego Mayer
@Chrono79
May 28 2016 03:39
@Gmunker have you remove it from inside the loop?
Greg Munker
@Gmunker
May 28 2016 03:39
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i=0; i<=contacts.length - 1; i++) {

    if ((contacts[i].firstName === firstName) && (contacts[i].hasOwnProperty(prop))) {
    return contacts[i][prop];
    } else if (contacts[i].firstName !== firstName) {
      return "No such contact";
    } else if (contacts[i].hasOwnProperty(prop)) {
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
GAH
devyd09
@devyd09
May 28 2016 03:39
I am trying to Create a variable called hairColor and set it equal to a string of your hair color. This is my code var myHairColor = "blond"; it is telling me it is undefined. what am I doing wrong?
Greg Munker
@Gmunker
May 28 2016 03:40
damn i am tired
buiphuking
@buiphuking
May 28 2016 03:40
@Chrono79
fibonacci 1 1 2 3..... , num === 1 , sum odd num = 1, is mean sum all odd num fibonacci < 1 is 0
Diego Mayer
@Chrono79
May 28 2016 03:40
me too
Greg Munker
@Gmunker
May 28 2016 03:40
hold on fixing the else if for the prop
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i=0; i<=contacts.length - 1; i++) {

    if ((contacts[i].firstName === firstName) && (contacts[i].hasOwnProperty(prop))) {
    return contacts[i][prop];
    } else if (contacts[i].firstName !== firstName) {
      return "No such contact";
    } else if (contacts[i].hasOwnProperty(prop) !== prop) {
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
Diego Mayer
@Chrono79
May 28 2016 03:41
@buiphuking Return the sum of all odd Fibonacci numbers up to and including the passed number if it is a Fibonacci number.
Greg Munker
@Gmunker
May 28 2016 03:41
ok now it's still not returning correct if there is a firstname and prop that exists
but if i take out the else if's it works fine
Diego Mayer
@Chrono79
May 28 2016 03:42
What should I do for you to remove "No such contact" from the loop? @Gmunker
Norvin Burrus
@ndburrus
May 28 2016 03:43
@devyd09 the code looks good....
code:
var myHairColor = "blond"; 
console.log(myHairColor);
-----------------------------
output:
blond
Greg Munker
@Gmunker
May 28 2016 03:43
just the string or the whole else if
Diego Mayer
@Chrono79
May 28 2016 03:43
@Gmunker the else if delete it, put the return after the loop
Chris Cullen
@123xylem
May 28 2016 03:43
http://codepen.io/123xylem/pen/xOKZyy?editors=1011 Im wondering How I display Info on Freecodecamp stream given the data call only gives me a small json array with nothing I can make a good display out of
Alexis
@alexisgcn
May 28 2016 03:44
@Gmunker is better if you use indentation. Indent your second condition and dont use hasOwnProperty better use contacs[i][prop] and return it
Xavier Velez
@JonSnow08
May 28 2016 03:44
@Chrono79 thank you
CamperBot
@camperbot
May 28 2016 03:44
jonsnow08 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 913 | @chrono79 |http://www.freecodecamp.com/chrono79
buiphuking
@buiphuking
May 28 2016 03:45
@Chrono79
my code works, i don't know exactly want i'm thinking that moment , i 've lost my mind something
devyd09
@devyd09
May 28 2016 03:45
@ndburrus it still tells me its undefined... oops I spelt blonde wrong.. hahaha is there a reason why it would be telling me that?
Diego Mayer
@Chrono79
May 28 2016 03:46
I'm going to sleep, take care
Isaac Pak
@pak11273
May 28 2016 03:46
can someone check this code out:
function destroyer(arr) {
  var args = Array.from(arguments);
  var end = args.length;
  args = args.slice(1, end);

  arr.filter(rmArgs);

  function rmArgs(value) {
    value !== args;
  }
  return args;
}
buiphuking
@buiphuking
May 28 2016 03:46
@Chrono79
As an example, passing 4 to the function should return 5 because all the odd Fibonacci numbers under 4 are 1, 1, and 3.
Norvin Burrus
@ndburrus
May 28 2016 03:47
@devyd09 if you're working in the browser, refresh? try outside the browser? i'm not sure why there would be an "undefined" error... there is a declared & initialized variable...
buiphuking
@buiphuking
May 28 2016 03:47
num = 1, under 1 is 0, i think so
Diego Mayer
@Chrono79
May 28 2016 03:47
@buiphuking yes, that's ok, but I think that for numbers like 1 or 2 you should return 2
devyd09
@devyd09
May 28 2016 03:48
@ndburrus I tried that but still same thing... weird
buiphuking
@buiphuking
May 28 2016 03:48
@Chrono79
1 return 0, 2 return 2
Diego Mayer
@Chrono79
May 28 2016 03:48
@buiphuking I agree to disagree
Andy Roush
@AndyRoush
May 28 2016 03:49
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16];   // Change this Line
not letting me pass
because of no bracket notation to access testObj
but I have it right there no?
Alexis
@alexisgcn
May 28 2016 03:50
@pak11273 make args equal to arr.slice.call(arguments) and arg.slice(0,1)
Andrew Dinh
@andrewtdinh
May 28 2016 03:52
Hi @AndyRoush . Maybe try
var player = testObj[playerNumber];
Norvin Burrus
@ndburrus
May 28 2016 03:52
@AndyRoush challenge name?
@devyd09 can you post code?
Andrew Dinh
@andrewtdinh
May 28 2016 03:53
Or
```
Norvin Burrus
@ndburrus
May 28 2016 03:54
@AndyRoush you need to use the variable (playerNumber) to access the property. the variable can change, whereas the hard coded 16 cannot change.... make sense?
DC
@dctor
May 28 2016 03:57
@Chrono79 the reason my loop didn't work was i had a = in i<=.length....it works now thanks
CamperBot
@camperbot
May 28 2016 03:57
dctor sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 914 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen Mansfield
@StephenMansfield
May 28 2016 04:01
o wow that was annoying
spent like half an hour trying to figure out Seek and destroy, only to realize that the function is set up wrong and needs more variables
Isaac Pak
@pak11273
May 28 2016 04:03
@StephenMansfield im still battling it out lol
devyd09
@devyd09
May 28 2016 04:05
@ndburrus var myHairColor = "brown";
that is all I have
ThaleSelaht
@ThaleSelaht
May 28 2016 04:05
@StephenMansfield so u hardcoded it, cuz it doesn't need more variables
Stephen Mansfield
@StephenMansfield
May 28 2016 04:06
really? @ThaleSelaht
daiwik
@daiwik
May 28 2016 04:06
This message was deleted
This message was deleted
Chris Cullen
@123xylem
May 28 2016 04:06
http://codepen.io/123xylem/pen/xOKZyy How can I get my text to not sit under the images? I want my text to start in the top center but the image is making it start in the middle
Stephen Mansfield
@StephenMansfield
May 28 2016 04:07
this is what i see when i hit the reset button
```

function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Andy Roush
@AndyRoush
May 28 2016 04:08
@andrewtdinh that did it, thanks!
Stephen Mansfield
@StephenMansfield
May 28 2016 04:08
if i do a console.log(arr); on this
CamperBot
@camperbot
May 28 2016 04:08
andyroush sends brownie points to @andrewtdinh :sparkles: :thumbsup: :sparkles:
:cookie: 229 | @andrewtdinh |http://www.freecodecamp.com/andrewtdinh
Stephen Mansfield
@StephenMansfield
May 28 2016 04:08
i only ever get [1, 2, 3, 1, 2, 3]
ThaleSelaht
@ThaleSelaht
May 28 2016 04:08
@StephenMansfield all functions has an native property called arguments, try to console.log(arguments) inside ur function
@StephenMansfield When I said property I meant object
Ken Truong
@kjjtruong
May 28 2016 04:11
@123xylem you mean you want the image to be on the left of the text?
DJ
@qualitymanifest
May 28 2016 04:12
@123xylem if you want it at the top above the picture, insert the titles into the DOM before you insert the pictures. if you just want it to not be below the picture, try giving outputHeadings display: inline;
Ken Truong
@kjjtruong
May 28 2016 04:12
@123xylem left of the display name and text
Stephen Mansfield
@StephenMansfield
May 28 2016 04:13

@ThaleSelaht soooooo what would expect this to print out in the console?
```
function destroyer(arr) {
console.log(arr[0],arr[1],arr[2]);
return arr;
}

destroyer([1, "tester", "mester", 1, 2, 3], "if i see this", "I was messing it up the entire time");

Chris Cullen
@123xylem
May 28 2016 04:13
@kjjtruong so image with text to right of it and both of them at the top of their div
Stephen Mansfield
@StephenMansfield
May 28 2016 04:13
function destroyer(arr) {
console.log(arr[0],arr[1],arr[2]);
return arr;
}
destroyer([1, "tester", "mester", 1, 2, 3], "if i see this", "I was messing it up the entire time");
ThaleSelaht
@ThaleSelaht
May 28 2016 04:13
@StephenMansfield haha rly funny;
Andrew Dinh
@andrewtdinh
May 28 2016 04:14
@AndyRoush Glad you got it right!
ThaleSelaht
@ThaleSelaht
May 28 2016 04:14
@StephenMansfield cast a console.log(arguments) inside ur function to see the magic happen
Chris Cullen
@123xylem
May 28 2016 04:15
@qualitymanifest the inline thing took my divs out
ThaleSelaht
@ThaleSelaht
May 28 2016 04:15
@StephenMansfield literraly "console.log(arguments)" btw
Stephen Mansfield
@StephenMansfield
May 28 2016 04:16
@ThaleSelaht thanks, i see it now
CamperBot
@camperbot
May 28 2016 04:16
stephenmansfield sends brownie points to @thaleselaht :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
ThaleSelaht
@ThaleSelaht
May 28 2016 04:16
@StephenMansfield np mate
Isaac Pak
@pak11273
May 28 2016 04:17
anyone else think the mdn documentation for js is too technical?
ThaleSelaht
@ThaleSelaht
May 28 2016 04:18
@pak11273 I got used to it, and sincerally it delivers what we need
Eldar Tinjić
@EldarT90
May 28 2016 04:19
im trying to get data in form of json, but it wont respond
Isaac Pak
@pak11273
May 28 2016 04:21
@ThaleSelaht probably so, but I guess the issue is that if you don't have more background in js than what fcc teaches before the challenges, then you will end up spending hours filling in gaps with the mdn docs like I am.
Norvin Burrus
@ndburrus
May 28 2016 04:22
@devyd09 nothing wrong with it.... https://repl.it/CWKx/0 test it yourself... :)
code:
var myHairColor = "brown"; 
console.log(myHairColor);
-----------------
output:
brown
ThaleSelaht
@ThaleSelaht
May 28 2016 04:23
@pak11273 I have to agree
Xavier Velez
@JonSnow08
May 28 2016 04:32
can someone help with Profile Lookup checkpoint please
```js
function lookUpProfile(firstName, prop){
// Only change code below this line
//Check if the firstName is equal to the arrays first name and if prop is a property of that contact

  while(i < contacts.length){ 

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

      if (prop===contacts[i].lastName){
        return prop;
  }
      else if (prop===contacts[i].number){
       return prop;
  }
       else if (prop===contacts[i].likes[1||2||3]){
        return prop; }
          else {return "No such property";}
}
else{
  return "No such contact";
}
i = 0;
i++;
  }
even when I define i before the while loop i get an error
Isaac Pak
@pak11273
May 28 2016 04:35
@JonSnow08 where is contacts defined?
Xavier Velez
@JonSnow08
May 28 2016 04:35
var i = 0 before the while line i mean

//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){
// Only change code below this line
//Check if the firstName is equal to the arrays first name and if prop is a property of that contact

var i= 0;  
  while(i < contacts.length){ 

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

      if (prop===contacts[i].lastName){
        return prop;
  }
      else if (prop===contacts[i].number){
       return prop;
  }
       else if (prop===contacts[i].likes[1||2||3]){
        return prop; }
          else {return "No such property";}
}
else{
  return "No such contact";
}

i++;
  }
// If both are true then return the value of that prop
//if firstName doesnt match any array return No such contact
//If prop does not match any of the properties then return No such property  

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Norvin Burrus
@ndburrus
May 28 2016 04:35
@JonSnow08 unmatched "{". function lookUpProfile(firstName, prop){ also, you are iterating through contacts, so this line needs attention {firstName does not have an "i"}: if (firstName === contacts.firstName[i]){ question answer: yes, i added the contacts object prior to testing... :) review/check the logic: if (prop===contacts[i].lastName){ should we check for prop (as opposed to lastName) here? not sure why these 2 lines are included: else if (prop===contacts[i].number){ else if (prop===contacts[i].likes[1||2||3]){
Xavier Velez
@JonSnow08
May 28 2016 04:37
@ndburrus even with the entire code?
sorry I didnt paste the whole thing
ah ok
Isaac Pak
@pak11273
May 28 2016 04:38
@JonSnow08 contacts[i] not contacts.firstName[i]
Chris Cullen
@123xylem
May 28 2016 04:39
Easy Question: Why is my link only working on right click? http://codepen.io/123xylem/pen/xOKZyy?editors=0010
"  <a href =" + data.featured[i].stream.channel.url + " >Link  </a>   "
Do i need a function with the link or should it work automatically
Norvin Burrus
@ndburrus
May 28 2016 04:47
@JonSnow08 is it getting clearer, or fuzzier?
Xavier Velez
@JonSnow08
May 28 2016 04:47
@ndburrus honestly fuzzier hahahha
Norvin Burrus
@ndburrus
May 28 2016 04:48
@JonSnow08 ok, thanks for your honesty... want to walk through the logic?
CamperBot
@camperbot
May 28 2016 04:48
ndburrus sends brownie points to @jonsnow08 :sparkles: :thumbsup: :sparkles:
:cookie: 221 | @jonsnow08 |http://www.freecodecamp.com/jonsnow08
Xavier Velez
@JonSnow08
May 28 2016 04:48
@ndburrus i'd love to thank you
CamperBot
@camperbot
May 28 2016 04:48
jonsnow08 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @ndburrus |http://www.freecodecamp.com/ndburrus
Philip Eckert
@pae4557
May 28 2016 04:49
@ndburrus Is it possible to work this problem with for loops instead? Currently working on it myself and that's how I have it started. :/
Norvin Burrus
@ndburrus
May 28 2016 04:49
ok, we'll map, or approach, the logic in the same order as it is given in the challenge... yes, for loop/s are useful in this challenge...
Isaac Pak
@pak11273
May 28 2016 04:50
@pae4557 yes use for loops
Xavier Velez
@JonSnow08
May 28 2016 04:51
see I started with for loops and I couldnt figure out where to begin, it seemed clearer with a while loop
Philip Eckert
@pae4557
May 28 2016 04:51
Thank you @pak11273
CamperBot
@camperbot
May 28 2016 04:51
pae4557 sends brownie points to @pak11273 :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @pak11273 |http://www.freecodecamp.com/pak11273
Isaac Pak
@pak11273
May 28 2016 04:51
you intermingle loops
i mean. you can use different loops within your function
Norvin Burrus
@ndburrus
May 28 2016 04:52
@JonSnow08 ok, the 1st requirement checks if firstName is an actual firstName. you have if (firstName === contacts.firstName[i]){ this needs a little work. can you see why? hint: contacts is your object table.... it has all of the information (to be seached) in it.
Ken Truong
@kjjtruong
May 28 2016 04:52
@123xylem FYI you need to double check your stynax where you're appending all your HTML. Your forgot a '>' for the opening DIV
@123xylem that's throwing your styling off
Xavier Velez
@JonSnow08
May 28 2016 04:53
@ndburrus my logic was to compare the variable first name to the array's first name
Isaac Pak
@pak11273
May 28 2016 04:53
i personally would rather use for loops than while loops :)
Xavier Velez
@JonSnow08
May 28 2016 04:53
ah so i only need contacts
Norvin Burrus
@ndburrus
May 28 2016 04:54
@JonSnow08 exactly. notice that the iterating counter/value (i) is attached to firstName.... there are no firstName's with multiple values. there are multiple firstNames within the contacts object... so where should the i be? said another way - what should the i be attached to/associated with?
Xavier Velez
@JonSnow08
May 28 2016 04:55
gotcha
Ken Truong
@kjjtruong
May 28 2016 04:55
@123xylem you can't open links within codpens viewer. Use target="_blank"
Xavier Velez
@JonSnow08
May 28 2016 04:56
the contacts
if (firstName === contacts[i]){
Norvin Burrus
@ndburrus
May 28 2016 04:56
@JonSnow08 more specifically, the contacts object
Xavier Velez
@JonSnow08
May 28 2016 04:57
like that?
or am I getting further away?
Norvin Burrus
@ndburrus
May 28 2016 04:58
@JonSnow08 yes, exactly... now, you have identified (with the i) that we are iteratnig through the contacts object, but what property are we looking for (firstName, lastName, number, or likes)?
Xavier Velez
@JonSnow08
May 28 2016 04:58
the firstName
Norvin Burrus
@ndburrus
May 28 2016 04:58
@JonSnow08 so, we need to tell the code... how do we do that?
Xavier Velez
@JonSnow08
May 28 2016 04:58
gotcha
so contact[i].firstName
contacts*
Norvin Burrus
@ndburrus
May 28 2016 04:59
@JonSnow08 you bet... so what is our 1st logic conditional code line?
Xavier Velez
@JonSnow08
May 28 2016 05:00
if (firstName === contacts[i].firstName){
Norvin Burrus
@ndburrus
May 28 2016 05:00
@JonSnow08 right on.... ok... now, we also need to check if prop is a value of the contact (once a match is found on the firstName). make sense? so, we get a firstName match... how can we do this (check this record for a prop match)?
Xavier Velez
@JonSnow08
May 28 2016 05:03
nest an if within that first one that checks for each prop vs the actual properties within the object
if (prop===contacts[i].lastName){
return prop;
}
else if (prop===contacts[i].number){
return prop;
}
else if (prop===contacts[i].likes[1||2||3]){
return prop; }
else {return "No such property";}
Norvin Burrus
@ndburrus
May 28 2016 05:05
@JonSnow08 ok, lets use the instructions here. we are checking for prop, right?
Xavier Velez
@JonSnow08
May 28 2016 05:05
yup
Norvin Burrus
@ndburrus
May 28 2016 05:06
@JonSnow08 ok, we are inside a for loop and on a record with a firstName match. the i counter is guiding us. so, there are 4 records. let's say there is a match on the 3rd record. how can we search the 3rd contacts record for a prop (firstName, lastName, number, or likes) match? in your code you specify lastName, number, and likes1[3]. is there an easier way? in this example, how about contactsi
Xavier Velez
@JonSnow08
May 28 2016 05:10
if (prop === contacts[i].firstName || contacts[i].lastName ||contacts[i].number ||contacts[i].likes)
Isaac Pak
@pak11273
May 28 2016 05:12
is the filter function even worth using for Seek and Destroy challenge?
function destroyer(arr) {

  arr = arguments[0];
  arr = arr.filter(removeArgs);

  function removeArgs(value) {
    return value !== 2;
  }

  return arr;

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Xavier Velez
@JonSnow08
May 28 2016 05:12
so I don't have to specify which one to search through? is that what you're saying?
Norvin Burrus
@ndburrus
May 28 2016 05:12
@JonSnow08 hmmm.... how about a boulean return? we are simply looking to see if there is a match between the given value for prop and the record value for prop
Philip Eckert
@pae4557
May 28 2016 05:12

@ndburrus
for (j = 0; j < contacts[i].length; j++){
if (prop === contacts[i][j]){

would this code work? at this point?

Mithun reddy
@mithunreddyt
May 28 2016 05:13
can any one help with the concept of stand in line in java script
Philip Eckert
@pae4557
May 28 2016 05:13
It seems not, as contacts[0].length returns nothing for me
Parveen Sharma
@username-parveen
May 28 2016 05:13
Norvin Burrus
@ndburrus
May 28 2016 05:13
@JonSnow08 what do you think about if (contacts[i][prop]) { ? this simply means tell me true or false if the prop value given (as input) matches the prop record value...
Xavier Velez
@JonSnow08
May 28 2016 05:14
i honestly don't understand how that would work
there's not a boulean statement there that I can see, maybe I'm missing it
Mithun reddy
@mithunreddyt
May 28 2016 05:15
can any one help with the concept of stand in line in java script
Philip Eckert
@pae4557
May 28 2016 05:15
Well doesn't an if statement always evaluate to a boolean? such that if contacts[i][prop] exists it evaluates to true? @JonSnow08 @ndburrus
Eldar Tinjić
@EldarT90
May 28 2016 05:16
how do i combine json and react with using both of their perks
Xavier Velez
@JonSnow08
May 28 2016 05:16
@pae4557 ah that makes sense now
no need to use an === because if that doesnt exist it wont return true
Philip Eckert
@pae4557
May 28 2016 05:16
@JonSnow08 not sure if I'm even right haha
Xavier Velez
@JonSnow08
May 28 2016 05:17
haha well it makes logical sense right now
Norvin Burrus
@ndburrus
May 28 2016 05:17
@pae4557 yes, that would be true.... nice point. i guess i'm comparing it to the prior code attempt to use multiple conditions/statements when it can be accomplished with one boulean... and while using each individual prop to do the checking...
@JonSnow08 ok, nice.... so, now we can take an action based on the result (true/false). if true, what do we need to do?
Xavier Velez
@JonSnow08
May 28 2016 05:18
return prop i believe
Philip Eckert
@pae4557
May 28 2016 05:19
yes! @JonSnow08
@JonSnow08 return contacts[i][prop]; worked for me
Norvin Burrus
@ndburrus
May 28 2016 05:20
@JonSnow08 you are on fire :fire: ok, can we update the code... (and post, please)
Philip Eckert
@pae4557
May 28 2016 05:20
for (i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName){
if (contacts[i][prop]){
return contacts[i][prop];
}
}
}
Norvin Burrus
@ndburrus
May 28 2016 05:21
@JonSnow08 ok, what if the return from the boulean is false, what do we do then? we either: a) come back with the record prop, or b) inform that....
Xavier Velez
@JonSnow08
May 28 2016 05:22
return "No Such Property"
Norvin Burrus
@ndburrus
May 28 2016 05:22
@JonSnow08 super! ok, let's update the code and handle the final requirement... as luck would have it, the logic fits neatly/simply & conveniently in the decision structure...
@JonSnow08 aaahh, but where? can we post the code... need to make sure we're on the same page...
Xavier Velez
@JonSnow08
May 28 2016 05:24
in an else statement?
for (i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName){
if (contacts[i][prop]){
return contacts[i][prop];
}
}
}
Chris Cullen
@123xylem
May 28 2016 05:25
@kjjtruong thanks but target blank didnt help either unless I put it in the wrong place
CamperBot
@camperbot
May 28 2016 05:25
:warning: 123xylem already gave kjjtruong points
123xylem sends brownie points to @kjjtruong :sparkles: :thumbsup: :sparkles:
buiphuking
@buiphuking
May 28 2016 05:25
someone teach me the best technique to check a number is prime , plz !!!!!!!!!
Norvin Burrus
@ndburrus
May 28 2016 05:25
@JonSnow08 ok, put in what happens if false on prop... note: "If firstName does not correspond to any contacts then return "No such contact""
Chris Cullen
@123xylem
May 28 2016 05:26
@kjjtruong Is it something to do with me not having a onclick function? Last time this happend to me I had to remove my button tag for the link to work. but this is a bit different
Xavier Velez
@JonSnow08
May 28 2016 05:26
for (i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName){
if (contacts[i][prop]){
return contacts[i][prop];
}
else{return "No such property";}
}
}
Chris Cullen
@123xylem
May 28 2016 05:26
RE WHy my links arent working
Norvin Burrus
@ndburrus
May 28 2016 05:27
@JonSnow08 alright the last requirement is "If prop does not correspond to any valid properties then return "No such property"" how do we handle this one?
Philip Eckert
@pae4557
May 28 2016 05:27
@ndburrus So wait, how does the logic work with the contact not being no such contact?
Xavier Velez
@JonSnow08
May 28 2016 05:27
wouldn't that be an else statement after the next }
sorry i think i confused us, no such contact, then no such property
Norvin Burrus
@ndburrus
May 28 2016 05:28
@JonSnow08 well done... :+1: @pae4557 that's where we're going...
Philip Eckert
@pae4557
May 28 2016 05:28
@JonSnow08 I don't believe so. I tried that, but then it stops executing the loop on the first run if it doesn't match
Xavier Velez
@JonSnow08
May 28 2016 05:28
or did I have it right the first time around?
Norvin Burrus
@ndburrus
May 28 2016 05:29
@JonSnow08 other way around.... prop then contact. we're working from the inside out... prop is the innermost eval right?
Xavier Velez
@JonSnow08
May 28 2016 05:29
for (i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName){
if (contacts[i][prop]){
return contacts[i][prop];
}
else{return "No such property";}
}else {return "No such contact";}
}
yep
Norvin Burrus
@ndburrus
May 28 2016 05:30
@JonSnow08 ok, see how the prop matches with the 1st if eval (true/false on firstName)?
Xavier Velez
@JonSnow08
May 28 2016 05:31
yeah they're closest together
Norvin Burrus
@ndburrus
May 28 2016 05:31
This message was deleted
Philip Eckert
@pae4557
May 28 2016 05:32
@ndburrus Sorry for asking such an elementary question, but how do I enter my code so that it appears in the formatted window?
Xavier Velez
@JonSnow08
May 28 2016 05:32
k done
Norvin Burrus
@ndburrus
May 28 2016 05:33
@JonSnow08 i'd organize the format so it's easier to read:
  for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i].firstName) {
      if (contacts[i][prop]) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else {
      result =  "No such contact";
    } 
  }
help format @pae4557 just type help (subject) and camperbor will assist if possible
CamperBot
@camperbot
May 28 2016 05:33

: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

Xavier Velez
@JonSnow08
May 28 2016 05:33
i just learned that today myself haha
for (i = 0; i < contacts.length; i++){

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

    if (contacts[i][prop]){

      return contacts[i][prop];
}

        else{return "No such property";}
}
          else {return "No such contact";}
}
better?
Philip Eckert
@pae4557
May 28 2016 05:34
for (i = 0; i < contacts.length; i++){
  if (firstName === contacts[i].firstName){
    if (contacts[i][prop]){
        return contacts[i][prop];
    }
    else { 
      return "No such property";
    }
  }
}
return "No such contact";
Norvin Burrus
@ndburrus
May 28 2016 05:35
@pae4557 nice... ok, does this all come together and make some sense?
Philip Eckert
@pae4557
May 28 2016 05:35
@ndburrus The above code passed the challenge, but is it really the way to go about it? The idea is that if the loop never executes it simply returns the "no such contact"
@ndburrus And yes it does now! Thank you so much for all the help.
CamperBot
@camperbot
May 28 2016 05:36
pae4557 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 442 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 28 2016 05:36
@pae4557 well, the loop will begin/execute on the 1st record... won't it?
Xavier Velez
@JonSnow08
May 28 2016 05:38
ah I had mine a bit early so it wasn't getting to it
Eldar Tinjić
@EldarT90
May 28 2016 05:38
need help with reactJS
Norvin Burrus
@ndburrus
May 28 2016 05:38
@pae4557 this is the 1st record...
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
Xavier Velez
@JonSnow08
May 28 2016 05:38
@ndburrus seriously thank you for taking the time out to walk us through that I have a much better understanding now. you should teach this for a living hahah
CamperBot
@camperbot
May 28 2016 05:38
jonsnow08 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: jonsnow08 already gave ndburrus points
Philip Eckert
@pae4557
May 28 2016 05:38
Yes it will
Norvin Burrus
@ndburrus
May 28 2016 05:39
@JonSnow08 @pae4557 welcome to all... a pleasure... i need to develop some more before offering guidance... much to learn... :+1:
Xavier Velez
@JonSnow08
May 28 2016 05:40
well your teaching method is flawless @ndburrus
Norvin Burrus
@ndburrus
May 28 2016 05:41
@JonSnow08 appreciate the kindness :) anyway, 2 people to the finish line is great... better than 1 person dropping off midstream.... good catch on where your code veered off... well done, again...
Chris Cullen
@123xylem
May 28 2016 05:45
http://codepen.io/123xylem/pen/xOKZyy?editors=1100 ANybody know why my links dont work on leftclick?
Jack Lyons
@JackEdwardLyons
May 28 2016 05:46
hey guys, im having trouble working on the logic for the "online" and "offline" status of my twitch API app
my code is like this:
/* Display online/offline users on click */
   $("button#online-channels").on("click", function() {
     if ($("div.wrapper").has(channelStatus === "Offline")) {
       $("div.wrapper").has(channelStatus === "Offline").addClass("remove-channels");
     } 
   });
Ayush Kenhi
@AyushKenhi
May 28 2016 05:49
Can someone help me with js code
Jack Lyons
@JackEdwardLyons
May 28 2016 05:53
hey @123xylem try this
"<div class=' streamOutput'><li class='streamsInfo'>" + "<img class='image' src='" + data.featured[i].image + "'> </img>" + "<p class='outputHeadings'>" + data.featured[i].stream.channel.display_name + "   :  " + data.featured[i].title + "</p>" + "<p class= 'streamText'" + data.featured[i].text + "</p>" + "<a target='_blank' href ='" + data.featured[i].stream.channel.url + "'" + ">Link</a><br></div>")
           }
         });;
it's because you need to nest the href in single quotes because it's already in double quotes
Ayush Kenhi
@AyushKenhi
May 28 2016 05:54
hey
CAn anybody help me
Jerliyah
@Jerliyah
May 28 2016 05:54
On the "Seek and Destroy" challenge, the given argument doesn't return completely when called. If you run the program plain (no edits), the returned value isn't the same as the input, and therefore how should I access the rest of the information to complete the challenge?
Jack Lyons
@JackEdwardLyons
May 28 2016 05:54
I added in target='_blank' as well because that will open it in another window @123xylem
Norvin Burrus
@ndburrus
May 28 2016 05:55
@AyushKenhi can you post your code so far?
Ayush Kenhi
@AyushKenhi
May 28 2016 05:56
@ndburrus I havent made any progress. Its completely new for me
Norvin Burrus
@ndburrus
May 28 2016 05:57
@AyushKenhi ok, we'll need 2 of the four array methods: push, pop, shift and unshift. which ones should we use?
Ayush Kenhi
@AyushKenhi
May 28 2016 05:57
@ndburrus I am not able to understand what he wants
i have learnt push, pop
Mithun reddy
@mithunreddyt
May 28 2016 05:58
me to not getting the same code @ndburrus
Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed. @ndburrus
Norvin Burrus
@ndburrus
May 28 2016 05:59
@AyushKenhi @mithunreddyt ok, the 1st requirement is: "Add the number to the end of the array," do we know how to do this?
Mithun reddy
@mithunreddyt
May 28 2016 05:59
.shift();
.push();
Ayush Kenhi
@AyushKenhi
May 28 2016 06:00
IDK..... I just know ... We have to use pop to remove end target
and push(); to the end of the array
Norvin Burrus
@ndburrus
May 28 2016 06:03
@AyushKenhi @mithunreddyt ok, this may be useful: JavaScript Array Methods: Unshift(), Shift(), Push(), And Pop(), {ref: http://www.bennadel.com/blog/1796-javascript-array-methods-unshift-shift-push-and-pop.htm } or this: JavaScript Array Management with Push(), Pop(), Shift() and Unshift(), {ref: http://blog.kevinchisholm.com/arrays-javascript/javascript-array-management-with-push-pop-shift-and-unshift/ }
Justin Woodward
@jwoo92
May 28 2016 06:03
im having trouble viewing this API in my console under the object section. can anyone assist me on how to properly view the object? i am using chrome and have clicked 'ctrl + shift + i' and refreshed the page.
Norvin Burrus
@ndburrus
May 28 2016 06:06
@AyushKenhi @mithunreddyt so, when we have the 2 array methods, we can construct our code... :)
@AyushKenhi push to handle/add the number to the array end is correct.. so what is the code for that?
Felix Rodriguez
@felixrodriguez12
May 28 2016 06:08
So my code isn't giving me Kristian's last name. Instead it results in "No such property. Please help: ```JS

//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){
// Only change code below this line

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

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

    // Incorrectly checks if "lastName" is equal to "vos"
  if (prop == contacts[i][prop])
    {
      return contacts[i][prop];
    }
   else if (prop !== contacts[i][prop] )
     {
       return "No such property";
     }
  }

}
return "No such contact";

}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Norvin Burrus
@ndburrus
May 28 2016 06:10
@felixrodriguez12 this line needs some attention (prop == contacts[i][prop]) if (or an if/else if statement) can evaluate to a boulean, so including an equality condition isn't necessary. this line is really evaluating if the inputted prop value exists in the contacts[i] record, right? additionally, this line else if (prop !== contacts[i][prop] ) exists (or can be used) to simply handle the case if the prop value is not in the matched firstName record, agree?
Ankur sharma
@ankur1163
May 28 2016 06:15
I need help
I am trying to create glow effect after 5 seconds but this isnt happening
here's my code
html
<html lang="en">

<body>

  <div id="tile1" class="tile1">


  </div>

  <div id="tile2" class="tile2">

  </div>

  <div id="tile3" class="tile3">

  </div>
  <button onclick="next">next</button>

</body>


<footer>
<script   src="https://code.jquery.com/jquery-2.2.4.min.js"   integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="   crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
  <script src="https://use.fontawesome.com/f19e167ed9.js"></script>

  <link rel="stylesheet" type="text/css" href="amazing.css">
  <script src="amazing.js"></script>



</footer>
</html>
css
Jerliyah
@Jerliyah
May 28 2016 06:16
@ThaleSelaht that seems so weird, but thanks
CamperBot
@camperbot
May 28 2016 06:16
jerliyah sends brownie points to @thaleselaht :sparkles: :thumbsup: :sparkles:
:cookie: 223 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
Ankur sharma
@ankur1163
May 28 2016 06:16
.tile1{
  height:100px;
  width:100px;


}

.grenpulse{
  -webkit-animation-name: greenPulse;
 -webkit-animation-duration: 2s;
 -webkit-animation-iteration-count: infinite;
}



@-webkit-keyframes greenPulse {
  from { background-color: #749a02; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #91bd09; -webkit-box-shadow: 0 0 18px #91bd09; }
  to { background-color: #749a02; -webkit-box-shadow: 0 0 9px #333; }
}


.tile2{
  height:100px;
  width:100px;

}
.orangepulse{
  -webkit-animation-name: orangePulse;
 -webkit-animation-duration: 2s;
 -webkit-animation-iteration-count: infinite;
}



@-webkit-keyframes orangePulse {
  from { background-color: #F2C7AA; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #94420C; -webkit-box-shadow: 0 0 18px #91bd09; }
  to { background-color: #F2C7AA; -webkit-box-shadow: 0 0 9px #333; }
}


.tile3{
  height:100px;
  width:100px;

}

.yellowpulse{
  -webkit-animation-name: yellowPulse;
 -webkit-animation-duration: 2s;
 -webkit-animation-iteration-count: infinite;
}



@-webkit-keyframes yellowPulse {
  from { background-color: #F5F5A4; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #969606; -webkit-box-shadow: 0 0 18px #91bd09; }
  to { background-color: #F5F5A4; -webkit-box-shadow: 0 0 9px #333; }
}
js
function next(){

setInterval(function(){ $("#tile1").addClass("greenPulse"); }, 5000);

 }
I expect to see glowing tile after 5 second interval
but it doesnt happen and there is no error in console
ThaleSelaht
@ThaleSelaht
May 28 2016 06:16
@Jerliyah lol kinda
Ankur sharma
@ankur1163
May 28 2016 06:18
i found one error and rectified it
<button onclick="next()">next</button>
It still doesnt work. I have added () next
Ayush Kenhi
@AyushKenhi
May 28 2016 06:19
@ndburrus code for using push or pop should be someArray.pop();
Chris Cullen
@123xylem
May 28 2016 06:20
@JackEdwardLyons Your a genius. Thanks
CamperBot
@camperbot
May 28 2016 06:20
123xylem sends brownie points to @jackedwardlyons :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @jackedwardlyons |http://www.freecodecamp.com/jackedwardlyons
Arin
@arinarjani
May 28 2016 06:20
@ankur1163 I am not sure if this is the problem, but in your CSS, .greenpulse is mispelled
Norvin Burrus
@ndburrus
May 28 2016 06:20
@AyushKenhi ok, we identified that we need to use push. what would be the code for this line?
Ayush Kenhi
@AyushKenhi
May 28 2016 06:21
@ndburrus someArray.push("something");
Aditya Giridhar
@agiridh
May 28 2016 06:21
@sjames1958gm yeah! :)
Norvin Burrus
@ndburrus
May 28 2016 06:22
@AyushKenhi ok, the instructions tell us what the inputs are: "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. " so, what is the something? "Add the number to the end of the array,"
Thomas Nguyen
@thomasnguyen
May 28 2016 06:22
<a href="">
            <div class="col-md-3 col-xs-6" id="col1">
                <img class="imgicon" src="http://i.imgur.com/TNRqU6G.png"><br>
                EDUCATION
            </div>
  </a>

<script>
 $("#col1").on("click", function(){
                    $("#col1").html("lol");
                });
</script>
so this code should work right? i want my code to change the html on click
Krona Emmanuel
@LightMode
May 28 2016 06:24
This message was deleted
Hello, I am doing the Record Collection WayPoint in the Basic Javascript section and I am having a hard time understanding the instructions because i am not a native english speaker. Can anyone please help me with it? https://www.freecodecamp.com/challenges/record-collection
ThaleSelaht
@ThaleSelaht
May 28 2016 06:26
@LightMode what's ur native lang?
Krona Emmanuel
@LightMode
May 28 2016 06:27
Urdu but Hindi is similar so i can understand that... @ThaleSelaht
Ayush Kenhi
@AyushKenhi
May 28 2016 06:27
kaise ho
Can you understand that
ThaleSelaht
@ThaleSelaht
May 28 2016 06:28
@LightMode I wish I could translate =D
Krona Emmanuel
@LightMode
May 28 2016 06:28
Yeah I can...Me theek hu...
ThaleSelaht
@ThaleSelaht
May 28 2016 06:29
@LightMode Looks like u found a fellow =D
Krona Emmanuel
@LightMode
May 28 2016 06:29
Thanks Btw @ThaleSelaht
CamperBot
@camperbot
May 28 2016 06:29
lightmode sends brownie points to @thaleselaht :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @thaleselaht |http://www.freecodecamp.com/thaleselaht
Krona Emmanuel
@LightMode
May 28 2016 06:29
Yeah
=)
Norvin Burrus
@ndburrus
May 28 2016 06:30
@AyushKenhi ok, what is the code the push the number onto the end of the array?
Ankur sharma
@ankur1163
May 28 2016 06:30
@arinarjani yeah, let me check
Krona Emmanuel
@LightMode
May 28 2016 06:30
@AyushKenhi Can you help?
Ankur sharma
@ankur1163
May 28 2016 06:30
still nothing
Krona Emmanuel
@LightMode
May 28 2016 06:30
But im not sure if other languages are allowed in chat or not?
ThaleSelaht
@ThaleSelaht
May 28 2016 06:31
@LightMode don't worry
Krona Emmanuel
@LightMode
May 28 2016 06:31
OK :)
Ayush Kenhi
@AyushKenhi
May 28 2016 06:36
What do you need help with @LightMode
Krona Emmanuel
@LightMode
May 28 2016 06:36
@AyushKenhi I cant understand the instruction at https://www.freecodecamp.com/challenges/record-collection
Ayush Kenhi
@AyushKenhi
May 28 2016 06:39
okay
Justin Woodward
@jwoo92
May 28 2016 06:41
im on the twitch.tv api project and i cant get my api to return certain Object's contents. any help?
kirbyedy
@kirbyedy
May 28 2016 06:43
if we look at your code might be easier for us to help :)
ogunoye adebamigbe john
@adebamigbejohn
May 28 2016 06:44
hello please i need help over here
i need help with word blanks
kwal0203
@kwal0203
May 28 2016 06:46
@jwoo92 post code
@adebamigbejohn post code
ogunoye adebamigbe john
@adebamigbejohn
May 28 2016 06:48

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

// Your code above this line
return result;
}

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

kwal0203
@kwal0203
May 28 2016 06:48
@adebamigbejohn you gotta store the words in the result variable
soarersiuhc
@soarersiuhc
May 28 2016 06:48
hi, did anyone look at https://www.freecodecamp.com/challenges/pairwise before?
kwal0203
@kwal0203
May 28 2016 06:49
@adebamigbejohn example: result = myNoun + ' ' + myVerb etc
@adebamigbejohn i think with that one you have to create your own variables to make a sentence i.e.: var word = 'The' and put that in there somewhere
AntonTokar
@AntonTokar
May 28 2016 06:50
thanks @CaroleAnneHannon for your help with Checkpoint: Stand in Line
CamperBot
@camperbot
May 28 2016 06:50
antontokar sends brownie points to @caroleannehannon :sparkles: :thumbsup: :sparkles:
:cookie: 844 | @caroleannehannon |http://www.freecodecamp.com/caroleannehannon
kwal0203
@kwal0203
May 28 2016 06:51
@soarersiuhc maybe use .filter function?
soarersiuhc
@soarersiuhc
May 28 2016 06:51
I just want a clarification
kwal0203
@kwal0203
May 28 2016 06:54
@soarersiuhc shouldn't it be 9?
@soarersiuhc maybe you can only use the first 0 once. That would make it the answer 10
@soarersiuhc yeah that's correct. You can only use the positions once. The answer is 10
@soarersiuhc 0 + 4 = 4, 1 + 5 = 6... 4 + 6 = 10
soarersiuhc
@soarersiuhc
May 28 2016 06:56
hm, I guess I am confused by "If multiple pairs are possible that have the same numeric elements but different indices, return the smallest sum of indices. "
so for example, are you saying that the combination (0,1) can be used multiple times?
Justin Woodward
@jwoo92
May 28 2016 06:57
@kwal0203 i believe i got it straightened out, thanks anyway.
CamperBot
@camperbot
May 28 2016 06:57
jwoo92 sends brownie points to @kwal0203 :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @kwal0203 |http://www.freecodecamp.com/kwal0203
ogunoye adebamigbe john
@adebamigbejohn
May 28 2016 06:57
thamks @kwal0203
kwal0203
@kwal0203
May 28 2016 06:57
@soarersiuhc no I'm saying the opposite. It can only be used once
soarersiuhc
@soarersiuhc
May 28 2016 06:57
nah, you are saying that as long as they have distinct pairs of indices you can reuse them
kwal0203
@kwal0203
May 28 2016 06:58
@soarersiuhc The indices can only be used once. The values don't matter
soarersiuhc
@soarersiuhc
May 28 2016 06:58
but I mean the actual pair of numbers themselves
ah i see
that clarifies things - the wording is confusing.
Thanks!
Justin Woodward
@jwoo92
May 28 2016 07:06
i cant seem to figure out why my stream = null in my if/else is not working. would someone look over my code? i am currently only figuring my api for a username. then i will code the rest. http://codepen.io/jwoo/pen/bebYLO?editors=1011
i have it set to a user that is 'offline'.
AntonTokar
@AntonTokar
May 28 2016 07:07

function trueOrFalse(wasThatTrue) {
if(wasThatTrue=4) {return "Yes, that was true"}
else return "No, that was false"}

trueOrFalse(5);

HELP. what's wrong with my code ?
CamperBot
@camperbot
May 28 2016 07:08
no wiki entry for: whats wrong with my code
Markus Kiili
@Masd925
May 28 2016 07:08
@AntonTokar = is assignment operator. === compares. What are you supposed to check?
AntonTokar
@AntonTokar
May 28 2016 07:09
anyway run test doesn't pass
trueOrFalse(true) should return "Yes, that was true"
Markus Kiili
@Masd925
May 28 2016 07:10
@AntonTokar Why are you then checking against 4?
AntonTokar
@AntonTokar
May 28 2016 07:11
I've checked any variables
Markus Kiili
@Masd925
May 28 2016 07:11
@AntonTokar if(x===true) or if(x) both check whether x is true.
AntonTokar
@AntonTokar
May 28 2016 07:12
@Masd925

function trueOrFalse(wasThatTrue) {
if(wasThatTrue===4) {return "Yes, that was true"}
else return "No, that was false"
}

trueOrFalse(6);

@Masd925 everything works, but the test does not pass
Markus Kiili
@Masd925
May 28 2016 07:13
@AntonTokar What is the challenge name?
AntonTokar
@AntonTokar
May 28 2016 07:13
@Masd925 Use Conditional Logic with If Statements
@Masd925 thanks
CamperBot
@camperbot
May 28 2016 07:14
antontokar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1641 | @masd925 |http://www.freecodecamp.com/masd925
AntonTokar
@AntonTokar
May 28 2016 07:14
@Masd925 I've done it. with your help
Markus Kiili
@Masd925
May 28 2016 07:14
@AntonTokar ok.
Ankur sharma
@ankur1163
May 28 2016 07:15
can someone help me
function next(){

setInterval(function(){ $("#tile1").addClass("greenPulse"); }, 5000);

 }
i am using this function to create delay of 5 seconds and then add class to element
but it isnt hapening
html code
<html lang="en">

<body>

  <div id="tile1" class="tile1">


  </div>

  <div id="tile2" class="tile2">

  </div>

  <div id="tile3" class="tile3">

  </div>
  <button onclick="next()">next</button>

</body>


<footer>
<script   src="https://code.jquery.com/jquery-2.2.4.min.js"   integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="   crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
  <script src="https://use.fontawesome.com/f19e167ed9.js"></script>

  <link rel="stylesheet" type="text/css" href="amazing.css">
  <script src="amazing.js"></script>



</footer>
</html>
Markus Kiili
@Masd925
May 28 2016 07:17
This message was deleted
Ankur sharma
@ankur1163
May 28 2016 07:18
why you deleted the message
I already added window :)
but still it didnt run
Markus Kiili
@Masd925
May 28 2016 07:18
@ankur1163 It is optional, I think.
Ankur sharma
@ankur1163
May 28 2016 07:18
ok