These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Mar 2016
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 00:02
@SAdamsKY01 if something after`it` is true
then you cen make one thing
and if not, you can skip it.
@SAdamsKY01 in your lesson `wasThatTrue` can be `true`
and in this case you return one thing
or you can return another, if it's not true.
@SAdamsKY01 understand?
Mason Mckenney
@MWMckenney
Mar 20 2016 00:08
I am struggling a little with storing values with the equal operator. I.e assigning the value in variable a and assigning it to variable b.
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:08
``return x !== false && x !== null && x!== "" && x !== 0 && x!==undefined && Number.isNaN(x) === false;``
Whats the best way to combine that? It seems like every time i use the || it gets screwy
I want it to be just one "X !==" Statement
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 00:10
@grizzlyadams4725 how tha task was called?
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:11
``````function bouncer(arr) {
// Don't show a false ID to this bouncer.
function filter(x){
return x !== false && x !== null && x!== "" && x !== 0 && x!==undefined && Number.isNaN(x) === false;
}
arr = arr.filter(filter);
return arr;
}

bouncer([7, "ate", "",  undefined, 0, NaN, false, 9]);``````
It works fine the way it is, but it looks terrible lol
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 00:11
```@grizzlyadams4725 var newArray = arr.filter(function(val) {
return Boolean(val) === true;
});
return newArray;
``` var newArray = arr.filter(function(val) {
return Boolean(val) === true;
});
return newArray;
f**k... anyway, you can copy the text.
that's all I've done with it
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:12
ohhh that's so much easier
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 00:12
yep
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:12
I was looking for soemthing like that
thanks @vl-doit
CamperBot
@camperbot
Mar 20 2016 00:13
grizzlyadams4725 sends brownie points to @vl-doit :sparkles: :thumbsup: :sparkles:
:star: 299 | @vl-doit | http://www.freecodecamp.com/vl-doit
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 00:13
I'm also a kind of hero when it comes to make 40 strings instead of 1 regexp...)))
@grizzlyadams4725 I want to pair program
@grizzlyadams4725 can you help me?
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:15
@vl-doit I'm not sure if I'm there yet, but I'm willing to help where I can
Oscar Fitch
@MrTaquito
Mar 20 2016 00:16

@grizzlyadams4725

function bouncer(arr) {
return arr.filter(function(x){
return x; });
}

easier
Andrew Vanboxel
@avanbox
Mar 20 2016 00:17
any jquery/javascript allstars around? I have a problem and im sure its something silly. (it always is).
MikeBeers
@MikeBeers
Mar 20 2016 00:18
I am just starting the sorted union. Wondering if anyone could explain it a little better. Not sure what it is trying to get me to do.
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 00:19
@MrTaquito Yep!
Andrew Vanboxel
@avanbox
Mar 20 2016 00:20
@MikeBeers you want to take the 3 arrays, and combine them into one, in the same order and remove duplicates
MikeBeers
@MikeBeers
Mar 20 2016 00:20
got it. thanks
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:20
lol thanks @MrTaquito I missed one sentence "and constructs a new array of all the values for which callback returns a true value or a value that coerces to true. "
CamperBot
@camperbot
Mar 20 2016 00:20
grizzlyadams4725 sends brownie points to @mrtaquito :sparkles: :thumbsup: :sparkles:
:star: 273 | @mrtaquito | http://www.freecodecamp.com/mrtaquito
grizzlyadams4725
@grizzlyadams4725
Mar 20 2016 00:21
I spent way too long on that problem for it to have been that simple :P
Andrew Vanboxel
@avanbox
Mar 20 2016 00:21
can someone tell me why the console.log(divTitle) will not work in my pen? im sure its a scope issue but i cant figure it out.
Ulises Rangel
@urangel
Mar 20 2016 00:33
hello everyone! :D
DJ
@qualitymanifest
Mar 20 2016 00:39
@avanbox AJAX calls are asynchronous, so despite the .getJSON starting to run before the console.log, the console.log fires before the .getJSON finishes
@avanbox you could do all your work inside the .getJSON success function (probably the easiest option here), or you could use jquery .when .done
Andrew Vanboxel
@avanbox
Mar 20 2016 00:45
thanks. Im trying to get that 'title' and use it in the function below that creates divs
Thanks @qualitymanifest
CamperBot
@camperbot
Mar 20 2016 00:47
avanbox sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1087 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
tupelo87
@tupelo87
Mar 20 2016 00:53
can anyone help me in understanding the Stand in Line challenge thing?
williamquan
@williamquan
Mar 20 2016 00:56
Can someone help me with Make Object Properties Private Challenge?
``````var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear;

this.getGear = function(change) {
gear += change;
};

this.setGear = function() {
return gear;
};
};``````
Marc
@wumpafruits
Mar 20 2016 00:59
This message was deleted
looking some steps up i guess i should be loking into using a for looppp
Ariel
@abibliophile
Mar 20 2016 01:12
I'm not quite sure where I'm going wrong here
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

var prop=collection[id][prop];

switch (prop){
case (prop=="tracks"||prop!==""):
prop.push();
break;
case (prop!=="tracks"||prop!==""):
prop=value;
break;
case (prop===""):
prop.delete();
break;

}
return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");``````
Moisés Man
@moigithub
Mar 20 2016 01:16
@abibliophile before `switch` add `console.log(prop);` and check on console/devtools what ur prop value is
uriznik
@uriznik
Mar 20 2016 01:17
@williamquan think about what names of the function you need to create, 'setGear' and 'getGear'
Ariel
@abibliophile
Mar 20 2016 01:21
@moigithub I added in the console.log(prop); statement before switch but nothing has changed. all that is displayed is the collection (bizarrely enough, even when i delete the return statement for the collection)
Moisés Man
@moigithub
Mar 20 2016 01:24
@abibliophile soooo u opened devtools and checked console ??
Ariel
@abibliophile
Mar 20 2016 01:25
how do you do that? sorry
Moisés Man
@moigithub
Mar 20 2016 01:25
console.log is for debuggin.. to see what ur code `var prop=collection[id][prop];` is doing
F12 on most browsers... or right click whatever element on ur page, select inspect and switch tab to "console"
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:26
``````function chunk(arr, size) {
var myArray=[],
array=arr,
cut=size,
length = array.length/size;

myArray[0][0]=arr[0];
myArray[0][1]=arr[1];
myArray[1][0]=arr[2];
myArray[1][1]=arr[3];

console.log(myArray);

}
chunk(["a", "b", "c", "d"], 2);``````
im just writing things down to clarify but getting TypeError Cannot set propery of '0' undefined. Why that happens ?
Ariel
@abibliophile
Mar 20 2016 01:28
okay @moigithub i did that. what do i do with that information?
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:29
hello, is there a way to update my solutions on projects I've done for freecodecamp? In some cases the links are incorrect, and I would prefer having all of them link to the full webpage as opposed to the editor.
Micah Bales
@micahbales
Mar 20 2016 01:30
Hi! Can anyone give me a hint on what my next step should be in solving this problem? The exercise is here: https://www.freecodecamp.com/challenges/where-art-thou
``````function where(collection, source) {
var arr = [];
for (var i in collection) {
for (var j in collection[i]) {
arr.push(collection[i]);
}
}
return arr;
//return Object.keys(collection).map(Number);
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });``````
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:33
wow this challenge
Anton Bredl
@antonbr13
Mar 20 2016 01:33
``````function repeat(str, num) {
if (num < 0 ){
return '';
}
else{

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

return str ;
}
}
}

console.log(repeat("abc", 3));``````
can i get some help on the above

Repeat a string repeat a string

Repeat a given string (first argument) num times (second argument). Return an empty string if num is a negative number.

Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:36
michabales you should check each item in the array for the field you want, if the field exists check the contents of that field, if they are the same as the source then you should add them to an array which you then return
Micah Bales
@micahbales
Mar 20 2016 01:37
@someonefromcanada38 Yes, I am trying to do that. My confusion is how to do that.
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:37
alternate solution is to do the reverse, with the array you are given check each component for the field required, then check if the fields contents are the same as source, if not pop it off of the array.
Micah Bales
@micahbales
Mar 20 2016 01:37
@someonefromcanada38 And when you say "field", what do you mean?
you mean the key/value pair?
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:37
I'm calling "first" and "last" fields
yes
the key is "first" or "last"
you can search if that key exists
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:38
``````var myArray = [];
for(var i = 0 ; i < num ; i ++){
myArray[i]= str;
}
myArray=myArray.join(separator);``````
@antonbr13 find out join function and separator you might be surprised how easy it is
thats just a little hint
@antonbr13 and u dont need num.length for a num because its integer so u just use num
you might try removing that length
Anton Bredl
@antonbr13
Mar 20 2016 01:40
good call on the num.length - i get that just a mistake out of repetition
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:40
micahbales if you are confused about the syntax array[key] will give you the value if it does not exist I think you will get an undefined which should not matter if you are using === as your comparison operator.
Micah Bales
@micahbales
Mar 20 2016 01:42
@someonefromcanada38 but i'm confused because i'm trying to find a match with "source", which is a key/value pair.
I'm not just searching for a key or a value, but both
it's really a string, isn't it?
er, no, i guess it's not a string
might be easier if it were
Anton Bredl
@antonbr13
Mar 20 2016 01:43
@uRTLy i know i can't use return in the for loop because that stops the iteration and breaks out of the flow of the for loop
i am struggling with a fix for that
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:44
@antonbr13 yes you cant use return more than once so using array and returning joined by separator array so string is good idea
Moisés Man
@moigithub
Mar 20 2016 01:44
@micahbales what data type `collection` and `source` are ??
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:44
@antonbr13 i pasted that
Anton Bredl
@antonbr13
Mar 20 2016 01:44
and I am also no familiar with what you were trying to get across with the 'find out join function and separator you might be surprised how easy it is' -
Micah Bales
@micahbales
Mar 20 2016 01:44
the first is an array of objects
the second is an object
@moigithub
Anton Bredl
@antonbr13
Mar 20 2016 01:45
ohh okay i see what you are saying
Moisés Man
@moigithub
Mar 20 2016 01:45
@micahbales ok :) for ..IN is not meant to use with Arrays....
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:45
@antonbr13 just paste good separator in join function. its variable now but its supposed to be value you want to separate each word with.
method*
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:45
@micahbales Object.keys(value) is the syntax you are looking for to find the key of a key/value pair
Micah Bales
@micahbales
Mar 20 2016 01:45
@moigithub seems to work...
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:46
you can compare Object.keys(source) and Object.keys(array[x]) to find out if they have the same key
Moisés Man
@moigithub
Mar 20 2016 01:46
yep... works.. but if ur arrays Must keep an order.. it can lead to unknows behaviors.. (according to doc) @micahbales so better use another type of iterators.. for/loop, forEach, while/loops, map
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:47
and then you can use source[key] to get the value and array[key] to get the value
Micah Bales
@micahbales
Mar 20 2016 01:47
@moigithub What's the alternative?'
@moigithub Sorry, didn't see you answered that question already
Thanks, @someonefromcanada38. I'll give that a try.
CamperBot
@camperbot
Mar 20 2016 01:48
micahbales sends brownie points to @someonefromcanada38 :sparkles: :thumbsup: :sparkles:
Moisés Man
@moigithub
Mar 20 2016 01:48
yep was editing :P
CamperBot
@camperbot
Mar 20 2016 01:48
:star: 315 | @someonefromcanada38 | http://www.freecodecamp.com/someonefromcanada38
Andrew Irwin
@someonefromcanada38
Mar 20 2016 01:48
@micahbales let me know if you have any more trouble with it.
Micah Bales
@micahbales
Mar 20 2016 01:49
will do!
and thanks @moigithub
CamperBot
@camperbot
Mar 20 2016 01:49
micahbales sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 766 | @moigithub | http://www.freecodecamp.com/moigithub
Anton Bredl
@antonbr13
Mar 20 2016 01:51
@uRTLy thanks mayne - i wasn't logically thinking about that properly for some reason
CamperBot
@camperbot
Mar 20 2016 01:51
antonbr13 sends brownie points to @urtly :sparkles: :thumbsup: :sparkles:
:star: 100 | @urtly | http://www.freecodecamp.com/urtly
Anton Bredl
@antonbr13
Mar 20 2016 01:51
``````function repeat(str, num) {
var answer = [];
if (num < 0 ){
return '';
}
else{

for(var i = 0; i < num; i++) {

answer.push(str);
}
}
answer = answer.join('');
return answer;
}

