These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Nov 2016
Moisés Man
@moigithub
Nov 26 2016 00:01
@Aggredicus EACH/every function have its own arguments object
means calling arguments inside one funciton have different values than calling inside another function
Khalid
@Khaleed
Nov 26 2016 00:02
@Aggredicus the aguments object is an array-like, it is not a real array
goubin510
@goubin510
Nov 26 2016 00:02
Hey, I think the verification script is bugged, I get the exact same string as expected but it doesn't validate... I'm at exercice DNA Pairing. any idea or comment ?
Khalid
@Khaleed
Nov 26 2016 00:02
it doesn't have array methods such as indexOf
Somia ♡
@somiajagadish
Nov 26 2016 00:03

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

}

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

// Change this value to test
switchOfStuff(1);

Hey guys! Another switch statement!!
Yay fun lol jk jk
Moisés Man
@moigithub
Nov 26 2016 00:04
@somiajagadish what the instruction says.. should be a for apple ??
or 1 for apple
and.. if a.. probably it should be a string.. soo need to be 'a' on quotes..
wihtout.. mean its a variable
Babawale Patrick Okare
@waleOkare
Nov 26 2016 00:04
dont know what am doing wrong??

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp === true)){

 return myObj[checkProp];

} else {

 return "Not Found";

}
// return checkProp;
}

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

goubin510
@goubin510
Nov 26 2016 00:04
no offense but just go back to switch definition..
Viorel Morari
@viorell91
Nov 26 2016 00:04
@Khaleed yes sure, I think the problem is in the getFullName since the test case "bob.getFullName() should return 'Haskell Curry' after bob.setFullName("Haskell Curry")" is the only one which fails. To be more precise I guess setting the full name without this is the issue but I have no idea how to avoid it
Somia ♡
@somiajagadish
Nov 26 2016 00:05
Oh sorry guys i know what it is i didnt add the last one ahahaha sorry :)
Khalid
@Khaleed
Nov 26 2016 00:05
excellent @viorell91, you did well
next question, do you know what this points to?
coy17a
@coy17a
Nov 26 2016 00:06
hey guys, anyone can help me? I am trying to use the slice function but i got this message: arr.slice not a function arrs=arr.slice(0,num);
Somia ♡
@somiajagadish
Nov 26 2016 00:06

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Help?
Moisés Man
@moigithub
Nov 26 2016 00:07
:point_up: 25 de noviembre de 2016 19:04 @somiajagadish
goubin510
@goubin510
Nov 26 2016 00:07
hey, I've an issue on DNA pairing, I'm getting the exact same string as asked but it doesn't validate...
Khalid
@Khaleed
Nov 26 2016 00:08
@coy17a that is what is called a TypeError
Viorel Morari
@viorell91
Nov 26 2016 00:08
@Khaleed this refers globally to the function it is attached if I'm not wrong
Khalid
@Khaleed
Nov 26 2016 00:08
it means that splice was called on something that is not an array
^^^ @coy17a
Somia ♡
@somiajagadish
Nov 26 2016 00:08

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Help
Moisés Man
@moigithub
Nov 26 2016 00:09
@somiajagadish plz scroll up.. re-read
no need to repost
David Amanze
@GodKingShogun
Nov 26 2016 00:09
i went back and looked at earlier modules and it helped but i am still not coming to the right conclusion
these are the instructions

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

this is what i was given and what i have done so far
coy17a
@coy17a
Nov 26 2016 00:09
@Khaleed ok thanks, let me check.
David Amanze
@GodKingShogun
Nov 26 2016 00:09

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result="My "+myAdjective+"scary "+myNoun+" who loves icecream"+myVerb+" very"+myAdverb;
// Your code above this line
return result;
}

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

CamperBot
@camperbot
Nov 26 2016 00:09
coy17a sends brownie points to @khaleed :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for khaleed
Somia ♡
@somiajagadish
Nov 26 2016 00:09

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Help?
David Amanze
@GodKingShogun
Nov 26 2016 00:10

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result="My "+myAdjective+"scary "+myNoun+" who loves icecream"+myVerb+" very"+myAdverb;
// Your code above this line
return result;
}

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

Somia ♡
@somiajagadish
Nov 26 2016 00:10

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Moisés Man
@moigithub
Nov 26 2016 00:10
omg.. wtb ignore button ?
MrSpongen
@MrSpongen
Nov 26 2016 00:10
@GodKingShogun Just did that one :)
Somia ♡
@somiajagadish
Nov 26 2016 00:10

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Can someone plz help?
mikaeel6
@mikaeel6
Nov 26 2016 00:10
I'm doing the stand in line challenge and I am completely stumped
Khalid
@Khaleed
Nov 26 2016 00:11
@viorell91 this is a keyword that is super tricky, the best way i think about it is that this is the thing that comes before a full stop and a variable or a method!
Somia ♡
@somiajagadish
Nov 26 2016 00:11

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Moisés Man
@moigithub
Nov 26 2016 00:11
@somiajagadish u gonna get banned if u keep spamming .. plz stop
Somia ♡
@somiajagadish
Nov 26 2016 00:11
I'm not spamming.......
Moisés Man
@moigithub
Nov 26 2016 00:11
reposting ur code every 2 seconds ?
Somia ♡
@somiajagadish
Nov 26 2016 00:12
Im asking for help :(
mikaeel6
@mikaeel6
Nov 26 2016 00:12
can anybody tell me anything about the stand in line javascript challenge
MrSpongen
@MrSpongen
Nov 26 2016 00:12
@GodKingShogun Code looks good to me, not sure what is wrong. Does it have to be in order?
@mikaeel6 I'm stuck on that one too :P can't figure it out ...
Khalid
@Khaleed
Nov 26 2016 00:13
@viorell91 technically this can point to four things:- 1) window object if it is called globally 2) object if it is called as a method 3) new instance of a class if you're doing object-oriented programming 4) this can point to whatever you want by using call or apply methods on the function prototype
David Amanze
@GodKingShogun
Nov 26 2016 00:13
if it was in order it wouldnt make sense
Khalid
@Khaleed
Nov 26 2016 00:13
@somiajagadish i don't think you were spamming, you were showing your code
Somia ♡
@somiajagadish
Nov 26 2016 00:13
@moigithub I'm not going to get banned
Khalid
@Khaleed
Nov 26 2016 00:14
but perhaps just post your code less frequently
Somia ♡
@somiajagadish
Nov 26 2016 00:14
@Khaleed Exactly!
Khalid
@Khaleed
Nov 26 2016 00:14
we can always scroll up to see :)
Somia ♡
@somiajagadish
Nov 26 2016 00:14
@Khaleed Thanks for a little more positivity! :)
CamperBot
@camperbot
Nov 26 2016 00:14
somiajagadish sends brownie points to @khaleed :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for khaleed
David Amanze
@GodKingShogun
Nov 26 2016 00:14
im going to post it again so you dont have to keep scrolling back up. please dont think i am spamming

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result="My "+myAdjective+"scary "+myNoun+" who loves icecream"+myVerb+" very"+myAdverb;
// Your code above this line
return result;
}

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

Khalid
@Khaleed
Nov 26 2016 00:15
@somiajagadish have you ever done any pairing?
Somia ♡
@somiajagadish
Nov 26 2016 00:15
@GodKingShogun Trust me, at least one person will think your spamming
Khalid
@Khaleed
Nov 26 2016 00:15
when i was new to programming, this was very helpful to me
MrSpongen
@MrSpongen
Nov 26 2016 00:15
Anybody can give pointers on https://www.freecodecamp.com/challenges/stand-in-line? I can't understand what is expected of me to do...
Somia ♡
@somiajagadish
Nov 26 2016 00:15
No I've never heard of it @Khaleed
Khalid
@Khaleed
Nov 26 2016 00:15
pairing means working with another coder on the same computer
or screen
one person is the driver, doing the typing
coy17a
@coy17a
Nov 26 2016 00:16

@Khaleed I don't understand th error, i believe it is an array. Look my code please: function chunkArrayInGroups(arr, size) {
// Break it up.

var elements=0;
if (arr.length%size===0){
elements=arr.length/size;
}
else {
elements=arr.lenght/size+1;
}

var arrs=[];

for (var i=0;i<elements;i++){
var num=size+i;
arrs=arr.slice(0,num);
arr=arr.unshift(arrs);
}
return arrs;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Khalid
@Khaleed
Nov 26 2016 00:16
the other is the navigator, giving you directions on how to write :)
Somia ♡
@somiajagadish
Nov 26 2016 00:16
@Khaleed Oh okay
mikaeel6
@mikaeel6
Nov 26 2016 00:17
is thee a place to find the answer to the challenge if you cant figure it out and no one will tell you how its done
Khalid
@Khaleed
Nov 26 2016 00:18
@coy17a have you defined the size variable?
if (arr.length%size===0){ elements=arr.length/size; }
coy17a
@coy17a
Nov 26 2016 00:19
size is the second argument of the function @Khaleed
mikaeel6
@mikaeel6
Nov 26 2016 00:19
I'm doing the stand in line
Khalid
@Khaleed
Nov 26 2016 00:20
cool
Moisés Man
@moigithub
Nov 26 2016 00:20
if u do case a: <-- a will be treated like a variable.. and javascript will try to get its content...
it should be case 'a': <-- on quotes.. cuz its a string
@somiajagadish
MrSpongen
@MrSpongen
Nov 26 2016 00:20
@mikaeel6 same. but I can't figure out what is expected of me :/
coy17a
@coy17a
Nov 26 2016 00:21
@Khaleed I think i know what happened, i don't need to put = for unshift, that was the mistake
Ka'
@k4p0
Nov 26 2016 00:21
@MrSpongen yup I can tell you, are you still there?
Khalid
@Khaleed
Nov 26 2016 00:22
@coy17a run it!
and see if your hypothesis is correct
MrSpongen
@MrSpongen
Nov 26 2016 00:22
@k4p0 Yep.
@k4p0 Scratching my head as we speak :)
Ka'
@k4p0
Nov 26 2016 00:23
@mikaeel6 , @MrSpongen you need to do 2 things
Khalid
@Khaleed
Nov 26 2016 00:23
@coy17a i see now
coy17a
@coy17a
Nov 26 2016 00:24
@Khaleed it is running , not the right answer thought. I will work in the algorithm now, thank you so much!
CamperBot
@camperbot
Nov 26 2016 00:24
coy17a sends brownie points to @khaleed :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for khaleed
Khalid
@Khaleed
Nov 26 2016 00:24
your arr has been re-assigned as a number when you did arr = arr.unshift(arrs);
@coy17a The unshift method adds one or more elements to the beginning of an array and returns the new length of the array.
new length's type is a number
so when you called arr.splice
arr is no longer an array
it is a number
and you get the TypeError
slice is not function
this is a typical error :)
Ka'
@k4p0
Nov 26 2016 00:26
@mikaeel6 , @MrSpongen one is, adding an 'item' at the end of the array ('arr'). Then you'll need to remove from that array, the first value. So if you have nextInLine([1, 2, 3], 4) you have to put that 4 at the end firstly, then remove the 1 from beggening, and return that 1 as an answer
MrSpongen
@MrSpongen
Nov 26 2016 00:26
@k4p0 Alright... ?
coy17a
@coy17a
Nov 26 2016 00:26
@Khaleed than you so much!!
Khalid
@Khaleed
Nov 26 2016 00:27
you're welcome
Ka'
@k4p0
Nov 26 2016 00:27
i hope it is clearer at least a bit, that displaying code maybe distracing and a bit different from previous tasks
MrSpongen
@MrSpongen
Nov 26 2016 00:27
Yes I feel quite confused with all the other code, kind of makes it harder to understand the task as the structure feels so totally different all of a sudden. @k4p0
Ka'
@k4p0
Nov 26 2016 00:27
@MrSpongen, @mikaeel6 I assume, you'd finish it off by adding two lines
still too vague?
MrSpongen
@MrSpongen
Nov 26 2016 00:33
Do I need to push, pop or shift things?
Or am I overthinking the challenge? :)
because I can't figure it out by just adding code within the function and change the return line
@k4p0
Ka'
@k4p0
Nov 26 2016 00:37
@MrSpongen yup, exactly two of them
i believe, you're on good way ;p
Khensura25
@Khensura25
Nov 26 2016 00:38
someone ..please help lol
Ka'
@k4p0
Nov 26 2016 00:39
@Khensura25 what's the problem?
MrSpongen
@MrSpongen
Nov 26 2016 00:40
Aaaaaaaaaaaah wait. Ok. So I need to add 6 to the array and then remove the first value?
Ka'
@k4p0
Nov 26 2016 00:41
@MrSpongen yup
i believe you had an array of [1,2,3,4,5] and an item = 6, if so, you're right
mikaeel6
@mikaeel6
Nov 26 2016 00:42
can some one tell me what is wrong with this code it is from the stand in line challenge:

