28th
Mar 2016
Micah Bales
@micahbales
Mar 28 2016 00:00
@moigithub lol well that should have been obvious, huh? thanks so much for pointing that out
CamperBot
@camperbot
Mar 28 2016 00:00
micahbales sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: micahbales already gave moigithub points
Micah Bales
@micahbales
Mar 28 2016 00:00
had been staring at it for a while. :)
Dustin
@Key-Banger
Mar 28 2016 00:06
@Szakins I'll post it if it works.
devonwilson1
@devonwilson1
Mar 28 2016 00:08
someone gotta trips for help?
counting cards assignment
Moisés Man
@moigithub
Mar 28 2016 00:10
@Key-Banger hows the Diff going? i got a working code using reduce + indexOf + lastIndexOf
oloughlinp
@oloughlinp
Mar 28 2016 00:11
@devonwilson1 the intent is that var vount = 0changes depending on the car. If the card is between 2-6, add one to count
Dustin
@Key-Banger
Mar 28 2016 00:11
@moigithub problematic. I got it to work for numbers. .sort() gives me issues with strings.
oloughlinp
@oloughlinp
Mar 28 2016 00:11
@devonwilson1 if it is 7,8,9, don't change the count variable
Moisés Man
@moigithub
Mar 28 2016 00:12
@Key-Banger probably u DONT need to sort em :)
oloughlinp
@oloughlinp
Mar 28 2016 00:12
@devonwilson1 after you change the count varibale, then you need to decide what to print.
Dustin
@Key-Banger
Mar 28 2016 00:16
devonwilson1
@devonwilson1
Mar 28 2016 00:18
ok so what would this look like

var count = 0;