repeat("abc", 3);``````
@uRTLy got it tho!
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:53
no problem :D
Rex Smith Jr.
@rsmith731
Mar 20 2016 01:55
has anyone did the Word Blanks exercise?
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:56
whats exactly ur problem
Julián
@Ulian
Mar 20 2016 01:56
I'm sad, I think I'm not made for this. I know what each method (.map, .reduce, ect) does, I know how to use it, but I can't find out WHEN to use it. I mean, I have to look at google to get a clue. Intermediate and advanced algorithm scripting are making me crazy.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:57
@pitazo same feeling here
Rex Smith Jr.
@rsmith731
Mar 20 2016 01:57
@uRTLy not exactly understanding what its asking me to do
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:57
@pitazo when it comes to real coding I cant do shit
@pitazo we need just time. thats all hack for those everyday
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 01:57
@pitazo me too!
@pitazo man, that's cool!
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:57
@rsmith731 just add values they want
Julián
@Ulian
Mar 20 2016 01:58
@uRTLy Yes, maybe time will fix us ahah.
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 01:58
@pitazo i'm f**king with No Repeats Please
Patrick Tłuszcz
@uRTLy
Mar 20 2016 01:58
@rsmith731 add each string they give you
@rsmith731 to one word
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 01:58
I'm trying to solve it with mathematical method @pitazo
at least I've spent 10 hours, but I'm close to eccentric solution
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:00
2 hours ago I was depply thinking about my knowledge
For whole day I was trying to do Tic Tac Toe
Julián
@Ulian
Mar 20 2016 02:01
@vl-doit I didnt get yet, I just finished "Exact Change". I'm afraid to start with "Inventory Update"
Rex Smith Jr.
@rsmith731
Mar 20 2016 02:01
@uRTLy it said that its already defined, so i only put the var name = “string name” and it’s still not working
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 02:01
@pitazo I haven't even completed them yet. I'm just doing my second Advanced task.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:02
@rsmith731 are you sure you talking about Word Blanks?
Rex Smith Jr.
@rsmith731
Mar 20 2016 02:02
@uRTLy yes
``````function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun = "cat";
myAdjective = "little";
myVerb = "hit";
myAdverb = "slowly";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly", "dog", "big", "ran", "quickly");``````
Julián
@Ulian
Mar 20 2016 02:03
@vl-doit Oh, I'm doing in a correlative order.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:03
@rsmith731 all they want is add 4 variables they give you, you can concatenate them by + and separate by some non character
Rex Smith Jr.
@rsmith731
Mar 20 2016 02:03
@uRTLy ok let me try that
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 02:03
@pitazo let's try to open private chat
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:04
@rsmith731 write variables like this ```js var a =0, b="hi", c="dog;```
use one var and separate with comma
Rex Smith Jr.
@rsmith731
Mar 20 2016 02:04
@uRTLy ok that makes sense, thanks
CamperBot
@camperbot
Mar 20 2016 02:04
rsmith731 sends brownie points to @urtly :sparkles: :thumbsup: :sparkles:
:star: 102 | @urtly | http://www.freecodecamp.com/urtly
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:04
@vl-doit @pitazo how long you learning web development at all?
Julián
@Ulian
Mar 20 2016 02:05
@uRTLy With javascript start just 6 days ago ahah. CSS and HTML maybe 2 o 3 month
Vladimir Logachev
@VladimirLogachev
Mar 20 2016 02:06
@uRTLy several years I've been using only HTML+CSS. JS is 9 days
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:07
@rsmith731 and dont assign those values again, They pass you it with a function so you do result = and then you concatenate what they give you in function wordBlanks
well why youre so far
with 9 days doing it
Im doing js a bit longer but skipped most of stuff here because heard these challenges are better than else.
ichirped
@ichirped
Mar 20 2016 02:29
help convert html entities
CamperBot
@camperbot
Mar 20 2016 02:29

# Problem Explanation:

• You have to create a program that will convert HTML entities from string to their corresponding HTML entities. There are only a few so you can use different methods.
Rex Smith Jr.
@rsmith731
Mar 20 2016 02:41
@uRTLy sorry but i still couldn’t figure it out
:(
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:45

@rsmith731 atleast you tried now stop wasting your time on such trivial thing, pick a solution and you'll get back to it another time.

``````var result = myNoun + " " + myAdjective + " " + myVerb + " " +  myAdverb ;

return result;``````

But i suggest you getting back to it and actually understandin it

i edited it . in `""` should be any non character separator you want to use ;
They wanted you to add variables they passed you in function name and return it to them just by separating it with any separator.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 02:51
``function wordBlanks(myNoun, myAdjective, myVerb, myAdverb )``

<----- that function has variables like
"myNoun", "myAdjectie" , "myVerb"
you can use them inside your function, assign them to variables or manipulate on them

like

``````

var myOfficialNoun = myNoun < --- they passed it to you

myOfficialNoun = "Dog";

return myOfficialNoun;``````

you can do whatever you want on variables they pass you,

they passed them here

``````wordBlanks("cat", "little", "hit", "slowly");

so  myNoun is equal to "cat" and myAdjective to "little"``````

@rsmith731

Eduardo A. González Robles
@GonzandRobles
Mar 20 2016 02:57
This message was deleted
Joseph
@revisualize
Mar 20 2016 02:58

#### Here are some learning resources that I found via my Facebook feed in the last few days: http://www.syncfusion.com/resources/techportal/ebooks

If you sign up you can use your gmail address like this:
username+syncfusion.com @ gmail dot com (fixed it for non-linking)
and in the future you'll be able to filter out all of the spam that you may get.
Eduardo A. González Robles
@GonzandRobles
Mar 20 2016 02:58

Hi, I have a question, val inside ( ) means that is part of a function right?
What does it mean when you put val inside [ ] in the return statement.
Example:

``````function phoneticLookup(val) {
var result = "";

var lookup = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

result = lookup[val];

return result;
}

phoneticLookup("charlie”);``````

Thanks

Joseph
@revisualize
Mar 20 2016 02:59
That isn't working?
Eduardo A. González Robles
@GonzandRobles
Mar 20 2016 03:00
Sorry not in the return statement but in the result = lookup[val];
Joseph
@revisualize
Mar 20 2016 03:00
@GonzandRobles So, `val` is the variable that you're taking in from the function call.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:01
``phoneticLookup("charlie")``

charlie is inside your val;

``function phoneticLookup(val)``

means you will pick one variable ,
if they give call a function like this phoneticLookup("charlie")
they pass it to you

Eduardo A. González Robles
@GonzandRobles
Mar 20 2016 03:01
@revisualize ok, but why does it have to go inside [ ] ?
Joseph
@revisualize
Mar 20 2016 03:01
Because it is a variable.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:02
Because you want to pick "charlie" from ur object
Moisés Man
@moigithub
Mar 20 2016 03:02
cuz lookup is an object..
and to access their values.. u can use or Dot notation OR Brackets notation
the previous exercises before the one u doing was about object notations....probably u wanna review those :)
Joseph
@revisualize
Mar 20 2016 03:03
This message was deleted
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:03
``````val = "charlie"
var lookup = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

lookup["charlie"]= "Chicago";
result = "Chicago";``````
I just explained functions and passing arguments with them before ur question,
Eduardo A. González Robles
@GonzandRobles
Mar 20 2016 03:03
@moigithub ohh ok, it makes sense now
thanks guys
Joseph
@revisualize
Mar 20 2016 03:05
``````var val = 3;

var myArr = ['a','b','c','d','e','f'];
return myArr[val];

var myObj = {
0: "a",
1: "b",
2: "c",
3: "d",
4: "e",
5: "f",
};
return myObj[val];``````
Moisés Man
@moigithub
Mar 20 2016 03:05
if u see curly brackets {...} is an object...
if u see square brackets [...] is an array...
there are some video challenges on fcc-map about those
Joseph
@revisualize
Mar 20 2016 03:06
@moigithub Arrays are objects. Objects may not be arrays.
Moisés Man
@moigithub
Mar 20 2016 03:06
Array's use numeric indices....
Objects use keys or properties (whichever u wanna call it )
Eduardo A. González Robles
@GonzandRobles
Mar 20 2016 03:06
Thanks @moigithub @revisualize
CamperBot
@camperbot
Mar 20 2016 03:06
gonzandrobles sends brownie points to @moigithub and @revisualize :sparkles: :thumbsup: :sparkles:
:star: 760 | @revisualize | http://www.freecodecamp.com/revisualize
:star: 767 | @moigithub | http://www.freecodecamp.com/moigithub
Artur Sęp
@a-sep
Mar 20 2016 03:07
God morning All :)
Joseph
@revisualize
Mar 20 2016 03:09
var my = [1];
typeof(my);
=> 'object'
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:10
array os an object
is
lol
a lot of mess here
JiaLe Guo
@gabygoole
Mar 20 2016 03:14
why palindrome("1 eye for of 1 eye.") should return false?
Joseph
@revisualize
Mar 20 2016 03:14
because it isn't a palindrome.
JiaLe Guo
@gabygoole
Mar 20 2016 03:14
eyeforofeye
Joseph
@revisualize
Mar 20 2016 03:14
1
CamperBot
@camperbot
Mar 20 2016 03:14

## The Return Early Pattern

The return early pattern in JavaScript is a simple way to reduce the number of `else` statements within a function body to zero. There are many reasons to prefer this pattern over using `else` statements.

• Reducing the total amount of code on the page
• Reduce line length by reducing logical complexity
• Improve Readability

The essence of the return early pattern is to replace the need for `else` conditionals in JavaScript functions by using the `return` keyword in the body of the `if` statement.

Let us create function that behaves differently under certain conditions (note: this is a trivial and contrived example just to get the point accross).

```js
function willItBlend(someObject) {
var ItWillBlend;

if (someObject.blendable ==== 'It will blend') {
itWillBlend = true;
} else {
itWillBlend = false;
:pencil: read more about the return early pattern on the FCC Wiki

Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:14
eye 1 fo rof eye 1
Moisés Man
@moigithub
Mar 20 2016 03:15
keep the numbers
JiaLe Guo
@gabygoole
Mar 20 2016 03:15
reverse it it still be eyeforofeye
Joseph
@revisualize
Mar 20 2016 03:15
You keep the numbers. So, no it isn't.
JiaLe Guo
@gabygoole
Mar 20 2016 03:15
Note
You'll need to remove all non-alphanumeric characters
@revisualize
Joseph
@revisualize
Mar 20 2016 03:16
GREAT! All non-alphanumeric. Everything that is not alpha OR numeric
Meaning.. Keep everything that is alpha and numeric
JiaLe Guo
@gabygoole
Mar 20 2016 03:17
I got it,thanks!
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:17
!@#\$%^&*()_
couple of non alpha
numeric
Joseph
@revisualize
Mar 20 2016 03:18
/me passes the comprehensive reading exam.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:19
what does that mean
Mandeep Bhutani
@mandeep
Mar 20 2016 03:36
hi all
Artur Sęp
@a-sep
Mar 20 2016 03:37
@mandeepbhutani hi
Mandeep Bhutani
@mandeep
Mar 20 2016 03:37
im having a problem with palindromes
i cant pass one of the test cases
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:41
show the code
Mandeep Bhutani
@mandeep
Mar 20 2016 03:41
sure
im not sure how to paste i n the channel but here's a paste https://bpaste.net/show/a34f148d7bf1
Joseph
@revisualize
Mar 20 2016 03:44
@mandeepbhutani Note: You'll need to remove all non-alphanumeric characters
You're not doing this.
@mandeepbhutani You're also not returning `true` or `false`
Mandeep Bhutani
@mandeep
Mar 20 2016 03:44
@revisualize if i do that then the last test case wont pass. right?
@revisualize i know i was just testing
Joseph
@revisualize
Mar 20 2016 03:45
@mandeepbhutani Please re-read the lesson.
Mandeep Bhutani
@mandeep
Mar 20 2016 03:45
alright let me take a look
Joseph
@revisualize
Mar 20 2016 03:46
@mandeepbhutani
Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
@mandeepbhutani You started doing that here:
``````  str = str.replace(/ /g, "");
str = str.toLowerCase();
str = str.replace(/[.,]/g,"");``````
So, you clearly read it.
Artur Sęp
@a-sep
Mar 20 2016 03:47
@mandeepbhutani to paste code use :
``` (pres enter and past your code and than pres enter + ctrl)
Joseph
@revisualize
Mar 20 2016 03:47
help format
CamperBot
@camperbot
Mar 20 2016 03:47

## :point_right: code formatting [wiki]

### Multi line Code

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

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

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

### Single line Code

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

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