function nextInLine(arr, item) {

item = testArr.shift();

// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5,];
item = testArr.push(6);
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

Walid Ashri
@walidashri
Nov 26 2016 00:44
@mikaeel6 use the func paramter arr not testArr and one step is missing
mikaeel6
@mikaeel6
Nov 26 2016 00:45
thanks
MrSpongen
@MrSpongen
Nov 26 2016 00:45
This message was deleted
'Before: [1,2,3,4,5]
2,3,4,56
After: [2,3,4,5]'
Feels like I am close :P
thought I should push the 6 to item, but it says item.push() is not a function ... hmm.

function nextInLine(arr, item) {
arr.shift(); // Your code here

return arr + item; // Change this line
}

Chris
@ckipp01
Nov 26 2016 00:50
jQuery is giving me a bit of trouble. I'm not sure why .remove() is not working. Line 13 of my js portion. Would love a lil help.
MrSpongen
@MrSpongen
Nov 26 2016 00:51
What am I missing? :(
Ka'
@k4p0
Nov 26 2016 00:52
@MrSpongen you cant use the push that way
Zaluth
@Zaluth
Nov 26 2016 00:52

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
}
]

function lookUpProfile(firstName, prop){

}

I'm totally stuck, help?

Ka'
@k4p0
Nov 26 2016 00:54
@MrSpongen when you're removing the first value, save it to new variable, that u can return it as an answer
Stephen James
@sjames1958gm
Nov 26 2016 00:54
@ckipp01 This is your class name on your HTML - firtChannelEverything
@Zaluth contacts is an array you should start with a loop over the contacts
Zaluth
@Zaluth
Nov 26 2016 00:55

@sjames1958gm i did this, but it's probably wrong

var name;
var property;

for (i = 0; i < contacts.length; i++) {
name = contacts[i];
property = name[prop];
}

Stephen James
@sjames1958gm
Nov 26 2016 00:57
@Zaluth You need to check the firstName property of the contact vs. the parameter as the first thing in the loop.
Then if there is a match check if it has the property
@sjames1958gm thank you kind sir
CamperBot
@camperbot
Nov 26 2016 00:58
ckipp01 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4531 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
MrSpongen
@MrSpongen
Nov 26 2016 00:58
function nextInLine(arr, item) {
item = arr.shift(); // Your code here
arr.push(item);
return item; // Change this line
}
Stephen James
@sjames1958gm
Nov 26 2016 00:58
@ckipp01 I think I saw another typo - thrid instead of third
Zaluth
@Zaluth
Nov 26 2016 00:59
@sjames1958gm so, both these things go inside the loop?
MrSpongen
@MrSpongen
Nov 26 2016 00:59
test #2 and #3 passes, but not #1 and #4.
Ka'
@k4p0
Nov 26 2016 00:59
@MrSpongen almost
Stephen James
@sjames1958gm
Nov 26 2016 00:59
@MrSpongen The order of operations is add to the end then remove from the beginning
Ka'
@k4p0
Nov 26 2016 00:59
you actually overwritten the item value
Stephen James
@sjames1958gm
Nov 26 2016 01:00
@Zaluth Yes, think about the loop as going through a stack of business cards, then you check the cards firstName against the one you are looking for
Then you check for the property
Ka'
@k4p0
Nov 26 2016 01:00
but it would be okay, if you change the order of lines
Surajit Basak
@surajitbasak109
Nov 26 2016 01:00
Can anyone check if there is any bug on my project?
http://codepen.io/regexp/full/yVoNaZ/
Zaluth
@Zaluth
Nov 26 2016 01:00
@sjames1958gm a nested loop, then
Stephen James
@sjames1958gm
Nov 26 2016 01:01
@Zaluth No, since contacts is an object you can access the properties directly using .firstName or[prop]
Ka'
@k4p0
Nov 26 2016 01:01
@MrSpongen if you create new variable instead of item and return it as answer, it will be okay also
Stephen James
@sjames1958gm
Nov 26 2016 01:02
@surajitbasak109 I did not see any bugs - nice an clean design - well done
Khensura25
@Khensura25
Nov 26 2016 01:02

@k4p0 having a hard time creating this function heres the directions: Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

If value is empty (""), delete the given prop property from the album.

Stephen James
@sjames1958gm
Nov 26 2016 01:03
@Khensura25 See all those ifs in the instructions - those translate to ifs in your code
Surajit Basak
@surajitbasak109
Nov 26 2016 01:03
Thank you :D
Zaluth
@Zaluth
Nov 26 2016 01:03
@sjames1958gm i'll give it a try, thanks
CamperBot
@camperbot
Nov 26 2016 01:03
zaluth sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4532 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
MrSpongen
@MrSpongen
Nov 26 2016 01:04
@k4p0 Haha this is so much harder then it should be xD
Khensura25
@Khensura25
Nov 26 2016 01:04

my code is here is :

function updateRecords(id, prop, value) {
var trackArray = [];
if (prop == "tracks" && value !== "")
{
prop.push(value);
}
else if (prop == "tracks" && collection[prop] === "")
{
trackArray.push(prop); //Might switch this parameter to 'prop'
}
else if (collection[prop] === "")
{
delete collection[prop];
}
return collection;
}

silver537
@silver537
Nov 26 2016 01:04
Nonesense
Khensura25
@Khensura25
Nov 26 2016 01:04
@k4p0
Ka'
@k4p0
Nov 26 2016 01:05
@Khensura25 Oh, yup. English is not my first language and I've had my own problems with translating instructions of that challange into my code. But someone here will explain it to you, i believe so ;)
MrSpongen
@MrSpongen
Nov 26 2016 01:07
Wohoo I solved it! :D @k4p0
Khensura25
@Khensura25
Nov 26 2016 01:08
@sjames1958gm ??
MrSpongen
@MrSpongen
Nov 26 2016 01:08
Created a new variable, pushed item into arr, and then shifted item from arr. Is that correct, or did I cheat the system?
function nextInLine(arr, item) {
x = arr.push(item);
x = arr.shift(item); // Your code here
return x; // Change this line
}
Ka'
@k4p0
Nov 26 2016 01:11
@MrSpongen the first line of your function could be only "arr.push(item);" there was no need to assign it to x, but nonetheless... well done ;-)!
MrSpongen
@MrSpongen
Nov 26 2016 01:13
@k4p0 Ah, ok :)
Stephen James
@sjames1958gm
Nov 26 2016 01:17
@Khensura25 you are not using id anywhere and id should be used to select the object that the changes are made to.
@MrSpongen shift doesn't take a parameter - but it doesn't effect anything - you could have done return arr.shift();
He Liu
@HeLiu
Nov 26 2016 01:21
function makeBook(name, author, genre, isbn, num ){
  author = [];
 return{
    name : name,
   author : author.join(', '),
    genre : genre,
    ISBN : isbn,
    numberOfPages: num
 };
}

makeBook("Harry Potter and the Sorcerer's Stone", "J.K. Rowling", "Fantasy", "0-7475-3269-9", 30);

makeBook("Snow Crash", "Neal Stephenson", "Fantasy", "0-553-08853-X", 488);

makeBook("Structure and Interpretation of Computer Programs", "Gerald Jay Sussman", "Hal Ableson", "Computer Science", "0-262-51087-1", 657);
i am trying to make this accept several authors. im not really too sure how to use join
one or several authors
i was using a ternary operator before but that only accepted two
Margaret
@Margaret2
Nov 26 2016 01:23
@HeLiu maybe you could input an array of authors
Stephen James
@sjames1958gm
Nov 26 2016 01:23
@HeLiu That is going to be difficult - how to know when end of authors and start of genre?
Moisés Man
@moigithub
Nov 26 2016 01:24
whatever string u passed to ur author parameter is gonna be replaced by empty array @HeLiu
He Liu
@HeLiu
Nov 26 2016 01:24
@sjames1958gm thats my confusion too!! hold on
blob
i dont know if that makes it any clearer
Christopher Villaba
@chrisvillaba
Nov 26 2016 01:25
blob
can you help from this guyz?
Margaret
@Margaret2
Nov 26 2016 01:25
so can't you just use makeBook("Structure and Interpretation of Computer Programs", ["Gerald Jay Sussman", "Hal Ableson"], "Computer Science", "0-262-51087-1", 657); and the array will be counted as a single argument, author
@HeLiu
Sakitha
@Sakitha
Nov 26 2016 01:26
function fn(f) {
  return function () {
   return f.apply(null, arguments);
  };
}
hey, why we don`t have to pass "f " as a argument to the second function?
He Liu
@HeLiu
Nov 26 2016 01:27
@Margaret2 that does make sense....i am going to save that and ask my instructor if anything is missing haha hes no where to be found on the holidays. thanks!
CamperBot
@camperbot
Nov 26 2016 01:27
heliu sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 505 | @margaret2 |http://www.freecodecamp.com/margaret2
He Liu
@HeLiu
Nov 26 2016 01:27
so i just pass that through the array paramenter?
itll show up as a value for the function?
Margaret
@Margaret2
Nov 26 2016 01:28
@HeLiu yeah, the array is the value of the parameter
then you can just get the data out of the array, which it looks like you were already doing with join
Diego Mayer
@Chrono79
Nov 26 2016 01:29
@Sakitha f is the function you apply, the argument of that function is what you pass there
That's a function constructor, you create an alias for other functions (or so I think)
Stephen James
@sjames1958gm
Nov 26 2016 01:29
@Sakitha because the scope of the inner function includes access to the parameter of the outer function
He Liu
@HeLiu
Nov 26 2016 01:29
@Chrono79 hey diego i think i talked to you about a leap year program? remember?
was that you?
Stephen James
@sjames1958gm
Nov 26 2016 01:30
@chrisvillaba a hole in one is where strokes equal 1
Diego Mayer
@Chrono79
Nov 26 2016 01:31
@HeLiu That doesn't ring a bell, no
Stephen James
@sjames1958gm
Nov 26 2016 01:31
@chrisvillaba The other ones you should compare strokes === to the value such as strokes === par -1 is a"Birdie"
Diego Mayer
@Chrono79
Nov 26 2016 01:33

@Sakitha

function fn(f) {
  return function() {
   return f.apply(null, arguments);
  };
}

var round = fn(Math.round);
round(2.45);

it's a kind of alias for other functions

Brian Lynch
@swindleNswoon
Nov 26 2016 01:38

function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(item);
return item; // Change this line
}

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

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

Noah Zielke
@NoahZielke
Nov 26 2016 01:38
Hey guys on the Celsius to Fahrenheit converter, I made the function fahrenheit = fahrenheit * 1.8 + 32; but the result is always null, what am i doing wrong?
Sakitha
@Sakitha
Nov 26 2016 01:38
@Chrono79 , @sjames1958gm thanks.
CamperBot
@camperbot
Nov 26 2016 01:38
sakitha sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2632 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 4533 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Nov 26 2016 01:38
@NoahZielke you have to use celsius, not fahrenheit twice
Noah Zielke
@NoahZielke
Nov 26 2016 01:39
so fahrenheit = celcius * 1.8 + 32; ?
Walid Ashri
@walidashri
Nov 26 2016 01:39
@swindleNswoon shift() takes no parameters and item hasn't changed
Margaret
@Margaret2
Nov 26 2016 01:40
@swindleNswoon you should probably be using arr.shift() without anything in ()
Diego Mayer
@Chrono79
Nov 26 2016 01:40
celsius @NoahZielke
c0d0er
@c0d0er
Nov 26 2016 01:40
@walidashri thanks!
CamperBot
@camperbot
Nov 26 2016 01:40
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 691 | @walidashri |http://www.freecodecamp.com/walidashri
Noah Zielke
@NoahZielke
Nov 26 2016 01:40
oh yeah oops
Margaret
@Margaret2
Nov 26 2016 01:41
@swindleNswoon fyi arr.shift() will return the value of the item it removes
Zaluth
@Zaluth
Nov 26 2016 01:41

function lookUpProfile(firstName, prop){

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

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

}

}

when there's only the first if, it works. when i add the two else if, it no longer works. why?

Noah Zielke
@NoahZielke
Nov 26 2016 01:41
hmmm still saying null

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celsius * 1.8 + 32;

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

// Change the inputs below to test your code
convertToF(30);
convertToF(0);
convertToF(-30);
convertToF(-10);
convertToF(20);
convertToF(30);

Diego Mayer
@Chrono79
Nov 26 2016 01:42
@Zaluth if you return always inside your loop, it won't run more than once
This condition is wrong: (contacts[i].hasOwnProperty(prop) != prop) { hasOwnProperty returns true or false, and prop is never true or false so...
Noah Zielke
@NoahZielke
Nov 26 2016 01:42
nevermind got it thanks @Chrono79
CamperBot
@camperbot
Nov 26 2016 01:42
noahzielke sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2633 | @chrono79 |http://www.freecodecamp.com/chrono79
Zaluth
@Zaluth
Nov 26 2016 01:42
@Chrono79 how should i do it?
Will
@Will-is-Coding
Nov 26 2016 01:43
@NoahZielke Looks fine to me. Are you supposed to console.log it? Otherwise may just need a refresh.
Diego Mayer
@Chrono79
Nov 26 2016 01:43
@Zaluth think about when you can say there is no such contact in the list. Hint: it's not at the first mismatch
c0d0er
@c0d0er
Nov 26 2016 01:44
@TylerMoeller thanks!
CamperBot
@camperbot
Nov 26 2016 01:44
c0d0er sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:cookie: 990 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Zaluth
@Zaluth
Nov 26 2016 01:47
@Chrono79 i mean, with the return thing. i need to return three different things, but shouldn't they be inside the loop?
Diego Mayer
@Chrono79
Nov 26 2016 01:47
@Zaluth not all, no
Walid Ashri
@walidashri
Nov 26 2016 01:48
@Chrono79 you helped out 10 campers got 11 thanks , while I helped one he didn't respond :)
CamperBot
@camperbot
Nov 26 2016 01:48
walidashri sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2634 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Nov 26 2016 01:49
@walidashri lol, thanks ;)
CamperBot
@camperbot
Nov 26 2016 01:49
chrono79 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 692 | @walidashri |http://www.freecodecamp.com/walidashri
Zaluth
@Zaluth
Nov 26 2016 01:49
@Chrono79 can you give some details? i'm kinda stuck
Chris Cullen
@123xylem
Nov 26 2016 01:50
Hi,
Im on chrome Dev tools. I have made changes to my source file on a webpage app but the changes dont work or come into effect.. speciically me defining allEnemies array.
Diego Mayer
@Chrono79
Nov 26 2016 01:50
@Zaluth of the 3 returns, which one do you think should be done after the loop and why? After the loop means you searched through the whole list
Chris Cullen
@123xylem
Nov 26 2016 01:50
How do i change this?
Dusliat
@Alchemistioc
Nov 26 2016 01:51

Hi guys, I'm almost done with the switch statement challenge. There's just one thing wrong and I can't figure out what.
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case "alpha":
caseInSwitch(1);
break;
case "beta":
caseInSwitch(2);
break;
case "gamma":
caseInSwitch(3);
break;
case "delta":
caseInSwitch(4);
break;
}

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

// Change this value to test
caseInSwitch(2);

Diego Mayer
@Chrono79
Nov 26 2016 01:52
@Alchemistioc you're calling your function from inside the switch (not what you have to do). You should change answer value there, read the instructions again, which values you should write in your cases and which values you should set answer to
Khensura25
@Khensura25
Nov 26 2016 01:53
true @sjames1958gm , I having trouble since this is a complex object, trying to access the nested properties
Zaluth
@Zaluth
Nov 26 2016 01:54
@Chrono79 the prop one? because it's compared with all the properties, not one of a specific object?
@Chrono79 but even if this is right, there are still 2 returns in the loop
Diego Mayer
@Chrono79
Nov 26 2016 01:54
@Zaluth no, the prop depends on a specific contact
If the 2 returns that are inside the loop are inside ifs that doesn't always become true, your loop could run as expected
Christopher Villaba
@chrisvillaba
Nov 26 2016 01:55
thank you @sjames1958gm
CamperBot
@camperbot
Nov 26 2016 01:55
chrisvillaba sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4534 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 26 2016 01:56
@chrisvillaba :+1:
Diego Mayer
@Chrono79
Nov 26 2016 01:56
@Zaluth I'm gonna give you an example
...
var arr = [1,2,3,4,5,6];
for (var i=0; i<arr.length; i++){
  if (arr[i]<2) {
    return "less than 2";
  else {
    return "greater or equal than 2";
  }
}

That loop will only run once

...
var arr = [1,2,3,4,5,6];
for (var i=0; i<arr.length; i++){
  if (arr[i]>10) {
    return "greater than 10";
  else if (arr[i]>20){
    return "greater than 20";
  }
}
return "all numbers were less than or equal than 10"

This one will run until the end

John Wolfe
@wolfejw86
Nov 26 2016 02:01
can anyone confirm if there is a bug with the profile lookup algorithm?
Dusliat
@Alchemistioc
Nov 26 2016 02:01
Thanks @Chrono79
CamperBot
@camperbot
Nov 26 2016 02:01
alchemistioc sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2635 | @chrono79 |http://www.freecodecamp.com/chrono79
Chris
@ckipp01
Nov 26 2016 02:02
@sjames1958gm you sure did. Thanks!
CamperBot
@camperbot
Nov 26 2016 02:02
ckipp01 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4535 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Nov 26 2016 02:02
@wolfejw86 show your code, at first there is no bug there afaik
Stephen James
@sjames1958gm
Nov 26 2016 02:02
@ckipp01 :+1:
John Wolfe
@wolfejw86
Nov 26 2016 02:03

];

var firstNameTest = false;

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i ++) {
if (contacts[i].firstName == firstName) {
firstNameTest = true;
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
}
}

if (firstNameTest === true) {
return "No such property";
}
else {
return "No such contact";
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");

var code="formatted"
Diego Mayer
@Chrono79
Nov 26 2016 02:03
@wolfejw86 use ``` to format the code, before and after it, in their own line
John Wolfe
@wolfejw86
Nov 26 2016 02:03