function cc(card) {
// Only change code below this line
if (card < 7) {
return "5 Bet";
}
else if (card > 6) {
return "0 Hold";
}

return "Change Me";
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Bill
@W8sconsin
Mar 28 2016 00:18
https://www.freecodecamp.com/challenges/record-collection Could someone help me to figure out what exactly to do on this exercise?
Moisés Man
@moigithub
Mar 28 2016 00:20
@Key-Banger [1,2,3,4,1].indexOf(1) <--- return 0 (the first 1 )
[1,2,3,4,1].lastIndexOf(1) <--- returns 4 (the last 1 )
devonwilson1
@devonwilson1
Mar 28 2016 00:20
so am i using an if statement
or how would i write out if 2, 3, 4, 5, 6, +1
and so forth?
Matt Green
@mattxgreen
Mar 28 2016 00:21
@Key-Banger You still working on the array diff?
Dustin
@Key-Banger
Mar 28 2016 00:22
@mattxgreen yea, I haven't tried .filter() yet. I got it to work with numbers using .filter() ironically. Array of strings goes haywire.
@mattxgreen this worked for numbers.
function diff(arr1, arr2) {
var newArr = [];
var newArr2 = [];
newArr = arr1.concat(arr2);
newArr = newArr.sort(function(a, b) {
return a - b;
});
newArr = newArr.reduce(function(previousValue, currentValue) {
if (previousValue !== currentValue) {

newArr2.push(previousValue);

return currentValue;
}
});
newArr2 = newArr2.filter(Boolean);
return newArr2;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Matt Green
@mattxgreen
Mar 28 2016 00:24
@Key-Banger So, I actually spent some time on that excercise, and did three different solutions. You want to see them, or you prefer to solve on your own first?
Dustin
@Key-Banger
Mar 28 2016 00:25
@mattxgreen I like to solve on my own, but also don't like spending a night reinventing the wheel. ha ha ha
Matt Green
@mattxgreen
Mar 28 2016 00:27
@Key-Banger it's up to you...
oloughlinp
@oloughlinp
Mar 28 2016 00:27
@Key-Banger I don't know if this is right - but try != instead of !==
Shawn Samii
@samii1031
Mar 28 2016 00:28
hiya! any one available to explain "Return Early Pattern for Functions" in regular english, because the example doesn't fit the exercise and I am good and confused in practice, I think I got it in principle
Matt Green
@mattxgreen
Mar 28 2016 00:29
@samii1031 I can help, what you need?
Dustin
@Key-Banger
Mar 28 2016 00:29
@mattxgreen Let me work. If you don't mind ill send you a message so if I get it or not you can share. I'd love to see a different(better) way once I figure it out.
Ramana Venkata
@vramana
Mar 28 2016 00:29
@oloughlinp i don't think it will make a difference changing operators there.
Shawn Samii
@samii1031
Mar 28 2016 00:29
Here is the example:
function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();
ok, bybrbyr new makes it to the console log
got it
Zabe Sangary
@zabesangary
Mar 28 2016 00:30
what are the difference between += and +
Shawn Samii
@samii1031
Mar 28 2016 00:30
but the excercise wants to compare number which isnt a function, right?
*numbers
Matt Green
@mattxgreen
Mar 28 2016 00:30
@samii1031 So the objective is to return undefined if a or b is < 0
Zabe Sangary
@zabesangary
Mar 28 2016 00:30
when you want to concatenate a variable or adding string
devonwilson1
@devonwilson1
Mar 28 2016 00:31
@samii1031
can you help me with the counting cards assignment
Shawn Samii
@samii1031
Mar 28 2016 00:31
@devonwilson1 - no sure I made it that far yet, but I'll do what I can
Ramana Venkata
@vramana
Mar 28 2016 00:32
@zabefloyd += is just short hand notation. Can you give an example? Then some one can illustrate better
oloughlinp
@oloughlinp
Mar 28 2016 00:32
@zabefloyd x += 3 is the same as x = x + 3 while just a plus sign is for adding things together how you would normally use the + sign
devonwilson1
@devonwilson1
Mar 28 2016 00:32
im not sure what function to use or statement to use like if statement or shift statement thing
Matt Green
@mattxgreen
Mar 28 2016 00:32
@samii1031 You familiar with logical operators? That should be all you need to solve this one
Shawn Samii
@samii1031
Mar 28 2016 00:33
oh
well that exoains that
*explains that
devonwilson1
@devonwilson1
Mar 28 2016 00:34
@oloughlinp can you help me specifically please
oloughlinp
@oloughlinp
Mar 28 2016 00:34
@devonwilson1 what are you stuck on?
Zabe Sangary
@zabesangary
Mar 28 2016 00:35
ah okay thanks for clearing my confusion
here is an example var anAdjective = "awesome!"; var ourStr = "Free Code Camp is "; ourStr += anAdjective; var someAdjective = "Awesome" + "!"; var myStr = "Learning to code is "; myStr += someAdjective;
applesauce9091
@applesauce9091
Mar 28 2016 00:36
can I have help with Adding a default option in Switch statements? I keep getting "ReferenceError: a is not defined"
Zabe Sangary
@zabesangary
Mar 28 2016 00:36
switch are awesome it makes sense
Ramana Venkata
@vramana
Mar 28 2016 00:37
@zabefloyd Use the  to format your code. long lines of code like above are considered harder to read.
Shawn Samii
@samii1031
Mar 28 2016 00:37
@applesauce9091 whats your code look like?
Matt Green
@mattxgreen
Mar 28 2016 00:38
@applesauce9091 post code
Zabe Sangary
@zabesangary
Mar 28 2016 00:38
using mac your code
applesauce9091
@applesauce9091
Mar 28 2016 00:38

function myTest(val) {
// Only change code below this line
case a:
break;
case b:
break;
case c:
break;

default:
answer = "stuff";

}

// Only change code above this line
}

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

devonwilson1
@devonwilson1
Mar 28 2016 00:38
really the specifics of how to write this out
@oloughlinp
im not sure what kind of assignment or statement to use
Zabe Sangary
@zabesangary
Mar 28 2016 00:38
lines
devonwilson1
@devonwilson1
Mar 28 2016 00:38
i was starting with an if if else statement at first
Zabe Sangary
@zabesangary
Mar 28 2016 00:38
This message was deleted
applesauce9091
@applesauce9091
Mar 28 2016 00:39
instruction Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Matt Green
@mattxgreen
Mar 28 2016 00:39
@applesauce9091 put "" around a b and c
applesauce9091
@applesauce9091
Mar 28 2016 00:39
tried it @mattxgreen still same thing
Zabe Sangary
@zabesangary
Mar 28 2016 00:40
This message was deleted
devonwilson1
@devonwilson1
Mar 28 2016 00:40
break;
something like that
Matt Green
@mattxgreen
Mar 28 2016 00:40
@applesauce9091 AND switch (val)
oloughlinp
@oloughlinp
Mar 28 2016 00:40
@devonwilson1 you'll want if statements. In words: if the card is 2,3,4,5, or 6, then you will want to add +1 to count. If the card is equal to 7,8, or 9, do nothing to the count otherwise if the card is equal 10, J, Q, K A, subtract 1 from count.
devonwilson1
@devonwilson1
Mar 28 2016 00:41
ok thanks ill try writing that out again
applesauce9091
@applesauce9091
Mar 28 2016 00:41
genius @mattxgreen thanks!!!
CamperBot
@camperbot
Mar 28 2016 00:41
applesauce9091 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 386 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
oloughlinp
@oloughlinp
Mar 28 2016 00:41
@devonwilson1 after you changed the count variable, you will need to decide what to print (the bet or hold in the instructions)
devonwilson1
@devonwilson1
Mar 28 2016 00:41
okay i will
Matt Green
@mattxgreen
Mar 28 2016 00:42
@applesauce9091 np
devonwilson1
@devonwilson1
Mar 28 2016 00:42
so am i writing if var count or if function cc(card)?
Shawn Samii
@samii1031
Mar 28 2016 00:42
@applesauce9091 don't forget case d
oloughlinp
@oloughlinp
Mar 28 2016 00:42
@devonwilson1 I wouldn't use a break, you are thinking of a switch statement that isn't needed on this exercise
devonwilson1
@devonwilson1
Mar 28 2016 00:42
okay
so what am i targeting with the if statement
oloughlinp
@oloughlinp
Mar 28 2016 00:43
Yep, several of them
devonwilson1
@devonwilson1
Mar 28 2016 00:43
var count or function cc(card)
oloughlinp
@oloughlinp
Mar 28 2016 00:44
This message was deleted
This message was deleted

var count = 0;

function cc(card) {
// Only change code below this line
if(card <= 6 .....){
do something to count;
}

return "Change Me";
// Only change code above this line
}

Micah Bales
@micahbales
Mar 28 2016 00:44
Hi folks! I'm trying to make sure that the input I receive from a text box has no spaces, but my code doesn't seem to be working. Check out line 69 for the critical piece: http://codepen.io/micahbales/pen/ONmXry?editors=0010
Bill
@W8sconsin
Mar 28 2016 00:47
Could someone help with this? 
// Only change code below this line
function update(id, prop, value) {
collection[id][prop] = value;
if (value === "") {
collection[id][prop].pop();
}
return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
update(2548, "artist", "");
I get "TypeError: collection[id][prop].pop is not a function". What is the correct syntax?
devonwilson1
@devonwilson1
Mar 28 2016 00:49
@oloughlinp this what i got so far

var count = 0;

function cc(card) {
// Only change code below this line
if(card >= 2, 3, 4, 5, 6) {
return "+1";

}
else if (card >= 7, 8, 9) {
return "0";
}
else if (card >= 10, 'J', 'Q', 'K', 'A')
return "-1";

return "Change Me";
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

oloughlinp
@oloughlinp
Mar 28 2016 00:50
@devonwilson1

devonwilson1
@devonwilson1
Mar 28 2016 00:50
yes
obviously its wrong not sure how to go about changing this
oloughlinp
@oloughlinp
Mar 28 2016 00:50
var count = 0; function cc(card) { // Only change code below this line if(card >=2 || card<=6) { count++; }
devonwilson1
@devonwilson1
Mar 28 2016 00:51
i do not understand i feel so stupid
oloughlinp
@oloughlinp
Mar 28 2016 00:52
The syntax isn't quite right. You can only compare one thing at a time (like is x>6) and connect the comparisions with a logical connective (or ||, and &&)
devonwilson1
@devonwilson1
Mar 28 2016 00:52
okay so do all the possible card values separately?
oloughlinp
@oloughlinp
Mar 28 2016 00:52
so you can ask if(x is greater than 2, or x is less than 6) if(card>=2 || card<=6)
@devonwilson1 you can combine them in the if statements like the table in the example by using && and or || statements.
Kent
@kenthub
Mar 28 2016 00:54

I'm working on the challenge "Stand in Line" and i'm stuck. Can anyone offer a suggestion as to if I am on the right track using .push() I'm not sure what the challenge wants specifically.

function queue(arr, item) {

item = arr.push();

return item; // Change this line
}

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

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


Andres Ariel Alvarez-Saucedo
@Andr3sAlv
Mar 28 2016 00:56

Can someone help me figure out why this isn’t running? function bigCC(arr) {
return n.split("").filter(function(e) {
return e != '-';
}).reduce(function(p,n) {
return parseInt(p)+parseInt(n);
}) >= p.split("").filter(function(e) {
return e != '-';
}).reduce(function(p,n) {
return parseInt(p) + parseInt(n);
}) ? n : p; });
}

bigCC(['4916-2600-1804-0530', '4779-252888-3972','4556-4242-9283-2260'])

Kevin Mulligan
@kmulligan
Mar 28 2016 00:58
Going to need someone to explain boolean operators to me. Have no idea, have looked at MDN and W3Schools and scratching my head
oloughlinp
@oloughlinp
Mar 28 2016 00:59
var count = 0;
function cc(card) {
// Only change code below this line
if(card >=2 || card <= 6) {
count++;
} else if (card <= 9){
//do nothing to count
} else //no if statement needed, since we covered the rest of the possibilities
count--;
@devonwilson1
@kmulligan You know how plus, minus, times, divide work? They operate on two numbers, conduct an operation (+,-,*,/), and give you a number in return.
Kevin Mulligan
@kmulligan
Mar 28 2016 01:05
I get AND, OR, NOT logic
I just don't know what the challenge is asking
oloughlinp
@oloughlinp
Mar 28 2016 01:05
@kmulligan sounds good lol
@kmulligan which exercise?
Kevin Mulligan
@kmulligan
Mar 28 2016 01:06
Boo Who
oloughlinp
@oloughlinp
Mar 28 2016 01:06
Ah, not that far yet
Christy Rettger
@ChristyRettger
Mar 28 2016 01:07
I think I'm done with my Random Quote Machine project, anyone want to check it out and give me some feedback please? http://codepen.io/christyrettger/full/xVrdeR/
Kevin Mulligan
@kmulligan
Mar 28 2016 01:08
@ChristyRettger Looks good, you might make the tweet button bigger and have it tweet attribution to the person you are quoting instead of to codepen
oloughlinp
@oloughlinp
Mar 28 2016 01:09
@kmulligan compare the parameter with === true or false is what cocmes to mind when I read it
Christy Rettger
@ChristyRettger
Mar 28 2016 01:09
@kmulligan Does it help if you think about the Boolean as "If true, return true"? Do you have any context for the Boolean you're trying to use?
@kmulligan Thank you for the feedback! I don't really use Twitter, is a tweet supposed to contain a link back to the original page or no? I could take that out but I figured maybe it was like sharing on Facebook and should have the link for who ever sees it to read more. I don't really know what the standard for tweets is though.
CamperBot
@camperbot
Mar 28 2016 01:11
christyrettger sends brownie points to @kmulligan :sparkles: :thumbsup: :sparkles:
:star: 306 | @kmulligan | http://www.freecodecamp.com/kmulligan
Kevin Mulligan
@kmulligan
Mar 28 2016 01:11
@ChristyRettger @oloughlinp I think it it wanting me to use something called object.prototype.valueOf()... what I have works except for two things, which is my guess due to these things called boolean primitives.
function boo(bool) {

var x = Boolean(bool);

if (x) {
return false;
}

if (!x) {
return true;
}
oloughlinp
@oloughlinp
Mar 28 2016 01:12
@kmulligan Do you understand the difference between a primitive and an object? That's what the exercise is really getting at.
Yan Kozlovskiy
@YanKozlovskiy
Mar 28 2016 01:12
what do we do for the mutation challenge?
function mutation(arr) {
var a = arr[0].toLowerCase().split("").sort();
var b = arr[1].toLowerCase().split("").sort();
if (b.indexOf(a)) {
return true;
}
return false;
}// Go through every character, if a character isn't there return false. Otherwise return true;
mutation(["hello", "hey"]);
Kevin Mulligan
@kmulligan
Mar 28 2016 01:13
@ChristyRettger I mean if you wanted to get fancy you could have it include a link with a shortened URL in it. I can see what you're saying to have it include "Generated from [url to website]" ... only thing is the URL is so long, you only get 140 characters
oloughlinp
@oloughlinp
Mar 28 2016 01:16
@kmulligan that valueOf will turn the argument into a primitive type - you don't want to do that. You just want to see if the argument is a(boolean) primitive type
Christy Rettger
@ChristyRettger
Mar 28 2016 01:17
@kmulligan Yeah that 140 characters is why most of the quotes are cut off and I didn't even put in anything for it to display attribution for the quote. I guess I could do a shorter link but some of the quotes still won't display in full. Generally I think maybe having created a link that changes with the page content was the purpose of the exercise but maybe it's not really a useful button for the content lol. Unless I put "read the rest of the quote here: url..." maybe I'll do it that way. Appreciate the comments! :)
Kevin Mulligan
@kmulligan
Mar 28 2016 01:18
@ChristyRettger I think for the purpose of the challenge you can say you passed, just something to keep in mind
oloughlinp
@oloughlinp
Mar 28 2016 01:18
@kmulligan === compares both type and value, so did:
function boo(bool) {
// What is the new fad diet for ghost developers? The Boolean.
return bool === true || bool ===false;
}

boo(null);
Kevin Mulligan
@kmulligan
Mar 28 2016 01:21
@oloughlinp huh. ok
I dunno, I could be slow, but I think that challenge needs a lot better wording
Bartek
@dyczol
Mar 28 2016 01:23
hey campers ! I'm working on Bonfire- Return the largest number. I want to sort through each array and then push index 0 of each sorted array into placeHolder. The following code sorts only through the first array. Any suggestions or hints ?
function largestOfFour (arr){
var placeHolder = [];
var largestNumber = 0;
for(var i in arr){
for(var j in arr){
arr[j].sort(function(a, b){return b-a;});
return arr;
}
}

}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
oloughlinp
@oloughlinp
Mar 28 2016 01:24
@dyczol here's a hint: should both for loops be the same? they are both iterating on the same thing.
@dyczol and what are you doing with i?
Bartek
@dyczol
Mar 28 2016 01:25
@oloughlinp is it about the second for loop ? maybe

for(var j in arr[i]) ??
oloughlinp
@oloughlinp
Mar 28 2016 01:26
Exactly
Theres a little more to it though
Bartek
@dyczol
Mar 28 2016 01:30
ok, the first one makes sense. something with the sort function ? i'm not worrying about pushing the numbers yet. I want to sort all arrays first ....
oloughlinp
@oloughlinp
Mar 28 2016 01:30
This message was deleted
This message was deleted
Bartek
@dyczol
Mar 28 2016 01:34
Currently i have this and it returns [5,4,3,1]
for(var i in arr){
for(var j in arr[i]){
arr[i].sort(function(a, b){return b-a;});
return arr[i];
}
so the question is how do I sort through the next array..
oloughlinp
@oloughlinp
Mar 28 2016 01:36
Return makes you stop looping and return :)
Bartek
@dyczol
Mar 28 2016 01:38
aha! thank you @oloughlinp
CamperBot
@camperbot
Mar 28 2016 01:38
dyczol sends brownie points to @oloughlinp :sparkles: :thumbsup: :sparkles:
:star: 260 | @oloughlinp | http://www.freecodecamp.com/oloughlinp
Yan Kozlovskiy
@YanKozlovskiy
Mar 28 2016 01:38
where can we get the answers to the challenges?
Christy Rettger
@ChristyRettger
Mar 28 2016 01:39
@dyczol when I get stuck I copy/paste my code into code pen and change all the return's to console.log's to see what parts are actually running and where it's getting stuck... usually it's running fine and a poorly place return is stopping it, then if I think I need return's I change them back one at a time, and keep testing, if it gets stuck then instead of return I needed to assign a variable... so in your code above instead of "return arr[i];" you could store that arr[i] result as a variable for later use. Maybe more of an answer than you were looking for but I've done that a few times when I've meant to have a loop and it didn't seem to be looping.
Kevin Mulligan
@kmulligan
Mar 28 2016 01:42
It is interesting to me to see how different people tackle the same problem
oloughlinp
@oloughlinp
Mar 28 2016 01:43
I do console.log() when I get stuck on the website, and use Firefox's console to see what outputs (F12) instead of codepen
Bartek
@dyczol
Mar 28 2016 01:44
@ChristyRettger thanks! sounds like a great idea , will definitely give it a shot.
CamperBot
@camperbot
Mar 28 2016 01:44
dyczol sends brownie points to @christyrettger :sparkles: :thumbsup: :sparkles:
:star: 289 | @christyrettger | http://www.freecodecamp.com/christyrettger
Elbert Cortez
@trip16661
Mar 28 2016 01:50
function findLongestWord(str) {
var splittedStr = str.split(" ");
var longestWord = 0;
for (a = 0; a < splittedStr.length;a++){
if(splittedStr[a].length > longestWord.length){
longestWord = splittedStr;
}
}

return longestWord.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
i don't think im doing anything wrong
but nothing is returning
Kevin Mulligan
@kmulligan
Mar 28 2016 01:51
@trip16661 what is the length of longestWord
wait
Elbert Cortez
@trip16661
Mar 28 2016 01:52
@kmulligan i initialize it to 0
so it suposed to have just 1
harpoon747
@harpoon747
Mar 28 2016 01:53
Hi Everyone ! Need a little help in the code below
var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

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

this.getGear = function(){
return gear;
};
this.setGear = function(gear){
this.gear = gear;
};
};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);
myBike.getGear();
myBike.setGear(3);
myBike.getGear();
myBike.setGear(1);
myBike.getGear();
Kevin Mulligan
@kmulligan
Mar 28 2016 01:53
@trip16661 No sorry I misread what was going on
@trip16661 in your if statement, when you first do it, my guess is longestWord.length = undefined? since it is set to 0 above, but not 100%. I would remove the .length part from that if statement
Elbert Cortez
@trip16661
Mar 28 2016 01:57
that return 9
which is false so i think i might be doing something wrong
i think it's counting the arrays inside of splittedStr
but it shouldn't
the a is targeting the first array so it should just..
Christy Rettger
@ChristyRettger
Mar 28 2016 02:03
@trip16661 I think you need to decide if longestWord is a length or a string... by initially making it 0 it's like you're going to use it to keep track of the longest length, but then in your if statement it should say: longestWord = splittedStr[a].length, otherwise you're changing longestWord to a string, which then has a .length property to use in the > statement...
Kent
@kenthub
Mar 28 2016 02:11
Anyone able to help with Javascript? Code challenge"Stand in Line".
function queue(arr, item) {
var newArray =
arr.push(item);
arr.shift();

return newArray;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Elbert Cortez
@trip16661
Mar 28 2016 02:15
@ChristyRettger @kmulligan thanks
CamperBot
@camperbot
Mar 28 2016 02:15
trip16661 sends brownie points to @christyrettger and @kmulligan :sparkles: :thumbsup: :sparkles:
:star: 308 | @kmulligan | http://www.freecodecamp.com/kmulligan
:star: 290 | @christyrettger | http://www.freecodecamp.com/christyrettger
SUSHANTH PATWARI
@suzello
Mar 28 2016 02:17
Anyone able to help with Javascript? Code challenge "Return Largest Numbers in Arrays"

function largestOfFour(arr) {
// You can do this!
for (var i=0; i <= arr.length-1; i++)
{
arr = Math.max.apply(Math, arr[i]); // 306

return arr;
}
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

This message was deleted
harpoon747
@harpoon747
Mar 28 2016 02:20
@kenthub you need to return the removed element only
Kent
@kenthub
Mar 28 2016 02:21
@harpoon747 Thanks, I guess I read to much into it.
CamperBot
@camperbot
Mar 28 2016 02:21
kenthub sends brownie points to @harpoon747 :sparkles: :thumbsup: :sparkles:
:star: 240 | @harpoon747 | http://www.freecodecamp.com/harpoon747
SUSHANTH PATWARI
@suzello
Mar 28 2016 02:28
function largestOfFour(arr) {
// You can do this!
for (var i=0; i <= arr.length-1; i++)
{
arr = Math.max.apply(Math, arr[i]);

return arr;
}
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Matt Green
@mattxgreen
Mar 28 2016 02:42
@suzello The goal is to find a single largest number, or 4 numbers?
Pascal T.
@omegga
Mar 28 2016 02:42
@suzello what do you have to do ?
Matt Green
@mattxgreen
Mar 28 2016 02:44
@suzello Well, this will get you an array of 4 (instantiate answer above for loop):
answer.push(Math.max.apply(Math, arr[i]));
If you need 1 answer, you could do the same math on that array, or you could add a a condition to your existing logic
SUSHANTH PATWARI
@suzello
Mar 28 2016 02:47
@mattxgreen i need largest number from each array
*sub array
Artur Sęp
@a-sep
Mar 28 2016 02:48
God morning all :)
SUSHANTH PATWARI
@suzello
Mar 28 2016 02:50
@mattxgreen thank you , got it
CamperBot
@camperbot
Mar 28 2016 02:50
suzello sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 387 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
harpoon747
@harpoon747
Mar 28 2016 02:58
Hi Guys ! Stuck in Make Object Properties Private Challenge. Can someone suggest what mistakes I am making in the below code
var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

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

this.getGear = function(){
return gear;
};
this.setGear = function(gear){
this.gear = gear;
};
};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);
myBike.getGear();
myBike.setGear(3);
myBike.getGear();
myBike.setGear(1);
myBike.getGear();
Susan
@susanpv
Mar 28 2016 03:10
hello, I am stuck in the reverse.. am I doing something wrong here?

function reverseString(str) {
var str1= "";
var pos = 0;

for (i=1;i<=str.length;i++)
{
pos = str.Length - i;
str1 += str.substring(pos,1);
}
return str1;
}

reverseString("Howdy");

Yashdeep Hinge
@yashdeeph709
Mar 28 2016 03:13
Pierre Humberdroz
@phumberdroz
Mar 28 2016 03:13
function chunkArrayInGroups(arr, size) {
var result = [];
var test = [];
arr.forEach (function(element, index, array){
if(test.length === size){
result.push(test);
test = [];
test.push(element);

} else {
test.push(element);
}
console.log (test);
console.log (typeof result);
});

return result;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
What is wrong with this ?
https://www.freecodecamp.com/challenges/chunky-monkey the challange
DJ
@qualitymanifest
Mar 28 2016 03:14
@susanpv you have capitalized Length here, length doesn't get capitalized though pos = str.Length - i;. but regardless, you're overcomplicating it
Aknotts
@Aknotts
Mar 28 2016 03:14
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
switch(val) {
case "alpha":
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
break;
case "":
result = "undefined";
}

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

// Change this value to test
phoneticLookup("charlie");
Sidharth Kriplani
@sidkrip
Mar 28 2016 03:16
CamperBot
@camperbot
Mar 28 2016 03:16

# Problem Explanation:

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


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

if(str[i] has not been used) {
put str[i] into the current position;
mark str[i] as used
perm(current position in original string, what's been used in original string, current string build thus far)
unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
}
Pierre Humberdroz
@phumberdroz
Mar 28 2016 03:18
@sidkrip was that for me?
Sidharth Kriplani
@sidkrip
Mar 28 2016 03:18
nope
DJ
@qualitymanifest
Mar 28 2016 03:18
@meat147 the second, full "test" array isn't getting pushed to result because you're only pushing on a fresh run of the loop. by the time that test === ["c", "d"] the forEach loop has ended
@meat147 a simple for loop would be easier
Pierre Humberdroz
@phumberdroz
Mar 28 2016 03:19
@qualitymanifest just saw that too thanks!
CamperBot
@camperbot
Mar 28 2016 03:19
meat147 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1121 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Pierre Humberdroz
@phumberdroz
Mar 28 2016 03:20
function chunkArrayInGroups(arr, size) {
var result = [];
var test = [];
arr.forEach (function(element, index, array){
if(test.length === size){
result.push(test);
test = [];
test.push(element);

} else {
test.push(element);
}
console.log (test);
console.log (typeof result);
});
result.push(test);
console.log("Final "+ result);
return result;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
My final result
anthonyjl92
@anthonyjl92
Mar 28 2016 03:36
how do you remove all non-alphanumeric characters in a string?
Stefan Gisi
@stgisi
Mar 28 2016 03:38
@anthonyjl92 http://www.regexr.com/
@anthonyjl92 https://regex101.com/
Andy Morgan
@AndrewRMorgan
Mar 28 2016 03:41
function destroyer(arr) {

var toRemove = [];
for (var i = 1; i < arguments.length; i++) {
toRemove.push(arguments[i]);
}

var toStay = arguments[0].filter(function(val) {
for (var x = 0; x < toRemove.length; x++) {
return val !== toRemove[x];
}
});

}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
Can someone tell me why the second part of this is only remove 2 from the array?
Stefan Gisi
@stgisi
Mar 28 2016 03:42
@AndrewRMorgan Hold on a sec, I'll take a look at it
Andy Morgan
@AndrewRMorgan
Mar 28 2016 03:43
@stgisi Thanks.
CamperBot
@camperbot
Mar 28 2016 03:43
andrewrmorgan sends brownie points to @stgisi :sparkles: :thumbsup: :sparkles:
:star: 312 | @stgisi | http://www.freecodecamp.com/stgisi
Zara Leventhal
@zaralev
Mar 28 2016 03:48
@JamesPatel37 thank you! sorry for late response :)
CamperBot
@camperbot
Mar 28 2016 03:48
zaralev sends brownie points to @jamespatel37 :sparkles: :thumbsup: :sparkles:
:star: 254 | @jamespatel37 | http://www.freecodecamp.com/jamespatel37
EternityElephant
@EternityElephant
Mar 28 2016 03:48
Hey guys I wa wondering if i could get an explanation for the challenge "Slasher Flick". I'm not sure what it's asking me to do
I thought it was simple but looking at the return values i should be getting im confused
Matt Green
@mattxgreen
Mar 28 2016 03:53
@EternityElephant It's asking you to return the last howMany elements
anthonyjl92
@anthonyjl92
Mar 28 2016 03:53
is there a special regular expression to remove underscores? or is it written like /_/gi?
Matt Green
@mattxgreen
Mar 28 2016 03:53
so, [1,2,3,4,5,6,7,8,9], 3 would be 7,8,9
@anthonyjl92 I believe that works, but if not you can protect it /\_/gi
EternityElephant
@EternityElephant
Mar 28 2016 03:55
ohhh lol alright i gotcha
anthonyjl92
@anthonyjl92
Mar 28 2016 03:55
thank you
Stefan Gisi
@stgisi
Mar 28 2016 03:55
This message was deleted
Matt Green
@mattxgreen
Mar 28 2016 03:55
@anthonyjl92
Stefan Gisi
@stgisi
Mar 28 2016 03:57
@AndrewRMorgan I fixed it and sent it to you in private chat
@AndrewRMorgan With an explanation, you were close though! Good job
CamperBot
@camperbot
Mar 28 2016 03:58
stgisi sends brownie points to @andrewrmorgan :sparkles: :thumbsup: :sparkles:
:star: 266 | @andrewrmorgan | http://www.freecodecamp.com/andrewrmorgan
Stefan Gisi
@stgisi
Mar 28 2016 03:58
Anyone finished tic-tac-toe yet?
Ramana Venkata
@vramana
Mar 28 2016 03:59
@stgisi Do you need help ??
Stefan Gisi
@stgisi
Mar 28 2016 04:00
@vramana I mean... I'm almost done, just debugging. I don't think you'd wanna loop at the slop I threw together though hahaha. Just curious how long it took you.
Charly
@Ralooe
Mar 28 2016 04:01
hey everyone, i'm really trying to find what i need out of the help chat but updating the record collection has me stuck ... what am i doing wrong ?

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

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

for(id in collection){

 if (value !== ""){

if (prop !== "tracks"){
//update or set value of prop
collection.id[prop] = value;
break;
}
else if(prop === "tracks" || value !== ""){
//push value onto end of tracks array
collection.id[prop].push(value);
break;
}

}
else {
// delete that prop
collection.id[prop] = "";
break;
}

}//for loop
return collection;
}

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

Ramana Venkata
@vramana
Mar 28 2016 04:02
@stgisi I never finished the challenges. Too boring because I know I can do them and I am a bit lazy. I will complete them someday. But I can review your code if you want me to.
Stefan Gisi
@stgisi
Mar 28 2016 04:02
@vramana Okay, hold on a moment
Matt Green
@mattxgreen
Mar 28 2016 04:03
@Ralooe at a glance I see this:
function update(id, prop, value) {
for(id in collection){
@Ralooe You are overwriting id
Charly
@Ralooe
Mar 28 2016 04:04
so how do i loop through the obj?
Stefan Gisi
@stgisi
Mar 28 2016 04:04
@vramana I sent you a private message
Ramana Venkata
@vramana
Mar 28 2016 04:05
@Ralooe I use Object.keys(collection) it returns an array of keys of the object
Matt Green
@mattxgreen
Mar 28 2016 04:05
@Ralooe You can do it like that, but I would use a different var name. I would also declare it locally with var=
@Ralooe That probably isn't your only problem... gimme a min
anthonyjl92
@anthonyjl92
Mar 28 2016 04:06
function palindrome(str) {
var newstr=str.toLowerCase().replace(/\W+|\_/gi,"");
var reverse=newstr.split("").reverse().join("");

if(reverse === newstr){
return true;
}
return false;
}

palindrome("race Car");
Is there a more efficient way to solve palindromes?
Charly
@Ralooe
Mar 28 2016 04:06
@mattxgreen @vramana thnks
CamperBot
@camperbot
Mar 28 2016 04:06
ralooe sends brownie points to @mattxgreen and @vramana :sparkles: :thumbsup: :sparkles:
:star: 229 | @vramana | http://www.freecodecamp.com/vramana
:star: 388 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Matt Green
@mattxgreen
Mar 28 2016 04:08
@Ralooe You can't access object with a variable name with dot notation... you have to use bracket
so:
DJ
@qualitymanifest
Mar 28 2016 04:09
@anthonyjl92 you don't need the + in your regex since you're using the g flag, and you don't need the i in your regex since everything is lowercase already
@anthonyjl92 that's not a bad solution though
@anthonyjl92 another way to make it shorter would be to just return newstr compared with itself reversed
Matt Green
@mattxgreen
Mar 28 2016 04:10
@Ralooe
collection.id[prop] = value;
// should be:
collection[id][prop] = value;
anthonyjl92
@anthonyjl92
Mar 28 2016 04:10
@qualitymanifest thank you for the tips!
Charly
@Ralooe
Mar 28 2016 04:12
@mattxgreen that + new var in the loop ?
Matt Green
@mattxgreen
Mar 28 2016 04:13
@Ralooe I think that'll get you going... yes I would rename id. This is simple: for (var key in collection)
Charly
@Ralooe
Mar 28 2016 04:13
@mattxgreen k .. i'll try that
V Arun Kumar
@arunvkumr
Mar 28 2016 04:15
@anthonyjl92 you could also do..
function palindrome(str) {
str=str.toLowerCase().replace(/\W|_/gi,"");
var reverse=str.split("").reverse().join("");
return (reverse === newstr);
}
palindrome("race Car");
Matt Green
@mattxgreen
Mar 28 2016 04:19
@arunkumrv
function palindrome(str) {
str = str.toLowerCase().replace(/[^a-z0-9]|\s+|\r?\n|\r/gmi,'');
return (str == str.split('').reverse().join(''));
}
:p
V Arun Kumar
@arunvkumr
Mar 28 2016 04:20
@mattxgreen your solution is shorter.. but the regexp is lengthy :wink:
Matt Green
@mattxgreen
Mar 28 2016 04:21
I know... your regex is better
I'm declaring what to keep, and you're just throwing away whitespace
anthonyjl92
@anthonyjl92
Mar 28 2016 04:26
function findLongestWord(str) {
var arr=str.split(" "); //words are split by spaces
var longest=0; //default longest word length

for(var i=0;i<arr.length;i++){ //loops through array of words
if(arr[i].length>longest){ //if current word length is longer
longest=arr[i].length; //set longest to current word length
}
}
return longest;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
is there way to shorten this? are there better solutions?
Ramana Venkata
@vramana
Mar 28 2016 04:28
@anthonyjl92 There is.
All solutions involve the same computations you are doing here. Some run slower some run faster. Some are terse Some are length.
anthonyjl92
@anthonyjl92
Mar 28 2016 04:33
yea I think that's a big concern of mine. There are multiple solutions to these problems but I want to write code that's short and efficient
Ramana Venkata
@vramana
Mar 28 2016 04:34
@anthonyjl92 Shortest code may not be the most efficient.
Atleast The solution I have in mind will not run faster than what you wrote.
anthonyjl92
@anthonyjl92
Mar 28 2016 04:36
ah I see, is there a program that checks the runtime of solutions?
Ramana Venkata
@vramana
Mar 28 2016 04:37
@anthonyjl92 Runtime will vary. You can try to benchmark your solution us jsperf.com etc., But it's truly not worth it.
The advice I heard is that until you hit a bottleneck. Don't worry about micro-optimizations. Just trust the compiler. If ever you run in trouble, profile your code and optimize the slow parts.
And it worked for all the time.
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:41
anthonyjl92
@anthonyjl92
Mar 28 2016 04:41
CamperBot
@camperbot
Mar 28 2016 04:41
:star: 229 | @vramana | http://www.freecodecamp.com/vramana
Andy Roush
@AndyRoush
Mar 28 2016 04:46
Hi guys. I am on this converting lesson, and I honestly have no idea what to do here. If anyone can give me some guidance.... I don't even know where to start =(. https://www.freecodecamp.com/challenges/convert-celsius-to-fahrenheit
Zabe Sangary
@zabesangary
Mar 28 2016 04:47
This message was deleted
Matt Green
@mattxgreen
Mar 28 2016 04:47
@AndyRoush step 1: create a variable called fahrenheit
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:47
Tf=tc*(9/5)+32
Paul Borawski
@iAmNawa
Mar 28 2016 04:48
hello everyone!
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:48
That's all @AndyRoush
Zabe Sangary
@zabesangary
Mar 28 2016 04:48
why is it counting from 1? is that because it counts the [] bracket space?
if that make sense
var myArray = [0];
Matt Green
@mattxgreen
Mar 28 2016 04:49
@AndyRoush then assign the fahrenheit var to the return val of the celcius formula
Andy Roush
@AndyRoush
Mar 28 2016 04:49
@HecticHiccups How did you come up with TF and TC?
Kelvin-penang
@Kelvin-penang
Mar 28 2016 04:49
function myFunction() {
var myVar = 'use strict';
console.log(myVar);
}
myFunction();
Can anybody help? I thought I already had no Global variable in here
Andy Roush
@AndyRoush
Mar 28 2016 04:50
@mattxgreen Ok cool. But what does this mean? This is what confuses me - if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}
Kelvin-penang
@Kelvin-penang
Mar 28 2016 04:50
but I still can't pass the test
Ramana Venkata
@vramana
Mar 28 2016 04:51
@zabefloyd Can you rephrase your question?
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:51
Temperature in Far, temp in celcius @AndyRoush
Zabe Sangary
@zabesangary
Mar 28 2016 04:51
okay
Matt Green
@mattxgreen
Mar 28 2016 04:52
@AndyRoush They are just checking to ensure fahreheit has value before returning it
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:52
You don't need to change anything else @AndyRoush
And that mean they're making sure it isn't null.
Matt Green
@mattxgreen
Mar 28 2016 04:53
@AndyRoush you don't really need to be concerned with it at the moment. Just assign the correct val to fahrenheit and it'll work
Andy Roush
@AndyRoush
Mar 28 2016 04:54
Ok cool thanks @mattxgreen and @HecticHiccups . I will try and work it out now.
CamperBot
@camperbot
Mar 28 2016 04:54
andyroush sends brownie points to @mattxgreen and @hectichiccups :sparkles: :thumbsup: :sparkles:
:star: 389 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
:star: 204 | @hectichiccups | http://www.freecodecamp.com/hectichiccups
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:54
No thank you for the brownies.
Andy Roush
@AndyRoush
Mar 28 2016 04:55
np :)
Jesus Arteaga
@HecticHiccups
Mar 28 2016 04:55
I was starving nom nom nom
Zabe Sangary
@zabesangary
Mar 28 2016 04:56
@vramana var myArray = [0, 1, 3];
what is the index of 0?
Kyle Morton
@kmorton1988
Mar 28 2016 04:56
I'm so lost with geolocation.
Idon't know how to use it to display local weather.
or at least I"m not sure where to go next.
Ramana Venkata
@vramana
Mar 28 2016 04:56
@zabefloyd 0
Zabe Sangary
@zabesangary
Mar 28 2016 04:56
Kyle Morton
@kmorton1988
Mar 28 2016 04:56
been googling for the past 4 days
still can't wrap my head around it.
Zabe Sangary
@zabesangary
Mar 28 2016 04:57
it is not 1?
thought it is one
Kyle Morton
@kmorton1988
Mar 28 2016 04:57
What?
Ramana Venkata
@vramana
Mar 28 2016 04:57
@zabefloyd Array indices start with 0. You will get used to it.
Zabe Sangary
@zabesangary
Mar 28 2016 04:58
ah okay thought it counts [] the empty space but I guess that only happens if you use quotes?
Kyle Morton
@kmorton1988
Mar 28 2016 04:59
[] inidates that the variable is an array
each item in the array is separated by a comma, such as var array = [1, 2, 3, 4], in this case, the number 1 is at index 0.
Jesus Arteaga
@HecticHiccups
Mar 28 2016 05:00
Hai
Zabe Sangary
@zabesangary
Mar 28 2016 05:01
what if have space [1 , 3 , 5];
Clare Dickerson
@claredickerson
Mar 28 2016 05:01
i really wish i was having an easier time with javascript :( sometimes it makes perfect sense and other times i can't.
Zabe Sangary
@zabesangary
Mar 28 2016 05:02
@claredickerson have you tried http://www.asmarterwaytolearn.com/
that book will help you if you are a beginner like me
Clare Dickerson
@claredickerson
Mar 28 2016 05:02
@zabefloyd i will look at it, thanks
CamperBot
@camperbot
Mar 28 2016 05:02
claredickerson sends brownie points to @zabefloyd :sparkles: :thumbsup: :sparkles:
:star: 56 | @zabefloyd | http://www.freecodecamp.com/zabefloyd
Zabe Sangary
@zabesangary
Mar 28 2016 05:03
it is the top rated book at amazon
Kyle Morton
@kmorton1988
Mar 28 2016 05:06
@zabefloyd I'm not sure what you mean "what if I have space". The array there is pretty simple. index 0 = 1, index 1 = 3, index 2 = 5
Ramana Venkata
@vramana
Mar 28 2016 05:07
@claredickerson Practice a lot. Only writing more JS makes you better. Have you watched any Programming Talks ??
Kyle Morton
@kmorton1988
Mar 28 2016 05:07
@claredickerson I'm right there with you.
Clare Dickerson
@claredickerson
Mar 28 2016 05:07
@vramana i haven't. like a TED talk or some other organization?
Rayner Rodriguez
@raynerjrp
Mar 28 2016 05:07

Why I can't push an element as an array at the end of tracks property in the collection object
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
}
};

collection[2548]["tracks"].push(value);
What I'm doing wrong?

Clare Dickerson
@claredickerson
Mar 28 2016 05:07
@kmorton1988 solidarity and brownie points (thx!)
CamperBot
@camperbot
Mar 28 2016 05:07
claredickerson sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
:star: 296 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
Ramana Venkata
@vramana
Mar 28 2016 05:08
@claredickerson Talks given by software engineers.
Zabe Sangary
@zabesangary
Mar 28 2016 05:08
because it is Bon Jovi lol
Kyle Morton
@kmorton1988
Mar 28 2016 05:08
lol. Wouldn't mind another mind if ever you wanted to joint code sometime @claredickerson
Clare Dickerson
@claredickerson
Mar 28 2016 05:08
@vramana i'll look into it
haha i'll consider it @kmorton1988
Stefan Gisi
@stgisi
Mar 28 2016 05:09
@vramana thanks
CamperBot
@camperbot
Mar 28 2016 05:09
stgisi sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
Ramana Venkata
@vramana
Mar 28 2016 05:09
@claredickerson Watch this talk https://www.youtube.com/watch?v=hQVTIJBZook There are things to learn but don't worry about them. Just listen to the guy.
CamperBot
@camperbot
Mar 28 2016 05:09
:star: 230 | @vramana | http://www.freecodecamp.com/vramana
Zabe Sangary
@zabesangary
Mar 28 2016 05:10
the weird pars of JavaScript :D https://www.youtube.com/watch?v=Bv_5Zv5c-Ts
Ramana Venkata
@vramana
Mar 28 2016 05:10
I have seen that talk 5 or 6 times but it still feels so awesome to re watch it.
Malviya
@malviyaprateek
Mar 28 2016 05:11
how to solve "Stand in Line" in js
Ramana Venkata
@vramana
Mar 28 2016 05:27
@malviyaprateek What have you tried till now??
Tanner Kiser
@Kiser3613
Mar 28 2016 05:28
Hey guys! I need some help with Nesting For Loops in Javascript!
Ramana Venkata
@vramana
Mar 28 2016 05:28
@Kiser3613 What help do you need?
Tanner Kiser
@Kiser3613
Mar 28 2016 05:29
@vramana Well here is my code. I'm not sure what I'm doing wrong.

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var a = 0; a < arr.length; a++){
for (var i = 0; i < arr[a].length; i++) {

product = product * a;  

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

product = product * i;
Ramana Venkata
@vramana
Mar 28 2016 05:32
@Kiser3613 Hint: You need to multiply the numbers of the array arr
Matt Green
@mattxgreen
Mar 28 2016 05:33
@Kiser3613 you're missing a critical { (if your code is pasted accurately
Tanner Kiser
@Kiser3613
Mar 28 2016 05:33
@mattxgreen I didn't paste very well! Thank you though!
CamperBot
@camperbot
Mar 28 2016 05:33
kiser3613 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 390 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Tanner Kiser
@Kiser3613
Mar 28 2016 05:33
@vramana Ok, I'll try it out! Thanks!
CamperBot
@camperbot
Mar 28 2016 05:33
kiser3613 sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 231 | @vramana | http://www.freecodecamp.com/vramana
Clare Dickerson
@claredickerson
Mar 28 2016 05:38
thanks @vramana i'll watch it!
CamperBot
@camperbot
Mar 28 2016 05:38
claredickerson sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 232 | @vramana | http://www.freecodecamp.com/vramana
Ramana Venkata
@vramana
Mar 28 2016 05:40
@claredickerson I highly recommend you do. There may be things you don't understand them. Just listen it as a story.
Abdullah Hoosen
@abdullahhoosen
Mar 28 2016 05:50
thanks @CaroleAnneHannon for your help with Checkpoint: Stand in Line
CamperBot
@camperbot
Mar 28 2016 05:50
abdullahhoosen sends brownie points to @caroleannehannon :sparkles: :thumbsup: :sparkles:
:star: 813 | @caroleannehannon | http://www.freecodecamp.com/caroleannehannon
Olawale Akinseye
@brainyfarm
Mar 28 2016 06:00
@Kiser3613, to access element in your two dimensional array, you do arr[a][i]
Elbert Cortez
@trip16661
Mar 28 2016 06:12
function confirmEnding(str, target) {
var targetEnding = target.length;
var ending = str.Substring(str.length -targetEnding);
if(ending === target){return true;}
else{return false;}

// "Never give up and good luck will find you."
// -- Falcor

}

confirmEnding("Bastian", "n");
here I am again D:
Umesh Kunwar
@umeshku
Mar 28 2016 06:14
palindrome("0_0 (: /-\ :) 0-0") should return true.
How to do this?
palindrome("0_0 (: /-\ : ) 0-0") should return true.
Zabe Sangary
@zabesangary
Mar 28 2016 06:16
This message was deleted
var users = ['rgnet1', 'zabe', 'grae'];
for (var i = 0; i <= users.length; i++) {
console.log("There are " + i + " users" );
}
kirbyedy
@kirbyedy
Mar 28 2016 06:17
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
so you will have to use the regex for start
and the method toLowerCase
Zabe Sangary
@zabesangary
Mar 28 2016 06:18
how can I get the output like this
1 rgnet1
2 zabe
3 grae
Elbert Cortez
@trip16661
Mar 28 2016 06:19
@trip16661 substring in cap D:im an idiot
Ramana Venkata
@vramana
Mar 28 2016 06:19
@zabefloyd It should be console.log(i + 1, users[i])
Zabe Sangary
@zabesangary
Mar 28 2016 06:19
neat!
do you mind if you tell me what is going on here console.log(i + 1, users[i])?
Ramana Venkata
@vramana
Mar 28 2016 06:21
@zabefloyd You wanted to print 1 2 3 the start of each line. which is achieved by console.log(i+1)
Zabe Sangary
@zabesangary
Mar 28 2016 06:21
correct
kirbyedy
@kirbyedy
Mar 28 2016 06:21
@vramana I dont think that will work
There are 01 rgnet1 users
There are 11 zabe users
There are 21 grae users
Zabe Sangary
@zabesangary
Mar 28 2016 06:22
it worked
Ramana Venkata
@vramana
Mar 28 2016 06:22
You wanted to print the names beside those numbers. console.log(i+1, users[i]) or console.log(i + 1 + " " + users[i])
Zabe Sangary
@zabesangary
Mar 28 2016 06:23
that's right yes it worked fine
Ramana Venkata
@vramana
Mar 28 2016 06:23
console.log can take multiple arguments and it will inserts spaces automatically between arguments.
kirbyedy
@kirbyedy
Mar 28 2016 06:23
which one worked
Zabe Sangary
@zabesangary
Mar 28 2016 06:24
the output is
1 "rgnet1"
2 "zabe"
3 "grae"
4 undefined
for (var i = 0; i < users.length; i++) {

console.log(i + 1, users[i] );
}
Ramana Venkata
@vramana
Mar 28 2016 06:25
@zabefloyd it should be i < users.length
Zabe Sangary
@zabesangary
Mar 28 2016 06:25
ah was wondering where the 4 undefined came from
Anas R. Firdousi
@afirdousi
Mar 28 2016 06:25
kirbyedy
@kirbyedy
Mar 28 2016 06:28
hmmm why the hell is my output this:
There are 01 rgnet1 users
There are 11 zabe users
There are 21 grae users
with the same code
Zabe Sangary
@zabesangary
Mar 28 2016 06:29
kirbyedy
@kirbyedy
Mar 28 2016 06:30
var users = ['rgnet1', 'zabe', 'grae'];
for (var i = 0; i < users.length; i++) {
console.log("There are " + i+1 + " " + users[i] + " users" );
}
the difference is the text basically
in the log
Zabe Sangary
@zabesangary
Mar 28 2016 06:32
you are adding i + i
var users = ['rgnet1', 'zabe', 'grae'];

for (var i = 1; i < users.length; i++) {

console.log("No" + i + " User Name is" + users[i] );
}
try this

var users = ['rgnet1', 'zabe', 'grae'];
for (var i = 1; i < users.length; i++) {
console.log("There are " + i+1 + " " + users[i] + " users" );
}

Ramana Venkata
@vramana
Mar 28 2016 06:34
@kirbyedy wrap i + 1 in paranthesis (i + 1). Then your code will work.
kirbyedy
@kirbyedy
Mar 28 2016 06:35
its the brackets
tax @vramana
CamperBot
@camperbot
Mar 28 2016 06:36
kirbyedy sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 233 | @vramana | http://www.freecodecamp.com/vramana
Zabe Sangary
@zabesangary
Mar 28 2016 06:36
and to count from 1 change it from 0 to 1 , for (var i = 1; i < users.length; i++)
Ramana Venkata
@vramana
Mar 28 2016 06:36
@zabefloyd Then you have use <= instead of < other wise you will miss out one number
Matt Green
@mattxgreen
Mar 28 2016 06:37
@AndyRoush remove the period
Andy Roush
@AndyRoush
Mar 28 2016 06:39
thanks @mattxgreen that worked =)
CamperBot
@camperbot
Mar 28 2016 06:39
andyroush sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 391 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Zabe Sangary
@zabesangary
Mar 28 2016 06:39
ah yes that's right way I rather count from 1
var users = ['rgnet1', 'zabe', 'grae'];
for (var i = 1; i <= users.length; i++) {
console.log("There are " + i + " " + users[i] + " users" );
}
Ramana Venkata
@vramana
Mar 28 2016 06:40
@zabefloyd But Since array indexing starts from 0 you have to write users[i -1]
Other you will be trying to read users[3] which is undefined.
@zabefloyd As I said earlier indexing start's with 0. It may feel a little wierd now. You will get used to it.
Zabe Sangary
@zabesangary
Mar 28 2016 06:42
ah didn't see the undefined yes
great thanks!
Ramana Venkata
@vramana
Mar 28 2016 06:44
Zabe Sangary
@zabesangary
Mar 28 2016 06:46
JS < # :D
Zabe Sangary
@zabesangary
Mar 28 2016 06:53
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[3][0];
the output is undefined
Matt Green
@mattxgreen
Mar 28 2016 06:54
are you looking for 10?
Zabe Sangary
@zabesangary
Mar 28 2016 06:54
anything
any number
Matt Green
@mattxgreen
Mar 28 2016 06:54
[3][0][0] is 10
element [3][0] is an array
Zabe Sangary
@zabesangary
Mar 28 2016 06:55
it says undefined
Matt Green
@mattxgreen
Mar 28 2016 06:55
show me the code in it's entirety
Zabe Sangary
@zabesangary
Mar 28 2016 06:57
that's the all code
Matt Green
@mattxgreen
Mar 28 2016 06:57
you're not returning anything?
Zabe Sangary
@zabesangary
Mar 28 2016 06:58
no is not
Matt Green
@mattxgreen
Mar 28 2016 06:58
what is the objective?
Ramana Venkata
@vramana
Mar 28 2016 06:58
@zabefloyd Which challenge is this ??
Zabe Sangary
@zabesangary
Mar 28 2016 06:58
@vramana Access MultiDimensional Arrays With Indexes
that helps?
cause the url takes the entire page
Islam Ibakaev
@dagman
Mar 28 2016 06:59
maybe you should write return myData?
Zabe Sangary
@zabesangary
Mar 28 2016 07:00
or console.log()?
yes
kirbyedy
@kirbyedy
Mar 28 2016 07:01
you are suppose to find the number 8 no ?
Zabe Sangary
@zabesangary
Mar 28 2016 07:01
return or console
yes
now I will find how to
just wanted know why I get undefined
kirbyedy
@kirbyedy
Mar 28 2016 07:01
so you need to access the third array and second element
Islam Ibakaev
@dagman
Mar 28 2016 07:01
@zabefloyd myData should be equal to 8.
kirbyedy
@kirbyedy
Mar 28 2016 07:01
arrays are 0 based
Islam Ibakaev
@dagman
Mar 28 2016 07:02
@zabefloyd var myData = myArray[2][1];
try this
kirbyedy
@kirbyedy
Mar 28 2016 07:02
@dagman why giving the answer ?
Joseph Stivala
@joestivala
Mar 28 2016 07:03
@zabefloyd I was having a problem understanding it myself earlier, check this video out it helped me https://www.youtube.com/watch?v=Cta5s1QBD8E
Islam Ibakaev
@dagman
Mar 28 2016 07:04
:smile:
Zabe Sangary
@zabesangary
Mar 28 2016 07:07
i was trying myArray[2][1][0];
it was close :) thanks guys again!
the third and second element that clears it up
ah cool will watch it @joestivala
Ramana Venkata
@vramana
Mar 28 2016 07:11
@joestivala Quick advice: Don't use document.writeIt is not a good practice.
Joseph Stivala
@joestivala
Mar 28 2016 07:12
@vramana thats a given but the explination about how to setup and understand the arrays is the benefit of the video
Ramana Venkata
@vramana
Mar 28 2016 07:12
Okay
Islam Ibakaev
@dagman
Mar 28 2016 07:13
I WANNA SEE YOUR WEATHER APP
!
Miguel T Rivera
@mtrivera
Mar 28 2016 07:19
wiki cipher
CamperBot
@camperbot
Mar 28 2016 07:19

## :point_right: algorithm caesars cipher [wiki]

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

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Himzo
@himzo-bosnjakovic
Mar 28 2016 07:20
Hi, I need someone that is a javascript expert, I am doing a school project if anyone wants to help PM me please...
Zabe Sangary
@zabesangary
Mar 28 2016 07:23
wiki cipher
CamperBot
@camperbot
Mar 28 2016 07:23

## :point_right: algorithm caesars cipher [wiki]

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

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Trilok reddy
@Trilokreddy007
Mar 28 2016 07:23
has any one solved convert celsius to farenheit
@zabefloyd can u help im not able to solve convert celsius to farenheit
Islam Ibakaev
@dagman
Mar 28 2016 07:24
@Trilokreddy007 click on temperature http://codepen.io/dagman/pen/eZRBeq
@Trilokreddy007
    function toF(celsius) {
celsius = parseInt(celsius);
return Math.round((celsius * (9 / 5) + 32)) + '°F';
}

function toC(fahrenheit) {
fahrenheit = parseFloat(fahrenheit);
return Math.round(((fahrenheit - 32) * (5 / 9))) + '°C';
}
seasons
@seasonscao
Mar 28 2016 07:27
Excuse me, i have a question. What is the question meaning?
Trilok reddy
@Trilokreddy007
Mar 28 2016 07:28

@dagman function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);

@seasonscao describe the question
seasons
@seasonscao
Mar 28 2016 07:29
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
just output : var myStr = backslash tab tab carriage-return new-line ?
kirbyedy
@kirbyedy
Mar 28 2016 07:30
@seasonscao there is the table on left, which explains
tab is \t for example
Trilok reddy
@Trilokreddy007
Mar 28 2016 07:30
@kirbyedy can u tell me how to solve challenge 144
kirbyedy
@kirbyedy
Mar 28 2016 07:31
I dont know what is the challenge 144
you can ask a question and I will try to help
seasons
@seasonscao
Mar 28 2016 07:31
@kirbyedy thank you
CamperBot
@camperbot
Mar 28 2016 07:31
seasonscao sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 752 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Trilok reddy
@Trilokreddy007
Mar 28 2016 07:32

@kirbyedy Convert Celsius to Fahrenheitfunction convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert();

kirbyedy
@kirbyedy
Mar 28 2016 07:33
@Trilokreddy007 do you know mathematically how to convert celsius to fahrenheit ?
Trilok reddy
@Trilokreddy007
Mar 28 2016 07:33
@kirbyedy nope
Islam Ibakaev
@dagman
Mar 28 2016 07:33
@Trilokreddy007 maybe this
function convert(celsius) {
if ( typeof celsius !== 'number' ) {
return 'fahrenheit not defined';
}
return celsius * (9 / 5) + 32;
}

convert('hello'); // 'fahrenheit not defined'
convert(30); // 86
kirbyedy
@kirbyedy
Mar 28 2016 07:33
Lars
@LarsEum
Mar 28 2016 07:34
Hello everybody, I guess I have a simple question: Im on WayPoint (Nesting For Loops int he basic javascript lessons). There is a multi-dimensional arry, which should be multiplied. My question is about the nested loop, which iterates for the length of arr[i].length. Isnt't arr[i].length equal to the number of parts of the outside array? in this case = 3? [[1,2],[3,4],[5,6,7]] Shouldnt the iteration go for the length of each inside array?
Islam Ibakaev
@dagman
Mar 28 2016 07:35
@Trilokreddy007 fahrenheit = celsius * (9 / 5) + 32
Trilok reddy
@Trilokreddy007
Mar 28 2016 07:36
@dagman worked like charm thanks alot
CamperBot
@camperbot
Mar 28 2016 07:36
trilokreddy007 sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 364 | @dagman | http://www.freecodecamp.com/dagman
Robert Axelsen
@robaxelsen
Mar 28 2016 07:39
help record collection
CamperBot
@camperbot
Mar 28 2016 07:39

# Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

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

If value is blank, delete that prop.

Always return the entire collection object.

martinturner400
@martinturner400
Mar 28 2016 07:42
hi all, pretty confused with this?! i think it is just the way the question is worded, but what exactly are they asking me to do??
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
am i actually supposed to include these words, or just the escape sequences?
Elbert Cortez
@trip16661
Mar 28 2016 07:45
function truncateString(str, num) {
var myTruncated ="";
if (num <= 3){

return str.slice(0, num) + "...";
}else {

return str.slice(0, num - 3) + "...";
}

// Clear out that junk in your trunk

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
what am i missing?
martinturner400
@martinturner400
Mar 28 2016 07:47
no worries figured it out, very strangely worded that one though i think!
rouje
@rouje
Mar 28 2016 07:47

@LarsEum

arr = [[1,2],[3,4],[5,6,7]]
//arr.length is 3
//arr[0].length is 2
//arr[1].length is also 2
//arr[2].length is 3

Lars
@LarsEum
Mar 28 2016 07:49
yes. and arr[i] i thought describes the length of the outside loop, which is permanently 3
or is that my mistake?
martinturner400
@martinturner400
Mar 28 2016 07:51
@trip16661 have you called the function?
Islam Ibakaev
@dagman
Mar 28 2016 07:52
@trip16661 i got 'A-tisket...'
Lars
@LarsEum
Mar 28 2016 07:53
Or lets put it another way: Dont I have to tell the iteration to iterate in arr[0] just two times and for example in arr2 three times
or steps?
ah moment
yes
of course
thanks
:-)
rouje
@rouje
Mar 28 2016 07:54
:+1:
Lars
@LarsEum
Mar 28 2016 07:54
mhh,m why didn´t it send browny points?
Clare Dickerson
@claredickerson
Mar 28 2016 07:57
you have to tag the person you're thanking @LarsEum
:D
kirbyedy
@kirbyedy
Mar 28 2016 08:00
@claredickerson thanks
CamperBot
@camperbot
Mar 28 2016 08:00
kirbyedy sends brownie points to @claredickerson :sparkles: :thumbsup: :sparkles:
:star: 197 | @claredickerson | http://www.freecodecamp.com/claredickerson
Clare Dickerson
@claredickerson
Mar 28 2016 08:01
haha no problem
Trilok reddy
@Trilokreddy007
Mar 28 2016 08:02
@dagman once againhere : Escaping Literal Quotes in Strings
var myStr = "I am a \" double quoted \" string inside \"double quotes\".";
out put = "iam a "double quoted" string inside "double quotes "". how can put the extra double quote at the end using backslashes
kirbyedy
@kirbyedy
Mar 28 2016 08:04
@Trilokreddy007 you just need them inside the quote
Islam Ibakaev
@dagman
Mar 28 2016 08:04
@Trilokreddy007 i did that way myStr = "I am a \"double quoted\" string inside \"double quotes\"";
and its works
looks like you made the same
Trilok reddy
@Trilokreddy007
Mar 28 2016 08:08
@dagman it is not working still it printing single " at end
kirbyedy
@kirbyedy
Mar 28 2016 08:10
@Trilokreddy007 paste the exact code
you have to be careful with all the letters
and dots
and spaces
Trilok reddy
@Trilokreddy007
Mar 28 2016 08:11
@kirbyedy var myStr = "I am a \" double quoted \" string inside \"double quotes\"";
kirbyedy
@kirbyedy
Mar 28 2016 08:12
you have extra spaces
"I am a \"double quoted\" string inside \"double quotes\"";
Islam Ibakaev
@dagman
Mar 28 2016 08:13
@Trilokreddy007 var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
Clare Dickerson
@claredickerson
Mar 28 2016 08:19
I've decided to do some Code Avengers javascript tutorials to see if they help me more. I have a better chance of understanding the how if I also understand the why, which they don't always explain here. Anyone else use it? Thoughts?
kirbyedy
@kirbyedy
Mar 28 2016 08:24
@claredickerson is that free or... ?
Clare Dickerson
@claredickerson
Mar 28 2016 08:26
yes! @kirbyedy
lessons 1 and 2 are a little basic but 3 gets fun
kirbyedy
@kirbyedy
Mar 28 2016 08:26
Error: Server Error ughm... :(
but I have to pay
J Player
@Heyjp
Mar 28 2016 08:29
Anything you can use to supplement your learning is good, I haven't used that site personally but if you want to get to grips with the inner workings of javascript https://www.udemy.com/understand-javascript/ is a good resource. I think the first 4 hours are on youtube as well.
John Michael Tubiera
@jmstubiera
Mar 28 2016 08:29
@claredickerso I guess this was the one I tried back then when it was still like playing Zelda however you control the movements by code. Seems the site has been updated though.
Clare Dickerson
@claredickerson
Mar 28 2016 08:40
@Heyjp i'll check it out!
@kirbyedy huh. weird. i googled "learn javascript free" and it was in a list haha. maybe there was a certain url?
oops
try that one
i even set up a profile from there and it never asked my to pay
kirbyedy
@kirbyedy
Mar 28 2016 08:44
ok that one works, tax @claredickerson
CamperBot
@camperbot
Mar 28 2016 08:44
kirbyedy sends brownie points to @claredickerson :sparkles: :thumbsup: :sparkles:
:warning: kirbyedy already gave claredickerson points
kirbyedy
@kirbyedy
Mar 28 2016 08:45
I will give it a try, just for fun :)
Clare Dickerson
@claredickerson
Mar 28 2016 08:45
@jmstubiera there was a little game thing where you moved a tank. it did remind me of zelda a little.
CamperBot
@camperbot
Mar 28 2016 08:45
claredickerson sends brownie points to @jmstubiera :sparkles: :thumbsup: :sparkles:
:star: 137 | @jmstubiera | http://www.freecodecamp.com/jmstubiera
Clare Dickerson
@claredickerson
Mar 28 2016 08:45
ha! apparently it thinks tank is thank. ENJOY YOUR POINT!
@kirbyedy you bet!
kirbyedy
@kirbyedy
Mar 28 2016 08:46
lol
John Michael Tubiera
@jmstubiera
Mar 28 2016 08:46
@claredickerson oh lol tanks tanks tanks
CamperBot
@camperbot
Mar 28 2016 08:46
jmstubiera sends brownie points to @claredickerson :sparkles: :thumbsup: :sparkles:
:star: 198 | @claredickerson | http://www.freecodecamp.com/claredickerson
Clare Dickerson
@claredickerson
Mar 28 2016 08:47
lolol
I ALMOST HAVE 200! CAN I GET 2 MORE TANKS?!
jkjkjk
kirbyedy
@kirbyedy
Mar 28 2016 08:49
you can solve 2 challenges in the fcc map
easy ones
Clare Dickerson
@claredickerson
Mar 28 2016 08:57
I KNOWWWWW lol :)
i'm going to sleep for now
HAVE A GOOD NIGHT ALL! if you kids tweet feel free to find me @clareeewolf. sometimes i'm funny. :) i like to see tweets. no presh.
kirbyedy
@kirbyedy
Mar 28 2016 09:00
night
Robert Axelsen
@robaxelsen
Mar 28 2016 09:10
help Profile Lookup
CamperBot
@camperbot
Mar 28 2016 09:10

# Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

@mohamma548
Mar 28 2016 09:15
guys whats wrong with this code

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

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

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

Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:16
help Make a Person
CamperBot
@camperbot
Mar 28 2016 09:16

# Explanation:

When I started the program I figured I just had to create the six functions mentioned in the details. However, it was not that simple. Creating them as a function was not the right way, I had to create them in a different way to make them a key.

There is also a tricky part as you need six keys no more or less, so at first I had the variable that store the original name as a key too which was wrong.

As for the usage of array, that is optional, you could also create new variable to hold the separated string if you wish but an array is easier to deal with as strings are immutable.

Read the instructions carefully, it is always a good hint in itself to run the code and check what the test results were so you know what to expect but do not fixate yourself on that. Once you understand what you need to do, this problem is very easy and straightforward.

Sonkeng Maldini
@sdmg15
Mar 28 2016 09:18
@camperbot it's how with your algorith explanation?
Trilok reddy
@Trilokreddy007
Mar 28 2016 09:18
@kirbyedy thanks buddy ur were write it doesn't execute properly if it has space it.
CamperBot
@camperbot
Mar 28 2016 09:18
trilokreddy007 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 754 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
@mohamma548
Mar 28 2016 09:19

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

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

Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:21
@mohamma548 what is the output
help Truncate String
CamperBot
@camperbot
Mar 28 2016 09:21
no wiki entry for: truncate string
@mohamma548
Mar 28 2016 09:23
@CatalinScr it doest work for smaller strings
eg "A-"
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:24
one sec
@mohamma548
Mar 28 2016 09:28

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

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