Artur Sęp
@a-sep
Mar 20 2016 03:47
:)
Mandeep Bhutani
@mandeep
Mar 20 2016 03:47
@revisualize same problem
``````function palindrome(str) {
str = str.replace(/ /g, "");
str = str.toLowerCase();
str = str.replace(/\W/g,"");
var pal = str.split("").reverse().join("");
return str == pal;
}``````
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:48
dont use double assign on return
Joseph
@revisualize
Mar 20 2016 03:48
Again, you're not removing ALL non-alphanumeric characters. Including "_".
Mandeep Bhutani
@mandeep
Mar 20 2016 03:48
hmm
Artur Sęp
@a-sep
Mar 20 2016 03:48
@mandeepbhutani ```
Joseph
@revisualize
Mar 20 2016 03:49
@uRTLy == is not a double assign it is a comparison. It is correct.
Artur Sęp
@a-sep
Mar 20 2016 03:49
``str = str.replace(/\W|\_/g,'');``
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:49
=== is valid comparision
Mandeep Bhutani
@mandeep
Mar 20 2016 03:49
@revisualize thanks i got it
CamperBot
@camperbot
Mar 20 2016 03:49
mandeepbhutani sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 761 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 20 2016 03:49
=== is a strict comparison.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:49
the only valid comparision
Joseph
@revisualize
Mar 20 2016 03:49
== is still a comparison.
No.
Mandeep Bhutani
@mandeep
Mar 20 2016 03:49
@a-sep i used ^0-9a-zA-Z]
[^0-9a-zA-Z]
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:50
so keep using == lol for real
why would u want to return true or false in that challenge
Joseph
@revisualize
Mar 20 2016 03:50
str.replace(/\W_/g,'');
@uRTLy because that is the requirement of the challenge.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:50
in check for palindromes ?
Joseph
@revisualize
Mar 20 2016 03:50
palindrome("race car") should return true.
palindrome("not a palindrome") should return false.
yes.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:51
oh ye I messed
still Im using ===
Joseph
@revisualize
Mar 20 2016 03:52
Patrick Tłuszcz
@uRTLy
Mar 20 2016 03:54
as I said according to Stevan Stoyanov's book or whatever his name was "Patterns" I'm using ===
Patrick Tłuszcz
@uRTLy
Mar 20 2016 04:00
Pascal T.
@omegga
Mar 20 2016 04:01
help no repeats
CamperBot
@camperbot
Mar 20 2016 04:01

# Problem Explanation:

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

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

``````if(str[i] has not been used) {
put str[i] into the current position;
mark str[i] as used
perm(current position in original string, what's been used in original string, current string build thus far)
unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
}``````
Joseph
@revisualize
Mar 20 2016 04:01
@uRTLy I understand the issues of not using === and with using ==.
Patrick Tłuszcz
@uRTLy
Mar 20 2016 04:02
opposite it is
Frank XC
@tenkdayz
Mar 20 2016 04:05

\$(".halfcircle").click(function(){
if(Game.power){
var pInput = Number(\$(this).val());
Game.players.push(pInput);
if(Game.players.length===Game.sequence.length){
reminder(Game.sequence,false); //<<<< problem
}
compare();
}
});

var i =0;
function compare(){
if(Game.sequence[i]===Game.players[Game.players.length-1]){
i++;
}else{
alert("wrong key");
Game.players =[];
reminder(Game.sequence,true); //<<problem
i=0;
j=0;
}
}

var j=0;
function reminder(arr,outcome){ // this function is triggered twice by the 2 previous ones
j=0;
Game.playerFail = outcome;
var r = setInterval(function(){
resetColors();
\$("[value='"+arr[j]+"']").css("background","#ccc");
j++;
if(j>arr.length){
clearInterval(r);
resetColors();
j=0;
if(!Game.playerFail){randPush();}
}
},tempo);
}

PattyCreates
@PattyCreates
Mar 20 2016 04:07
Hi Guys. I'm having issues with getting a simple toggle to work.
I don't know what's happening, but I was wondering if there is anyone around to help.
Artur Sęp
@a-sep
Mar 20 2016 04:09
help format
CamperBot
@camperbot
Mar 20 2016 04:09

## :point_right: code formatting [wiki]

### Multi line Code

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

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

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

### Single line Code

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

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

PattyCreates
@PattyCreates
Mar 20 2016 04:12
``````%section
.row
.columns.six.phone-three.mobile-three
%a{:href => root_path, :alt => "LU"}
LUMobile
.columns.six.phone-one.mobile-one
%h4.toggle-mobile-nav-click
CL
%section.toggle-mobile-nav-slide
%ul
%a{:href => how_it_works_path, :alt => "How it works"}
%li.name
Approach

:javascript
\$(document).ready(function() {
\$(".toggle-mobile-nav-click").click(function() {
\$(".toggle-mobile-nav-slide").toggleSlide();
});
});``````
Ugh, my indentation got funky when pasting it here. But rest assured the haml is indented properly in the html area.
Rex Smith Jr.
@rsmith731
Mar 20 2016 04:18
@uRTLy thanks so much for your help!!!! :+1:
CamperBot
@camperbot
Mar 20 2016 04:18
rsmith731 sends brownie points to @urtly :sparkles: :thumbsup: :sparkles:
:star: 103 | @urtly | http://www.freecodecamp.com/urtly
PattyCreates
@PattyCreates
Mar 20 2016 04:20
Ah, nvm. I figured it out.
Geez that was frustrating.
Joseph
@revisualize
Mar 20 2016 04:30
What is `%`
Oh, it is HAML. meh.
Lallo Vigil
@lalov1
Mar 20 2016 04:45
Having trouble with Profile Lookup:
``````function lookUp(firstName, prop){

// Only change code below this line
for (i = 0; i < contacts.length; i++){
console.log(i);
console.log(contacts[i].firstName);
console.log(contacts[i][prop]);
if (firstName === contacts[i].firstName && contacts[i][prop]===prop){
return contacts[i][prop];
}else if (firstName !== contacts[i].firstName){
return "No such contact";
}
else {
return "No such property";
}
}
// Only change code above this line
}``````
CamperBot
@camperbot
Mar 20 2016 04:45
:bulb: to format code use backticks! ``` more info
Lokendra Sharma
@kuroop
Mar 20 2016 04:52
@lalov1 Firstly don't you think that knowing whether the contact exist in the array or not will require you to complete the full loop ? and the returl "No such contact" should be out of for loop ?
sloo012
@sloo012
Mar 20 2016 05:10
``````function sumPrimes(num) {
var nextNum = 3;
var sum =2;
while(nextNum <=num){

if((nextNum !==3 && nextNum % 3 !== 0) || (nextNum !== 5 && nextNum %5 !==0) || (nextNum !== 7 && nextNum %7 !==0)){
sum += nextNum;
}
nextNum += 2;
}
return sum;
}