'''];

var firstNameTest = false;

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i ++) {
if (contacts[i].firstName == firstName) {
firstNameTest = true;
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
}
}

if (firstNameTest === true) {
return "No such property";
}
else {
return "No such contact";
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");

CamperBot
@camperbot
Nov 26 2016 02:03
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Nov 26 2016 02:04

var firstNameTest = false;


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i ++) {
    if (contacts[i].firstName == firstName) {
        firstNameTest = true;
         if (contacts[i].hasOwnProperty(prop)) {
           return contacts[i][prop];
         }
      }
  }

  if (firstNameTest === true) {
    return "No such property";
  }
  else { 
    return "No such contact";
  }




// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");
don't use global vars @wolfejw86
Note that the tests call your function several times and the global var keeps its value between calls
John Wolfe
@wolfejw86
Nov 26 2016 02:05
is that what's throwing it off?
Diego Mayer
@Chrono79
Nov 26 2016 02:06
@wolfejw86 try making it local
I wouldn't do it like that, but it could work
John Wolfe
@wolfejw86
Nov 26 2016 02:07
i made it local and it worked
@Chrono79 I am very new to programming, how would you do it?
Diego Mayer
@Chrono79
Nov 26 2016 02:07

I would return "No such property" in an else of

 if (contacts[i].hasOwnProperty(prop)) {
           return contacts[i][prop];
         }

And I would not use a condition on No such contact, if it reaches that part of the function that means no other result was returned

Alexander Køpke
@alexanderkopke
Nov 26 2016 02:07
locals for the win
John Wolfe
@wolfejw86
Nov 26 2016 02:08
oh just for the last part?
smart!
i think i will refactor that now
thank you
Diego Mayer
@Chrono79
Nov 26 2016 02:09
no problem
Chris Cullen
@123xylem
Nov 26 2016 02:10
Can someone help me with my dev tools app...
I open a .indexfile.. then change the files sources on the dev tools.. But my changes dont get saved or executed when i press refresh.. Am i changing them in the wrong place?
John Wolfe
@wolfejw86
Nov 26 2016 02:14
js
function lookUpProfile(firstName, prop){
// Only change code below this line

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

    }
  }

  return "No such contact";



// Only change code above this line
}
is this better do you think @Chrono79
Diego Mayer
@Chrono79
Nov 26 2016 02:14
@wolfejw86 much better, don't you think?
John Wolfe
@wolfejw86
Nov 26 2016 02:14
yes i thought so
much simpler
nhanly91
@nhanly91
Nov 26 2016 02:15
[ '2', '\n', 'H', 'a', 'c', 'k', 'e', 'r', '\n', 'R', 'a', 'n', 'k' ]
hi everyone I want to split this array and store it in 3 variables, split by '\n'
I need a short way rather than for loop :)
John Wolfe
@wolfejw86
Nov 26 2016 02:15
makes more since now too. today is my first day with javascript objects
sense*
Diego Mayer
@Chrono79
Nov 26 2016 02:16

@nhanly91 do you want to see how you could do it?

var [a,b,c] = [ '2', '\n', 'H', 'a', 'c', 'k', 'e', 'r', '\n', 'R', 'a', 'n', 'k' ].join("").split("\n");
console.log(a);
console.log(b);
console.log(c);

It's called deconstructing, the [a,b,c] part

Moisés Man
@moigithub
Nov 26 2016 02:16
[ '2', '\n', 'H', 'a', 'c', 'k', 'e', 'r', '\n', 'R', 'a', 'n', 'k' ].join("").split("\n")
Zaluth
@Zaluth
Nov 26 2016 02:17
@Chrono79 i was doing something similar to the code above, but trying to use && instead of an if inside an if. is it possible?
nhanly91
@nhanly91
Nov 26 2016 02:18
@Chrono79 @moigithub thanks
CamperBot
@camperbot
Nov 26 2016 02:18
nhanly91 sends brownie points to @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2636 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 2251 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
Nov 26 2016 02:18
@Zaluth with && you have some repetition, you have to repeat the condition on firstName, so nested is preferred, but both should work
if (a && b) {
  //do something
} else if (a && !b)
  //do something else
}
Zaluth
@Zaluth
Nov 26 2016 02:25
@Chrono79 i finally made it. thank you
CamperBot
@camperbot
Nov 26 2016 02:25
zaluth sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2637 | @chrono79 |http://www.freecodecamp.com/chrono79
Zaluth
@Zaluth
Nov 26 2016 02:26

function lookUpProfile(firstName, prop){

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

return "No such contact";

}

Diego Mayer
@Chrono79
Nov 26 2016 02:28
@Zaluth in your first if, if any of the 2 conditions is false the code jumps to the else if
Let's say, the firstName didn't match, and the first contact hasn't the property you looked for, you'll return "No such property"
That's why you should repeat the condition about firstName there or use nested ifs
c0d0er
@c0d0er
Nov 26 2016 02:32
@0x0936 thanks
CamperBot
@camperbot
Nov 26 2016 02:32
c0d0er sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1984 | @0x0936 |http://www.freecodecamp.com/0x0936
Zaluth
@Zaluth
Nov 26 2016 02:35
@Chrono79 is it wrong? it works fine for me
Diego Mayer
@Chrono79
Nov 26 2016 02:36
@Zaluth maybe because of the tests setup, I think if you pass a firstName and a prop you should look for both of them at the same time, not if the prop exists in a contact with another firstName
Zaluth
@Zaluth
Nov 26 2016 02:38
the instructions say If both are true, then return the "value" of that property
(both being the firstName and prop) @Chrono79
Diego Mayer
@Chrono79
Nov 26 2016 02:39
@Zaluth that's the first part, yes
If prop does not correspond to any valid properties then return "No such property"
I think valid properties refer to the properties of the contact that has the firstName passed
Zaluth
@Zaluth
Nov 26 2016 02:40
@Chrono79 sorry, i don't understand what you mean
@Chrono79 oh
Diego Mayer
@Chrono79
Nov 26 2016 02:41
at least, that's what I understand and sound logic to me
Zaluth
@Zaluth
Nov 26 2016 02:41
@Chrono79 the messages are lagging, it takes forever to get the rest of them
@Chrono79 but yes, you're right
@Chrono79 OH now i get what you mean hahaha
c0d0er
@c0d0er
Nov 26 2016 02:43
@toianw thanks
CamperBot
@camperbot
Nov 26 2016 02:43
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @toianw |http://www.freecodecamp.com/toianw
Zaluth
@Zaluth
Nov 26 2016 02:44
@Chrono79 you should test it like lookUpProfile("firstName", "prop"); and then only the property is returned. i think that's what you mean
@Chrono79 or at least, that's how it's supposed to work
Diego Mayer
@Chrono79
Nov 26 2016 02:47
if (a && b) {
  //do something
} else if (a && !b) //if you ommit the test over a here it isn't the same, because a could be false
  //do something else
}
with a being the test over firstName and b the test on prop is the same as these nested ifs
if (a) {
  if (b) {
    //do something
  } else {
    //do something else  
  }
}
@Zaluth either way it works, because all contacts has the same properties in the tests (at least, the same properties names)
"Kristian", "address" should return "No such property" <- when do you think it returns no such property with your code?
That is a test I created, not one of the challenge tests
It returns that at the first loop, it never reaches Kristian's contact object
nhanly91
@nhanly91
Nov 26 2016 02:54
['F','r','e','e','c','o','d','e','c','a','m','p']
another case, I want to split this array to 2 array. the first array contains all odd-indexed characters, the second contains all even-indexed characters. Don't use for loop :)
Diego Mayer
@Chrono79
Nov 26 2016 02:55
@nhanly91 use filter
Abhisek Pattnaik
@abhisekp
Nov 26 2016 02:55
@nhanly91 use _.partition
Zaluth
@Zaluth
Nov 26 2016 02:57
@Chrono79 i see. i gotta go now, but thanks a lot for the help :)
CamperBot
@camperbot
Nov 26 2016 02:57
zaluth sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: zaluth already gave chrono79 points
Diego Mayer
@Chrono79
Nov 26 2016 02:57
:+1:
@abhisekp isn't that part of underscore library?
I think he's asking about some challenges where he can't use libraries
Lean Junio
@leanjunio
Nov 26 2016 02:59
hey guys, is anyone else stuck on the wikipedia viewer?
Margaret
@Margaret2
Nov 26 2016 03:00
@Chrono79 you could always copy their function though :wink:
Abhisek Pattnaik
@abhisekp
Nov 26 2016 03:01
@nhanly91 @Chrono79
const arr = ['F','r','e','e','c','o','d','e','c','a','m','p'];
console.log(arr.reduce((p, c, i) => (p[i % 2].push(c), p), [[], []]));
Diego Mayer
@Chrono79
Nov 26 2016 03:01
@Margaret2 yes, but copying code isn't exactly the same as writing your own ;)
Dominic Muttel
@domuttel
Nov 26 2016 03:02
I am having a bit of trouble with Palindrome Checker
Margaret
@Margaret2
Nov 26 2016 03:02
@Chrono79 :joy:
Diego Mayer
@Chrono79
Nov 26 2016 03:02
@abhisekp :+1:
Dominic Muttel
@domuttel
Nov 26 2016 03:03
function palindrome(str) {
    var stringStrip = "";
    var stringLow = "";
    var stringReversed = "";
    stringStrip = str.replace(/[^0-9a-z]/gi, '').replace(/\d*/g,'');
    stringLow = stringStrip.toLowerCase();
    stringReversed = stringLow.split("").reverse().join("");
    if (stringLow === stringReversed) {
        return true;
    } else {
        return false;
    } 
}
palindrome("1 eye for of 1 eye.")
is supposed to return false according to the test?
Abhisek Pattnaik
@abhisekp
Nov 26 2016 03:04

the first array contains all odd-indexed characters, the second contains all even-indexed characters.

@nhanly91

arr.reduce((p, c, i) => (p[+!(i % 2)].push(c), p), [[], []])
nhanly91
@nhanly91
Nov 26 2016 03:06
@abhisekp thanks
CamperBot
@camperbot
Nov 26 2016 03:06
nhanly91 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3215 | @abhisekp |http://www.freecodecamp.com/abhisekp
Stephen James
@sjames1958gm
Nov 26 2016 03:07
@domuttel instructions are to keep numbers
Dominic Muttel
@domuttel
Nov 26 2016 03:07
Ah thatd be it
read it wrong... oops
Abhisek Pattnaik
@abhisekp
Nov 26 2016 03:07
@Chrono79 _.partition is from lodash
Margaret
@Margaret2
Nov 26 2016 03:08
@domuttel you should probably also lowercase it first because /[^a-z0-9]/ would remove capital letters too
Abhisek Pattnaik
@abhisekp
Nov 26 2016 03:10
/[^0-9a-z]/gi won't remove uppercase
Dominic Muttel
@domuttel
Nov 26 2016 03:10
@Margaret2
stringStrip = str.replace(/[^0-9a-zA-Z]/g, '');
all good!
Margaret
@Margaret2
Nov 26 2016 03:10
@abhisekp oh i forgot about the i
@domuttel :+1:
Dominic Muttel
@domuttel
Nov 26 2016 03:11
What is the best info / ways to learn regex more in detail?
im a bit uncertain about the tail /g, /i, /gi
g = global?
Diego Mayer
@Chrono79
Nov 26 2016 03:12
@domuttel Global pattern flags
g modifier: global. All matches (don't return after first match)
https://regex101.com/ <- check javascript at the left column
Abhisek Pattnaik
@abhisekp
Nov 26 2016 03:14
how can you you forget about yourself ;P
Margaret
@Margaret2
Nov 26 2016 03:15
@abhisekp lol
Dominic Muttel
@domuttel
Nov 26 2016 03:16
ive found this RegExr
Margaret
@Margaret2
Nov 26 2016 03:18
:+1: cool
Dominic Muttel
@domuttel
Nov 26 2016 03:18
Thanks dudes and dudettes
Stephen James
@sjames1958gm
Nov 26 2016 03:20
@domuttel :+1:
brandonminkim
@brandonminkim
Nov 26 2016 03:27

  function bouncer(arr) {
// Don't show a false ID to this bouncer.
  var answer = [];
  for (var i = 0; i < arr.length; i++) {
    if((typeof(arr[i]) != "boolean")
      && (arr[i] !== null)
      && (arr[i] !== "")
      && (arr[i] !== 0)
      && (arr[i] !== undefined)
      && (!isNaN(arr[i]))
    ){
      answer.push(arr[i]);
    }


  // console.log(answer);
  }
  console.log(answer);
}
  bouncer([7,"ate",false, null, "", 0, undefined, NaN]);
this doesn't return string "ate", can anyone help me why?
Ken Nawrocki
@nawrockp
Nov 26 2016 03:29
@brandonminkim I dont see that your function returns anything
perhaps return answer ?
brandonminkim
@brandonminkim
Nov 26 2016 03:30
@nawrockp i meant it doesn't push "ate" to array
Margaret
@Margaret2
Nov 26 2016 03:30
@brandonminkim because "ate" isNaN (is not a number)
@brandonminkim so your function will only return numbers
brandonminkim
@brandonminkim
Nov 26 2016 03:30
@Margaret2 isn't "ate" a string?
Margaret
@Margaret2
Nov 26 2016 03:31
@brandonminkim isNaN means "not a number". And a string is not a number, so isNaN("ate") returns true
but your statement is testing for isNaN to return false
brandonminkim
@brandonminkim
Nov 26 2016 03:31
@Margaret2 @nawrockp oh! thank you
CamperBot
@camperbot
Nov 26 2016 03:31
brandonminkim sends brownie points to @margaret2 and @nawrockp :sparkles: :thumbsup: :sparkles:
:cookie: 361 | @nawrockp |http://www.freecodecamp.com/nawrockp
:cookie: 506 | @margaret2 |http://www.freecodecamp.com/margaret2
brandonminkim
@brandonminkim
Nov 26 2016 03:32
@Margaret2 right. I wanted to have only number and string
Moisés Man
@moigithub
Nov 26 2016 03:34
use Number.isNaN() instead of isNaN()
Lusako Njwaba
@lunjwaba1
Nov 26 2016 03:34
Hello people
Margaret
@Margaret2
Nov 26 2016 03:34
@lunjwaba1 hi :wave:
Lusako Njwaba
@lunjwaba1
Nov 26 2016 03:36
@Margaret2 I got a little problemo with my code hope you can help, code to follow.....
'''
CamperBot
@camperbot
Nov 26 2016 03:36
:bulb: to format code use backticks! ``` more info
Lusako Njwaba
@lunjwaba1
Nov 26 2016 03:36
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  var newStr = str.replace(/[\s\_]/gi, "-"), //Replace whitespace and underscores
      newerStr = newStr.split("");


 newerStr.forEach(function(element){
   var cap = element.toUpperCase(); //uppercase letter
   if(element === cap && element !== "-" && 
      newerStr.indexOf(element) !== 0 &&        
      newerStr.indexOf(element) -1 !== "-"){

      newerStr.splice(newerStr.indexOf(element),0,"-"); //place a -before uppercase letter   
   }     
 }); 

  var finalStr = newerStr.join("").toLowerCase();
      console.log(finalStr);

  return finalStr;


}
I keep getting a bunch of unwanted dashes --------
wonder were what I am doing wrong
Margaret
@Margaret2
Nov 26 2016 03:38
ok, i will take a look at it
@lunjwaba1 the first and third parts (new str and finalStr) look right, but in the second part, you are basically saying "if an element is a capital letter, replace it with a dash"
you have to include the original letter and the dash
Margaret
@Margaret2
Nov 26 2016 03:44
in my answer, i just used the replace function again with another regex @lunjwaba1
Lusako Njwaba
@lunjwaba1
Nov 26 2016 03:45
@Margaret2 ok I'll try replace on the second part
leslieparker25
@leslieparker25
Nov 26 2016 03:54
Help! I'm having trouble with the "Word Blanks" exercise
CamperBot
@camperbot
Nov 26 2016 03:54
no wiki entry for: im having trouble with the word blanks exercise
Lusako Njwaba
@lunjwaba1
Nov 26 2016 03:58
thanks @Margaret2 your way worked: ) I used a callback function with replace...worked like a charm
CamperBot
@camperbot
Nov 26 2016 03:58
lunjwaba1 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 507 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Nov 26 2016 04:00
Awesome! 😃
Lusako Njwaba
@lunjwaba1
Nov 26 2016 04:04
Shorter code too :smile:
He Liu
@HeLiu
Nov 26 2016 04:04
can someone give me a hint on how to write a function that gets the remainder of two numbers divided...without using %?
ohh wait
can this be done just by using plus and minus?
Ken Nawrocki
@nawrockp
Nov 26 2016 04:06
@HeLiu Yeah, that is what I am thinking
Will
@Will-is-Coding
Nov 26 2016 04:07
@leslieparker25 What do you have so far?
tanglongyang
@tanglongyang
Nov 26 2016 04:10
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = myStorage.car["inside"]["glove box"]; // Change this line
is there something wrong?
gloveBoxContents should equal "maps"
Use dot and bracket notation to access myStorage
He Liu
@HeLiu
Nov 26 2016 04:12
ok so as i am doing some reading
the right answer came up on quora
idunno if thats a good thing or bad thing
i didnt get the answer on my own
Will
@Will-is-Coding
Nov 26 2016 04:12
@tanglongyang You should use bracket notation for them all, including car I believe.
Walid Ashri
@walidashri
Nov 26 2016 04:13
@tanglongyang no but I think the challenge needs only one bracket
tanglongyang
@tanglongyang
Nov 26 2016 04:14
it doesn't work.
Will
@Will-is-Coding
Nov 26 2016 04:15
Oh it does say use dot and bracket. Sorry. So it's probably expecting you to use dot notation for single words, and bracket for two words @tanglongyang
tanglongyang
@tanglongyang
Nov 26 2016 04:16
yes. I just pass the exam.
Will
@Will-is-Coding
Nov 26 2016 04:16
Okay, good. Sorry for the confusion.
tanglongyang
@tanglongyang
Nov 26 2016 04:17
thx anyway @Will-is-Coding @walidashri
CamperBot
@camperbot
Nov 26 2016 04:17
tanglongyang sends brownie points to @will-is-coding and @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 695 | @walidashri |http://www.freecodecamp.com/walidashri
:cookie: 482 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Aaron
@apalm1341
Nov 26 2016 04:26
Hey all
Johnny
@JohnnyBizzel
Nov 26 2016 04:26
Anyone know what a Progressive Web App is?
:tumbleweed:
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:26
var listItems = document.getElementById("itemList").getElementByTagName("li"); for ( i = 0; i < listItems.length; i++) { listItems[i].innerHTML = "Hello World"; }
anyone see anything wrong with this?
Johnny
@JohnnyBizzel
Nov 26 2016 04:27
@lazersharkPM Nothing obvious. What is wrong?
Ken Nawrocki
@nawrockp
Nov 26 2016 04:27
@JohnnyBizzel no, I have been developing for years and this is the first time I have heard of it. However it makes sense
Johnny
@JohnnyBizzel
Nov 26 2016 04:28
@nawrockp Looks like Google's version of node or something: https://codelabs.developers.google.com/codelabs/your-first-pwapp/#0
The next big thing!
Aaron
@apalm1341
Nov 26 2016 04:28
Is it true that u only need to worry about copyright infringement and plagiarism and anything else like that that could possibly be bad to do and get u in trouble somehow is when u r making a lot of money??
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:28
@JohnnyBizzel Just wasn't seeing a response from teh internetz. I realize it may have been my connection. Thanks for the second opinion :)
CamperBot
@camperbot
Nov 26 2016 04:28
lazersharkpm sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 869 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Aaron
@apalm1341
Nov 26 2016 04:29
I guess piracy would be another thing added to the list too?
Johnny
@JohnnyBizzel
Nov 26 2016 04:29
@lazersharkPM Ok, glad it's working :+1: And Merry Christmas!
Ken Nawrocki
@nawrockp
Nov 26 2016 04:30
@JohnnyBizzel Well the whole app market is ready for a slap in the face. Too much bloat. Google seems to be giving a lot of preference to websites that load quicker as well.
@JohnnyBizzel thanks for the link, I will be reading up on it...
CamperBot
@camperbot
Nov 26 2016 04:31
nawrockp sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 870 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 26 2016 04:31
@nawrockp Hmm. Interesting times. Definitely worth knowing Node and this PWA stuff. Thanks!
@nawrockp Cookie for Ken please. Thank you!
CamperBot
@camperbot
Nov 26 2016 04:32
johnnybizzel sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles:
:cookie: 363 | @nawrockp |http://www.freecodecamp.com/nawrockp
Ken Nawrocki
@nawrockp
Nov 26 2016 04:33
@JohnnyBizzel I am a web developer, not an app developer, but seriously the hybrid apps that are developed today are just way too bloated. Js dependency hell .
Johnny
@JohnnyBizzel
Nov 26 2016 04:34
@nawrockp Yes, it seems like you need to know your dependencies with Node.
Brandon Culpepper
@Culpepper533
Nov 26 2016 04:34
I'm so close to getting this worked out but I'm forgetting how to assign variables.

// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
processed = 2;
processedArg= processed;

Johnny
@JohnnyBizzel
Nov 26 2016 04:35
@Culpepper533 This is a variable assignment changed = change(10);
Matt
@airborneprayer
Nov 26 2016 04:35
How do you copy the screen of code to here?
Johnny
@JohnnyBizzel
Nov 26 2016 04:36
@airborneprayer Select all Ctl+A and then paste Ctl+V
'''
CamperBot
@camperbot
Nov 26 2016 04:36
:bulb: to format code use backticks! ``` more info
Brandon Culpepper
@Culpepper533
Nov 26 2016 04:37
thanks @JohnnyBizzel :+1:
CamperBot
@camperbot
Nov 26 2016 04:37
culpepper533 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 871 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Ken Nawrocki
@nawrockp
Nov 26 2016 04:37
@JohnnyBizzel With npm? Yeah you need to really watch over what they are adding to your app. I am no expert but this is ridiculous . The idea behind making a hybrid-web app is that it can be used on all platforms. Seems the js community has forgotten that and think that they can just add whatever they want to. Service workers still need a bit more support, but that will come: http://caniuse.com/#search=service%20workers
Khensura25
@Khensura25
Nov 26 2016 04:37
help anoyone
CamperBot
@camperbot
Nov 26 2016 04:37
no wiki entry for: anoyone
Khensura25
@Khensura25
Nov 26 2016 04:37
help anyone
CamperBot
@camperbot
Nov 26 2016 04:37
no wiki entry for: anyone
Ken Nawrocki
@nawrockp
Nov 26 2016 04:39
@JohnnyBizzel do you know how long this page/idea has been out. I am a bit clueless
Johnny
@JohnnyBizzel
Nov 26 2016 04:39
@nawrockp I guess support will slowly become adopted. Like flexbox.