what is with this wrong "trunkating a string"
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:29
@mohamma548 in that case A- has a length of 2
first you must check if num > 3
@mohamma548
Mar 28 2016 09:30
@CatalinScr ya but did you check the instruction?
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:31
@mohamma548 yes, look at this:
function truncateString(str, num) {
// Clear out that junk in your trunk
if(num<=3){
return str.slice(0,num) + "...";
}
else {if(str.length>num){
return str.slice(0,num-3)+"...";
}
}

return str;
}
@mohamma548
Mar 28 2016 09:34
@CatalinScr what is the difference then with my code?
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:37
@mohamma548 you solution was very good, but you must checked first if the num is smaller than 3.
Ayan Bhowmick
@Ayan5
Mar 28 2016 09:37
~~~
var myStr="I am a\"double quoted\"string inside\"double quoted\"";
lpix
@lpix
Mar 28 2016 09:38
This message was deleted
rouje
@rouje
Mar 28 2016 09:38
@Ayan5 you're missing a space
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:39
@mohamma548 in the case A-, 1 the if checks first if A-.length>1 (and it is ) and return the result ...
Ayan Bhowmick
@Ayan5
Mar 28 2016 09:40
@TreadStone071 where did I missed space?
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:40
@mohamma548 checking first if num < 3 with this case you return A...
@mohamma548
Mar 28 2016 09:40
@CatalinScr what about the last case?
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:40
which one
@mohamma548
Mar 28 2016 09:40
the last case is a bit different
for num=2
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:42
@mohamma548 truncateString("Absolutely Longer", 2). In this case when if 2<3 return Ab...
@mohamma548
Mar 28 2016 09:42
@CatalinScr ya it works thx
CamperBot
@camperbot
Mar 28 2016 09:42
mohamma548 sends brownie points to @catalinscr :sparkles: :thumbsup: :sparkles:
:star: 345 | @catalinscr | http://www.freecodecamp.com/catalinscr
Catalin Scripcariu
@CatalinScr
Mar 28 2016 09:43
@mohamma548 I know that because I tested it. You have understood?
rouje
@rouje
Mar 28 2016 09:50
@Ayan5 also check for spelling. they must exactly match what is required
Sonkeng Maldini
@sdmg15
Mar 28 2016 10:05
when i do this javascript var myvar = -1; javascript
what does it means really in memory ?
sayan
@sayan1991
Mar 28 2016 10:06
can you help me with this code