sumPrimes(19);``````
Hi I need help with "sum of primes" problem
It wouldn't filter out the odd prime numbers
I tried to use if statement.. Something's wrong there
It is still adding the divisible number to the sum
Jeff Day
@realitygenerator
Mar 20 2016 05:16
I'm not sure why this isn't working. It returns true no matter what but I'm not seeing why
``````function palindrome(str) {
// Good luck!
var noTag = str.replace(/^[a-zA-Z0-9!@#\$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*\$/|"");
var lowerStr = noTag.toLowerCase();
var splitStr = lowerStr.split('');
if (splitStr === splitStr.reverse()){
return true;
}
}``````
Jason
@jpr00
Mar 20 2016 05:18
@sloo012 The || in your if statement should all be &&
Anton Bredl
@antonbr13
Mar 20 2016 05:25

Truncate a string
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a "..." ending.

Note that the three dots at the end add to the string length.

If the num is less than or equal to 3, then the length of the three dots is not added to the string length.

``````
function truncate(str, num) {
var string = str;
//   var num = num -3;

if(num <= 3) {
string = string.slice(0, num);
return string + '...';
}

else {
string = string.slice(0, num-3 ) + '...';
return string;
}

}

truncate("A-tisket a-tasket A green and yellow basket", 11);``````
i am getting 4 of 6 to pass
1. truncate("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket".

2. truncate("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) should return "A-tisket a-tasket A green and yellow basket".

^the above two are not passing
Jason
@jpr00
Mar 20 2016 05:27
@antonbr13 You need to test num against str.length . there is no need to slice if num is >= to str.length
Garrett
@grrttmrtn
Mar 20 2016 05:27
@realitygenerator you can cut 80% of your regex out
``````function titleCase(str) {
var arr = str.split(" ");
for (i = 0; i < arr.length; i++) {
arr = arr[i].toLowerCase();
arr = arr[i][0].toUpperCase();
}
return arr.join(' ');
}

titleCase("I'm a little tea pot");``````
Can someone help me with this
@lalov1 your second else if statement isn't necessarily needed. Look into getting rid of the last else statement and moving it outside of your loop
Anton Bredl
@antonbr13
Mar 20 2016 05:30
@jpr00 thanks yoo - i was missing that last little bit of logic
CamperBot
@camperbot
Mar 20 2016 05:30
antonbr13 sends brownie points to @jpr00 :sparkles: :thumbsup: :sparkles:
:star: 279 | @jpr00 | http://www.freecodecamp.com/jpr00
Jason
@jpr00
Mar 20 2016 05:30
@antonbr13 No problem
Jeff Day
@realitygenerator
Mar 20 2016 05:30
thank you @grrttmrtn I have /\W|_/g, '' as the RegEx expression now. but the code still always returns true
CamperBot
@camperbot
Mar 20 2016 05:30
realitygenerator sends brownie points to @grrttmrtn :sparkles: :thumbsup: :sparkles:
:star: 280 | @grrttmrtn | http://www.freecodecamp.com/grrttmrtn
DJ
@qualitymanifest
Mar 20 2016 05:31
@grrttmrtn strings are immutable, so you can't just uppercase the first letter like that
sloo012
@sloo012
Mar 20 2016 05:31
@jpr00 I don't think that's the problem
Garrett
@grrttmrtn
Mar 20 2016 05:33
@realitygenerator try returning your variables to see how your code is working so you can see if it is returning what you want
Jason
@jpr00
Mar 20 2016 05:34
@sloo012 The way you had it in your posted code, it was slicing and adding the ... when it should have just returned the whole string. what do you have now?
Jeff Day
@realitygenerator
Mar 20 2016 05:34
I did and they are.
DJ
@qualitymanifest
Mar 20 2016 05:35
@grrttmrtn i would recommend the same to you, except console.log instead of return. you may want to run it on something other than FCC's editor, maybe https://repl.it/languages/javascript
Garrett
@grrttmrtn
Mar 20 2016 05:36
@qualitymanifest, been trying that. Getting blank return lol
DJ
@qualitymanifest
Mar 20 2016 05:37
@grrttmrtn https://repl.it/BxwM try running that. you're changing arr to a single letter on the first run of the loop
Jason
@jpr00
Mar 20 2016 05:38
@sloo012 sorry, was looking at the wrong code... on yours, the || are allowing numbers through that should not. for example, 9 is not not 5 and 9 % 5 is not 0, so that let's it through even though 9 % 3 is 0
Garrett
@grrttmrtn
Mar 20 2016 05:38
@realitygenerator try assigning .reverse to a variable and return that. See if that returns whta you want
DJ
@qualitymanifest
Mar 20 2016 05:39
@realitygenerator can you paste your current code here
Jeff Day
@realitygenerator
Mar 20 2016 05:42
``````function palindrome(str) {
// Good luck!
var noTag = str.replace(/\W|_/g, '');
var lowerStr = noTag.toLowerCase();
var splitStr = lowerStr.split('');
if (splitStr === splitStr.reverse()){
return true;
}
}

palindrome("nope");``````
splitStr and splitStr.reverse() are both returning the expected values but it still returns true for every parameter
sloo012
@sloo012
Mar 20 2016 05:45
@realitygenerator if you console.log splitStr.reverse() , it is not reversing at all
Jeff Day
@realitygenerator
Mar 20 2016 05:46
if you change the return to splitStr.reverse() it is.
someoneoffl
@someoneoffl
Mar 20 2016 05:47
i'm stuck on word blanks
please help
DJ
@qualitymanifest
Mar 20 2016 05:48
@realitygenerator see here https://repl.it/BxwM/1
@realitygenerator when you're running `if (splitStr === splitStr.reverse())` it is mutating the array, and BOTH arrays you're comparing are reversed
sloo012
@sloo012
Mar 20 2016 05:49
@realitygenerator splitStr.reverse().join("")
DJ
@qualitymanifest
Mar 20 2016 05:49
@realitygenerator you could get rid of `splitStr`, and just compare lowerStr to itself reversed. you would also need to have an `else` for `false`
Jeff Day
@realitygenerator
Mar 20 2016 05:51
thank you @qualitymanifest that looks like it's my problem
CamperBot
@camperbot
Mar 20 2016 05:51
realitygenerator sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1089 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Mar 20 2016 05:51
no problem :+1:
demipixel
@demipixel
Mar 20 2016 05:51
:thumbsdown:
DJ
@qualitymanifest
Mar 20 2016 05:52
@demipixel wat
demipixel
@demipixel
Mar 20 2016 05:52
have you done exact change?
DJ
@qualitymanifest
Mar 20 2016 05:53
yeah. i don't really have much time right now but if you have some code i can take a look
demipixel
@demipixel
Mar 20 2016 05:53
Uh
Do you have like 5min
DJ
@qualitymanifest
Mar 20 2016 05:54
@demipixel maybe. just post it dude. if i cant help you someone else will
Anton Bredl
@antonbr13
Mar 20 2016 05:55
should i learn regex?
I have been avoiding it to this point
any thoughts?
I look at my solution for the Title Case toy problem and think there must be a better way
``````function titleCase(str) {
var string = str.split(' ');
console.log(string);
var solution = [];

for(var i = 0; i < string.length; i++){
var firstChar = string[i].charAt(0);
var remainingStr = string[i].slice(1).toLowerCase();
var word = firstChar.toUpperCase() + remainingStr;
solution.push(word);

}
solution = solution.join(' ');
return solution;
}

titleCase("I'm a little tea pot");``````
Artur Sęp
@a-sep
Mar 20 2016 06:01

@antonbr13 Here is my solution:
```
function titleCase(str) {
str = str.toLowerCase("");

str = str.split(" ");

var newArray = str.map(function(val){

``````var l = val.split("").shift().toUpperCase();

val = l + val.substr(1, val.length);
return val;``````

});

str = newArray.join(" ");
console.log(str);

return str;
}

titleCase("I'm a little tea pot");

``````function titleCase(str) {
str = str.toLowerCase("");
str = str.split(" ");
var newArray = str.map(function(val){
var l = val.split("").shift().toUpperCase();

val = l + val.substr(1, val.length);
return val;
});
str = newArray.join(" ");
console.log(str);
return str;
}
titleCase("I'm a little tea pot");``````
help format
CamperBot
@camperbot
Mar 20 2016 06:02

## :point_right: code formatting [wiki]

### Multi line Code

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

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

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

### Single line Code

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

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

Artur Sęp
@a-sep
Mar 20 2016 06:03

@antonbr13 ```
function titleCase(str) {
str = str.toLowerCase("");
str = str.split(" ");
var newArray = str.map(function(val){
var l = val.split("").shift().toUpperCase();

val = l + val.substr(1, val.length);
return val;
});
str = newArray.join(" ");
console.log(str);
return str;
}
titleCase("I'm a little tea pot");
```

sorry for spam :)
RyanEnright
@RyanEnright
Mar 20 2016 06:22
Accessing Nested Arrays in JSON
cannelflow
@cannelflow
Mar 20 2016 06:26
@RyanEnright tried something?
RyanEnright
@RyanEnright
Mar 20 2016 06:27
@cannelflow was going to post a question then decided to work on the problem a bit more
cannelflow
@cannelflow
Mar 20 2016 06:28
good idea @RyanEnright
Tabi
@mrpassiontea
Mar 20 2016 06:34
Anybody know how to get the for loop to iterate the + for the first C
Sumeet Batheja
@bathejasumeet
Mar 20 2016 06:35
Hi all
RyanEnright
@RyanEnright
Mar 20 2016 06:37
This message was deleted
Zach
@Moose1551
Mar 20 2016 06:50
Hello, gang. I'm trying to reverse a jQuery function. In this link: http://jsfiddle.net/meEf4/, the div decreases in opacity as I scroll down. How would I reverse the effect so that the opacity of each div increases as I scroll down? I'm sure it's an easy fix, I just can't seem to reverse it.
surendra
@surendrap720
Mar 20 2016 06:52
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
please help me
how do we do this
rphares
@rphares
Mar 20 2016 06:54
@surendrap720 , use the chart to change that sequence-- all those come from the `output` side of the chart, switch them into the `code` side of the chart
the final result should be a string (its name is`myStr` :blush: ) so be sure to put the whole thing in one set f quotes ~
surendra
@surendrap720
Mar 20 2016 06:59
i did not get anything
rphares
@rphares
Mar 20 2016 07:00
@surendrap720 , can you paste what you are trying, please?
surendra
@surendrap720
Mar 20 2016 07:03
yes
var myStr='"\backlash" "\ttab" "\ttab" "\rcarriage-return" "\nnew-line"';
rphares
@rphares
Mar 20 2016 07:04
okay, good start, just a few things to fix :)
surendra
@surendrap720
Mar 20 2016 07:04
tysm
rphares
@rphares
Mar 20 2016 07:04
First, we dont need the text in there, we just want the code part,
so, for example, that first part, the backslash,
surendra
@surendrap720
Mar 20 2016 07:05
okay
rphares
@rphares
Mar 20 2016 07:05
should just be `\\` not, `\backslash`
surendra
@surendrap720
Mar 20 2016 07:05
var myStr='"\" "\t" "\t" "\r" "\n"';
you mean this ?
rphares
@rphares
Mar 20 2016 07:06
good, that first change is done
now, we have too many `""`
we only need those to make it a string,
surendra
@surendrap720
Mar 20 2016 07:06
okay
rphares
@rphares
Mar 20 2016 07:06
`var example = "this is a string";`
we dont need them around each part of the sequence, just around the whole sequence
surendra
@surendrap720
Mar 20 2016 07:07
var myStr="\ \t \t \r \n";
this is correct ?
rphares
@rphares
Mar 20 2016 07:07
try running tests :blushL
oh wait--
surendra
@surendrap720
Mar 20 2016 07:08
i got it right
rphares
@rphares
Mar 20 2016 07:08
do you have one or two spaces in between each one... if i recall, it may be picky about only having one...
cool
surendra
@surendrap720
Mar 20 2016 07:08
tysm @rphares
rphares
@rphares
Mar 20 2016 07:08
congrats and happy coding!
Anytime~
surendra
@surendrap720
Mar 20 2016 07:08
yeah
shanky
@shaanky
Mar 20 2016 07:29
Hello developers :smile:
we need help in one challnge of javascript
CHallnge - Profile Lookup
``````
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop){

if(firstName == "Akira")
{
if(prop == "likes")
{
return ["Pizza", "Coding", "Brownie Points"];
}
else
{
return "No such Property";
}
}
else
{
return "No Such Contact";
}
if(firstName == "Harry")
{
if(prop == "likes")
{
return ["Hogwarts", "Magic", "Hagrid"];
}
else
{
return "No such Property";
}
}
else
{
return "No Such Contact";
}

if(firstName == "Sherlock")
{
if(prop == "likes")
{
return ["Intriguing Cases", "Violin"];
}
else
{
return "No such Property";
}
}
else
{
return "No Such Contact";
}
if(firstName == "Kristian")
{
if(prop == "lastName")
{
return "Vos";
}
else
{
return "No such Property";
}
}
else
{
return "No Such Contact";
}
}
lookUp("Kristian", "lastName");``````
what i'm doing wrong??
Olawale Akinseye
@brainyfarm
Mar 20 2016 07:32
@shaanky
That isn't the approach you should use.
shanky
@shaanky
Mar 20 2016 07:32
than??? @brainyfarm
anthonygallina1
@anthonygallina1
Mar 20 2016 07:33
:)
hi @brainyfarm :)
shanky
@shaanky
Mar 20 2016 07:34
Hi @anthonygallina1
Olawale Akinseye
@brainyfarm
Mar 20 2016 07:34
@shaanky
You loop through the object and then on the current iteration, check if the object has the `firstName` that matches what you want and then check for `prop` .
Good morning from here @anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 07:34
:thumbsup:
shanky
@shaanky
Mar 20 2016 07:35
you mean i should use for loop ??? @brainyfarm
anthonygallina1
@anthonygallina1
Mar 20 2016 07:35
@shaanky hi
shanky
@shaanky
Mar 20 2016 07:35
@anthonygallina1 good mrng
anthonygallina1
@anthonygallina1
Mar 20 2016 07:36
@shaanky stick with @brainyfarm if you do you will understand
Olawale Akinseye
@brainyfarm
Mar 20 2016 07:37
You can use a `for` loop @shaanky and you can iterate using `forEach`.
shanky
@shaanky
Mar 20 2016 07:37
ok
Olawale Akinseye
@brainyfarm
Mar 20 2016 07:38
I used `forEach` and think `for` loop might be very easy to handle though.
shanky
@shaanky
Mar 20 2016 07:40
let me try n i'll get back 2 u
Olawale Akinseye
@brainyfarm
Mar 20 2016 07:42
Thanks for the confidence @anthonygallina1 :grinning:
CamperBot
@camperbot
Mar 20 2016 07:42
brainyfarm sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:star: 1251 | @anthonygallina1 | http://www.freecodecamp.com/anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 07:42
@brainyfarm You rock thank you
CamperBot
@camperbot
Mar 20 2016 07:42
anthonygallina1 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1647 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 07:42
You have a nice solution too man @anthonygallina1 :D
anthonygallina1
@anthonygallina1
Mar 20 2016 07:43
Thank you
It worked thats all I know probably could be shorter?
shanky
@shaanky
Mar 20 2016 07:47
hello guys @anthonygallina1 and @brainyfarm
i'm unable to go further as i'm unable to think what to do next
``````for(var i=0; i < contacts.length; i++)
{
if()
}``````
can you tell me what to do next please as i m new to this course please
anthonygallina1
@anthonygallina1
Mar 20 2016 07:50
@shaanky wait for brainyfarm
@shaanky I can do it in the editor because of the console
shanky
@shaanky
Mar 20 2016 07:51
ok @anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 07:52
@shaanky yes then you have some thing to take with you.
shanky
@shaanky
Mar 20 2016 07:53
actully i want to know what should i ryt in if condition
Hello Guys???
anthonygallina1
@anthonygallina1
Mar 20 2016 07:57
ok so I hope he comes back Lets see you will want to look for the key Do you know what the key is?
shanky
@shaanky
Mar 20 2016 07:57
anyone is there??
anthonygallina1
@anthonygallina1
Mar 20 2016 07:57
the key in the array
do you know it?
shanky
@shaanky
Mar 20 2016 07:58
no @anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 07:58
No?
K
Lets start with first name that is one of the keys
shanky
@shaanky
Mar 20 2016 08:00
@anthonygallina1 tell me this approch is ryt??
``````for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].likes == prop)
{
return contacts[i].likes;
}
}
}``````
anthonygallina1
@anthonygallina1
Mar 20 2016 08:00
and the var you will be working with is contacts because contacts = the array
no I think want to look for first name instead of likes
Brian Daub
@briandaub
Mar 20 2016 08:03
Anyone working on the Wikipedia Viewer and want to pair?
anthonygallina1
@anthonygallina1
Mar 20 2016 08:04
@shaanky you still there?
shanky
@shaanky
Mar 20 2016 08:04
yes i'm
@anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 08:05
k so you want to look for first name right?
shanky
@shaanky
Mar 20 2016 08:05
yes
anthonygallina1
@anthonygallina1
Mar 20 2016 08:05
in the array
shanky
@shaanky
Mar 20 2016 08:05
yes its arry of objects
anthonygallina1
@anthonygallina1
Mar 20 2016 08:06
remember has own property?
shanky
@shaanky
Mar 20 2016 08:06
yes i do
its to check wheather this property is present or not
ryt
anthonygallina1
@anthonygallina1
Mar 20 2016 08:07
yes
shanky
@shaanky
Mar 20 2016 08:08
so first thing I will ryt for loop like this
``````for(var i=0; i < contacts.length; i++)
{}``````
ryt??
@anthonygallina1
@anthonygallina1 r u there???
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:11
@shaanky
Nice start !!!
shanky
@shaanky
Mar 20 2016 08:12
@brainyfarm
anthonygallina1
@anthonygallina1
Mar 20 2016 08:12
bk
got knocked off line
shanky
@shaanky
Mar 20 2016 08:13
@brainyfarm and @anthonygallina1 u both are such nice guys its like my mentor
please bare with me if i could not understand anything
so whats next step???
anthonygallina1
@anthonygallina1
Mar 20 2016 08:14
if you learn how to do it then you can do it later Or apply it to another piece of code you are working on :)
shanky
@shaanky
Mar 20 2016 08:15
yes that is what i need :smile:
`````` for(var i=0; i < contacts.length; i++)
{
if(contacts[i].hasOwnProperty(firstName) == firstName)
{

if(contacts[i].hasOwnProperty(likes) == prop)
{
return contacts[i].likes;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
is this ryt???
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:17
Almost @shaanky :D
Did you write the code above @shaanky ?
anthonygallina1
@anthonygallina1
Mar 20 2016 08:17
yup need a var
shanky
@shaanky
Mar 20 2016 08:18
@brainyfarm yes its me
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:19
Nice job man @shaanky :D
Now, let us correct the errors one at a time
shanky
@shaanky
Mar 20 2016 08:19
ok @brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:21
First @shaanky
`contacts[i].hasOwnProperty(firstName)` would return `true` or `false`.
Remember, what it does is to test if the object had a property `firstName`.
Robert Uivarosi
@URobert
Mar 20 2016 08:23
@anthonygallina1 :wave:
shanky
@shaanky
Mar 20 2016 08:23
ok, if we take example as lookUp("Akira", "likes");
Robert Uivarosi
@URobert
Mar 20 2016 08:23
@anthonygallina1 how are you?
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:23

So by doing `if(contacts[i].hasOwnProperty(firstName) == firstName)`, you are saying:

`if(true === firstName)` or `if(false === firstName)`

@shaanky

shanky
@shaanky
Mar 20 2016 08:24
than this will check wheather firstName==Akira this is true or false rtyt
anthonygallina1
@anthonygallina1
Mar 20 2016 08:24
@URobert good we are walking through this lesson right now :)
Robert Uivarosi
@URobert
Mar 20 2016 08:24
@anthonygallina1 sorry to interrupt
anthonygallina1
@anthonygallina1
Mar 20 2016 08:24
np
:)
shanky
@shaanky
Mar 20 2016 08:25
@brainyfarm ok
anthonygallina1
@anthonygallina1
Mar 20 2016 08:25
@brainyfarm so is that boolean because of the out put?
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:26

@shaanky
The hint is this, if you decide to use a `for` loop, then you do not have to check if the object has `firstName` as a property .

*We know all objects has the property `firstName`.

shanky
@shaanky
Mar 20 2016 08:28
@brainyfarm ok, actully @anthonygallina1 suggest me to write hasOwnProperty
anthonygallina1
@anthonygallina1
Mar 20 2016 08:28
yes
LeoStarzz
@LeoStarzz
Mar 20 2016 08:28
``````\$(document).ready(function() {
var weather = new XMLHttpRequest();
weather.open("GET", "http://api.openweathermap.org/data/2.5/weather?q=Minsk,BY&appid=c7806a19f58c00f2d0eeecf8d5dd4785", false);
weather.send(null);

var r = JSON.parse(weather.response);
var info = "Current location: " + r.name + " <p>";
info += "Current temp: " + (r.main.temp - 32) / 1.8 + " <p>";
info += "Current wind speed: " + r.wind.speed;
document.getElementById("weather").innerHTML = info;
});
Why it doesn't work?
P.S Weather app``````
anthonygallina1
@anthonygallina1
Mar 20 2016 08:29
@shaanky but still looking for first name not likes
shanky
@shaanky
Mar 20 2016 08:29
@brainyfarm so you mean i dnt need to write that hasOwnProperty ryt??
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:29
Exactly @anthonygallina1 , `.hasOwnProperty()` would return `true` or `false`.
shanky
@shaanky
Mar 20 2016 08:29
@brainyfarm should i write like this...
``if(contacts[i].firstName == firstName)``
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:30

@shaanky
Oh yes!!!!

Brilliant man!

shanky
@shaanky
Mar 20 2016 08:31
``````for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].likes == prop)
{
return contacts[i].prop;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
@brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:32
Now, let us take the next one @shaanky :D
@shaanky
After a little correction ;)
shanky
@shaanky
Mar 20 2016 08:32
ok np i'm enjoying it... @brainyfarm
anthonygallina1
@anthonygallina1
Mar 20 2016 08:33
:)
I have a feeling I may see shorter code than what I have
shanky
@shaanky
Mar 20 2016 08:34
@anthonygallina1 do not worry I will tell you how can you do that...........jus joking...
:smile:
anthonygallina1
@anthonygallina1
Mar 20 2016 08:35
lol
shanky
@shaanky
Mar 20 2016 08:35
@brainyfarm what next step
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:35
Now, we take take this line @shaanky `if(contacts[i].likes == prop)`
V Bhargav Chowdary
@bhargav4
Mar 20 2016 08:35
help no repeats please
CamperBot
@camperbot
Mar 20 2016 08:35

# Problem Explanation:

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

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

``````if(str[i] has not been used) {
put str[i] into the current position;
mark str[i] as used
perm(current position in original string, what's been used in original string, current string build thus far)
unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
}``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:35
Now, we take take this line @shaanky
`if(contacts[i].likes == prop)`
shanky
@shaanky
Mar 20 2016 08:36
ok @brainyfarm
AceMaridiam
@AceMaridiam
Mar 20 2016 08:36
I don't understand how to access the second type in Accessing Nested Arrays in JSON
The given example does not help me in the least
shanky
@shaanky
Mar 20 2016 08:38
@AceMaridiam just check this myPlants1.list1;
sorry i forgot brackets
This message was deleted
anthonygallina1
@anthonygallina1
Mar 20 2016 08:38
brb
shanky
@shaanky
Mar 20 2016 08:39
``   myPlants[1].list[1];``
@AceMaridiam check above solution
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:39

Instead of `if(contacts[i].likes == prop)` @shaanky
Remember, `prop` is the property supplied to use when the function is invoked (it might not always be `"likes"` but we know it will always be identified as `prop`).

Now using `.hasOwnProperty()`, check if the current contact object has a property `prop`.

AceMaridiam
@AceMaridiam
Mar 20 2016 08:40
Okay. I get it now. I feel a bit defeated by my inability to solve that; but it is late for me.
thank you @shaanky
CamperBot
@camperbot
Mar 20 2016 08:40
acemaridiam sends brownie points to @shaanky :sparkles: :thumbsup: :sparkles:
:star: 120 | @shaanky | http://www.freecodecamp.com/shaanky
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:40
See you soon @anthonygallina1 :D
shanky
@shaanky
Mar 20 2016 08:40
@brainyfarm hey
hold on
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:41
Hi @shaanky .
Have you seen my last message?
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:41
Hi! I was wondering if I could get some help with something super basic
shanky
@shaanky
Mar 20 2016 08:41
where r u going???
i need to complete my example, yes i seen that
@brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:42
I am here @shaanky , Anthony said he would be right back :P
shanky
@shaanky
Mar 20 2016 08:42
Ok i thought i r going
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:42
Now fix that part and let us proceed man :D
Alex Brown
@webtechalex
Mar 20 2016 08:43
hey all. I’m trying (failing) to complete the quote generator project at the moment. :) What is the equivalent of \$.getJSON() in normal Javascript?
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:43
Sure @aileenxinchien :D
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:43
Thanks @brainyfarm
CamperBot
@camperbot
Mar 20 2016 08:43
aileenxinchien sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1648 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:43
What error are you getting @webtechalex ?
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:43
So I'm in the profile lookup section
anthonygallina1
@anthonygallina1
Mar 20 2016 08:43
bk
Alex Brown
@webtechalex
Mar 20 2016 08:44
I’m not. I haven’t got anywhere with it yet
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:44
That exactly is what we are working on @aileenxinchien :D
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:44
And I wrote the main part of the code but am getting a reference error for the contacts
Do you mind if I post my code here?
shanky
@shaanky
Mar 20 2016 08:44
``````for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].likes == prop)
{
return contacts[i].hasOwnProperty(prop);
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:44
Great! I thought I recognized it haha
shanky
@shaanky
Mar 20 2016 08:44
@brainyfarm is this ryt??
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:44
Ah I tried it very differently
I went with property first, since I saw that each object had the same keys
This message was deleted
oh. god that looks horrible. How do I post code?
anthonygallina1
@anthonygallina1
Mar 20 2016 08:45
@shaanky I know how to write this line but I dont know why it is right `if(contacts[i].likes == prop)` and that isnt right I believe
shanky
@shaanky
Mar 20 2016 08:46
@aileenxinchien i'm also stuck with this same example
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:46
@shaanky
Not yet, remember you have to check if the object has that property first before returning anything
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:46
so @shaanky you should take out the .likes
Alex Brown
@webtechalex
Mar 20 2016 08:46
@brainyfarm I still can’t work out what API’s I need to use for the project (I think they should be stated in the instructions). But I was looking back at the tutorial code and wondered how to do it in ‘vanilla’ JS
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:46
@aileenxinchien
Please share you code :D
shanky
@shaanky
Mar 20 2016 08:46
and I am getting class from @brainyfarm check our conversion
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:47
definitely! how do i format the message for code? i entered it before and it looked horrible
```?
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:47

@webtechalex
vanilla js ;)

Do you want some api suggestion?

Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:47
`code` <= will that work?
```function lookUp(firstName, prop){ // Only change code below this line if (contacts[0][prop]){ var nameNotFound = true; while (nameNotFound){ for (i=0; i<contacts.length; i++) { if (contacts[i].firstName===firstName){ nameNotFound=false; return contacts[i][firstName][prop]; } } nameNotFound=false; return "No such contact"; } } else { return "No such property"; } // Only change code above this line }```
@shaanky how did you format your post?
shanky
@shaanky
Mar 20 2016 08:47
yes @aileenxinchien
im telling you
Alex Brown
@webtechalex
Mar 20 2016 08:48
@brainyfarm yes please. :)
anthonygallina1
@anthonygallina1
Mar 20 2016 08:48
shakes his head
shanky
@shaanky
Mar 20 2016 08:48
first hit `button 3 times than shift + enter and again` button 3 times
@brainyfarm can you share your code
please
Sidharth Kriplani
@sidkrip
Mar 20 2016 08:49
anyone done with Steamroller?
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:49
This message was deleted
Sidharth Kriplani
@sidkrip
Mar 20 2016 08:49
help format
CamperBot
@camperbot
Mar 20 2016 08:49

## :point_right: code formatting [wiki]

### Multi line Code

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

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

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

### Single line Code

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

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

Olawale Akinseye
@brainyfarm
Mar 20 2016 08:49
@shaanky
Here is an example `myObj.hasOwnProperty(myProp)` would check if `myObj` has a property `myProp` and would be `true` or `false` .
Hello @sidkrip :D
Sidharth Kriplani
@sidkrip
Mar 20 2016 08:50
@brainyfarm hey! just came back :D
shanky
@shaanky
Mar 20 2016 08:50
@aileenxinchien than click on chat mode than enter
Sidharth Kriplani
@sidkrip
Mar 20 2016 08:50
hope you have been good man :D
need help though
anthonygallina1
@anthonygallina1
Mar 20 2016 08:51
@shaanky true or false depending on if it is in the array Once the bottom part of the program is complete
shanky
@shaanky
Mar 20 2016 08:52
@brainyfarm
`````` for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].hasOwnProperty(prop))
{
return ;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
this is ryt??? @anthonygallina1 and @brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:53
@shaanky
Nice!
anthonygallina1
@anthonygallina1
Mar 20 2016 08:53
@shaanky yes so far
Alex Brown
@webtechalex
Mar 20 2016 08:53
@brainyfarm thanks. Is that the one that’s used in the demo project?
CamperBot
@camperbot
Mar 20 2016 08:53
webtechalex sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1649 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
anthonygallina1
@anthonygallina1
Mar 20 2016 08:53
good
Sidharth Kriplani
@sidkrip
Mar 20 2016 08:53
@brainyfarm ...
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:53
I don't think so @aileenxinchien .
Actually, I did not check the demo project :P
Jakub Adamec
@jadamec16
Mar 20 2016 08:53
Hi, why it appends only 1st div from #desk and no every divs from that?
``````function takeCards() {
player[maxCard()] = player[maxCard()].concat(desk);
document.getElementById("P" + maxCard()).appendChild(document.getElementById("desk").querySelector("span div"));
}``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:54
@sidkrip
What part of that algo are you having issues with?
shanky
@shaanky
Mar 20 2016 08:54
@brainyfarm and @anthonygallina1 whats next
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:54
Could you share your code?
anthonygallina1
@anthonygallina1
Mar 20 2016 08:55
@brainyfarm should I do the var for checking the data base next?
shanky
@shaanky
Mar 20 2016 08:55
@brainyfarm you r telling me to share code???
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:55
No @shaanky
I was referring to @sidkrip .
Sure @anthonygallina1 :D
shanky
@shaanky
Mar 20 2016 08:56
ok But @brainyfarm my example still incomplete
please help me
@anthonygallina1
???
Sidharth Kriplani
@sidkrip
Mar 20 2016 08:57

@brainyfarm here is my code:

``````function steamroller(arr) {
// I'm a steamroller, baby
var len=arr.length;
var arra=[];
for(var i=0; i<len; i++) {
if(arr.isArray()) {
flatten(arr[i]);
arra.push(arr[i]);
}
else {
arra.push(arr[i]);
}
}
return arr;
}

function flatten(arr) {
var val;
while(arr.isArray()) {
for(var i=0; i<arr.length; i++) {
val=arr[i];
}
}
if (arr.isArray()) {
flatten(val);
}
else
return val;
}

steamroller([1, [2], [3, [[4]]]]);``````

I dont know how to flatten the array

Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:57
``````function lookUp(firstName, prop){
// Only change code below this line
if (contacts[0].hasOwnProperty(props)){
var nameNotFound = true;
while (nameNotFound){
for (i=0; i<contacts.length; i++) {
if (contacts[i].firstName===firstName){
nameNotFound=false;
return contacts[i][firstName][prop];
}
}
nameNotFound=false;
return "No such contact";
}
} else {
return "No such property";
}
// Only change code above this line
}``````
anthonygallina1
@anthonygallina1
Mar 20 2016 08:57
@shaanky I did a variable at the top to contain the data Do you remember how to do a var?
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:57
there it is! ok. so my problem is that it's giving me a reference error in the first if
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:57
Aileen xin Chien
@aileenxinchien
Mar 20 2016 08:58
the thing is, i tried trouble shooting it with
```
return contacts[0].hasOwnProperty("likes");
and it's fine it returns the variable
even works with the var prop instead of likes
but when i put it into an if statement it freaks out!
shanky
@shaanky
Mar 20 2016 08:59
@brainyfarm ???
Olawale Akinseye
@brainyfarm
Mar 20 2016 08:59
@shaanky
@anthonygallina1 is suggesting something to you :point_up:
anthonygallina1
@anthonygallina1
Mar 20 2016 08:59
@shaanky Do you remember how to do a var/
shanky
@shaanky
Mar 20 2016 09:00
@anthonygallina1 yes like this var myVar =11;
ryt??
@brainyfarm what??
anthonygallina1
@anthonygallina1
Mar 20 2016 09:01
@shaanky at the top above your code make a variable and make it `= "";`
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:01
shanky
@shaanky
Mar 20 2016 09:01
``````for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].hasOwnProperty(prop))
{
return contacts[i].likes ;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:01
I think @anthonygallina1 wants you to have a variable to store the property value if it exists or store an empty string if it does not @sidkrip .
anthonygallina1
@anthonygallina1
Mar 20 2016 09:02
@shaanky I think they call that instantiating it?
shanky
@shaanky
Mar 20 2016 09:03
yes so (var myVar;) like this
ryt?
Sidharth Kriplani
@sidkrip
Mar 20 2016 09:03
@brainyfarm didnt get what you said.
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:03
@sidkrip what section is this code from?
as in what chapter/lesson?
shanky
@shaanky
Mar 20 2016 09:04
`````` var myVar;
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].hasOwnProperty(prop))
{
return contacts[i].likes ;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
@anthonygallina1 i took myVar above
anthonygallina1
@anthonygallina1
Mar 20 2016 09:04
@shaanky missed this part `= "";`
shanky
@shaanky
Mar 20 2016 09:06
`````` var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].hasOwnProperty(prop))
{
return contacts[i].likes ;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:06
Just some few minutes @sidkrip .
I want to check my solution
Sidharth Kriplani
@sidkrip
Mar 20 2016 09:06
@brainyfarm its the Steamroller bonfire
anthonygallina1
@anthonygallina1
Mar 20 2016 09:06
@shaanky good
shanky
@shaanky
Mar 20 2016 09:06
@anthonygallina1 ryt, ok!!
anthonygallina1
@anthonygallina1
Mar 20 2016 09:07
@shaanky ok on our next line of code we are going to be plugging into that
shanky
@shaanky
Mar 20 2016 09:08
ok how do i do that??
@anthonygallina1
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:08
@sidkrip for that first if(arr.isArray()) within the for loop, did you mean if(arr[i].isArray()?
anthonygallina1
@anthonygallina1
Mar 20 2016 09:09
@shaanky So instead of returning we want to use contacts and return the property
Sidharth Kriplani
@sidkrip
Mar 20 2016 09:09
@brainyfarm yes, my bad
anthonygallina1
@anthonygallina1
Mar 20 2016 09:10
@shaanky So myVar would equal contacts
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:11
@sidkrip i think you might've done that in the second flatten function as well
anthonygallina1
@anthonygallina1
Mar 20 2016 09:11
@shaanky see in your loop
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:11
@anthonygallina1 if you have a second, i'm having trouble in the same section as @shaanky - i can't figure out why i can't check to see if the parameter prop is in the array
shanky
@shaanky
Mar 20 2016 09:11
`````` var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i].prop;
return myVar;
}
else
{
return "No Such Property";
}
}
else
{
return "No Such Contact";
}
}``````
@anthonygallina1 you mean like this???
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:12
i'm trying if(contacts[0].hasOwnProperty(prop){}, but it says there's a reference error
but when i do a return on the same line, it gives me true!
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:12
@sidkrip
I used an entirely different approach.
anthonygallina1
@anthonygallina1
Mar 20 2016 09:13
@shaanky very close
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:13
`contacts[0].hasOwnProperty(prop)` should be `contacts[i].hasOwnProperty(prop)`?
@aileenxinchien
shanky
@shaanky
Mar 20 2016 09:13
@anthonygallina1 ok whats next and thnx for bare with me
CamperBot
@camperbot
Mar 20 2016 09:13
shaanky sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles:
shanky
@shaanky
Mar 20 2016 09:13
:smile:
CamperBot
@camperbot
Mar 20 2016 09:13
:star: 1252 | @anthonygallina1 | http://www.freecodecamp.com/anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 09:13
@shaanky but we dont want to return the data from the array yet
shanky
@shaanky
Mar 20 2016 09:14
ok @anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 09:14
@shaanky so you can del return myVar
Sidharth Kriplani
@sidkrip
Mar 20 2016 09:15
@brainyfarm please do enlighten me
shanky
@shaanky
Mar 20 2016 09:15
@anthonygallina1 ok i deleted that;
Sidharth Kriplani
@sidkrip
Mar 20 2016 09:15
@brainyfarm I would like to know how you approached the prblem
*problem
Alex Brown
@webtechalex
Mar 20 2016 09:15
@brainyfarm and others: okay I’ve given up on the ‘no jquery’ idea for the moment. I have a button with the id of `getQuote` and a blockquote element with the id of `quoteText` I’m trying to display the JSON data in the blockquote element to check it is working. I get nothing. Here is my code:
``````\$(document).ready(function() {
\$("#getQuote").on("click", function(){
\$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json", function(json) {
\$("#quoteText").html(JSON.stringify(json));
});
});
});``````
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:16
@brainyfarm no. i see that all the objects (in this case) have the same keys, so i just used objects[0] instead of cycling through them
it's just easier
shanky
@shaanky
Mar 20 2016 09:17
@anthonygallina1 ????
anthonygallina1
@anthonygallina1
Mar 20 2016 09:17
@shaanky and this is where you want to check in the array `myVar = contacts[i][prop];`
shanky
@shaanky
Mar 20 2016 09:17
r u there???
anthonygallina1
@anthonygallina1
Mar 20 2016 09:17
@shaanky see the difference
shanky
@shaanky
Mar 20 2016 09:18
``````var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{

if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
}
else
{
return "No such property";
}
}
else
{
return "No such contact";
}
}``````
ryt??
anthonygallina1
@anthonygallina1
Mar 20 2016 09:18
yes
shanky
@shaanky
Mar 20 2016 09:18
@anthonygallina1
anthonygallina1
@anthonygallina1
Mar 20 2016 09:19
@shaanky so that pulls i and the property
@shaanky and makes myVAr equal it
shanky
@shaanky
Mar 20 2016 09:20
`````` myVar = contacts[i][prop];
return myVar;``````
likes this @anthonygallina1
?
Aileen xin Chien
@aileenxinchien
Mar 20 2016 09:21
@shaanky are you getting a reference/null error at all?
Jakub Adamec
@jadamec16
Mar 20 2016 09:22
Hi, why it appends only 1st div from #desk and no every divs from that?
``````function takeCards() {
player[maxCard()] = player[maxCard()].concat(desk);
document.getElementById("P" + maxCard()).appendChild(document.getElementById("desk").querySelector("span div"));
}``````
shanky
@shaanky
Mar 20 2016 09:22
no @aileenxinchien
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:22

Here is what I did @sidkrip .

Create an empty array to hold all single elements which are not arrays

• I had a function that maps through an array and if items are single (not array), it pushes it into my empty array*
• If the item is an array, it maps over that one again (recursion)**

Here is a part of my code

``````if( !Array.isArray( current )){
// Push it into the singles array
singles.push( current );

}
// map over it if `current` is not an array
else { mapper( current ); }``````

`mapper` is the name of my nested function

anthonygallina1
@anthonygallina1
Mar 20 2016 09:22
@shaanky the code above is correct the longer one
shanky
@shaanky
Mar 20 2016 09:23
@anthonygallina1 in the challenge i'm got the 2 tick ryt but still 3 ticks are showing cross,
that is why i'm unable to go further challnge
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:24
Good job @anthonygallina1 and @shaanky :D
anthonygallina1
@anthonygallina1
Mar 20 2016 09:24
@shaanky yup so now you assign no such property to your var which is myVar
shanky
@shaanky
Mar 20 2016 09:24
@brainyfarm thanx to you and @anthonygallina1 my bestest mentor for javascript
CamperBot
@camperbot
Mar 20 2016 09:24
shaanky sends brownie points to @brainyfarm and @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:warning: shaanky already gave anthonygallina1 points
:star: 1650 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
anthonygallina1
@anthonygallina1
Mar 20 2016 09:25
@shaanky making more sense?
@brainyfarm thank you
CamperBot
@camperbot
Mar 20 2016 09:25
anthonygallina1 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:25
Almost there @shaanky , keep following @anthonygallina1 and I love how you helped the other guy earlier :D
CamperBot
@camperbot
Mar 20 2016 09:25
:star: 1651 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
shanky
@shaanky
Mar 20 2016 09:26
``````var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
return myVar;
}
else
{
myVar ="No such property";
return myVar;
}
}
else
{
myVar = "No such contact";
return myVar;
}
}``````
@brainyfarm help that i did ??
This message was deleted
• or @anthonygallina1 did??
basia-s
@basia-s
Mar 20 2016 09:28
@gboyega Thank you for the advice!
CamperBot
@camperbot
Mar 20 2016 09:28
basia-s sends brownie points to @gboyega :sparkles: :thumbsup: :sparkles:
:star: 273 | @gboyega | http://www.freecodecamp.com/gboyega
shanky
@shaanky
Mar 20 2016 09:28
@anthonygallina1 yes ....
anthonygallina1
@anthonygallina1
Mar 20 2016 09:29
@shaanky passed?
Sidharth Kriplani
@sidkrip
Mar 20 2016 09:29
@brainyfarm I will try implmenting it
*implementing
anthonygallina1
@anthonygallina1
Mar 20 2016 09:29
@shaanky :thumbsup: good job
shanky
@shaanky
Mar 20 2016 09:30
no still there
@anthonygallina1
:worried:
anthonygallina1
@anthonygallina1
Mar 20 2016 09:31
@shaanky yes you shouldnt need return myVar;
@shaanky I think it will make the program stop and return at that point rather than complete
shanky
@shaanky
Mar 20 2016 09:33
`````` var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
//  return myVar;
}
else
{
myVar ="No such property";
// return myVar;
}
}
else
{
myVar = "No such contact";
//return myVar;
}
// return myVar;
}``````
@anthonygallina1 check this
@anthonygallina1
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:36
Nice @sidkrip :D
shanky
@shaanky
Mar 20 2016 09:36
??
@brainyfarm
@brainyfarm and @anthonygallina1 ??? r u there???
anthonygallina1
@anthonygallina1
Mar 20 2016 09:37
`````` var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
//  return myVar;
}
else
{
myVar ="No such property";
// return myVar;
}
}``````
@shaanky I think I missed a bracket
shanky
@shaanky
Mar 20 2016 09:38
yes
anthonygallina1
@anthonygallina1
Mar 20 2016 09:38
try your code
shanky
@shaanky
Mar 20 2016 09:40
i tried it showing No such contact
@anthonygallina1
``````var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
//  return myVar;
}
else
{
myVar ="No such property";
// return myVar;
}
}
else
{
myVar = "No such contact";
//return myVar;
}
}
return myVar;``````
this is the code @anthonygallina1
why should not include return in this as its saying the prop values
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:44
@shaanky
Delete your last `else` statement.
shanky
@shaanky
Mar 20 2016 09:46
``````  var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
// return myVar;
}
else
{
myVar ="No such property";
// return myVar;
}
}
// else
//  {
//  myVar = "No such contact";
//return myVar;
//  }
}
//return myVar;``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:46
Nice.
shanky
@shaanky
Mar 20 2016 09:47
@brainyfarm @anthonygallina1
scottmike0
@scottmike0
Mar 20 2016 09:47
sooo, I am doing falsy Bouncer and I am unsure where I go wrong
``````var cannotbe = [false,null,0,"",undefined,NaN];

function filterbyCannotbe(value){

for(var i = 0; i<cannotbe.length;i++){//following the pattern mentioned on the filter page api
if( cannotbe[i] == value){
return false;
}

}
return true;

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.
arr = arr.filter(filterbyCannotbe);

return arr;
}

bouncer([7, "ate", "", false, 9]);``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:47
Could you put a comment to show where your for loop ends @shaanky ?
@scottmike0 You do not need to loop inside your `filterbyCannotbe` function.
shanky
@shaanky
Mar 20 2016 09:48
``````var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
}
else
{
myVar ="No such property";
}
}

}//here for loop ends``````
@brainyfarm
scottmike0
@scottmike0
Mar 20 2016 09:49
@brainyfarm how then would i go through the array?
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:50
Now outside of your `for` loop @shaanky , `if(mayVar === "")` then return "No such contact`otherwise, return`value of `myVar`.
shanky
@shaanky
Mar 20 2016 09:53
`````` var myVar ="";
for(var i=0; i < contacts.length; i++)
{
if(contacts[i].firstName == firstName)
{
if(contacts[i].hasOwnProperty(prop))
{
myVar = contacts[i][prop];
}
else
{
myVar ="No such property";
}
}

}

if(myVar === "")
{
return "No such Contact";
}

return myVar;``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:53

@scottmike0
You can test `value` directly.

Hold on let me show an example

shanky
@shaanky
Mar 20 2016 09:53
@brainyfarm
@brainyfarm is this correct???
@anthonygallina1 where r u???
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:56
Does that pass @shaanky ?
shanky
@shaanky
Mar 20 2016 09:56
nope
@brainyfarm
only 1 condition is remaing which for "no such contact"
@brainyfarm
how this condition will check this??? @brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 09:58
Nice @shaanky .
`"No such Contact"` or `No such contact` ? ;)
shanky
@shaanky
Mar 20 2016 09:59
last one urs "No such contact"
@brainyfarm
what to do for that??
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:00

Here is an example @scottmike0

``````function killTwo(arr){

function bulletForTwos(item){

return item != 2;
}

return arr.filter(bulletForTwos);

}

killTwo([2,4,1,3,9,5,2,2,2,5,0]) //[4, 1, 3, 9, 5, 5, 0]``````

Now, think of `filter` as a gun/shooter and your job is to load the bullet as the shooter knows how to handle how many times he should shoot

shanky
@shaanky
Mar 20 2016 10:01
@brainyfarm please tell me??? My Mentor
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:02
@shaanky
You have an uppercase `C` in `contact`
zyggymaroo
@zyggymaroo
Mar 20 2016 10:02

can someone help me with the testing objects for properties section? the following is code:// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty("gift");
return "pony"
}
myObj.hasOwnProperty("pet");
myObj.hasOwnProperty("bed");

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

the pony part works but I'm unsure how to complete the rest...
shanky
@shaanky
Mar 20 2016 10:04
@zyggymaroo you need to use if conditon
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:04
@zyggymaroo
Remember you do not know if `"gift"` would always be the argument of your function when it is called but you know you have an identifier for anything passed which is `checkProp`.
shanky
@shaanky
Mar 20 2016 10:04
@zyggymaroo check this
``````if(myObj.hasOwnProperty(checkProp))
{
return myObj[checkProp];
}
else if(myObj.hasOwnProperty(checkProp))
{
return myObj[checkProp];
}
else
{
return "Not Found";
}``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:05
shanky
@shaanky
Mar 20 2016 10:05
@brainyfarm sorry :smile:
zyggymaroo
@zyggymaroo
Mar 20 2016 10:05
oh @shaanky thanks haha
CamperBot
@camperbot
Mar 20 2016 10:05
zyggymaroo sends brownie points to @shaanky :sparkles: :thumbsup: :sparkles:
:star: 121 | @shaanky | http://www.freecodecamp.com/shaanky
shanky
@shaanky
Mar 20 2016 10:05
ok next time will not going to provide sorry
@brainyfarm
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:05
Did your code validate @shaanky ?
anthonygallina1
@anthonygallina1
Mar 20 2016 10:06
@shaanky sry sry cat threw up
shanky
@shaanky
Mar 20 2016 10:06
yesssssssssssssssss it worksssssssssssss mannnnn
@brainyfarm u r genius
thank you very much
anthonygallina1
@anthonygallina1
Mar 20 2016 10:07
yup
shanky
@shaanky
Mar 20 2016 10:07
and @anthonygallina1 thnx you toooo
CamperBot
@camperbot
Mar 20 2016 10:07
shaanky sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:warning: shaanky already gave anthonygallina1 points
anthonygallina1
@anthonygallina1
Mar 20 2016 10:07
he is
shanky
@shaanky
Mar 20 2016 10:08
@brainyfarm say somthing
anthonygallina1
@anthonygallina1
Mar 20 2016 10:08
thank you @brainyfarm
CamperBot
@camperbot
Mar 20 2016 10:08
anthonygallina1 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:warning: anthonygallina1 already gave brainyfarm points
scottmike0
@scottmike0
Mar 20 2016 10:08
I still cannot pass the last 2 test cases for falsy bouncer
``````function filterbyCannotbe(value){
return value !== false && value !== null && value !==0 && value !== "" && value !== undefined && value !==isNaN();

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.
arr = arr.filter(filterbyCannotbe);

return arr;
}

bouncer([7, "ate", "", false, 9]);``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:09
Almost @scottmike0 .
scottmike0
@scottmike0
Mar 20 2016 10:09
@brainyfarm what am I missing?
shanky
@shaanky
Mar 20 2016 10:10
@brainyfarm :+1:
@anthonygallina1 :+1:
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:10
The proper why to check for `NaN` is `isNaN(value)` and you also have to check if type of that `value` is a number otherwise, you would get false positives.
anthonygallina1
@anthonygallina1
Mar 20 2016 10:10
@shaanky you did the work
shanky
@shaanky
Mar 20 2016 10:10
@anthonygallina1 why @brainyfarm he is not saying somthing
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:11
@shaanky
Hi, you fixed it ?
anthonygallina1
@anthonygallina1
Mar 20 2016 10:11
@shaanky nice piece of code
scottmike0
@scottmike0
Mar 20 2016 10:11
i see
shanky
@shaanky
Mar 20 2016 10:12
@brainyfarm yes i did it? but without your help it could not be possible.
scottmike0
@scottmike0
Mar 20 2016 10:12
@brainyfarm by doing that I ended up getting the last two correct, but the first two are wrong
``!isNaN(value);``
anthonygallina1
@anthonygallina1
Mar 20 2016 10:12
@shaanky yet
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:12

In short @scottmike0 , you may want to check like this:

`isNaN(value) && typeof(value) === "number"`

shanky
@shaanky
Mar 20 2016 10:13
@anthonygallina1 i need 1 more help from you guys
@brainyfarm
scottmike0
@scottmike0
Mar 20 2016 10:13
@brainyfarm why would i use a string to check?
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:13
If you do not check for the type @scottmike0 , `isNaN("ate")` would return true
GOOD JOB @shaanky !!!!
Well done @anthonygallina1 :D
shanky
@shaanky
Mar 20 2016 10:14
Challange - Counting Cards
@brainyfarm and @anthonygallina1
scottmike0
@scottmike0
Mar 20 2016 10:14
@brainyfarm isnt isNaN only checking for the exact phrase NaN?
shanky
@shaanky
Mar 20 2016 10:15
``````  if(card == 2 || card == 3 || card == 4 || card == 5 || card == 6)
{
return count + " Hold";
}
else if(card == 7 || card == 8 || card == 9)
{

return  count + " Hold";
}
else if(card == 10 || card == "J" || card == "Q" ||card == "K" || card == "A")
{

return count +  " Hold";
}
else if(card == 3 || card == 7 || card == "Q" || card == 8 || card == "A")
{

return  count + " Hold";
}
else if(card == 2 || card == "J" || card == 9 || card == 2 || card == 7)
{
return count + " Bet";
}
else if(card == 3 || card == 2 || card == "A"|| card == 10 || card == "K")
{

return count + " Hold";
}``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:15
No @scottmike0
Rememeber, `NaN` means `Not a Number`
anthonygallina1
@anthonygallina1
Mar 20 2016 10:16
I am building a header parser I can see where counting cards could be utilized in it.
scottmike0
@scottmike0
Mar 20 2016 10:17
@brainyfarm so by declaring typeof (value) and using strict checking for a string, it returns false?
@brainyfarm and the strict check for the type of did not seem to do anything in terms of output versus not having it
Alex Brown
@webtechalex
Mar 20 2016 10:18

@brainyfarm okay I tried it in Atom just in case it was a Codepen issue. Still nothing. No errors in the console:

``````<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Testing JSON</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script type="text/javascript">
\$(document).ready(function() {
\$("#getData").on("click", function(){
\$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json", function(json) {
\$("#test").html(JSON.stringify(json));
});
});
});
</script>
</head>
<body>
<button type="button" name="button" id="getData">Get Data</button>
<p id="test">Data</p>
</body>
</html>``````

I just don’t get it :(

anthonygallina1
@anthonygallina1
Mar 20 2016 10:19
@shaanky start with your count and declare a count variable make it equal 0
scottmike0
@scottmike0
Mar 20 2016 10:19
@brainyfarm
`` return value !== false && value !== null && value !==0 && value !== "" && value !== undefined && !isNaN(value) && typeof value  === "number";``
anthonygallina1
@anthonygallina1
Mar 20 2016 10:20
@shaanky wait did they all ready give you a function?
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:20
@scottmike0
`typeof(value) != "number"` .
There is one more thing @webtechalex .
I think you are having issues with CORS.
scottmike0
@scottmike0
Mar 20 2016 10:21
@brainyfarm thats the same thing as `!== "number"`
@brainyfarm in terms of output, and It now oddly only passed 1
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:24
@webtechalex
You have a problem with CORS.
scottmike0
@scottmike0
Mar 20 2016 10:24
``````function filterbyCannotbe(value){
return value !== false && value !== null && value !==0 && value !== "" && value !== undefined && !isNaN(value) && typeof value  != "number";

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.

return arr.filter(filterbyCannotbe);
}

bouncer([7, "ate", "", false, 9]);``````
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:24
scottmike0
@scottmike0
Mar 20 2016 10:24
@brainyfarm ah, i had or statements, but they did not seem to work at first
alpox
@alpox
Mar 20 2016 10:25
@scottmike0 You don't have to test each case separately. You have to test if the values are falsy and they are falsy if as example `if(!value) { console.log("falsy") }`comes through
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:25
scottmike0
@scottmike0
Mar 20 2016 10:26
@alpox testing each case seperately did not seem to work
alpox
@alpox
Mar 20 2016 10:26
@scottmike0 i said ou don't have to anyway :D
scottmike0
@scottmike0
Mar 20 2016 10:26
I replaced every and statement with or, but still am only getting one to pass
alpox
@alpox
Mar 20 2016 10:26
It would work done right
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:26
scottmike0
@scottmike0
Mar 20 2016 10:27
@brainyfarm
``````function filterbyCannotbe(value){
return value !== false||value !== null || value !==0 || value !== "" || value !== undefined || !isNaN(value) && typeof value  != "number";

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.

return arr.filter(filterbyCannotbe);``````
alpox
@alpox
Mar 20 2016 10:27
@brainyfarm I see but such code in real libs would be no good
scottmike0
@scottmike0
Mar 20 2016 10:28
@alpox i am confused on why this code does not pass
alpox
@alpox
Mar 20 2016 10:29
@scottmike0 I wonder why you test for `typeof value != "number"`since only zero is falsy
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:29
Help out @alpox :D
CamperBot
@camperbot
Mar 20 2016 10:29
no wiki entry for: `out @alpox d`
scottmike0
@scottmike0
Mar 20 2016 10:31
@alpox without it I miss "ate" in the array
@alpox but now I miss the entire array
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:33
Look at this @scottmike0
``````function filterbyCannotbe(value){
return value != "" && value != "false" && (!isNaN(value) && typeof(value) === "number")

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.

return arr.filter(filterbyCannotbe);
}

bouncer([7, "ate", "", false, 9, NaN]);``````
scottmike0
@scottmike0
Mar 20 2016 10:33
@brainyfarm why do you have not 0
alpox
@alpox
Mar 20 2016 10:34
This message was deleted
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:34
Sorry about the last message about you having too many `&&` .
scottmike0
@scottmike0
Mar 20 2016 10:34
@brainyfarm and I am confused for the reason of the parenthesis connected
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:34

@scottmike0
I am not writing your code :P

So I did not include everything

scottmike0
@scottmike0
Mar 20 2016 10:35
@brainyfarm i dont want ya to write my code :P
@brainyfarm am just wondering what exactly does typeof mean
alpox
@alpox
Mar 20 2016 10:37
@scottmike0 Well typeof value == "number" means that you test if value is indeed a number
@scottmike0 isNaN(value) gives you TRUE for everything that is not a number
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:38
@scottmike0
``````typeof([1,2,3]) // "object"
typeof(NaN)  // "number"
typeof("hello") // "string"
typeof({})  // "object"
typeof(111) // "number"
typeof(true)// "boolean"``````
scottmike0
@scottmike0
Mar 20 2016 10:40
@alpox soo if the value is not a string then it becomes falsy? `!isNaN(value) && typeof value != "number";`
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:42
scottmike0
@scottmike0
Mar 20 2016 10:42
@brainyfarm i see, so type of returns a string of whatever it is called.
alpox
@alpox
Mar 20 2016 10:43
@scottmike0 `isNaN("test")` Gives you true because `"test"` is not a number. If you say `isNaN(5)`that gives you false because 5 is a valid number. `isNaN(NaN)` gives you true because NaN is a number but has no value set.
JiaLe Guo
@gabygoole
Mar 20 2016 10:45
``````function destroyer(arr) {
var resArr = arr[0];
for(var i = 1; i < arr.length; i++){
resArr = resArr.filter(function(ele){
return ele != arr[i];
});
}
return resArr;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);``````
It prompt: don't make functions in loop?
what't that?
alpox
@alpox
Mar 20 2016 10:45
And so you have to go sure that if you test for isNaN, the value you're testing for has the type of a number @scottmike0
This message was deleted
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:46
Yes @scottmike0 and like I explained and @alpox above, the only effective way to prevent a false positive is to check if it is `NaN` and if the type is also "number".
scottmike0
@scottmike0
Mar 20 2016 10:46
@alpox so then whenever you test for IsNan you always have to test for typeof?
@alpox which is why you put both in parenthesis?
Pierre-François Pirlet
@pfpirlet
Mar 20 2016 10:47
Hi guys ! Just a few words to thank you: I've been following the ongoing chat as I was stuck on the same challenge as @scottmike0 and your comments helped me out ! Wish you goold luck @scottmike0
alpox
@alpox
Mar 20 2016 10:47
@scottmike0 Or just be sure that you test if its a number. Well you can also use isNaN to test if you are working with a valid number (And no other datastructure) so you wouldn't have to test for typeof in that case
@scottmike0 We put them both in paranthesis because they have to get tested together before exposing true or false
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:48
@gabygoole
You do not have to loop when using `filter`.
scottmike0
@scottmike0
Mar 20 2016 10:49
@alpox i am abit lost then why is this `!(typeof value == "number" && isNaN(value))` not the same as `!typeof value == "number" && !isNaN(value)`
JiaLe Guo
@gabygoole
Mar 20 2016 10:50
@brainyfarm but I don't know the number of arguments
alpox
@alpox
Mar 20 2016 10:50
@scottmike0 Following the rules of mathematical logic if you remove the paranthesis and set the not-operators to both of the values the && would turn into an || but still had to be in paranthesis
scottmike0
@scottmike0
Mar 20 2016 10:51
@alpox yeah I tried using demorgans logic rule, but still did not get the same value
JiaLe Guo
@gabygoole
Mar 20 2016 10:51
@brainyfarm I can't filter the array without knowing the number of arguments
alpox
@alpox
Mar 20 2016 10:51
@scottmike0 Thats maybe bit confusing, you have to think bit about it :D btw. `!typeof value == "number"`doesnt work since you would have to use `typeof value != "number"`
Alex Brown
@webtechalex
Mar 20 2016 10:52
thanks @brainyfarm but still no luck:
``````<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Testing JSON</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script type="text/javascript">
\$(document).ready(function() {
\$("#getData").on("click", function(){
\$.getJSON("https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json", function(json) {
\$("#test").html(JSON.stringify(json));
});
});
});
</script>
</head>
<body>
<button type="button" name="button" id="getData">Get Data</button>
<p id="test">Data</p>
</body>
</html>``````
CamperBot
@camperbot
Mar 20 2016 10:52
webtechalex sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1653 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Alex Brown
@webtechalex
Mar 20 2016 10:52
@brainyfarm what is CORS?
alpox
@alpox
Mar 20 2016 10:52
@webtechalex try adding a `callback=?` to your url query settings
scottmike0
@scottmike0
Mar 20 2016 10:52
`!(typeof value == "number" && isNaN(value))` also is not the same as `typeof value != "number" || !isNaN(value)`
Da-tang
@Klesas
Mar 20 2016 10:53

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

// Only change code below this line

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

alpox
@alpox
Mar 20 2016 10:53
@webtechalex CORS is Cross Origin Resource Sharing
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:53
@gabygoole
You should use `Array.prototype.slice.call(arguments)` and in the case of `destroyer([3, 5, 1, 2, 2], 2, 3, 5);`, Array.prototype.slice.call(arguments) would give you `[[3, 5, 1, 2, 2],[ 2, 3, 5]]`
scottmike0
@scottmike0
Mar 20 2016 10:53
ah
alpox
@alpox
Mar 20 2016 10:53
@scottmike0 You would have to put paranthesis around: `(typeof value != "number" || !isNaN(value))` Because of the operator precedences
scottmike0
@scottmike0
Mar 20 2016 10:54
@alpox yeah i just noticed that
Alex Brown
@webtechalex
Mar 20 2016 10:54
@alpox what is that? I didn’t think I was doing anything unusual or different from what is in the tutorials
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:54
@webtechalex
Is your project online?
Alex Brown
@webtechalex
Mar 20 2016 10:54
no
local only
alpox
@alpox
Mar 20 2016 10:54
@scottmike0 if you have a lot of && in a row and then a || something at the end, it is as you would do `(blabla && blabla && blabla) || somethingElse`
Alex Brown
@webtechalex
Mar 20 2016 10:54
well at least, tis version
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:55
Hold on .
Alex Brown
@webtechalex
Mar 20 2016 10:55
the codepen version is obviously online
but I’ve ditched that for the moment
alpox
@alpox
Mar 20 2016 10:55
@webtechalex You try to access resources which are not on the current domain you're working on (Since the api has another domain). A workaround is to use 'jsonp' requests
scottmike0
@scottmike0
Mar 20 2016 10:55
@alpox i was pretty amazed though rules of mathematical logic can work in code
alpox
@alpox
Mar 20 2016 10:56
you do that with setting callback=? or using \$.ajax with a dataType: 'jsonp' @webtechalex
Alex Brown
@webtechalex
Mar 20 2016 10:56
…I’m starting to feel that the tutorials were inadequate for this project! Haha!
Where do I set `callback=?` ?
alpox
@alpox
Mar 20 2016 10:57
This may help you
@scottmike0 Programming and computer science depends on mathematical rules :-)
Olawale Akinseye
@brainyfarm
Mar 20 2016 10:57
Rahul Nayak
@pragyes31
Mar 20 2016 10:57
Hello People
can somebody help me with "Testing Objects for Properties" exercise?
alpox
@alpox
Mar 20 2016 10:58
@brainyfarm And i would recommend against it since there is not a lot of work to do to come around that matter and using a third-party domain request only slows things down
scottmike0
@scottmike0
Mar 20 2016 10:58
@pragyes31 what have you done currently
Rahul Nayak
@pragyes31
Mar 20 2016 10:58

here is my code : ```function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)){

``return myObj.checkProp;``

}
else {
return "Not Found";
}

}
```

Alex Brown
@webtechalex
Mar 20 2016 10:59
thanks @alpox still no luck with callback=? included though
CamperBot
@camperbot
Mar 20 2016 10:59
webtechalex sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 421 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Mar 20 2016 10:59
@webtechalex Whats your code?
Alex Brown
@webtechalex
Mar 20 2016 11:00
@alpox
``````<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Testing JSON</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script type="text/javascript">
\$(document).ready(function() {
\$("#getData").on("click", function(){
\$.getJSON("https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsoncallback=?", function(json) {
\$("#test").html(JSON.stringify(json));
});
});
});
</script>
</head>
<body>
<button type="button" name="button" id="getData">Get Data</button>
<p id="test">Data</p>
</body>
</html>``````
alpox
@alpox
Mar 20 2016 11:00
@webtechalex take away the https://crossorigin.me/
@webtechalex and add a `&`in front of the callback=?
Himzo
@himzo-bosnjakovic
Mar 20 2016 11:00
guys i need some help
```````
```````

// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.list[1]; // Change this line
```