@nawrockp Which page did you mean?

do you know how long this page/idea has been out. I am a bit clueless

Ken Nawrocki
@nawrockp
Nov 26 2016 04:41
@JohnnyBizzel personally I am a wordpress developer. And the theme developers (which make my job easier I must say) have just added so much js and css that sites just don't donwload correctly at times anymore. Hard to troubleshoot
@JohnnyBizzel well the google page on it? First time I have heard about it but it makes complete sense. https://developers.google.com/web/progressive-web-apps/
Johnny
@JohnnyBizzel
Nov 26 2016 04:42
@nawrockp Sounds like a hassle. Have you heard of Genesis Framework?
@nawrockp I heard about PWA on a Medium post recommended by Quincey.
Ken Nawrocki
@nawrockp
Nov 26 2016 04:43
@JohnnyBizzel yeah I did a lot of work with genesis a couple of years ago. Its simple and makes sense. But clients want bang and boom today
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:43

I'm having no luck with my JS variable. It's not acting upon the HTML at all. What am I missing?

```<!DOCtype html>
<!DOCTYPE html>

<html>

<head>
<link rel="stylesheet" type="javascript" href="jabble01.JS">
<title>JS</title>
</head>

<body>

<hi id="headline"> Click a list item to replace this text. </h1><br>

<button > Add New Item</button>

<ul id="itemList">

<li>First Item </li>

<li>Second Item</li>

<li>Third Item</li>

<li>Fourth Item</li>

<li>Fifth Item</li>
</ul>

<script type="text/javascript">
var listItems = document.getElementById("itemList").getElementByTagName("li");
for ( i = 0; i < listItems.length; i++) {
listItems[i].innerHTML = "Hello World";
}
</script>

</body>
</html>
```