function findLongestWord(str) {
var lonfestword = str.split(" ");

var newArray = lonfestword.map(function(val){return val.length;});

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

  if(newArray[i] > max) {
max = newArray[i];
} 

return max;
}
}
findLongestWord("The quick brown fox jumped over the lazy dog");

can not get the longest word in the string
rouje
@rouje
Mar 28 2016 10:19
@sayan1991 your for loop returns max on the first iteration. :smile:
jamesbcn
@jamesbcn
Mar 28 2016 10:23

https://www.freecodecamp.com/challenges/returning-boolean-values-from-functions

"You should not use any if or else statements"

What am I supposed to do here?

lpix
@lpix
Mar 28 2016 10:33
@jamesbcn use boolean to replace the if/else statement
J Player
@Heyjp
Mar 28 2016 10:44
@jamesbcn look at the hints, your answer should be very similar to the second example they give
Alex Tze
@Tze14
Mar 28 2016 10:55
help caesars
CamperBot
@camperbot
Mar 28 2016 10:55

## :point_right: algorithm caesars cipher [wiki]

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

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Brendan Kinahan
@BKinahan
Mar 28 2016 10:56
Pnrfne'f Pvcure, ybgf bs sha
Andreas Alme
Mar 28 2016 10:58
hey you lovely guys, Im having some trouble with Profile Lookup, have a look:
function lookUp(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";
}

} else {
return "No such contact";

}
}

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
something Im missing?
Brendan Kinahan
@BKinahan
Mar 28 2016 11:00
@Addibro Looks like you're only checking the first contact before deciding how to return.
Andreas Alme
Mar 28 2016 11:01
@BKinahan loop's not doing what it should you mean?
Brendan Kinahan
@BKinahan
Mar 28 2016 11:03
@Addibro Sort of.. the loop has the correct general structure, but you can only decide that there is no matching contact after the loop has completed, because only then an you know that all of the contacts were checked and none of them match the name.
Andreas Alme
Mar 28 2016 11:05
@BKinahan yeah.. must confess Im a bit confused
Brendan Kinahan
@BKinahan
Mar 28 2016 11:11
First step in the loop:
i==0:
if(contacts[0].firstName == firstName) { // if the first contact's name matches
if(contacts[0].hasOwnProperty (prop)){ // if the property is there
return contacts[0].prop;  // there is a slight error here, it should be bracket notation for the variable prop
} else { return "No such property"; // if the property is not in the first contact
}
} else { // if the first contact's name does not match
return "No such contact"; // by this point it is definite that one of the returns is reached, so the loop and function stop, and no other contacts are checked
}
}
}
Andreas Alme
Mar 28 2016 11:15
@BKinahan right.. that make sense, thanks. Not comfortable with the notation rules yet. So, how should one make the loop continue?
CamperBot
@camperbot
Mar 28 2016 11:15
addibro sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1164 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 28 2016 11:16
@Addibro well, if you move the return "No such contact"; line outside of the for loop, the entire loop will run, and if it doesn't reach any of the return lines within it, the function will keep going after the loop and reach the last return
Andreas Alme
Mar 28 2016 11:18
@BKinahan right, I'll try that, thanks a lot mate
CamperBot
@camperbot
Mar 28 2016 11:18
addibro sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
Andreas Alme
Mar 28 2016 11:32
@BKinahan hey, I tried this one, but I get "contact is not defined":
for (var i = 0; i < contact.length; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty (prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
kirbyedy
@kirbyedy
Mar 28 2016 11:33
once you write contact, next time contacts
1 line
Andreas Alme
Mar 28 2016 11:34
@kirbyedy aw shit, thanks man
CamperBot
@camperbot
Mar 28 2016 11:34
addibro sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 756 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Lawrence Archer
@LawrenceArcher
Mar 28 2016 11:35
help falsy bouncer
CamperBot
@camperbot
Mar 28 2016 11:35

# Problem Explanation:

Remove all falsy values from an array.

Trilok reddy
@Trilokreddy007
Mar 28 2016 11:53
@kirbyedy hi challenge 148 escape sequences in strings=myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
@mohamma548
Mar 28 2016 11:57
hey guys could you help please with this code

function chunkArrayInGroups(arr, size) {
// Break it up.'
var arr1= [];

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

 arr1[i]=arr.slice(i,i+size);

}
return arr1 ;

}

Pascal T.
@omegga
Mar 28 2016 12:00
@mohamma548 try this
arr1.push(arr.slice(i,i+size) );
Trilok reddy
@Trilokreddy007
Mar 28 2016 12:01
@Scriptonaut hi challenge 148 escape sequences in strings=myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
has anyone has completed challenge 148
Brendan Kinahan
@BKinahan
Mar 28 2016 12:09
@Trilokreddy007 the challenges aren't numbered, there are other ways to get points. Use the challenge title.
@Trilokreddy007 use the table in the instructions to construct a string of the correct escaped characters
anthonygallina1
@anthonygallina1
Mar 28 2016 12:49
@BKinahan hi
Brendan Kinahan
@BKinahan
Mar 28 2016 12:49
@anthonygallina1 howdy
anthonygallina1
@anthonygallina1
Mar 28 2016 12:49
:)
@BKinahan seems preety quiet in here
Colin
@CThor
Mar 28 2016 12:51
I would chat more but I have to be low-key at work :smile:
anthonygallina1
@anthonygallina1
Mar 28 2016 12:51
Hi @CThor
kirbyedy
@kirbyedy
Mar 28 2016 12:51
how is this possible
same code in safari produces 17mil. loops, and in chrome 3mil
anthonygallina1
@anthonygallina1
Mar 28 2016 12:52
@kirbyedy hello :)
kirbyedy
@kirbyedy
Mar 28 2016 12:52
hi
same computer, just a different browser
anthonygallina1
@anthonygallina1
Mar 28 2016 12:53
Hmm would have to look into the source of the 2 browsers
kirbyedy
@kirbyedy
Mar 28 2016 12:53
firefox 5mil
anthonygallina1
@anthonygallina1
Mar 28 2016 12:53
This message was deleted
kirbyedy
@kirbyedy
Mar 28 2016 12:54
function measureLoopSpeed() {
var count = 0
function addOne() { count = count + 1 }

// Date.now() returns a big number representing the number of
// milliseconds that have elapsed since Jan 01 1970
var now = Date.now()

// Loop until Date.now() is 1000 milliseconds (1 second) or more into
// the future from when we started looping. On each loop, call addOne
while (Date.now() - now < 1000) addOne()

// Finally it has been >= 1000ms, so let's print out our total count
console.log(count)
}