Alex Brown
@webtechalex
Mar 20 2016 11:02
@alpox still nothing
Olawale Akinseye
@brainyfarm
Mar 20 2016 11:02
Besides @webtechalex
I tested in firefox and your code works, you may want to learn the the jsonp method @alpox is suggestion*
alpox
@alpox
Mar 20 2016 11:02
@webtechalex Code now?
scottmike0
@scottmike0
Mar 20 2016 11:02
@pragyes31 think of how json objects are accessed
Alex Brown
@webtechalex
Mar 20 2016 11:02
``````<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Testing JSON</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script type="text/javascript">
\$(document).ready(function() {
\$("#getData").on("click", function(){
\$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json&callback=?", function(json) {
\$("#test").html(JSON.stringify(json));
});
});
});
</script>
</head>
<body>
<button type="button" name="button" id="getData">Get Data</button>
<p id="test">Data</p>
</body>
</html>``````
scottmike0
@scottmike0
Mar 20 2016 11:02
@pragyes31 a tip, is that they are not used with . often
Olawale Akinseye
@brainyfarm
Mar 20 2016 11:02
See you guys later :D
alpox
@alpox
Mar 20 2016 11:02
@scottmike0 I wonder why you are all talking about json objects... That are javascript objects, not json..
Rahul Nayak
@pragyes31
Mar 20 2016 11:02
@scottmike0 i am not there yet. Json. stuck at objects in JS
alpox
@alpox
Mar 20 2016 11:03
@webtechalex Looks fine for me now
scottmike0
@scottmike0
Mar 20 2016 11:03
@pragyes31 i mean javascript objects
JoshuaPP
@JoshuaPP
Mar 20 2016 11:03
Hi, would anyone be able to help me with 'Profile lookup' please?
Alex Brown
@webtechalex
Mar 20 2016 11:03
@brainyfarm tried in firefox as well… nothing
Theodore P.
@Ierofantis
Mar 20 2016 11:04
can anyone help me on this?
``````function findLongestWord(str) {

var res=str.split('').join();

var sorted = res.sort(function (a, b)
{ return b.length - a.length });

console.log(sorted[0]);

}``````
Alex Brown
@webtechalex
Mar 20 2016 11:05
@brainyfarm do you get the json data appearing on the page when you click the “Get Data” button?
scottmike0
@scottmike0
Mar 20 2016 11:05
@pragyes31 a tip is from this example accessing objects by brackets
Alex Brown
@webtechalex
Mar 20 2016 11:05
@alpox not sure what’s wrong then. May have to bail on these projects and look at the source code
Olawale Akinseye
@brainyfarm
Mar 20 2016 11:05
@webtechalex Yes.
Don't give up yet @webtechalex .
alpox
@alpox
Mar 20 2016 11:06
@webtechalex I see that on safari it seems that it cannot translate the json response
Yash Vardhan
@blankyash
Mar 20 2016 11:06
what is wrong with my code here?
``````unction lookUp(firstName, prop){
// Only change code below this line

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

if (firstName == contacts.firstName && prop == contacts[prop]){
return contacts[prop];
}

else if (firstName !== contacts.firstName){
return "No such contact";
}
}``````
alpox
@alpox
Mar 20 2016 11:06
@webtechalex The request itself works but i get this: SyntaxError: Unexpected token ':'. Parse error.
Yash Vardhan
@blankyash
Mar 20 2016 11:06
The challenge is Profile Lookup
Olawale Akinseye
@brainyfarm
Mar 20 2016 11:07
@blankyash
When do you return`No such property`?
In addition, your `No such contact` should be outside the for loop
negyvenketto
@negyvenketto
Mar 20 2016 11:08
@Ierofantis why do you join the split string?
@Ierofantis also: you split every character. if you want to split words, you need to put a space between the apostrophes
Alex Brown
@webtechalex
Mar 20 2016 11:10
@alpox okay, In Chrome I now get:
``GET https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json&callback=jQuery1122013595645562315095_1458471702584&_=1458471702585 net::ERR_INSECURE_RESPONSE``
…not sure why it’s suddenly an https!
dhstambolliu
@dhstambolliu
Mar 20 2016 11:12
Alex Brown
@webtechalex
Mar 20 2016 11:12
on Firefox I get:
``SyntaxError: missing ; before statement``
alpox
@alpox
Mar 20 2016 11:12
@webtechalex Good question... i don't know why it gets it
Alex Brown
@webtechalex
Mar 20 2016 11:13
aaah wait a minute! These errors are in the jquery script
not to do with my code
@brainyfarm I’m really trying not to quit on this but I’m very close! :)
alpox
@alpox
Mar 20 2016 11:15
Its still http for me
Alex Brown
@webtechalex
Mar 20 2016 11:15
@alpox where? in the console error?
negyvenketto
@negyvenketto
Mar 20 2016 11:16
alpox
@alpox
Mar 20 2016 11:16
@webtechalex In my network panel i see that
@webtechalex Well i see that unexpected token thing in my console
Artur Sęp
@a-sep
Mar 20 2016 11:17
Hi , is this the best solution or it's to messy?
lesson Chunky Monkey
``````function chunk(arr, size) {
// Break it up.
var myArr =[];
var steps =Math.ceil(arr.length/size);
var n = 0;

for(var i=0; i<steps; i++){
var a2 = arr.slice(n,n+size);
myArr[i] = a2;
n += size;
}

console.log(myArr);
return myArr;
}