Sorry for the massive text dump
but I don't see any errors
Ken Nawrocki
@nawrockp
Nov 26 2016 04:43
@JohnnyBizzel Checking that out now. That guy really hit the nail on the head about development. Too much bloat recently
Johnny
@JohnnyBizzel
Nov 26 2016 04:44
@nawrockp So Genesis is not that worth learning?
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:44
<script type="text/javascript"> var listItems = document.getElementById("itemList").getElementByTagName("li"); for ( i = 0; i < listItems.length; i++) { listItems[i].innerHTML = "Hello World"; } </script>
Aditi Roy
@AlluringAditi
Nov 26 2016 04:45
Hey Guys!!
Can someone please help me with this:
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%0A%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
I cannot figure out the logic on how to check if the "The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact."
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:45
I thought I'd dropped a big one, heh
doaldo
@doaldodm
Nov 26 2016 04:46

I need help with the guys
Smallest Common Multiple algorithm here is what I have but is to inefficient and ends in crash my browser.
function smallestCommons(arr) {
var min= Math.min.apply(null,arr);
var max= Math.max.apply(null, arr);
var cont;

for(var i=max; ;i+=max){
cont=0;
for(var j=min;j<=max;j++){
//console.log(i+"%"+j+"="+" "+i%j);
if(i%j===0){
cont++;
}

}if(cont===max-min+1){
  return i;

}
}

}

smallestCommons([1,5]);

Aditi Roy
@AlluringAditi
Nov 26 2016 04:46
@lazersharkPM hehe! :P
doaldo
@doaldodm
Nov 26 2016 04:46

function smallestCommons(arr) {
var min= Math.min.apply(null,arr);
var max= Math.max.apply(null, arr);
var cont;

for(var i=max; ;i+=max){
cont=0;
for(var j=min;j<=max;j++){
//console.log(i+"%"+j+"="+" "+i%j);
if(i%j===0){
cont++;
}

}if(cont===max-min+1){
  return i;

}
}

}

smallestCommons([1,5]);

Johnny
@JohnnyBizzel
Nov 26 2016 04:46
@lazersharkPM This looks wrong <hi id="headline"> should be <h1 id="headline">
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:46
ahhh, LET me try
@JohnnyBizzel It's true that was interfering with my h1 tag but the JS variable is ineffective. It doesn't change the html at all when the <ul> should be changed to "Hello World>
Ken Nawrocki
@nawrockp
Nov 26 2016 04:48
@JohnnyBizzel I really like genesis, but I am a programmer and it takes what wordpress does and erases some of it and adds its own. That might work, but clients always want something different so its not like you would get what they want by genesis. Its a lightweight framework. But WordPress has its own framework that works well enough.
Johnny
@JohnnyBizzel
Nov 26 2016 04:49
@lazersharkPM Also your have a JS file as your style sheet? Is this correct?
Ken Nawrocki
@nawrockp
Nov 26 2016 04:49
@JohnnyBizzel As far as programming, its good. But you will always need to modify something . So you still need to learn how WP works and if they want a lot of changes , well another theme might do as well.
Allisha
@lazershark4PrimeMinister
Nov 26 2016 04:50
I saved it as a .js file @JohnnyBizzel
Ken Nawrocki
@nawrockp
Nov 26 2016 04:50
@JohnnyBizzel no solid answer for you, I have been doing it for years and still have no strong reference.
Johnny
@JohnnyBizzel
Nov 26 2016 04:50
@nawrockp That's what I thought. I would prefer to learn how WP does things than some layer framework. It was a course I found on Lynda.
Ken Nawrocki
@nawrockp
Nov 26 2016 04:50
@JohnnyBizzel link?
James
@jbonds08
Nov 26 2016 04:51

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

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

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


  return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