measureLoopSpeed()
same code, different browsers
anthonygallina1
@anthonygallina1
Mar 28 2016 12:55
I believe it
kirbyedy
@kirbyedy
Mar 28 2016 12:55
looks like safari is the fastest... I hate it...
anthonygallina1
@anthonygallina1
Mar 28 2016 12:55
@kirbyedy maybe like the reason flex box doesnt work in all browsers the same
Probably not but I thought I would throw that in there
kirbyedy
@kirbyedy
Mar 28 2016 12:59
:)
Damian
@an0o0nym
Mar 28 2016 12:59
Hi guys, I have the two functions. Function1() returns multi-dimensional array. Function2(arr) as you can see takes an array as a parameter. how can I call Function2 with the result from function1? I tried several ways, i.e.:
Function1(Function2());
var arr = Function2(); Function1(arr);
But anytime I call that Function1 does not seem to get the arr parameter, and thus it is undefined inside it. I know I could do:
Function2(){ var jsonArr = ...//my code...// Function1(jsonArr)};
But is there any other way? SImilar to the first two examples I gave you?
Markus Kiili
@Masd925
Mar 28 2016 13:05
@an0o0nym To call function2 with the return value of function1, do: function2(function1(possible arguments...));
Damian
@an0o0nym
Mar 28 2016 13:10
@Masd925 that is what i tried to do. the function which should receive arguments from the other one does not receive it
Markus Kiili
@Masd925
Mar 28 2016 13:11
@an0o0nym You have to post the code if you wan't more advice.
Damian
@an0o0nym
Mar 28 2016 13:11
maybe I show you my code :
            function getWikiContent(){
$.getJSON("https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=Java&formatversion=2&callback=?", function(json){ console.log("Json output: "); console.log(json); return json; }); } function appendBox(arrJSON){ console.log("arrJSON inside appendBox: "); console.log(arrJSON); return true; } I called it like this: //1st try appendBox(getWikiContent()); //2nd try var arr = getWikiContent(); appendBox(arr); //3nd try getWikiContent(function(data){ appendBox(data); } But every time the array in appendBox is type of undefined. And it is always called as a first, thus causing this problem. @Masd925 ^^^ Jalay @JalaySimaria Mar 28 2016 13:16 @an0o0nym try removing return true; from appendBox function Damian @an0o0nym Mar 28 2016 13:16 it wasnt previous there, I added it just a sec ago. @JalaySimaria @JalaySimaria anyways it wont change anything as I do get nothing in console.log kirbyedy @kirbyedy Mar 28 2016 13:19 dont know if this makes any difference &format=json this is how I have it Markus Kiili @Masd925 Mar 28 2016 13:19 @an0o0nym Is your getWikiContent function returning anything? kirbyedy @kirbyedy Mar 28 2016 13:20 it does, but not the json formatted data Damian @an0o0nym Mar 28 2016 13:20 yes, multi-dim array @Masd925 kirbyedy @kirbyedy Mar 28 2016 13:21 try with this: &format=json instead of that one you have Damian @an0o0nym Mar 28 2016 13:22 @kirbyedy I do have a &format=json kirbyedy @kirbyedy Mar 28 2016 13:22 right, sorry, missed that Damian @an0o0nym Mar 28 2016 13:23 @kirbyedy no worries. kirbyedy @kirbyedy Mar 28 2016 13:24 @an0o0nym can you link your pen Damian @an0o0nym Mar 28 2016 13:25 Everything is working perfectly when I do getWikiContent(){ //code here appendBox(json); } It does return the console.log line from the appendBox function. My question is how can I do that in the other way, to call appendBox function which is outside getWikiContent(). Is there any way to do that? I called it like this: //1st try appendBox(getWikiContent()); //2nd try var arr = getWikiContent(); appendBox(arr); //3nd try getWikiContent(function(data){ appendBox(data); } But every time the array in appendBox is type of undefined. And it is always called as a first, thus causing this problem. @kirbyedy working on local machine Jalay @JalaySimaria Mar 28 2016 13:27 @an0o0nym here is what you need to do: function getWikiContent() { var obj_variable =$.getJSON("https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=Java&formatversion=2&callback=?", function(json) {
console.log("1) Json output: ");
console.log("2) " + json);
return json;
});
return obj_variable;
}

function appendBox(arrJSON) {
console.log("3) arrJSON inside appendBox: ");
console.log("4) " + arrJSON);
}

and then execute it like this:

appendBox(getWikiContent());

GIVE IT A TRY !

Damian
@an0o0nym
Mar 28 2016 13:27
Thats all Ive got
$(document).ready(function(){$("#searchButton").on("click", function(){
$("#feelingLucky").remove();$("#searchForm").animate({
margin: "8% auto"
},450);
//here I try to call my functions
});
});

function getWikiContent(){
$.getJSON("https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=Java&callback=?", function(json){ console.log("Json output: "); console.log(json); return json; }); } function appendBox(arrJSON){ console.log("arrJSON inside appendBox: "); console.log(arrJSON); return true; } @JalaySimaria hang on, will try @JalaySimaria seems to be working, however what I get is an object. No problem with that at all, but my original question was how to pass an array with the result of function getWIkiContent() to appendBox(arrJSON) kirbyedy @kirbyedy Mar 28 2016 13:34 maybe if you have the wiki call inside the append function ? just a thought... Mohammedaadem As @mohamma548 Mar 28 2016 13:35 what is wrong with this code? function mutation(arr) { if(arr.indexOf(arr,0)){ return true; } return false; } Damian @an0o0nym Mar 28 2016 13:37 @kirbyedy yes that would probably work, as I tried the opposite, namely append function inside wiki call. Jalay @JalaySimaria Mar 28 2016 13:38 @an0o0nym since the ajax response of getWIkiContent function is an object, you have to wrap that object into an array and then pass it to appendBox kirbyedy @kirbyedy Mar 28 2016 13:38 I have my wiki call inside the click button Damian @an0o0nym Mar 28 2016 13:40 @JalaySimaria you are right. will try that. Andreas Alme @Addibro Mar 28 2016 13:41 How come I can't use bracket notation on "contacts[i].firstName"? And how come I can't use dot notation on "contacts[i][prop]"? for (var i = 0; i < contacts.length; i++) { if (firstName == contacts[i].firstName) { if (contacts[i].hasOwnProperty (prop)) { return contacts[i][prop]; } else { return "No such property"; } } } return "No such contact"; Jalay @JalaySimaria Mar 28 2016 13:41 @mohamma548 in your if condition you don't need to add 2nd argument as 0 as it is 0 by default, but that's not an issue. nothing's wrong with that function. are you facing anything unusual? Zabe Sangary @zabesangary Mar 28 2016 13:42 var ourArray = ["Stimpson", "J", "cat"]; ourArray.shift(); ourArray.unshift("Happy"); var ourArray = ["Stimpson", "J", "cat"]; var b = ourArray.pop(); why do you need to assign it to a new variable and when not to? thanks in advance. Markus Kiili @Masd925 Mar 28 2016 13:44 @Addibro The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3. Konrad Turlejski @Konrad0381 Mar 28 2016 13:45 Can you tell me what I should do? Zabe Sangary @zabesangary Mar 28 2016 13:52  result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb; Jalay @JalaySimaria Mar 28 2016 13:52 @zabefloyd you don't need to assign that .pop method to a new variable unless you use the returned value, from that method, somewhere else in your code. some methods might return value and some might not, it's up to your requirement whether it's useful for you(then save it in variable) or not Zabe Sangary @zabesangary Mar 28 2016 13:53 @Konrad0381 you need to concatenate the result @JalaySimaria that makes sense thanks! CamperBot @camperbot Mar 28 2016 13:55 zabefloyd sends brownie points to @jalaysimaria :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for jalaysimaria lpix @lpix Mar 28 2016 13:56 function telephoneCheck(str) { // Good luck! //things to check: parentheses match correctly, begins with 1 if total length is 11, all numbers //check matching parentheses var p1 = str.indexOf('('); var p2 = str.indexOf(')'); //is there a first parenthesis? if((p2!==-1 && p1==-1)||(p1!==-1 && p2==-1)){ return false; }if(p1!==-1 && (p2-p1)!==4){ return false; } str = str.replace(/[.,\/#!$%\^&\*;:{}=\-_~()]/g, "");
str = str.replace(/\s+/g,"");

if(str.length<10||str.length>11){
return false;
}else {
if(str[0]!==1){
return false;
}
}
return true;
}
why is a telephone starting with 1 not recognized as valid?
Mar 28 2016 13:56
Thanks smile:
Arnaud Casamé
@arnaudcasame
Mar 28 2016 13:56
This message was deleted

Can someone help me with the destroyer algorithm? Don't even know where to start since function takes multiple arguments and the callback takes only one argument.

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

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Andreas Alme
Mar 28 2016 13:57
@Masd925 allright, thanks masd
CamperBot
@camperbot
Mar 28 2016 13:57
addibro sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1243 | @masd925 | http://www.freecodecamp.com/masd925
lpix
@lpix
Mar 28 2016 13:59
@djcase001 this one is tricky..start by separating the array from the numbers Hint: use splice
Josh Bivens
@joshbivens
Mar 28 2016 14:00
Quick question. Can anyone help me?
Arnaud Casamé
@arnaudcasame
Mar 28 2016 14:00
ok, but how do I manage the multiple arguments affair in the callback function????
Jalay
@JalaySimaria
Mar 28 2016 14:00
@djcase001 an idea: you can executing the callback function multiple times. meaning a for loop till the length of the array and execute callback function inside that for loop passing the current indexed array value
Arnaud Casamé
@arnaudcasame
Mar 28 2016 14:00
@lpix ok, but how do I manage the multiple arguments affair in the callback function????
Markus Kiili
@Masd925
Mar 28 2016 14:01
@djcase001 Use arguments object.
Dmytro Bondarenko
@gonardfreeman
Mar 28 2016 14:01
hey guys!
lpix
@lpix
Mar 28 2016 14:02
^ What @Masd925 said @djcase001 ..arguments object kind of acts like an array
Jalay
@JalaySimaria
Mar 28 2016 14:02
@joshbivens sure, what is it?
Dmytro Bondarenko
@gonardfreeman
Mar 28 2016 14:03
task says that we need to remove all non-alphabetical characters, but last testcase say that it must return true on this expression palindrome("0_0 (: /-\ :) 0-0")
lpix
@lpix
Mar 28 2016 14:03
Arnaud Casamé
@arnaudcasame
Mar 28 2016 14:03
@Masd925 give me an example. please
Dmytro Bondarenko
@gonardfreeman
Mar 28 2016 14:03
@lpix so it must return true with empty string/list?
lpix
@lpix
Mar 28 2016 14:04
@gonardfreeman have you tried it? with my answer removing non-alphanumerical answers passed the test
Markus Kiili
@Masd925
Mar 28 2016 14:04
@djcase001 You can use arguments[i] and arguments.length to access all the passed arguments.
lpix
@lpix
Mar 28 2016 14:05
@gonardfreeman it worked for me shrugs
Arnaud Casamé
@arnaudcasame
Mar 28 2016 14:05
@Masd925 it's getting a bit clear. but give me an example
Dmytro Bondarenko
@gonardfreeman
Mar 28 2016 14:05
@lpix just start reading, and was confused by it)
negyvenketto
@negyvenketto
Mar 28 2016 14:05
@gonardfreeman yes, you remove all non alphanumerics. so for that example you will check "0000"
Dmytro Bondarenko
@gonardfreeman
Mar 28 2016 14:05
@lpix ok, thank you)
CamperBot
@camperbot
Mar 28 2016 14:05
gonardfreeman sends brownie points to @lpix :sparkles: :thumbsup: :sparkles:
:star: 316 | @lpix | http://www.freecodecamp.com/lpix
Dmytro Bondarenko
@gonardfreeman
Mar 28 2016 14:05
@negyvenketto thanks)
CamperBot
@camperbot
Mar 28 2016 14:05
gonardfreeman sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 328 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
lpix
@lpix
Mar 28 2016 14:05
@gonardfreeman np
@djcase001 I converted the arguments into an array then I used splice to seperate the first argument from the rest
Markus Kiili
@Masd925
Mar 28 2016 14:07
@djcase001 for (var i=0; i<arguments.length; i++) {console.log(arguments[i]);} would print all the arguments of a function call.
Arnaud Casamé
@arnaudcasame
Mar 28 2016 14:08
Thanks a lot @Masd925
CamperBot
@camperbot
Mar 28 2016 14:08
djcase001 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1244 | @masd925 | http://www.freecodecamp.com/masd925
lpix
@lpix
Mar 28 2016 14:23
nvm..i got it
Zabe Sangary
@zabesangary
Mar 28 2016 14:26
var myList = [["Mango", 3, "Apple", 4], ["Grapes", 3, "Some", 4], [2, "item", 5, "item"], [2, "item", 5, "item5"]];
console.log(myList);
what is wrong with my code?
instruction
Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.
Pascal T.
@omegga
Mar 28 2016 14:31
@zabefloyd I guess all subarrays must start with item name then number of item
Zabe Sangary
@zabesangary
Mar 28 2016 14:39
The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity
that's what it says
DCOSMINC
@DCOSMINC
Mar 28 2016 14:41
function mutation(arr) {
for(var i = 0; i <arr[1].length;i++ ) {
if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase())!==-1) {
return true;
} else {
return false;
}
}
}
mutation(["hello", "hey"]);
Could someone tell me why the mutation bellow doesn't work with that?>.> everything else does
Theodore P.
@Ierofantis
Mar 28 2016 14:41