chunk(["a", "b", "c", "d"], 2);``````
Alex Brown
@webtechalex
Mar 20 2016 11:19
Ah yes I can see in the firefox network panel it’s showing as an http request but the chrome one is an https
@alpox what browser are you using?
Artur Sęp
@a-sep
Mar 20 2016 11:21
Anyone have done Chunky Monky?
Kai Schoos
@skusku
Mar 20 2016 11:22
Hello there
negyvenketto
@negyvenketto
Mar 20 2016 11:23
@a-sep it looks reasonable to me
@a-sep you can avoid using `n` by putting `i*size` in the slice function
Alex N.
@N0bl3
Mar 20 2016 11:24
@a-sep you can use myArr.push(a2) instead, remove the console.log and BTW there is a lot of different solutions & we have to put readability into account in such a way that we can disagree over what is the best solution to do something.
Artur Sęp
@a-sep
Mar 20 2016 11:25
@negyvenketto @N0bl3 thanks, I was thinking to long on that :)
CamperBot
@camperbot
Mar 20 2016 11:25
a-sep sends brownie points to @negyvenketto and @n0bl3 :sparkles: :thumbsup: :sparkles:
:star: 225 | @n0bl3 | http://www.freecodecamp.com/n0bl3
:star: 311 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
negyvenketto
@negyvenketto
Mar 20 2016 11:26
@a-sep :thumbsup:
Alex N.
@N0bl3
Mar 20 2016 11:30
@a-sep you can try to make it in fewer lines if that s what you mean ;)
JiaLe Guo
@gabygoole
Mar 20 2016 11:31
@brainyfarm I can't understand
alpox
@alpox
Mar 20 2016 11:31
@webtechalex I tested it on chrome and safari... all the same result :-/ i guess its the api's fault
Alex Brown
@webtechalex
Mar 20 2016 11:32
@alpox I don’t think so. The url displays the JSON data when you visit it
Brendan Kinahan
@BKinahan
Mar 20 2016 11:33
howdy folks
Alex Brown
@webtechalex
Mar 20 2016 11:33
it’s definitely my code
@alpox @brainyfarm I had a look at the example project, so, shame on me for that. However it was of no help anyway :)
Sidharth Kriplani
@sidkrip
Mar 20 2016 11:35
Need help with basic frontend development projects
does anything has to be included to use bootstrap? I mean, does it need to be installed or does some header link need to be added to the top of the html?
alpox
@alpox
Mar 20 2016 11:35
@webtechalex Well sry then... it seems that your API doesnt support 'jsonp' :-/ you have to go with the solution of before with the crossorigin.me
Brendan Kinahan
@BKinahan
Mar 20 2016 11:35
@sidkrip yup
alpox
@alpox
Mar 20 2016 11:35
@webtechalex
``````<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Testing JSON</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script type="text/javascript">
\$(document).ready(function() {
\$("#getData").on("click", function(){
\$.getJSON("https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json",
function(json) {
\$('#test').html(JSON.stringify(json));
});
});
});
</script>
</head>
<body>
<button type="button" name="button" id="getData">Get Data</button>
<p id="test">Data</p>
</body>
</html>
```````
This works
But i don't know how its different from your solution of before
Ive never seen that an API doesnt support jsonp requests anyway ^^
Brendan Kinahan
@BKinahan
Mar 20 2016 11:36
@sidkrip check out the CDN links here: http://getbootstrap.com/getting-started/
Artur Sęp
@a-sep
Mar 20 2016 11:37
I'm done for today, see you tomorrow :smiley:
Sidharth Kriplani
@sidkrip
Mar 20 2016 11:38
@BKinahan I have to use the jumbotron class, but the expected output isnt there.
negyvenketto
@negyvenketto
Mar 20 2016 11:38
@sidkrip if you do it in codepen, it's enough to add it in the settings, as instructed in get set for our front end development projects
Sidharth Kriplani
@sidkrip
Mar 20 2016 11:39
@negyvenketto I will check that out
Alex Brown
@webtechalex
Mar 20 2016 11:42
@alpox looks like it’s the API after all. It does support jsonp but the usage example for jsonp is in russian. Apparently you can set the language but I can’t work out how
the crossorigin.me code does work but it doesn’t update with more clicks of the button (same quote each time)
JoshuaPP
@JoshuaPP
Mar 20 2016 11:48
Hey, could anyone possibly drop me a message and help me with the 'Profile Lookup' lesson please?
Brendan Kinahan
@BKinahan
Mar 20 2016 11:48
@JoshuaPP any reason not to post your code and ask your question here?
JoshuaPP
@JoshuaPP
Mar 20 2016 11:55
@BKinahan How do I copy code in here so it formats nicely?
Alex Brown
@webtechalex
Mar 20 2016 11:55
@alpox @brainyfarm :+1: Thanks for your help with this. I think I’m going to work on some other stuff for now and look for some other tutorials on API’s and JSON later next week. The FCC tutorials haven’t been adequate in preparing me with the lknowledge needed to complete these projects and it’s just made me feel really bad. I will get there… just not today. :)
CamperBot
@camperbot
Mar 20 2016 11:55
webtechalex sends brownie points to @alpox and @brainyfarm :sparkles: :thumbsup: :sparkles:
:warning: webtechalex already gave alpox points
:star: 1654 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Bil
@thebiltheory
Mar 20 2016 11:56
@JoshuaPP ```
JoshuaPP
@JoshuaPP
Mar 20 2016 11:56
``````for (var i = 0; i < contacts.length; i++) {

if (firstName == contacts.firstname && prop == firstname[prop]) {

return firstName[prop];

}

} /*else if (firstName !== contacts.firstName) {

return "No such contact";

} else {

return "No such property";

}*/
// Only change code above this line
}``````
Bil
@thebiltheory
Mar 20 2016 11:56
``Your code here``
Oups
JoshuaPP
@JoshuaPP
Mar 20 2016 11:56
Thanks @thebiltheory
CamperBot
@camperbot
Mar 20 2016 11:56
joshuapp sends brownie points to @thebiltheory :sparkles: :thumbsup: :sparkles:
:star: 3 | @thebiltheory | http://www.freecodecamp.com/thebiltheory
Brendan Kinahan
@BKinahan
Mar 20 2016 11:56
@JoshuaPP `contacts.firstname` is the incorrect capitalization.
@JoshuaPP and I believe "No such property" should be returned if the name matches but the property doesn't exist for that contact. Also you're looping through the `contacts` array with `i` but you don't refer to `contacts[i]` in your code for the current contact being examined.
Sidharth Kriplani
@sidkrip
Mar 20 2016 12:03
@BKinahan how should we add a description below the image as in this sample codepen by Quincy Larson?
http://codepen.io/FreeCodeCamp/full/wMQrXV
Brendan Kinahan
@BKinahan
Mar 20 2016 12:06
@sidkrip at a guess that looks like bootstrap's caption class
JoshuaPP
@JoshuaPP
Mar 20 2016 12:06
@BKinahan Wow, I changed the capitalization. Can't believe I missed that..
I've also amended my code slightly but can't seem to understand where I'm going wrong... real brain freeze
``````for (var i = 0; i < contacts.length; i++) {

if (firstName == contacts[i].firstName && prop == contacts[i].firstName[prop]) {
return contacts[i].firstName[prop];
}
}``````
Sidharth Kriplani
@sidkrip
Mar 20 2016 12:07
thanks @BKinahan
CamperBot
@camperbot
Mar 20 2016 12:07
sidkrip sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1115 | @bkinahan | http://www.freecodecamp.com/bkinahan
JoshuaPP
@JoshuaPP
Mar 20 2016 12:07
I'm not worry about the rest of the code just yet, just want the first test to pass
Brendan Kinahan
@BKinahan
Mar 20 2016 12:09
@JoshuaPP `prop` is the name of the property, but `contacts[i].firstName[prop]` refers to the value of the property of `contacts[i].firstName` with the same name as the string `prop` refers to.
@JoshuaPP you should instead che