can someone help me with this challenge. I can't seem to get this one.
Khensura25
@Khensura25
Nov 26 2016 04:52
same here
:(
James
@jbonds08
Nov 26 2016 04:52
If value is empty (""), delete the given prop property from the album.
Khensura25
@Khensura25
Nov 26 2016 04:53
@jbonds08 how did you upload that screenshot unto here?
James
@jbonds08
Nov 26 2016 04:53
umm, you have to use three of the ` marks
not single quotation marks
but the other one
MoNag1
@MoNag1
Nov 26 2016 04:56
'''
CamperBot
@camperbot
Nov 26 2016 04:56
:bulb: to format code use backticks! ``` more info
Khensura25
@Khensura25
Nov 26 2016 04:57
Screen Shot 2016-11-25 at 8.03.23 PM.png

```
function updateRecords(id, prop, value) {
var findIt = id;
var hey = value;
var yo = prop;
var pleaseFindIt = collection[findIt];
var whereIsIt = collection[findIt][yo];
var trackFinder = collection[findIt][yo][hey];

if (yo == "tracks" && hey != "tracks" )
{
var trackArray = [];
trackArray.push(hey);
}

else if (yo == "tracks" && trackFinder !== "")
{
trackFinder.push(value);
}

else if (collection[prop] === "")
{
delete collection[prop];
}
return collection;
}

Johnny
@JohnnyBizzel
Nov 26 2016 05:03

@lazersharkPM Hi. If you are still there, I made a codepen: http://codepen.io/JohnnyBizzel/pen/vyJLBw

I was mistaken. You can't chain those operators together.

@Khensura25 Some strange variable names there. It makes your code hard to read.
You need to loop over the collection.
@jbonds08 @Khensura25 You need to use the .hasOwnProperty() function.
Johnny
@JohnnyBizzel
Nov 26 2016 05:09
Ok, looks like now one is around. Good night peeps. :zzz:
Ken Nawrocki
@nawrockp
Nov 26 2016 05:12
@JohnnyBizzel I am not saying there is anything wrong with Genesis, but the company that sells it is trying to make money like anyone else. The same happened with Thesis, another company that tried to corner the market on wordpress themes with a lot of marketing. I say that Genesis is better, and uses a better concept on how to make a quick website without bloat. But in the end I don't love them since I still ended up having to undo what they had done on top of what wordpress had already done. If I had my choice I would say uses Genesis, but I don't have my choice. Clients always want to change something and that requires udoing what Genesis already did and doing it over again sometimes. however, overall the themes are much less bloated than what I work with today and that is important. So if you ,as a businessman, could convince the cleint to use that, great. However they usually want bells and whistles that end up causing you to add some many plugins/custom scripts that it ends up being about the same amount of work. But as programmer, Genesis has the right idea :)
@JohnnyBizzel however all these sites, including those that I build , are bloated, and if Google decides to penalize them, well there will be some changes
Johnny
@JohnnyBizzel
Nov 26 2016 05:13
@nawrockp Ok thanks. It is worth knowing what is out there.
Most of the WP sites I host have low requirements. (Personal sites)
CamperBot
@camperbot
Nov 26 2016 05:13
johnnybizzel sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles:
:warning: johnnybizzel already gave nawrockp points
Ken Nawrocki
@nawrockp
Nov 26 2016 05:14
@JohnnyBizzel don
t get me wrong, for a normal website, with advanced functionality, Wordpress is the way to go. It's not cool, but it mature and that helps a lot. Try making an ecommerce website with a contact form and events page plus say maybe a portfolio that users can upload their images (securely ) from scratch. It would be a ton of work and with Wordpress if you know how to configure the site you can do it much better an more quickly. Problem is, there are a lot of Wordpress developers out there already.
Xenon Chau
@XenonChau
Nov 26 2016 05:19
I was passed "regular expression matches" quiz, and I have a question:
\s can match all blank.
\Scan match all non-blank.
var textString = "How many non-space characters are there in this sentence?";
why /\S+/g is NOT correct?
Aditi Roy
@AlluringAditi
Nov 26 2016 05:28
Hey Guys!
Can someone please help me Exercise 217.
How can I check, if the name supplied in the function is present in my defined LookUp?
Logan Sinclair
@LoganS1
Nov 26 2016 05:30
Could someone help me fix my regular expression to not include underscores? My current code is:
function palindrome(str) {
//declate variables
  var filteredArray;
  var filteredString;

  str = str.toLowerCase();      //change all letters to lowercase
  filteredArray = str.match(/\w/g);  //remove all non 0-9 and a-z chars
  filteredArray.reverse();  //reversed the array to prepare to test for palindrome
  filteredString = filteredArray.join("");  //turns the array back to a string

//tests to see if the input was a palindrome
  if (filteredString == filteredArray.reverse().join("")) {
    return true;
  }else{
    return false;
  }
}



palindrome("five|\_/|four");
CHAMPION
@Qchampion
Nov 26 2016 05:31
who can help me?
Logan Sinclair
@LoganS1
Nov 26 2016 05:32
I can try! whats your problem @Qchampion
Aditi Roy
@AlluringAditi
Nov 26 2016 05:32
@Qchampion I'm very much willing only if within my knowledge
CHAMPION
@Qchampion
Nov 26 2016 05:32
Return Early Pattern for Functions

// Setup
function abTest(a, b) {
// Only change code below this line
console.log(a<0,b<0);
return undefined;

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);

how to use return?
Logan Sinclair
@LoganS1
Nov 26 2016 05:33
what is the goal of the challenge?
CHAMPION
@Qchampion
Nov 26 2016 05:34
the 200th
Return Early Pattern for Functions
Aditi Roy
@AlluringAditi
Nov 26 2016 05:35
@Qchampion Sorry!! I got no idea! I haven't reached there!
Still stuck at challenge 217.
CHAMPION
@Qchampion
Nov 26 2016 05:36
My stuck at challenge 200
Aditi Roy
@AlluringAditi
Nov 26 2016 05:37
@Qchampion Can you share the link to the challenge
Logan Sinclair
@LoganS1
Nov 26 2016 05:38

So return takes whatever is given to it and "returns" it to the calling location.

for example i have a function that calulates price I call

var finalPrice = priceCalc(4, 7);

The function priceCalc turns into whatever the priceCalc function returned. So say it returned 7 the code now reads

var finalPrice = 7;

@Qchampion

Will
@Will-is-Coding
Nov 26 2016 05:38
@Qchampion Currently you're printing out if a and b are less than zero, then immediately returning undefined no matter what. I think you should be using an if statement to check their values.
Logan Sinclair
@LoganS1
Nov 26 2016 05:40

so your code is always returning undefined because you are telling to return undefined by saying

return undefined;

you need an if statement saying that if a < 0 OR b < 0, returns false

@Qchampion
CHAMPION
@Qchampion
Nov 26 2016 05:41
I will have a try,thanks
Logan Sinclair
@LoganS1
Nov 26 2016 05:41
anyone else having any problems, I will have to leave soon
Aditi Roy
@AlluringAditi
Nov 26 2016 05:42
@Qchampion Hey use this!!
if (a < 0 || b < 0){
return undefined;
}
Will
@Will-is-Coding
Nov 26 2016 05:42
Preferably don't give exact answers @CodeEveryDayDanny as that may lead to copy+paste and not understanding or thinking it out.
Aditi Roy
@AlluringAditi
Nov 26 2016 05:42
Ahhh!! Sorry my bad!
Logan Sinclair
@LoganS1
Nov 26 2016 05:43
@CodeEveryDayDanny It is looked down upon to give direct answers, try making the perosn understand first and make sure giving answers is ALWAYS a last resort.
__mifflin__
@cdrainxv
Nov 26 2016 05:43

@XenonChau: You current regex is not matching per character but per word. I used this:

var textString = "How many non-space characters are there in this sentence?";
console.log(textString.match(/[\w-?]/g).length); // => 49

To match all non-blank characters (including - and ?) and return their length.

Logan Sinclair
@LoganS1
Nov 26 2016 05:43
@CodeEveryDayDanny No problem everyone makes mistakes sometimes
Will
@Will-is-Coding
Nov 26 2016 05:43
^ @LoganS1
Aditi Roy
@AlluringAditi
Nov 26 2016 05:43
@LoganS1 Will keep that in mind for sure and apologies!
Now can someone please help me with 217!! I'm stuck there for a very long time now!
CHAMPION
@Qchampion
Nov 26 2016 05:44
Thanks for everyone,haha
Logan Sinclair
@LoganS1
Nov 26 2016 05:44
Thanks @cdrainxv
CamperBot
@camperbot
Nov 26 2016 05:44
logans1 sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:star2: 1117 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Aditi Roy
@AlluringAditi
Nov 26 2016 05:44
@Qchampion I hope you understood the logic
Will
@Will-is-Coding
Nov 26 2016 05:44
@CodeEveryDayDanny Which one is that/what are you having a problem with?
Aditi Roy
@AlluringAditi
Nov 26 2016 05:45
Okay I'm sharing the link to the problem
Logan Sinclair
@LoganS1
Nov 26 2016 05:45
^ The problem number is different per person @CodeEveryDayDanny
Aditi Roy
@AlluringAditi
Nov 26 2016 05:45
@LoganS1 @Will-is-Coding Profile Lookup
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%0A%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
@LoganS1 @Will-is-Coding So I'm stuck to find a Logic for:
"The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact."
Will
@Will-is-Coding
Nov 26 2016 05:47
@CodeEveryDayDanny Right, so are you already iterating through the contacts array?
Logan Sinclair
@LoganS1
Nov 26 2016 05:47
@CodeEveryDayDanny Oooh I remember this one, this one was tough can we see your code?
Use 3 batticks above and below your code to make your code easier to read. the bat ticks are below the escape key and to the left of the 1. It should look like this
'''
code
'''
CamperBot
@camperbot
Nov 26 2016 05:47
:bulb: to format code use backticks! ``` more info
Will
@Will-is-Coding
Nov 26 2016 05:48
```
//Code Here
```
@LoganS1 @CodeEveryDayDanny the backtick is to the left of 1 and above the tab, if on a QWERTY keyboard
Logan Sinclair
@LoganS1
Nov 26 2016 05:48
^ true, forgot for a moment of other layouts
How did you show the backticks @Will-is-Coding ? Did you \ before each one?
Aditi Roy
@AlluringAditi
Nov 26 2016 05:50
@LoganS1 @Will-is-Coding Okay So this is the one : ``` right?
Logan Sinclair
@LoganS1
Nov 26 2016 05:50
yup put 3 before your code, then copy your code under them, and lastly put 3 more after all you code
Will
@Will-is-Coding
Nov 26 2016 05:51
Yes you can escape the ` with \
Here is a useful function @CodeEveryDayDanny Have you encountered this already?
Logan Sinclair
@LoganS1
Nov 26 2016 05:51
it should look like
function bunchOfCode(){
//junk
}
Aditi Roy
@AlluringAditi
Nov 26 2016 05:51
Okay got it! but right now I'm stuck on how to proceed with the code!
Will
@Will-is-Coding
Nov 26 2016 05:52
@CodeEveryDayDanny The first step would be to iterate through the array, so first do that then post what you've got. Then check the link I just posted
Logan Sinclair
@LoganS1
Nov 26 2016 05:52
To iterate through the array try using the for statement you was taught earlier.
I have got to go, best of luck to you @CodeEveryDayDanny !
Aditi Roy
@AlluringAditi
Nov 26 2016 05:54
@LoganS1 Thanks man!
CamperBot
@camperbot
Nov 26 2016 05:54
codeeverydaydanny sends brownie points to @logans1 :sparkles: :thumbsup: :sparkles:
:cookie: 248 | @logans1 |http://www.freecodecamp.com/logans1
Aditi Roy
@AlluringAditi
Nov 26 2016 05:54
@Will-is-Coding I'm working on it now!
Lets see if I can get this!
Will
@Will-is-Coding
Nov 26 2016 05:55
@LoganS1 Btw, the way to not include a character or set of characters with regex is to [^a-c] so that wouldn't match a b or c in the string
[^ignore] essentially
Aditi Roy
@AlluringAditi
Nov 26 2016 06:08
@Will-is-Coding Hey!
Okay here's what I wrote, which is not working!
function lookUpProfile(firstName, prop){
// Only change code below this line
var i;
for(i=0; i<contacts.length; i++){
if(contacts.hasOwnProperty(prop) && firstName === contacts.firstName){
return contacts[prop];
}
else{
if(firstName !== contacts.FirstName){
return "No such contact";
}
else{
if(!cntacts.hasOwnProperty(prop)){
return "No such property";
}
}
}
}
// Only change code above this line
}
Will
@Will-is-Coding
Nov 26 2016 06:11

contacts is an array, so you need access each contact individually using the i variable.
So like

var arr = [ 'a', 'b', 'c'];
console.log(arr[0]); //Prints a

@CodeEveryDayDanny

You can also declare the i variable inside of the for(...)
Also the correct usages of if..if else..else as currently you have errors.
Watch for typos too !cntacts
Aditi Roy
@AlluringAditi
Nov 26 2016 06:14
@Will-is-Coding aahh okay checking!
He Liu
@HeLiu
Nov 26 2016 06:24
function stringLength(string){
  if(string.slice(0)){
    return string;
    }
  return stringLength(string.slice(0, -1));
}
```
hey guys i am writing a fucntion that defines the .length property
using recursive and slice
the problem is im not too sure how to return how many times its ran or sliced
im only returning the sting right now
Will
@Will-is-Coding
Nov 26 2016 06:33
@HeLiu if(string.slice(0)) what are you trying to do here?
Joseph
@revisualize
Nov 26 2016 06:33
@HeLiu youre not soing any math.
Why are you trying to rewrite .length()????
He Liu
@HeLiu
Nov 26 2016 06:36
its a problem that me and my partner are trying to do
to learn recursive functions better
@Will-is-Coding if(string.slice(0)===string?
im trying to get it to slice to the zero index and then return how many times it sliced..
Will
@Will-is-Coding
Nov 26 2016 06:40
@HeLiu As in till the string is empty? Well that current if statement doesn't really work the way you intend it to
As for keeping track, I'm a bit tired but all I can think of is to have a number outside of the recursive function that you increase by one each time you slice.
Arman Galstyan
@AGalstyanK622
Nov 26 2016 06:43
Capture.PNG
hello how can I do this pattern?
He Liu
@HeLiu
Nov 26 2016 06:46
@Will-is-Coding thank you!!
CamperBot
@camperbot
Nov 26 2016 06:46
heliu sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 483 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Will
@Will-is-Coding
Nov 26 2016 06:50
@HeLiu So check the string length instead of your current if statement and increase per call. No problem, good luck, recursives are tricky
@AGalstyanK622 Generally with a loop of some sort, increasing the amount of spaces out the X will be.
Arman Galstyan
@AGalstyanK622
Nov 26 2016 06:52
@Will-is-Coding can you write yeah I know
for(i=0;i<5;i++){

document.write("X")
for(j=0;j<4;j++){
    document.write("&nbsp")
    document.write("X")
}    
document.write("<br>")
}
later i DONT KNOW
He Liu
@HeLiu
Nov 26 2016 06:54
function stringLength(string){

  var count = stringLength(string.slice(0,-1));


}
stringLength("game")
ok im working right now uhhhhh
this exceeded maxium call stack as expected
i need a place for it to stop
im just thinking out loud lol
puchinepip
@puchinepip
Nov 26 2016 07:01
I can't understand the article
plesase
Parley Kennelly
@parleydk
Nov 26 2016 07:04
@puchinepip which piece don't you understand?
do you understand the general definition of a palindrome?
puchinepip
@puchinepip
Nov 26 2016 07:04
yes I do
I can't understand the replace method
Ogundele Olumide
@Lumexralph
Nov 26 2016 07:06
@HeLiu your reursion should stop when the length of the string is zero I think
Darth Skywalker
@adityaparab
Nov 26 2016 07:06
@puchinepip : Whats so not understandable in replace?
puchinepip
@puchinepip
Nov 26 2016 07:06
the code
Ogundele Olumide
@Lumexralph
Nov 26 2016 07:06
@HeLiu a condtion like that should be somewhere in your function
Parley Kennelly
@parleydk
Nov 26 2016 07:06
the regular expression piece?
puchinepip
@puchinepip
Nov 26 2016 07:06
can't understand this str.replace(regexp|substr, newSubStr|function)
Darth Skywalker
@adityaparab
Nov 26 2016 07:07
@puchinepip : the regexp|substr means, the first parameter to the replace method can either be a regular expression OR it can be a string that is supposed to be a substring of str
puchinepip
@puchinepip
Nov 26 2016 07:08
ok
can you give the code for removing the non-alphanumeric characters
Darth Skywalker
@adityaparab
Nov 26 2016 07:08
The 2nd parameter newSubStr|function represents the string that you want to replace in str where the 1st parameter matches
Parley Kennelly
@parleydk
Nov 26 2016 07:09
str.toLowerCase().replace(/[^A-Z0-9]+/gi, "");
This is what mine looks like. I had to lookup up JavaScript Regular Expressions to get it figured out.
Will
@Will-is-Coding
Nov 26 2016 07:09

@AGalstyanK622 Currently that would print

X X X X X
X X X X X

etc.
Your i is the row. The j needs to change per loop of i and only write one X and loop through j for nbsp's

Darth Skywalker
@adityaparab
Nov 26 2016 07:09
for now, you just pay attention to .replace(subStr, newSubStr)
don't worry about regexp and function for now
@puchinepip
puchinepip
@puchinepip
Nov 26 2016 07:09
so what does this mean
/[^A-Z0-9]+/gi
i know g for global and then i for case insensitive
Parley Kennelly
@parleydk
Nov 26 2016 07:10
it replaces all characters that aren't A....Z or 0....9 with an empty string.
puchinepip
@puchinepip
Nov 26 2016 07:10
and then the "" so that it will be replaced by nothing AKA be removed
Ogundele Olumide
@Lumexralph
Nov 26 2016 07:10
@parleydk you can also use \W for non alphanumeric characters
puchinepip
@puchinepip
Nov 26 2016 07:10
@Lumexralph how do you do that
Larry karani
@larryTheGeek
Nov 26 2016 07:10
@puchinepip it simply requires you to write a function that returns true is a string is pronounced the same way both in reverse and normal outline eg the word "eye" if u reverse it it will remain eye..the replace method " str.replace(/[\w_]\g," ") replaces all the non alpha numeric characters
Ogundele Olumide
@Lumexralph
Nov 26 2016 07:11
@puchinepip do what?
Darth Skywalker
@adityaparab
Nov 26 2016 07:11
@puchinepip : /^[A-Z0-9]+/ means a string the the BEGINS WITH (^) any number of characters(+) that are A-Z, a-z and 0-9
Parley Kennelly
@parleydk
Nov 26 2016 07:11
\W includes the '-' hyphen which isn't included in the palindrome definition.
Darth Skywalker
@adityaparab
Nov 26 2016 07:11
a-z will be considered because of i flag
puchinepip
@puchinepip
Nov 26 2016 07:12
gaaad I don't understand the syntax, honestly
how did you come up to that
Parley Kennelly
@parleydk
Nov 26 2016 07:12
lot's of googling
puchinepip
@puchinepip
Nov 26 2016 07:12
can you do it like step by step
Darth Skywalker
@adityaparab
Nov 26 2016 07:12
@puchinepip take a look at regexr.com
there is a cheatsheet in the left panel that explains the meaning of each symbol in regular expressions
Larry karani
@larryTheGeek
Nov 26 2016 07:13
@puchinepip
puchinepip
@puchinepip
Nov 26 2016 07:13
just what I needed @adityaparab
what was global for
Darth Skywalker
@adityaparab
Nov 26 2016 07:16
@puchinepip : For multiline strings
puchinepip
@puchinepip
Nov 26 2016 07:16
@larryTheGeek did you mean str.replace(/[\W_]/g,"")
is that correct?
Darth Skywalker
@adityaparab
Nov 26 2016 07:17
multiline and multiple matches
without g flag, the regex will only give you the first match
ignore the rest
puchinepip
@puchinepip
Nov 26 2016 07:18
Ohhh
Thanks for your answer guys.
puchinepip
@puchinepip
Nov 26 2016 07:29
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase().replace(/[^a-z0-9]/gi, "");

  for (var i = 0; i < Math.floor(str.length/2); i++){
    if (str[i] !== str[str.length - 1])
      return false;
  }

  return true;
}
I think there's a problem with the space
whitespace
hmmm
puchinepip
@puchinepip
Nov 26 2016 07:34
it says incorrect when there's a space
palindrome("race car"
palindrome("A man, a plan, a canal. Panama")
palindrome("never odd or even")
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:37
@puchinepip try str[str.length -1 - i]
puchinepip
@puchinepip
Nov 26 2016 07:37
ohhhh
i totally forgot
thanks
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:38
@puchinepip :smile:
puchinepip
@puchinepip
Nov 26 2016 07:38
@ghulamshabir thanks!
CamperBot
@camperbot
Nov 26 2016 07:38
puchinepip sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1150 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
masterkoda
@masterkoda
Nov 26 2016 07:43

can anyone help me with this code...
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:43
return myObj.["checkProp"] its not correct
masterkoda
@masterkoda
Nov 26 2016 07:44
@ghulamshabir if(myObj.hasOwnProperty(checkProp))
return myObj.[checkProp];
i have tried this
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:44
yes that one is good but without dot
masterkoda
@masterkoda
Nov 26 2016 07:45
if(myObj.hasOwnProperty("checkProp"))
return myObj.[checkProp];
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:45
remore quotes around checkprop
remove dot
masterkoda
@masterkoda
Nov 26 2016 07:46
@ghulamshabir sir can you explain total use of quotes....
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:46
yes sure
do you see gift pet bed in the object definition { ... }
masterkoda
@masterkoda
Nov 26 2016 07:48
yes
puchinepip
@puchinepip
Nov 26 2016 07:49

function titleCase(str) {
  str = str.toLowerCase();
  var array = str.split(" ");

  for (i = 0; i < array.length; i++){
    array[i][0] = array[i][0].toUpperCase();
  }

  str = array.join(" ");
  return str;
}

titleCase("I'm a little tea pot");
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:49
they are property keys, they work as index numbers work in arrays like 0, 1, 2
puchinepip
@puchinepip
Nov 26 2016 07:49

how do I access the first letters of the
function titleCase(str) {
str = str.toLowerCase();
var array = str.split(" ");

for (i = 0; i < array.length; i++){
array[i][0] = array[i][0].toUpperCase();
}

str = array.join(" ");
return str;
}

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

how do I access the first letters of ["i'm","a","little"]
masterkoda
@masterkoda
Nov 26 2016 07:50
@ghulamshabir ok sir
puchinepip
@puchinepip
Nov 26 2016 07:50
I can't use two dimensional array
masterkoda
@masterkoda
Nov 26 2016 07:51
@ghulamshabir what does quotes assign beside strings
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:52
when you know actual keys like these then you can access property value using either dot notaion or quotes on the key in brackets like this myObj.giftor myObj["gift"], it will return string pony
tanglongyang
@tanglongyang
Nov 26 2016 07:52

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

```who can tell me how to
create an empty array before adding the new value to the album's corresponding property.

puchinepip
@puchinepip
Nov 26 2016 07:53

function titleCase(str) {
  str = str.toLowerCase();
  var array = str.split(" ");

  for (i = 0; i < array.length; i++){
    array[i] = array[i].split("");
    array[i][0] = array[i][0].toUpperCase();
    array[i] = array[i].join("");
  }

  str = array.join(" ");
  return str;
}

titleCase("I'm a little tea pot");
is this correct
tanglongyang
@tanglongyang
Nov 26 2016 07:53
create an empty array before adding the new value to the album's corresponding property.
Ghulam Shabir
@ghulamshabir
Nov 26 2016 07:53
but if the key is in a variable like checkProp = "gift", then you must use brackets and checkProp without quotes, myObj[checkProp] will return also pony
puchinepip
@puchinepip
Nov 26 2016 07:53
I split it first, 1 dimensional array. then split it again, then join
masterkoda
@masterkoda
Nov 26 2016 07:54
@ghulamshabir then sir if i use my.Obj["checkProp"] is should also give the same as checkProp=gift..????
c0d0er
@c0d0er
Nov 26 2016 07:56
@toianw thanks!
CamperBot
@camperbot
Nov 26 2016 07:56
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 433 | @toianw |http://www.freecodecamp.com/toianw
masterkoda
@masterkoda
Nov 26 2016 07:56
@ghulamshabir thank you so much
CamperBot
@camperbot
Nov 26 2016 07:56
masterkoda sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1151 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Markus Kiili
@Masd925
Nov 26 2016 07:58
@masterkoda No, ["checkProp"] looks for property key "checkProp". Not "gift".
[checkProp] evaluates to ["gift"].
Darth Skywalker
@adityaparab
Nov 26 2016 08:00
@masterkoda use the force!
puchinepip
@puchinepip
Nov 26 2016 08:01
lmao
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:01
@masterkoda :smile:
@puchinepip you are not taking care of remaining letters of each word, you will end up with only one letter in each word with the current solution
c0d0er
@c0d0er
Nov 26 2016 08:12
does anybody know some good sass, react and d3 online or other learning sources?
Yerrapotu Manojkiran
@nani554
Nov 26 2016 08:17
help needed please
CamperBot
@camperbot
Nov 26 2016 08:17
no wiki entry for: needed please
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:19
Instructions
Write a switch statement to set answer for the following ranges:
1-3 - "Low"
4-6 - "Mid"
7-9 - "High"
Yerrapotu Manojkiran
@nani554
Nov 26 2016 08:19
got it
i have wrote wrong var name
thank you for looking at @ghulamshabir
CamperBot
@camperbot
Nov 26 2016 08:20
nani554 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1152 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:20
actually you don't have to declare your own
and don't repeat strings three times, it should be just one time
Yerrapotu Manojkiran
@nani554
Nov 26 2016 08:21
yeah that too modified
Alexander Huynh
@caesarsalad93
Nov 26 2016 08:22
Hi javascripters. Is it possible to have dynamic variable naming?
I'm not sure else how to describe it, but...
pseudo code something like, for(var i =0; i < people.length; i++){var person[i] = people[i];}
Bogdan Paliy
@bpalij
Nov 26 2016 08:24

cannot understand manipulating complex object. my code has a syntax error, but i dont know how to make it correct and in one variable```var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

// Add record here
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];```

Alexander Huynh
@caesarsalad93
Nov 26 2016 08:24
so you could name person 1, person 2, etc
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:26
@bpalij syntax should be like this [ { ... }, { ... } ]
Markus Kiili
@Masd925
Nov 26 2016 08:26
@bpalij The structure should be var myMusic = [{...},{...}];
Bogdan Paliy
@bpalij
Nov 26 2016 08:28
@ghulamshabir thanks, i tried semicolon instead, but it didnt work
CamperBot
@camperbot
Nov 26 2016 08:28
bpalij sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1153 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Bogdan Paliy
@bpalij
Nov 26 2016 08:30
@caesarsalad93 why not create an object or an array?
Yerrapotu Manojkiran
@nani554
Nov 26 2016 08:32
@huynh just see this ,for person1 u will get one answer and for person 2 u will get another answer
var name will be fixed but for different values ,answers will also be different
Alexander Huynh
@caesarsalad93
Nov 26 2016 08:34
@nani554 I need different variable names because I want to store the values
mesopotamija9
@mesopotamija9
Nov 26 2016 08:36

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

// Only change code below this line
var lookup = {
alpha:"Adams",
bravo:"Boston",
charlie:"Chicago",
delta:"Denver",
echo:"Easy",
foxtrot:"Frank",

};

result += lookup[val];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");
`

phoneticLookup("") should equal undefined
how i can make it?
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:37
@mesopotamija9 not +=
mesopotamija9
@mesopotamija9
Nov 26 2016 08:37
@ghulamshabir thank you
CamperBot
@camperbot
Nov 26 2016 08:37
mesopotamija9 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1154 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Alexander Huynh
@caesarsalad93
Nov 26 2016 08:37
@bpalij If I have a constructor function, say, function Person(birthday, age, favoriteFood), and I just wanna create a new person[i]
with i being a dynamic number of people I want to create
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:40
@caesarsalad93
var people = [];
for(var i=0; i<10; i++) {
  people.push(new Person("...", "..."))
}
Alexander Huynh
@caesarsalad93
Nov 26 2016 08:42
@ghulamshabir there no use of the variable i
inside the for statement?
Sourajyoti
@Sourajyoti
Nov 26 2016 08:43
easier way to do this:
function destroyer(arr) {
  var args = Array.from(arguments);
  args.shift();
  function check (value){
    for (i=0;i<args.length; i++){
      if(value===args[i]){return false;}
    }
    return true;
  }
  arr=arr.filter(check);
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
there should be one
????
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:45
@Sourajyoti do not reset arr, arr = arr.filter
Sourajyoti
@Sourajyoti
Nov 26 2016 08:45
okay, but any other way to shorten the ode?
code*?
Markus Kiili
@Masd925
Nov 26 2016 08:46
@caesarsalad93 You can make a function that returns an array of new persons. You can make a method on Person.prototype like .reproduce() that returns an array of persons. You can make a new constructor like function Group (){...} that contains an array of persons...
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:47
@Sourajyoti you can get rid of loop using indexOf
Aditi Roy
@AlluringAditi
Nov 26 2016 08:48
function lookUpProfile(firstName, prop) { var i=0; while(i<contacts.length) { if(contacts[i].firstName === firstName) { if(contacts.hasOwnProperty(prop) === true) { return contacts[i][prop]; } else { return "No such property"; } } i++; } return "No such contact"; }
Hi can someone please help me with this code and tell me what's wrong in this:
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:49
@CodeEveryDayDanny three backticks should be on new line to format properly
Aditi Roy
@AlluringAditi
Nov 26 2016 08:50
function lookUpProfile(firstName, prop)
{
  var i=0;
  while(i<contacts.length)
  {
    if(contacts[i].firstName === firstName)
      {
        if(contacts.hasOwnProperty(prop) === true)
          {
            return contacts[i][prop];
          }
        else
          {
            return "No such property";
          }
      }
    i++; 
  }
  return "No such contact";
}
@ghulamshabir thanks!!
CamperBot
@camperbot
Nov 26 2016 08:50
codeeverydaydanny sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1155 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Aditi Roy
@AlluringAditi
Nov 26 2016 08:50
Can Someone please help me with the code!!
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:50
@CodeEveryDayDanny :+1:
Markus Kiili
@Masd925
Nov 26 2016 08:51
@CodeEveryDayDanny Should be if(contacts[i].hasOwnProperty(prop)){...}
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:51
@CodeEveryDayDanny contacts[i].hasOwnProperty(prop)
Anyone help me?
Aditi Roy
@AlluringAditi
Nov 26 2016 08:51
@Masd925 @ghulamshabir Thanks Guys!! Got it!!
CamperBot
@camperbot
Nov 26 2016 08:51
codeeverydaydanny sends brownie points to @masd925 and @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: codeeverydaydanny already gave ghulamshabir points
:star2: 3012 | @masd925 |http://www.freecodecamp.com/masd925
Alexander Huynh
@caesarsalad93
Nov 26 2016 08:51
@Masd925 Interesting, it is hard for me to grasp without a concrete example though
Anyone help?
Yerrapotu Manojkiran
@nani554
Nov 26 2016 08:55
@mesopotamija9 what's the topic no.
Aditi Roy
@AlluringAditi
Nov 26 2016 08:55
@mesopotamija9 What is the problem that you are facing?
mesopotamija9
@mesopotamija9
Nov 26 2016 08:56
i dont know how to make if statment that will return be ===true if threre is property
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:56
@mesopotamija9 .hasOwnProperty method ?
mesopotamija9
@mesopotamija9
Nov 26 2016 08:56
if (myObj.hasOwnProperty === true) {
return myObj[checkProp];
i dont know how to print this
Look my idea
Ghulam Shabir
@ghulamshabir
Nov 26 2016 08:58
@mesopotamija9 this method takes a key then searches it in the object returns true for existent and false for non existent
mesopotamija9
@mesopotamija9
Nov 26 2016 08:59
can you give me working code so i will see what you ment?
Aditi Roy
@AlluringAditi
Nov 26 2016 09:00
@mesopotamija9 Hey in your if condition when you are calling the function hasOwnProperty you are not passing what needs to be checked!
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:01
if(obj.hasOwnProperty(prop) === true), here prop is varible which holds a key, and === true can be omitted
mesopotamija9
@mesopotamija9
Nov 26 2016 09:01
@CodeEveryDayDanny Thank you
CamperBot
@camperbot
Nov 26 2016 09:01
mesopotamija9 sends brownie points to @codeeverydaydanny :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for codeeverydaydanny
Aditi Roy
@AlluringAditi
Nov 26 2016 09:01
@ghulamshabir @mesopotamija9 It should be if f(obj.hasOwnProperty(checkProp) === true)
Markus Kiili
@Masd925
Nov 26 2016 09:02
@caesarsalad93 Here is one example. Maybe not the best choice of properties but anyway:
function Person(birthday, age, favoriteFood) {
  this.birthday = birthday;
  this.age = age;
  this.favoriteFood = favoriteFood;

  this.reproduce = function (num) {
    var arr = [];
    for (var i=0; i<num; i++) {
      arr.push(new Person(new Date(),0,favoriteFood))
    }
    return arr;
  }
}

var dad = new Person(new Date(1973,2,17),43,"Kebab");
dad.reproduce(3); 

/*

[ { birthday: Sat Nov 26 2016 11:00:05 GMT+0200 (FLE Standard Time),
    age: 0,
    favoriteFood: 'Kebab',
    reproduce: [Function] },
  { birthday: Sat Nov 26 2016 11:00:05 GMT+0200 (FLE Standard Time),
    age: 0,
    favoriteFood: 'Kebab',
    reproduce: [Function] },
  { birthday: Sat Nov 26 2016 11:00:05 GMT+0200 (FLE Standard Time),
    age: 0,
    favoriteFood: 'Kebab',
    reproduce: [Function] } ]

*/
Aditi Roy
@AlluringAditi
Nov 26 2016 09:02
@mesopotamija9 :)
mesopotamija9
@mesopotamija9
Nov 26 2016 09:02
yeah i was't typing prop :O :(
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:03
@CodeEveryDayDanny I avoid actual variables in challenge in my examples
Aditi Roy
@AlluringAditi
Nov 26 2016 09:04
@ghulamshabir Aaahh okay
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:04
@mesopotamija9 when I told you .hasOwnProperty takes a key, then you should have got the point here for giving it the checkProp
Aditi Roy
@AlluringAditi
Nov 26 2016 09:05
@ghulamshabir Yes I he gets it and me too!!
it was my bad!!
Cool!! (y)
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:07
@CodeEveryDayDanny @mesopotamija9 :smile: , people should think deeply on hints and undertand meaning of words carefully, they just ignore them and want straight solutions
Aditi Roy
@AlluringAditi
Nov 26 2016 09:07
@ghulamshabir Totally Agree :)
Alexander Huynh
@caesarsalad93
Nov 26 2016 09:14
@Masd925 That is very interesting. It is not the functionality that i'm looking for, but seeing the possibilities are intriguing... thank you
CamperBot
@camperbot
Nov 26 2016 09:14
caesarsalad93 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3013 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Nov 26 2016 09:14
@caesarsalad93 Yes, just giving the idea of returning an array of persons.
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:18
@Masd925 @caesarsalad93 couldn't be it better idea to kep track of each object and storing the instances in an array, and there shoud be a way to get all the instances created so far like getPeople() ?
Markus Kiili
@Masd925
Nov 26 2016 09:20
@ghulamshabir Yes, it depends what functionality you are after. A new constructor like Group is one option.
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:20
@Masd925 I see
Markus Kiili
@Masd925
Nov 26 2016 09:21
@ghulamshabir Now the functionality is like giving birth and forgetting that you did.
You just know they like kebab.
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:23
@Masd925 that was my point, your example of birth is good match but it seems funny though lol
Markus Kiili
@Masd925
Nov 26 2016 09:23
@ghulamshabir Yes, just an example of making persons.
Chris Cullen
@123xylem
Nov 26 2016 09:26

Player.prototype.update = function(dt) {
if(this.ctlKey === 'left' && this.x > 0){
             this.x = this.x - 50;
           } else if(this.ctlKey === 'right' && this.x != 400){
             this.x = this.x + 50;
             //if up key is pressed increment y
           } else if(this.ctlKey === 'up'){
             this.y = this.y - 50;
             //if down key is pressed and player is not on edge of map decrement y
           } else if (this.ctlKey === 'down' && this.y != 400){
             this.y = this.y + 50;
           }
           this.ctlKey = null; 
if
(this.y <25){
reset();}
alert(‘You Win!’); // THIS ALERT IS STOPPING MY WHOLE CODE AS IT SAYS --- Uncaught SyntaxError: Invalid or unexpected token


};
Hi any iidea why my alert at the bottom of update method is unextpected token?
I have another alert on a different method setup but dont see how tha would affect it
Markus Kiili
@Masd925
Nov 26 2016 09:29
@123xylem Your quotes are not correct. Try changing them to ""
Chris Cullen
@123xylem
Nov 26 2016 09:33
@Masd925 thanks but it doesnt change anything
CamperBot
@camperbot
Nov 26 2016 09:33
123xylem sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3014 | @masd925 |http://www.freecodecamp.com/masd925
Chris Cullen
@123xylem
Nov 26 2016 09:34
I cant see why that alert stops the program
app.js:63 Uncaught SyntaxError: Invalid or unexpected token this is the error but it doesnt make sense
Why would that error come up?\
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:38
@Masd925 @123xylem might be problem of scope ?
I know alert is in global scope
what happens in reset() ?
Chris Cullen
@123xylem
Nov 26 2016 09:41
@ghulamshabir sec
function reset(){setTimeout(function(){location.reload()},3000);  


}
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:43
try without reset(), might be issue with location.reload()
try location.reload(true)
Alexander Huynh
@caesarsalad93
Nov 26 2016 09:53
if(understand objects){
master javascript();
}
should return true or false
Ghulam Shabir
@ghulamshabir
Nov 26 2016 09:58

@caesarsalad93

if(understand objects && algorithms && frameworks(jquery, react){
master javascript();
}

you can add other conditions && depending on the logic (scope of projects)

Alexandro Pequeno
@Argestis
Nov 26 2016 10:05
how do you guys do to play sounds on js?
from a url? xD
Alexander Huynh
@caesarsalad93
Nov 26 2016 10:21
@Argestis use <audio> tag
find a .mp3 url and link it in the src attribute
CamperBot
@camperbot
Nov 26 2016 10:23
find a mp3 url and link it in the src attribute
nothing found
find react
nothing found
find seek and destroy
nothing found
Chris Cullen
@123xylem
Nov 26 2016 10:26
@ghulamshabir hEY Ghulam..for some reason when i npu tthe alert in setTimeout it works but not on its own... Does setTimeout bypass global scope or soimething?

EG

if
(this.y <=25){ setTimeout(function(){reset()},1000);
player.x =200;
player.y =400;

alert(‘You Win!’);

WORKS

this.y <25) {alert (you win);
DOESNT WORK
something about the setTimeout lets alert work but its weird
Ghulam Shabir
@ghulamshabir
Nov 26 2016 10:33
when js sees setTimeout, it says to it I will be right back after 1000 mil sec untill then I will call rest of your code @123xylem
homebrainbox
@homebrainbox
Nov 26 2016 10:42
Record Collection --- I'm sure I messed up my code. Would anyone care to have a look?
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  if (prop === "tracks" && value !== "") {

    if (id.hasOwnProperty("tracks") === false){

      collection.assign("tracks");

      collection[id][prop].push(value); 

    } else {


    collection[id][prop].push(value);

    } 

  } else if (value !== ""){

    collection[id][prop] = value;

  } else if (value === ""){

    delete collection[id][prop];

  }

  return collection;
}
Alexandro Pequeno
@Argestis
Nov 26 2016 10:43
@caesarsalad93 Hey thanks, tho I did it a little bit different. (:
CamperBot
@camperbot
Nov 26 2016 10:43
argestis sends brownie points to @caesarsalad93 :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @caesarsalad93 |http://www.freecodecamp.com/caesarsalad93
Jeff Greenlee
@JeffGreenlee42
Nov 26 2016 10:50
Has anyone done the "Caesars Cipher" challenge?
Ghulam Shabir
@ghulamshabir
Nov 26 2016 10:51
@JeffGreenlee42 your code ?
Jeff Greenlee
@JeffGreenlee42
Nov 26 2016 10:52
function rot13(str) { // LBH QVQ VG!
  var strCode = "";
  for(i=0; i < str.length; i++) {
    if(str[i].charCodeAt() >= 'A'.charCodeAt() && str[i].charCodeAt() <= 'Z'.charCodeAt()) {
        strCode += String.fromCharCode(str[i].charCodeAt() - 13);
    } else {
      strCode += str[i];
    }
  }

  return strCode;
}
debugger;
// Change the inputs below to test
rot13("SERR PBQR PNZC");
It works if the char is greater than A + 13 ... Not sure how handle wrapping around A-Z
Ghulam Shabir
@ghulamshabir
Nov 26 2016 10:55
@JeffGreenlee42 add 13 for A-M and subtract 13 for N-Z, and just add other characters as it as
Jeff Greenlee
@JeffGreenlee42
Nov 26 2016 10:55
hmmm.. ok... let me try that.
Chris Cullen
@123xylem
Nov 26 2016 10:56
@ghulamshabir ok so alert wasnt allowed to work as it took resources away from rest of my code i guess
Ghulam Shabir
@ghulamshabir
Nov 26 2016 10:57
@123xylem I am guessing that too
@123xylem alert blocks the browser but in the meantime you were reloading page
Jeff Greenlee
@JeffGreenlee42
Nov 26 2016 11:03
@ghulamshabir Thanks! That was it! :)