I have a problem if anyone could help me I would be nice.

Can I push this somehow to an array?

var newa=[];
var args = Array.prototype.slice.call(arguments);
var t = args.toString();

I 've made this but It only stores the first number of arguments

  for (var i=0; i<t.length;i++){
var v= newa.push(t);
return v ;

}
Jalay
@JalaySimaria
Mar 28 2016 14:47
@DCOSMINC this is wrong
for(var i = 0; i <arr[1].length;i++ ) {   // arr[1].length should be arr.length
DCOSMINC
@DCOSMINC
Mar 28 2016 14:48
but arr is an array with 2 strings in it
i wanna see the length of the second element
Shouldn't i ? ehm
CodaGirl
@CodaGirl
Mar 28 2016 14:50
Hello can someone explain to me what to they mean by encode the following sequence : backslash tab tab carriage-return new-line?
Mooli
@Mooli88
Mar 28 2016 14:50
hi all, im starting the Show the Local Weather project and the instructions suggest to go to http://openweathermap.org/current#geo for the Open Weather API. but i have no idea how to use it . how to i import this API and and use it ???
Mar 28 2016 14:50
@Ierofantis - not sure what you are trying to do, but after that Array.prototype.slice.call(arguments); call, the variable args should be an array?
Vivek
@vivek28111992
Mar 28 2016 14:51
@CodaGirl you should use \ to pass the element given in problem
Mar 28 2016 14:51
@CodaGirl - they just mean to make a string and use the code for each character - that is backslash is encoded as \\, tab as \t - the information that they have in the description of the lesson.
separated by spaces, of course.
Theodore P.
@Ierofantis
Mar 28 2016 14:52

 return newa.push(args);

this is what you mean?

CodaGirl
@CodaGirl
Mar 28 2016 14:52
@vivek28111992 @khaduch thank you for the fast response, but i already used this '// \t \t \r \n ' and it turned out to be not correct, am i doing it wrong?
CamperBot
@camperbot
Mar 28 2016 14:52
codagirl sends brownie points to @vivek28111992 and @khaduch :sparkles: :thumbsup: :sparkles:
:star: 431 | @vivek28111992 | http://www.freecodecamp.com/vivek28111992
Jalay
@JalaySimaria
Mar 28 2016 14:53
@DCOSMINC can you tell me what do you want to accomplish with that function? I'll get a better idea
DCOSMINC
@DCOSMINC
Mar 28 2016 14:53
@JalaySimaria i gotta check if the letters from the second string of the array are in the first string, it works for all the cases except the one that's in the picture
kirbyedy
@kirbyedy
Mar 28 2016 14:56
@CodaGirl you have to use the backslash not the slash, the rest is fine
first 2
pgjones72
@pgjones72
Mar 28 2016 14:58
hey guys. I'm still having issues accessing keys and properties in objects with bracket notation. any help?
function lookUp(firstName, prop){
// Only change code below this line

for(firstName in contacts){
for(prop in contacts[firstName]){
if(contacts[firstName].prop !== ""){
return firstName[prop];
}
else{
return "No such contact";
}
}
}
Nazgul13
@Nazgul13
Mar 28 2016 14:59
a
Jalay
@JalaySimaria
Mar 28 2016 14:59
@DCOSMINC ok I think this is what happening in your code for the given array
when it starts checking, "h" from hello and "h" from "hey" matches and it'll return true! finish game is over, it returned true and for loop will stop, it won't check for "e" and "y" from "hey".
makes sense?
Brendan Kinahan
@BKinahan
Mar 28 2016 14:59
@pgjones72 if(contacts[firstName].prop !== "") uses dot notation, not bracket notation
Nazgul13
@Nazgul13
Mar 28 2016 14:59
var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 1;
this.engines = 1;
};

//Try it out here
var myCar=new Car(3,1,2);
anyone know why this doesn't pass?
Markus Kiili
@Masd925
Mar 28 2016 15:00
@pgjones72 The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Vivek
@vivek28111992
Mar 28 2016 15:00
@CodaGirl you dont need //, you only need /
Markus Kiili
@Masd925
Mar 28 2016 15:00
@pgjones72 So .prop doesn't work there.
DCOSMINC
@DCOSMINC
Mar 28 2016 15:01
@JalaySimaria hmm i guess that makes sense...
Mooli
@Mooli88
Mar 28 2016 15:01
guys, do i need to know ajax in order to complete Show the Local Weather ?
DCOSMINC
@DCOSMINC
Mar 28 2016 15:01
@JalaySimaria thanks
CamperBot
@camperbot
Mar 28 2016 15:01
dcosminc sends brownie points to @jalaysimaria :sparkles: :thumbsup: :sparkles:
:star: 49 | @jalaysimaria | http://www.freecodecamp.com/jalaysimaria
Jalay
@JalaySimaria
Mar 28 2016 15:01
@DCOSMINC maybe you should do something like this:
function mutation(arr) {
for(var i = 0; i <arr[1].length;i++ ) {
if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase())===-1) {
return false; // keep iterating until it's false
}
}
return true;  // will return true if length of "hey" exceeds
}
pgjones72
@pgjones72
Mar 28 2016 15:01
@Masd925 [prop] doesn't work either
Brendan Kinahan
@BKinahan
Mar 28 2016 15:02
@pgjones72 for(firstName in contacts) is a confusing use of the for...in syntax
DCOSMINC
@DCOSMINC
Mar 28 2016 15:02
@JalaySimaria oh i see, that makes more sense... thanks
CamperBot
@camperbot
Mar 28 2016 15:02
dcosminc sends brownie points to @jalaysimaria :sparkles: :thumbsup: :sparkles:
:warning: dcosminc already gave jalaysimaria points
pgjones72
@pgjones72
Mar 28 2016 15:03
@BKinahan why?
@BKinahan sorry. I've been stuck here for a week
Matthew Fricker
@mattfricker
Mar 28 2016 15:03
@pgjones72 - can you copy all of your code, including the object you are trying to work on?
pgjones72
@pgjones72
Mar 28 2016 15:03
@mattfricker ok
Brendan Kinahan
@BKinahan
Mar 28 2016 15:03
@pgjones72 you're saying "for each element in contacts, call the current element by the variable firstName and do this with it:"
pgjones72
@pgjones72
Mar 28 2016 15:04
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop){
// Only change code below this line

for(firstName in contacts){
for(prop in contacts[firstName]){
if(contacts[firstName][prop] !== ""){
return firstName[prop];
}
else{
return "No such contact";
}
}
}

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Brendan Kinahan
@BKinahan
Mar 28 2016 15:04
@pgjones72 that can lead to a monster of a line something like if(firstName.firstName == firstName){... :P
pgjones72
@pgjones72
Mar 28 2016 15:05
@BKinahan sigh. I get the confusion. I'm as confused as the IDE
Brendan Kinahan
@BKinahan
Mar 28 2016 15:05
pgjones72
@pgjones72
Mar 28 2016 15:06
@BKinahan Thanks. I'll check that out
CamperBot
@camperbot
Mar 28 2016 15:06
pgjones72 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1167 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 28 2016 15:06
@pgjones72 but in short, using a variable name in a for...in loop that is the same as a parameter of your function should be avoided
Zabe Sangary
@zabesangary
Mar 28 2016 15:06
@mohamma548
Mar 28 2016 15:07
what is wrong witrh this code_

function mutation(arr) {
if(arr.indexOf(arr,0)){
return true;

}

return false;

}

Brendan Kinahan
@BKinahan
Mar 28 2016 15:07
@zabefloyd what part are you stuck with?
Zabe Sangary
@zabesangary
Mar 28 2016 15:07
var myList = [[["Mango"], [3]], [["Mango"], [3]], [[2], ["item"], [5]], ["item"]], [[2], ["item"], [5], ["item5"]]];
console.log(myList[0]);
here is m code, stuck on the order of arrays
Jalay
@JalaySimaria
Mar 28 2016 15:08

@pgjones72 prop is an argument here

function lookUp(firstName, prop){

and you're using that as a variable here

for(prop in contacts[firstName]){ // use something else, not prop
Brendan Kinahan
@BKinahan
Mar 28 2016 15:08
@mohamma548 arr.indexOf(arr) asks where arr is within arr, which is possibly only useful for detecting circular references
@zabefloyd the elements of your subarrays are each arrays with 1 element; they should instead simply be either strings or numbers
@zabefloyd e.g. "Mango" instead of ["Mango"]
pgjones72
@pgjones72
Mar 28 2016 15:11
on a completely unrelated note, my chat box will only work in a seperate window now. Is there a reason for this?
@mohamma548
Mar 28 2016 15:12
@BKinahan it returns only true why not false
pgjones72
@pgjones72
Mar 28 2016 15:13
i sign in on the new window and I can only chat here
Brendan Kinahan
@BKinahan
Mar 28 2016 15:13
@mohamma548 whatever arr is, arr probably isn't within it. So arr.indexOf(arr) == -1, which is truthy, as in if(-1) return true; will return true
St33lMagnolia
@St33lMagnolia
Mar 28 2016 15:14
please can someone tell me what I am doing wrong with the card count challenge? https://i.gyazo.com/thumb/200/_171a041bbcbaafc5ac69805a8595b928-png.jpg
chilledmuffin
@chilledmuffin
Mar 28 2016 15:15
@JalaySimaria
ObedJosiah
@obedjosiah
Mar 28 2016 15:15
help \$Confirm The Ending
CamperBot
@camperbot
Mar 28 2016 15:15

# Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the end('Bastian', 'n'); case.

Brendan Kinahan
@BKinahan
Mar 28 2016 15:15
@St33lMagnolia you're comparing card at the end when determining what to return, but you should be comparing count
Jalay
@JalaySimaria
Mar 28 2016 15:17
@chilledmuffin yes
Matthew Fricker
@mattfricker
Mar 28 2016 15:17
@pgjones72 Are you still having issues with the looping over of an array of objects?
pgjones72
@pgjones72
Mar 28 2016 15:17
@mattfricker oh yeah. driving me nuts
Zabe Sangary
@zabesangary
Mar 28 2016 15:18
var myList = ["item1", "item2", 5 , 3];
@BKinahan something like that?
Matthew Fricker
@mattfricker
Mar 28 2016 15:18
@pgjones72 Ok, so I went through your code, and I do not think a for...in loop here is you best choice - but I adapted it so it would work for you.
Brendan Kinahan
@BKinahan
Mar 28 2016 15:18
@zabefloyd closer, but each element of myList should be an array containing one string and one number.
chilledmuffin
@chilledmuffin
Mar 28 2016 15:19
@zabefloyd try this
var myList = [["car", 2], ["toffee", 6], ["crisps", 7], ["banana", 1], ["shoe", 5]];
Zabe Sangary
@zabesangary
Mar 28 2016 15:19
ah okay,
Matthew Fricker
@mattfricker
Mar 28 2016 15:20
@pgjones72 Since you were looping over an Array of objects, what you are doing when setting var in _ is getting the key to each index of that array.
arcjackson06
@arcjackson06
Mar 28 2016 15:20
var p = 0;
function chunkArrayInGroups(arr, size) {
// Break it up.

function setUpArr(){
var newArr = [];
for (i=0; i < Math.ceil(arr.length/size); i++){
newArr.push([]);

}
return newArr;
}

function arrayPass(){

var val = arr[p];
p = p + 1;

return val;

}

var toChunk = setUpArr();

for (j = 0; j < toChunk.length; j++){
if ( j !== toChunk.length-1 || arr.length % size === 0){
for (k = 0; k < size; k++){
toChunk[j][k] = arrayPass();
}
}
else{

toChunk[j] = arr.slice(arr.length - arr.length % size );
}
}

}

chunkArrayInGroups( ["a", "b" , "c" , "d" ], 2);
My code is correct but for some reason I'm not getting the check marks, can someone help
Brendan Kinahan
@BKinahan
Mar 28 2016 15:21
@arcjackson06 why is p a global variable?
Matthew Fricker
@mattfricker
Mar 28 2016 15:21
@pgjones72 So basically, 0, 1, 2 - so the way you reference each specific contact object within that array is with contacts[0], contaxts1, etc. In the codepen example I linked, that index value is stored in key
pgjones72
@pgjones72
Mar 28 2016 15:22
@mattfricker ok. Let me try to figure this out. Thanks!
CamperBot
@camperbot
Mar 28 2016 15:22
pgjones72 sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
Matthew Fricker
@mattfricker
Mar 28 2016 15:22
@pgjones72 So what you need to check is that contacts[0]["firstName"] === firstname
Brendan Kinahan
@BKinahan
Mar 28 2016 15:22
@arcjackson06 or to ask another way, what is the value of p at the end of one call of the function, and what happens if the function is called a second time?
Matthew Fricker
@mattfricker
Mar 28 2016 15:22
@pgjones72 No problem
CamperBot
@camperbot
Mar 28 2016 15:23
:star: 50 | @mattfricker | http://www.freecodecamp.com/mattfricker
OhMySweetJesus
@OhMySweetJesus
Mar 28 2016 15:23
Quick question. Anybody know how to access an object property in dot notation if the property is a string? myObj."property" obviously doesn't work so I'm not sure what to do.
Brendan Kinahan
@BKinahan
Mar 28 2016 15:24
@OhMySweetJesus myObj.property or myObj["property"]
Zabe Sangary
@zabesangary
Mar 28 2016 15:24
thank you guys :)
can't complain freecodecmap is awesome!
Brendan Kinahan
@BKinahan
Mar 28 2016 15:24
@OhMySweetJesus the latter is necessary if there's a space in the property name
St33lMagnolia
@St33lMagnolia
Mar 28 2016 15:24
@BKinahan your explanation is a bit vague, I don't get it
OhMySweetJesus
@OhMySweetJesus
Mar 28 2016 15:25
@BKinahan Yeah gotcha. Doesn't matter that it's a string. Thank you!
CamperBot
@camperbot
Mar 28 2016 15:25
ohmysweetjesus sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
arcjackson06
@arcjackson06
Mar 28 2016 15:25
@BKinahan I was trying a lot of things to get the p variable to increment after calling the second function, but actually after putting it in the first function I got the challenge
Zabe Sangary
@zabesangary
Mar 28 2016 15:25

was confused with
The second elements in each of your sub-arrays must all be numbers

thought it meant[3, "string"];

arcjackson06
@arcjackson06
Mar 28 2016 15:25
@BKinahan thank you!
CamperBot
@camperbot
Mar 28 2016 15:25
arcjackson06 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
Brendan Kinahan
@BKinahan
Mar 28 2016 15:25
@St33lMagnolia if (card<=0) think about what that means :D
CamperBot
@camperbot
Mar 28 2016 15:25
:star: 1168 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 28 2016 15:26
@OhMySweetJesus yeah, bracket notation is needed only if you're using a variable (that refers to a number or string), like myObj[var], or if there is a space as I mentioned
CamperBot
@camperbot
Mar 28 2016 15:26
api offline
St33lMagnolia
@St33lMagnolia
Mar 28 2016 15:26
it's supposed to be if(count <= 0) but even that's not working
@BKinahan it's supposed to be if(count <= 0) but even that's not working
Brendan Kinahan
@BKinahan
Mar 28 2016 15:27
@St33lMagnolia did you change it in the else if also?
St33lMagnolia
@St33lMagnolia
Mar 28 2016 15:33
yeah, it looks like this now and still nothing https://i.gyazo.com/29ad6db696eb333bf9e8f6ca42cf38dd.png
@BKinahan
pgjones72
@pgjones72
Mar 28 2016 15:33
ok here is my latest attempt that renders on, puny green check mark
function lookUp(firstName, prop){
// Only change code below this line

for(var key in contacts){
if(contacts[key]["firstName"] === firstName){
return contacts[key][prop];
}
else if(contacts[key]["firstName"][prop]===""){
return "No such property";
}
else{
return "No such contact";
}

}
St33lMagnolia
@St33lMagnolia
Mar 28 2016 15:33
or am i supposed to have case statements for every situation? @BKinahan
Brendan Kinahan
@BKinahan
Mar 28 2016 15:34
@St33lMagnolia you broke something that was correct before. if(count < 7) is incorrect now.
@pgjones72 your function returns something after checking the first key in contacts, no matter what it is. you can only decide there is "No such contact" after checking ALL the contacts
pgjones72
@pgjones72
Mar 28 2016 15:37
@BKinahan huh? I swear I'm not an idiot. lol
Brendan Kinahan
@BKinahan
Mar 28 2016 15:40
@pgjones72 "check the first key in contacts, if its name matches the given name, return the value of its 'prop' property" (oops, what if it doesn't have that property?) "else, if he value of it 'prop' property is an empty string, return "no such property" (something will go wrong here), "else, because its name doesn't match and its 'prop' property isn't an empty string, return 'No such contact', then try the next key in conta-- oh wait, can't check anything else, we have definitely returned something by now, so the function is done running."
Reckoo
@Reckoo
Mar 28 2016 15:40
@St33lMagnolia
  switch(card){

case card = 2:
case card = 3:
case card = 4:
case card = 5:
case card = 6:
count++;
break;

case card = 7:
case card = 8:
case card = 9:
count += 0;
break;

case card = 10:
case card = 'J':
case card = 'Q':
case card = 'K':
case card = 'A':
count--;
break;
}

if(count > 0){
return count + " Bet";
} else {
return count + " Hold";
}
Brendan Kinahan
@BKinahan
Mar 28 2016 15:41
@Reckoo (the middle chunk of your switch statement is unnecessary since it does nothing)
(also the syntax is incorrect throughout, try case 10: etc)
Reckoo
@Reckoo
Mar 28 2016 15:42
@BKinahan Alright, thanks. My code worked, but with what you said I can perfect it. Thx
CamperBot
@camperbot
Mar 28 2016 15:42
reckoo sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1170 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 28 2016 15:43
@Reckoo that worked? why? it uses assignment instead of checking for equality with ==
Bil
@thebiltheory
Mar 28 2016 15:43
Hey
Sup Wassuuup.
Brendan Kinahan
@BKinahan
Mar 28 2016 15:43
(not that that should work either, but y'know)
Bil
@thebiltheory
Mar 28 2016 15:44
Can someone tell me the difference between
var args = [];
var args = array.prototype;
Matthew Fricker
@mattfricker
Mar 28 2016 15:45
@thebiltheory The first line is an empty array. The second line should be Array.prototype.
Bil
@thebiltheory
Mar 28 2016 15:45
Yeah but isn’t this the same? @mattfricker
Matthew Fricker
@mattfricker
Mar 28 2016 15:46
@thebiltheory When you use [].slice instease of Array.prototype.slice, the difference is code style and how the engine looks up the method
Bil
@thebiltheory
Mar 28 2016 15:46
@mattfricker Array.prototype isn’t an array constructor which would be considered as an empty []
Matthew Fricker
@mattfricker
Mar 28 2016 15:46
@thebiltheory When you use [].slice, it looks on that empty array first to find that method. When it does not find it, it finds its prototype link and looks there
Bil
@thebiltheory
Mar 28 2016 15:46
Mmmh
Matthew Fricker
@mattfricker
Mar 28 2016 15:47
@thebiltheory When you do Array.prototype, you are looking explicitly on the array's prototype
Bil
@thebiltheory
Mar 28 2016 15:48
@mattfricker Sank uuuu
@mattfricker here brownies. Thanks!
CamperBot
@camperbot
Mar 28 2016 15:48
thebiltheory sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 51 | @mattfricker | http://www.freecodecamp.com/mattfricker
Brendan Kinahan
@BKinahan
Mar 28 2016 15:49
@thebiltheory compare the output of
[].hasOwnProperty('slice'); and
Array.prototype.hasOwnProperty('slice');
Bil
@thebiltheory
Mar 28 2016 15:49
wait
BKinahan @BKinahan waits
Jiimms
@jiimms
Mar 28 2016 15:52
how do we get this msg in blue?
BKinahan @BKinahan stops waiting
Jiimms
@jiimms
Mar 28 2016 15:55
I have completed the random quote generator with an array of quotes and now I have to add what i have seen here in other projects where you get the quotes from another website. Can some kind person here please point me towards the right resource to learn that functionality. I am not even sure what it is called.
pgjones72
@pgjones72
Mar 28 2016 15:55
here's variation 36.7
function lookUp(firstName, prop){
// Only change code below this line

for(var key in contacts){
if(contacts[key]["firstName"] === firstName && contacts[key]["firstName"]["prop"] !== " ") {
return contacts[key]["firstName"]["prop"];
}

else if(contacts[key]["firstName"] !== firstName){
return "No such contact";
}
else {
return "No such property";
}

}
// Only change code above this line
}
Marouane
@GacMarouan
Mar 28 2016 15:56
@jiimms you can try http://quotesondesign.com/
Bil
@thebiltheory
Mar 28 2016 15:56
@BKinahan why does prototype return true
I need to digg in this prototype thing
Jiimms
@jiimms
Mar 28 2016 15:58
@GacMarouan Thanks. That site has quotes. I want to learn how to add those quotes to my quote generator. so I was hoping for some learning resource where I can understand this.
CamperBot
@camperbot
Mar 28 2016 15:58
jiimms sends brownie points to @gacmarouan :sparkles: :thumbsup: :sparkles:
:star: 274 | @gacmarouan | http://www.freecodecamp.com/gacmarouan
Markus Kiili
@Masd925
Mar 28 2016 16:00
@thebiltheory All arrays inherit array methods from Array.prototype.
Bil
@thebiltheory
Mar 28 2016 16:01
@Masd925 Which is I assume predefined in the js core … ( I haven’t done my homework on this yet )
Steve Stout
@jessebae
Mar 28 2016 16:03

This is tougher for me than I expected. The parameter for the function checks for a property. If there is one it should return the property. I expect that checkProp would hold the value of the property checked. My condition inside the functions check to see if myObj has a property. Am I wrong in this?? I'm still not getting the return of the properties. // Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {

if (myObj.hasOwnProperty === true) {
return checkProp;
}else{
}
}
// Test your code by modifying these values
checkObj("gift"); what am I doing wrong?

Markus Kiili
@Masd925
Mar 28 2016 16:03
@thebiltheory Yes, Array is a built in globally available object.
Bil
@thebiltheory
Mar 28 2016 16:03
@Masd925 Thanks pal!
CamperBot
@camperbot
Mar 28 2016 16:03
thebiltheory sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1245 | @masd925 | http://www.freecodecamp.com/masd925
JoshuaPP
@JoshuaPP
Mar 28 2016 16:04
Hi, can anyone help me with the "Find the longest word in a string" problem? Here is my code so far:
function findLongestWord(str) {

var wordSplit = str.split(" ");
var longest = 0;

for (var i = 0; i < wordSplit.length; i++) {
if (longest < wordSplit[i].length) {
longest = wordSplit[i];
}
}

return longest;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Bil
@thebiltheory
Mar 28 2016 16:04
help prototype
CamperBot
@camperbot
Mar 28 2016 16:04

# js Array prototype concat

The concat() method returns a new array comprised of the array on which it is called joined with the array(s) and/or value(s) provided as arguments.

JoshuaPP
@JoshuaPP
Mar 28 2016 16:05
It just returns the first word each time
Markus Kiili
@Masd925
Mar 28 2016 16:05
@JoshuaPP You are one .length short there.
JoshuaPP
@JoshuaPP
Mar 28 2016 16:05
Return longest.length
Just returns 3
Markus Kiili
@Masd925
Mar 28 2016 16:06
@JoshuaPP longest = wordSplit[i].length;
JoshuaPP
@JoshuaPP
Mar 28 2016 16:06
But
That worked... but i dont understand why
Bil
@thebiltheory
Mar 28 2016 16:07
is FCC down?
JoshuaPP
@JoshuaPP
Mar 28 2016 16:07
Surely if I just assign longest = wordSplit[i]
then return longest.length its the same @Masd925
Markus Kiili
@Masd925
Mar 28 2016 16:08
@JoshuaPP No, because you are comparing longest earlier.
@JoshuaPP If you change it everywhere it will work.
JoshuaPP
@JoshuaPP
Mar 28 2016 16:08
OHHHH
once longest is assigned the word 'the' the comparison doesn't work when it loops again
that's why it was stopping for the first word each time?
I think I understand... even if my explanation is poor
Thanks @Masd925
CamperBot
@camperbot
Mar 28 2016 16:09
joshuapp sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1246 | @masd925 | http://www.freecodecamp.com/masd925
Steve Stout
@jessebae
Mar 28 2016 16:11

This is tougher for me than I expected. The parameter for the function checks for a property. If there is one it should return the property. I expect that checkProp would hold the value of the property checked. My condition inside the functions check to see if myObj has a property. Am I wrong in this?? I'm still not getting the return of the properties. // Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {

if (myObj.hasOwnProperty === true) {
return checkProp;
}else{
}
}
// Test your code by modifying these values
checkObj("gift"); what am I doing wrong?

Brendan Kinahan
@BKinahan
Mar 28 2016 16:14
@jessebae checkProp == "gift" so you're just returning "gift"; instead return the value of the "gift" property within myObj (access it with bracket notation)
@jessebae but also hasOwnProperty() requires an argument itself: the property for which to check
Steve Stout
@jessebae
Mar 28 2016 16:15
Thanks. I may be spending the rest of my life solving this one ;-) So far just 3 or 4 hours.
Brendan Kinahan
@BKinahan
Mar 28 2016 16:16
@jessebae further, in the condition of an if statement, === true can be omitted since .hasOwnProperty() will evaluate to true or false anyway
@jessebae as another example, if (2>1 === true) can be simplified to if(2>1)
Steve Stout
@jessebae
Mar 28 2016 16:17
Yes, I can see that. Thanks
Not sure I understand this: so you're just returning "gift"; instead return the value of the "gift"
gift is the value of the object. what is the value of "the gift"?
Brendan Kinahan
@BKinahan
Mar 28 2016 16:19
@jessebae return checkProp;. checkProp is equal to "gift" because that's the argument passed in for that parameter. "gift" is the name of a property in myObj, but you should return its value, which is "pony"
Steve Stout
@jessebae
Mar 28 2016 16:20
Oh yeah, I see that. So checkProp is checking the object instead of the property??? I thought it was checking to see if each obj has a property
Brendan Kinahan
@BKinahan
Mar 28 2016 16:21
yup, check if the object has that property. if it does, return that property's value. If not, return "Not Found"
checkProp is just a variable for the property the function is checking for in this call
there's only one object to check: myObj
Steve Stout
@jessebae
Mar 28 2016 16:22
so what var holds the value of the property?
Brendan Kinahan
@BKinahan
Mar 28 2016 16:23
there isn't one, and you don't really need one. you can just return the value after accessing it using bracket notation
Steve Stout
@jessebae
Mar 28 2016 16:24
OK. Thanks! very helpful. Now back to the drawing board with this clarified version of the problem
Thanks @BKinahan
CamperBot
@camperbot
Mar 28 2016 16:24
jessebae sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1171 | @bkinahan | http://www.freecodecamp.com/bkinahan
darrynwu29
@darrynwu29
Mar 28 2016 16:37
hello --
i changed, myStr = "Hello World";
but didn't work
Lucky charm
@luckycharm223
Mar 28 2016 16:37
I can't get over this problem.. Can someone help me please.. This is the challenge https://www.freecodecamp.com/challenges/assignment-with-a-returned-value
darrynwu29
@darrynwu29
Mar 28 2016 16:38
nevermind
i got it, sorry
Jiimms
@jiimms
Mar 28 2016 16:41
@luckycharm223 you dont have to change anything in the function, just call the function with argument 7 like function(7) and assign the result to var provided
@mohamma548
Mar 28 2016 16:46
hey guys whats wrong with this code?????

function mutation(arr) {
if(arr.indexOf(arr)){
return true;

}

return false;

}

I could not find false
Lucky charm
@luckycharm223
Mar 28 2016 16:49
@jiimms I don't fully understand