27th
Feb 2016
matthew3454
@matthew3454
Feb 27 2016 00:00
@moigithub I attempted to add console.log() @demipixel, but the activity still won't pass.
function palindrome(str) {
// Good luck!

str = str.toLowerCase().replace(/[^a-z]/g,"");
console.log(str);
return str === str.split("").reverse().join("");
}

palindrome("eye");
demipixel
@demipixel
Feb 27 2016 00:00
what does it log?
matthew3454
@matthew3454
Feb 27 2016 00:00
palindrome?
demipixel
@demipixel
Feb 27 2016 00:00
Yeah, what is it logging in the console
matthew3454
@matthew3454
Feb 27 2016 00:01
"random string"?
demipixel
@demipixel
Feb 27 2016 00:01
that's what is says in your console?
matthew3454
@matthew3454
Feb 27 2016 00:01
no I don't know what to put inside of it.
demipixel
@demipixel
Feb 27 2016 00:02
console.log(str) should output it to your console
You can open the console by right-clicking the page, clicking "Inspect Element" and then click "Console"'
You can also click the little Circle with a slash through it to clear the console
matthew3454
@matthew3454
Feb 27 2016 00:03
@demipixel This is what it said:eye
(program):6 eye
2check-for-palindromes:6 eye
check-for-palindromes:6 racecar
check-for-palindromes:6 notapalindrome
check-for-palindromes:6 amanaplanacanalpanama
check-for-palindromes:6 neveroddoreven
check-for-palindromes:6 nope
check-for-palindromes:6 almostomla
check-for-palindromes:6 myageissiegaym
check-for-palindromes:6 eyeforofeye
check-for-palindromes:6
demipixel
@demipixel
Feb 27 2016 00:04
Okay
@Mahin2k
Feb 27 2016 00:04
@demipixel yea im working on it
demipixel
@demipixel
Feb 27 2016 00:04
@Mahin2k
Feb 27 2016 00:05
im still stuck
matthew3454
@matthew3454
Feb 27 2016 00:05
Okay. Can you tell me exactly what to do?
@demipixel
demipixel
@demipixel
Feb 27 2016 00:05
@matthew3454 You're excluding a type of character that you shouldn't be
press cntrl-enter and look at the answer that has an X on it on the left
And you might be able to figure it out
@Mahin2k Alright
matthew3454
@matthew3454
Feb 27 2016 00:06
@demipixel mmk
demipixel
@demipixel
Feb 27 2016 00:06
function idk(str) {
var arr = str.split(' ');
for (var i = 0; i < arr.length; i++) {

}
}
This is what you have so far, right @Mahin2k ?
@Mahin2k
Feb 27 2016 00:07
@demipixel yea
matthew3454
@matthew3454
Feb 27 2016 00:08
@demipixel There are no red x's on the code and the error bar just says true and /testing challenge/ when I push"Ctrl/Enter" the only thing left to do is: palindrome("1 eye for of 1 eye.") should return false.
demipixel
@demipixel
Feb 27 2016 00:08
@matthew3454 Yep, which means you're returning true
Why do you think it's returning true?
matthew3454
@matthew3454
Feb 27 2016 00:08
and?
demipixel
@demipixel
Feb 27 2016 00:08
Look at the log
It's outputting eyeforofeye
matthew3454
@matthew3454
Feb 27 2016 00:08
I'm not sure. What should I replace it with?
demipixel
@demipixel
Feb 27 2016 00:08
Which IS a palidrome
It's the numbers
matthew3454
@matthew3454
Feb 27 2016 00:09
@demipixel ?
demipixel
@demipixel
Feb 27 2016 00:09
.replace(/[^a-z]/g, "");
That removes all numbers
And keeps a-z
matthew3454
@matthew3454
Feb 27 2016 00:10
@demipixel oh I see.
demipixel
@demipixel
Feb 27 2016 00:10
@Mahin2k Okay, so
For each one, we need to say "set the first character to uppercase"
@Mahin2k
Feb 27 2016 00:11
@demipixel yes
demipixel
@demipixel
Feb 27 2016 00:11
There's a few way we can do this
Do you want to know the long way first or do you just want to skip to the short way
@Mahin2k
Feb 27 2016 00:11
@demipixel long first
demipixel
@demipixel
Feb 27 2016 00:11
Okay, well
In order to access the first character, what we can do is make a second array
like
var arr2 = arr[i].split("");
This means if we have "teapot" that'll be converted into:
["t", "e", "a", "p", "o", "t"]
So if you have this, how would you set the first letter to be uppercase?
@Mahin2k
Feb 27 2016 00:13
@demipixel i dont want to do that
whats the short way?
demipixel
@demipixel
Feb 27 2016 00:13
hahaha
Norman Dela Cruz
@dcnr
Feb 27 2016 00:13
lol
demipixel
@demipixel
Feb 27 2016 00:13
It's like two extra lines
alpox
@alpox
Feb 27 2016 00:14
Anyone made spinal tap case? :D
I wonder why there are never questions about that ^^
demipixel
@demipixel
Feb 27 2016 00:14
The short way is to access the character immediately using
arr[i][0]
Norman Dela Cruz
@dcnr
Feb 27 2016 00:14
@alpox it's fairly easy with regex
alpox
@alpox
Feb 27 2016 00:14
@dcnr Yes it is but i see some people here which don't get regex, so i wonder why no questions are coming up
@dcnr Well i wonder how the regex of other people looks like for it
demipixel
@demipixel
Feb 27 2016 00:15
bf Spinal Tap
CamperBot
@camperbot
Feb 27 2016 00:15

## :fire:Bonfire: Spinal Tap Case :link:

function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
return str;
}

spinalCase('This Is Spinal Tap');

Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.

more info:  bf details | bf links | hint

demipixel
@demipixel
Feb 27 2016 00:15
Regex...?
@Mahin2k
Feb 27 2016 00:15
@demipixel but if i access one at a time then it wouldn't be automatic
alpox
@alpox
Feb 27 2016 00:15
@demipixel /[^a-z]/g was a regex
demipixel
@demipixel
Feb 27 2016 00:16
@Mahin2k No, the loop goes through, so i changes each time to be the word you're on
You're manually saying "I want the 0th element to be uppercase"
And it's always the 0th element for every word
@Mahin2k
Feb 27 2016 00:16
oh ok
Norman Dela Cruz
@dcnr
Feb 27 2016 00:16
@alpox you don't need regex for it too, but with it it's just return str.replace(/* pattern, sub */).toLowerCase()
demipixel
@demipixel
Feb 27 2016 00:16
um
Robert Richey
@0x0936
Feb 27 2016 00:16
I didn't consider spinal tap easy at all, with regex, because of dealing with camel case
demipixel
@demipixel
Feb 27 2016 00:16
return str.toLowerCase().split(' ').join('-');
????
alpox
@alpox
Feb 27 2016 00:17
@demipixel Wouldn't work that way :D there are not only white spaces
@demipixel "thisIsSpinalTap" hast to be split up too and joined with '-'
@demipixel "The_Andy_Griffith_Show" too
demipixel
@demipixel
Feb 27 2016 00:18
Uh
Is this one required for the certificate
alpox
@alpox
Feb 27 2016 00:18
"Teletubbies say Eh-oh" also a test case
No its not i see
demipixel
@demipixel
Feb 27 2016 00:18
Oh it is, but it's frontend
Hmmm
@Mahin2k
Feb 27 2016 00:18
@demipixel arr[i][0] returns cannot read property '0' of undefined
Norman Dela Cruz
@dcnr
Feb 27 2016 00:18
it's doable with one pattern but regex isn't really mandatory, you can do a for loop or what not lol
alpox
@alpox
Feb 27 2016 00:18
It is?
Okay maybe :D
@dcnr I have one too :D nice
demipixel
@demipixel
Feb 27 2016 00:19
alpox
@alpox
Feb 27 2016 00:19
@dcnr But i needed a look-forward pattern
Norman Dela Cruz
@dcnr
Feb 27 2016 00:19
@alpox I'll look at your profile solution :P
@Mahin2k
Feb 27 2016 00:19

@demipixel 
function titleCase(str) {
var arr = str.split(" ");

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

}
str.charAt(i);
arr[i][0].toUpperCase();
return str;

}

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



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

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

}
str.charAt(i);
arr[i][0].toUpperCase();
return str;

}

titleCase("I'm a little tea pot");
demipixel
@demipixel
Feb 27 2016 00:20
You have to put arr[i] inside the loop
Otavio J S Alves
@TatoAlves
Feb 27 2016 00:20
@alpox thank you very much
CamperBot
@camperbot
Feb 27 2016 00:20
tatoalves sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 161 | @alpox | http://www.freecodecamp.com/alpox
Norman Dela Cruz
@dcnr
Feb 27 2016 00:20
@alpox oh I see you used split but with backreferences and replace, you won't have to split and join :D
@Mahin2k
Feb 27 2016 00:20
@demipixel like this?
function titleCase(str) {
var arr = str.split(" ");

for (var i = 0; i < arr.length; i++) {
arr[i][0].toUpperCase();
}
str.charAt(i);

return str;

}

titleCase("I'm a little tea pot");
demipixel
@demipixel
Feb 27 2016 00:21
Okay, but that just returns a value
That won't actually make it upperCase
You have to say arr[i][0] = arr[i][0].toUpperCase()
alpox
@alpox
Feb 27 2016 00:22
@dcnr ah no? :D
demipixel
@demipixel
Feb 27 2016 00:22
You could do it without regex
Mmm, actually
Norman Dela Cruz
@dcnr
Feb 27 2016 00:23
@alpox yeah look at my pattern solution!
demipixel
@demipixel
Feb 27 2016 00:23
Yeah, you could
Norman Dela Cruz
@dcnr
Feb 27 2016 00:23
yeah don't have to use regex for it
matthew3454
@matthew3454
Feb 27 2016 00:24
@demipixel which regex do I need to use in return?
I mean as a replacement for js .replace(/[^a-z]/g, "");
alpox
@alpox
Feb 27 2016 00:24
@dcnr I see ^^
demipixel
@demipixel
Feb 27 2016 00:24
You need to include 0-9
matthew3454
@matthew3454
Feb 27 2016 00:24
How?
Norman Dela Cruz
@dcnr
Feb 27 2016 00:25
@matthew3454 You also need to add the number range so it wont remove numbers
@matthew3454 the same way you did the lowercase alphabet range
demipixel
@demipixel
Feb 27 2016 00:25
.replace(/[^a-z0-9]/g, "");
matthew3454
@matthew3454
Feb 27 2016 00:25
@dcnr oh okay I'tll give it a go
demipixel
@demipixel
Feb 27 2016 00:26
Regex like that is kind of weird, kinda something you just gotta know and its hard to "figure it out on your own"
matthew3454
@matthew3454
Feb 27 2016 00:26
@dcnr @demipixel Thank you. I love you
CamperBot
@camperbot
Feb 27 2016 00:26
matthew3454 sends brownie points to @dcnr and @demipixel :sparkles: :thumbsup: :sparkles:
:star: 734 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 41 | @demipixel | http://www.freecodecamp.com/demipixel
demipixel
@demipixel
Feb 27 2016 00:26
@matthew3454 I love you too <3
matthew3454
@matthew3454
Feb 27 2016 00:26
Oh how romantic
How much do you love me?
demipixel
@demipixel
Feb 27 2016 00:27
:thumbsdown:
Norman Dela Cruz
@dcnr
Feb 27 2016 00:27
:worried:
matthew3454
@matthew3454
Feb 27 2016 00:27
a;lsdfja;ojgaonjv;aflnbaeo;fae;rg!!!!!!!!!!
!!
demipixel
@demipixel
Feb 27 2016 00:27
;)
:zero:
Norman Dela Cruz
@dcnr
Feb 27 2016 00:27
:cake:
demipixel
@demipixel
Feb 27 2016 00:27
What am I doing with my life
Norman Dela Cruz
@dcnr
Feb 27 2016 00:27
helping people :D
matthew3454
@matthew3454
Feb 27 2016 00:28
YEAAAAAAAHHHHHHHHHHHH!!!!! WHOWOWHOWHOOOOOOOO!!!!!
demipixel
@demipixel
Feb 27 2016 00:28
Okay, now to do spinal case without any regex
Norman Dela Cruz
@dcnr
Feb 27 2016 00:28
hmmm
Paul Brown
@paulbwd
Feb 27 2016 00:28
Whats compose mode?
demipixel
@demipixel
Feb 27 2016 00:29
Let's you hit return without shift
Robert Richey
@0x0936
Feb 27 2016 00:29
@dcnr your regex for spinal tap is sorcery. I like it :+1:
alpox
@alpox
Feb 27 2016 00:31
I thought bit too far at it :D but its a two-liner though :D
Norman Dela Cruz
@dcnr
Feb 27 2016 00:32
@0x0936 lol thanks
CamperBot
@camperbot
Feb 27 2016 00:32
dcnr sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star: 1200 | @0x0936 | http://www.freecodecamp.com/0x0936
Norman Dela Cruz
@dcnr
Feb 27 2016 00:33
@paulbwd by using compose mode you don't have to do shift+enter to make a new line, but you have to do a ctrl+enter to send your chat message
@paulbwd you can toggle compose mode with ctrl + / or clicking the chat bubble thingy to the right
Paul Brown
@paulbwd
Feb 27 2016 00:34
ah does shift enter put you into compose mode?
as i always type the  then press shift enter and then ctrl enter to send
Norman Dela Cruz
@dcnr
Feb 27 2016 00:35
@paulbwd hmm I'm not sure :(
it doesn't happen to me
so far
Paul Brown
@paulbwd
Feb 27 2016 00:35
yes it does
the icon changes to compose mode
Norman Dela Cruz
@dcnr
Feb 27 2016 00:36
@paulbwd but
I've been using
shift enter
to type this
and I
don't change modes
Paul Brown
@paulbwd
Feb 27 2016 00:36
no after the three ticks
Norman Dela Cruz
@dcnr
Feb 27 2016 00:36
@paulbwd oooh yeah you're right!
J Lee
@SoYuMatic
Feb 27 2016 00:36
Question!!!
  var lookup = {
"bravo" : "Boston",
"charlie" : "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};

result = lookup[val];
// Why does result = lookup.val not work here???
Norman Dela Cruz
@dcnr
Feb 27 2016 00:37
@paulbwd but it switches back as soon as you send
thanks @paulbwd
CamperBot
@camperbot
Feb 27 2016 00:37
dcnr sends brownie points to @paulbwd :sparkles: :thumbsup: :sparkles:
:star: 285 | @paulbwd | http://www.freecodecamp.com/paulbwd
Paul Brown
@paulbwd
Feb 27 2016 00:37
yeah, cool :)
J Lee
@SoYuMatic
Feb 27 2016 00:37
is it because the keys are strings?
Paul Brown
@paulbwd
Feb 27 2016 00:37
thanks @dcnr
CamperBot
@camperbot
Feb 27 2016 00:37
paulbwd sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 735 | @dcnr | http://www.freecodecamp.com/dcnr
demipixel
@demipixel
Feb 27 2016 00:37
Ayyyyyyy
Norman Dela Cruz
@dcnr
Feb 27 2016 00:38
@SoYuMatic because by using the . notation, you're literally looking for that property name
demipixel
@demipixel
Feb 27 2016 00:38
Guess who just did spinal tap case without regex
Like a champ
Norman Dela Cruz
@dcnr
Feb 27 2016 00:38
ahah awesome! @demipixel
@SoYuMatic
var myObj = {
thePropertyName: "the Value";
};
• Using . you are directly using the property name itself
var result = myObj.thePropertyName; // the Value
• Using [] there are two ways:
1. Directly access by quoting the property name:
var result = myObj["thePropertyName"]; // the Value
2. Using a variable as property name by not quoting
var prop = "thePropertyName";
var result = myObj[prop]; // the Value
here prop is the variable that holds the name of your object property
Caleb Martin
@caleb272
Feb 27 2016 00:38
can someone help me with the where art thou problem
demipixel
@demipixel
Feb 27 2016 00:38
@dcnr
function spinalCase(str) {
return str.split('').map(c=>c=='_'||c==' '?'-':c).reduce((p,c,i)=>i!=0?(c==c.toUpperCase()&&c!='-'&&p[i-1]!='-'?p+'-'+c:p+c):p+c,'').toLowerCase();
}

spinalCase('This Is Spinal Tap');
@caleb272 sure
Caleb Martin
@caleb272
Feb 27 2016 00:39
i think I’m close but it just don’t work
function where(collection, source) {
var arr = [];

for (var c=0; c < collection.length; c++) {
var currentCollection = collection[c];

for (var k=0; k < Object.keys(currentCollection).length; k++) {
var collectionKey = currentCollection[Object.keys(currentCollection)[k]];

for (var s=0; s < Object.keys(source).length; s++) {
var currentSource = source[Object.keys(source)[s]];

for (var sk=0; sk < Object.keys(currentSource).length; sk++) {
var sourceKey = currentSource[Object.keys(currentSource)[sk]];

console.log(currentSource + "  " + currentKey);
if (collectionKey == currentSource) {
arr.push(currentCollection);
}

}
}
}
}

//return  [{ "a": 1, "b": 2 }, { "a": 1, "b": 2, "c": 2 }];
return arr;
}

where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
demipixel
@demipixel
Feb 27 2016 00:39
bf Where Art Thou
CamperBot
@camperbot
Feb 27 2016 00:39

## :fire:Bonfire: Where art thou :link:

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

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

MD Alsaffar
@Cyberistic
Feb 27 2016 00:39
help Write Reusable JavaScript with Functions
CamperBot
@camperbot
Feb 27 2016 00:39

# Write Reusable JavaScript with Functions

In JavaScript, we can divide up our code into reusable parts called functions.

Here's an example of a function:


function functionName() {
console.log("Hello World");
}

You can call or invoke this function by using its name followed by parentheses, like this:

functionName();

Each time the function is called it will print out the message "Hello World" on the dev console. All of the code between the curly braces will be executed every time the function is called.

Here is another example:
:pencil: read more about challenge write reusable javascript with functions on the FCC Wiki

demipixel
@demipixel
Feb 27 2016 00:39
That's a lot of loops inside each other...
Caleb Martin
@caleb272
Feb 27 2016 00:40
ya i know its bad practice but i can’t find any other way
i may have misunderstood the requirements
demipixel
@demipixel
Feb 27 2016 00:40
@caleb272 I see what you're trying to do
Caleb Martin
@caleb272
Feb 27 2016 00:40
am i supposed to check each variable with each variablee
demipixel
@demipixel
Feb 27 2016 00:41
Wait
You have to compare each item in the 2nd paramater
With each element in the first paramater
Norman Dela Cruz
@dcnr
Feb 27 2016 00:41
@demipixel that's awesome loool
Though I like formatting my conditional operators like so:
function spinalCase(str) {

return str
.split('')
.map(c => c == '_' || c == ' '
? '-'
: c)
.reduce((p, c, i) => i != 0
? (c == c.toUpperCase() && c != '-' && p[i - 1] != '-'
? p + '-' + c
: p + c)
: p + c, '')
.toLowerCase();
}

spinalCase('This Is Spinal Tap');
demipixel
@demipixel
Feb 27 2016 00:41
@dcnr I like to make hacks what they are: hacks
@Mahin2k
Feb 27 2016 00:41
@demipixel im still stuckk
demipixel
@demipixel
Feb 27 2016 00:41
I refuse to prettify my hacks
@Mahin2k
Feb 27 2016 00:41
function titleCase(str) {
var arr = str.split(" ");

for (var i = 0; i < arr.length; i++) {
arr[i][1] = arr[i][1].toUpperCase();
}
str.charAt(i);

return str;

}

titleCase("I'm a little tea pot");
Caleb Martin
@caleb272
Feb 27 2016 00:41
@demipixel are you talking to me
Norman Dela Cruz
@dcnr
Feb 27 2016 00:41
lol
demipixel
@demipixel
Feb 27 2016 00:42
Beauty is in the eye of the compactness
@caleb272 Okay, so
You need a for loop to go through each element in the first paramater
Caleb Martin
@caleb272
Feb 27 2016 00:42
k
demipixel
@demipixel
Feb 27 2016 00:42
Then you need a for loop for each key in the 2nd paramater
So you should only have two for-loops
Caleb Martin
@caleb272
Feb 27 2016 00:42
what is the source passed in for then
demipixel
@demipixel
Feb 27 2016 00:42
@Mahin2k Everything is 0-indexed so you'll want arr[i][0] actually
@caleb272 caleb is the second paramater
@Mahin2k
Feb 27 2016 00:43
@demipixel that doesnt work either
ive tried that
demipixel
@demipixel
Feb 27 2016 00:43
paramater = argument = whatever
@Mahin2k Errors?
@Mahin2k
Feb 27 2016 00:43
yeah
demipixel
@demipixel
Feb 27 2016 00:43
What's the error
Caleb Martin
@caleb272
Feb 27 2016 00:43
do i compare the whole object
@Mahin2k
Feb 27 2016 00:44
@demipixel it say cannot assign to read only property '0' of string 'I'm'
demipixel
@demipixel
Feb 27 2016 00:44
@caleb272 Oh, actually, you need 3 for loops
idk where your 4th is coming from
Caleb Martin
@caleb272
Feb 27 2016 00:44
i had 3 for loops and it was doing the first 2 tests right but it wouldn’t do the last 2
demipixel
@demipixel
Feb 27 2016 00:44
@Mahin2k Really?
@caleb272 lemme go back and look at your code
Caleb Martin
@caleb272
Feb 27 2016 00:45
k
demipixel
@demipixel
Feb 27 2016 00:45
Okay caleb
So you have a loop to go through each key in currentCollection
bitgrower
@bitgrower
Feb 27 2016 00:46
I did it with 2 loops ...
demipixel
@demipixel
Feb 27 2016 00:46
and each key in source
@Mahin2k
Feb 27 2016 00:46
@demipixel yes really
demipixel
@demipixel
Feb 27 2016 00:46
but currentCollection has a lot of extra keys we don't need
What if we only went through the keys in source?
For each key, we check to see if the object has the matching value for that key
bitgrower
@bitgrower
Feb 27 2016 00:46
if it's the challenge I think it is ?
demipixel
@demipixel
Feb 27 2016 00:47
@Mahin2k hmmmm
That's stupid
Caleb Martin
@caleb272
Feb 27 2016 00:47
so the first loop is for the collections first value
demipixel
@demipixel
Feb 27 2016 00:47
@Mahin2k
Feb 27 2016 00:48
@demipixel idk
Caleb Martin
@caleb272
Feb 27 2016 00:48
like so
for (var c=0; c<collection.length; c++) {}
Orestis Gklavas
@oglavas
Feb 27 2016 00:48
@Mahin2k Try to do your replacements with arr[i].charAt(0)
bitgrower
@bitgrower
Feb 27 2016 00:48
@Mahin2k -- you know you can toLowerCase or toUpperCase an entire string ... all at once, yes ?
demipixel
@demipixel
Feb 27 2016 00:48
@oglavas But you can't do arr[i].charAt(0) = ...
@bitgrower He only wants to do the first character
@caleb272 Yes, alright, that's correct
@Mahin2k
Feb 27 2016 00:49
@bitgrower but whats the point of that?
Orestis Gklavas
@oglavas
Feb 27 2016 00:50
@demipixel @Mahin2k You can combine it with replace() for example, from my solution: ara[i] = ara[i].replace(ara[i].charAt(0), (ara[i].charAt(0)).toUpperCase());
demipixel
@demipixel
Feb 27 2016 00:50
ew
bitgrower
@bitgrower
Feb 27 2016 00:50
well ... strings are immutable in js @mahin2k ... and I don't recall all the test cases, but some of them MIGHT have some uppercase characters in them ... so it would be a more general solution ...
Brian van Vlymen
@arduino731
Feb 27 2016 00:50
hi
Caleb Martin
@caleb272
Feb 27 2016 00:50

but this all comes back as undefined for (var c=0; c<collection.length; c++) {
var first = collection[c][0];

}

bitgrower
@bitgrower
Feb 27 2016 00:51
that is uppercase outside of the first character
Caleb Martin
@caleb272
Feb 27 2016 00:51
for (var c=0; c<collection.length; c++) {
var first = collection[c][0];

}
bitgrower
@bitgrower
Feb 27 2016 00:51
hi @arduino731
demipixel
@demipixel
Feb 27 2016 00:51
@caleb272 What is "first" suppose to contain?
collection[c] contains each element for whatever point you are in the loop
Caleb Martin
@caleb272
Feb 27 2016 00:51
the first of the collection
demipixel
@demipixel
Feb 27 2016 00:52
The first of the collection would be collection[0]
Caleb Martin
@caleb272
Feb 27 2016 00:52
each one so i can check it with source
demipixel
@demipixel
Feb 27 2016 00:52
Okay, think of it this way
The first loop is correct
Now, let's say we have another loop inside for each source
for (var c = 0; c < collection.length; c++) {
var currentCollection = collection[c];
for (var s = 0; s < source.length; s++) {

}
}
Waiiiiit
Nope, nvm
for (var c = 0; c < collection.length; c++) {
var currentCollection = collection[c];
for (var s = 0; s < Object.keys(source).length; s++) {

}
}
It is only two loops, I misinterpreted the problem by accident
@Mahin2k
Feb 27 2016 00:53
so how do i solve this?
bitgrower
@bitgrower
Feb 27 2016 00:53
...yeah, this is one of the test cases for Title Case: sHoRt AnD sToUt
@Mahin2k
Feb 27 2016 00:54
function titleCase(str) {
var arr = str.split(" ");

for (var i = 0; i < arr.length; i++) {
arr[i][1] = arr[i][1].toUpperCase();
}
str.charAt(i);

return str;

}

titleCase("I'm a little tea pot");
bitgrower
@bitgrower
Feb 27 2016 00:54

@Mahin2k ... solve the problem for just ONE word ...

...then you can create a loop to handle all of the words ...

demipixel
@demipixel
Feb 27 2016 00:54
@Mahin2k Do you know about map yet?
@caleb272 Let's think about it in english:
For each collection...
For each source key
if the key in the selected collection is the same as the key in the source, we're good
otherwise, we're just gonna give up
Orestis Gklavas
@oglavas
Feb 27 2016 00:56
@Mahin2k An idea would be to convert the input to lowercase and then convert the first letter in every word to uppercase
demipixel
@demipixel
Feb 27 2016 00:56
@oglavas That's what he's trying to do :P
@Mahin2k
Feb 27 2016 00:57
@demipixel exactly
Orestis Gklavas
@oglavas
Feb 27 2016 00:58
@demipixel @Mahin2k where is that, exactly? I can't see it in the code
bitgrower
@bitgrower
Feb 27 2016 00:58
you can't do this ... arri = arri.toUpperCase(); ... because, as I said, strings are immutable ... you can't change the string ...you can use a function which manipulates the string and puts it into a new variable ... but you cannot manipulate the contents of within arr[i], because it's a string ...
demipixel
@demipixel
Feb 27 2016 00:58
@bitgrower uuuuuuuuh
bitgrower
@bitgrower
Feb 27 2016 00:59
why do you think he's getting the read only errors, @demipixel
demipixel
@demipixel
Feb 27 2016 00:59
I guess you're right and I'm dumb
It's because my solution used map and I wasn't sure if map was at this part yet
However
bitgrower
@bitgrower
Feb 27 2016 01:00
probably not ... that's in the section on functional programming ...
Orestis Gklavas
@oglavas
Feb 27 2016 01:00
As I said, this worked for me, back when I did it:
ara[i] = ara[i].replace(ara[i].charAt(0), (ara[i].charAt(0)).toUpperCase());
demipixel
@demipixel
Feb 27 2016 01:00
You can do:
arr[i] = arr[i][0].toLowerCase() + arr[i].slice(...)
Caleb Martin
@caleb272
Feb 27 2016 01:00
okay i got this to knock off the first 2 but i have been here before
  for (var c = 0; c < collection.length; c++) {
var currentCollection = collection[c];

for (var s = 0; s < Object.keys(source).length; s++) {
var currentSourceKey = Object.keys(source)[0];

if (currentCollection[currentSourceKey] == source[currentSourceKey]) {
arr.push(currentCollection);
}
}
}
demipixel
@demipixel
Feb 27 2016 01:00
@oglavas Look at mine
Caleb Martin
@caleb272
Feb 27 2016 01:00
the last 2 don’t do it
demipixel
@demipixel
Feb 27 2016 01:00
@caleb272 You're really close
Okay, first, currentSourceKey
Caleb Martin
@caleb272
Feb 27 2016 01:00
i know i can feel it
demipixel
@demipixel
Feb 27 2016 01:01
You're always getting the 0th source key, you want the sth source key
Caleb Martin
@caleb272
Feb 27 2016 01:01
i have been here 3 times today and i can’t get past it
demipixel
@demipixel
Feb 27 2016 01:01
You're gonna get past it with me
Right now
You can do it
Okay, so currentSourceKey is always gonna contain the 0th key because you're doing Object.keys(...)[0]
Caleb Martin
@caleb272
Feb 27 2016 01:02
  for (var c = 0; c < collection.length; c++) {
var currentCollection = collection[c];

for (var s = 0; s < Object.keys(source).length; s++) {
var currentSourceKey = Object.keys(source)[0];

if (currentCollection[currentSourceKey] == source[currentSourceKey]) {
arr.push(currentCollection);
}
}
}
nop e
  for (var c = 0; c < collection.length; c++) {
var currentCollection = collection[c];

for (var s = 0; s < Object.keys(source).length; s++) {
var currentSourceKey = Object.keys(source)[s];

if (currentCollection[currentSourceKey] == source[currentSourceKey]) {
arr.push(currentCollection);
}
}
}
i mean thats what i had
demipixel
@demipixel
Feb 27 2016 01:03
Okay, we're almost there
Now, you're saying:
If the key in the source is equal to the key in the collection, add it to the "success" arr
Which is nearly what we want
But we want to say:
If all the keys in the source are equal to all the keys in the collection, add it to the "success" arr
Caleb Martin
@caleb272
Feb 27 2016 01:04
so i need another array
so im checking for keys not the value
?
demipixel
@demipixel
Feb 27 2016 01:06
Well
No, you don't need another array
But you can't push it to the success array as soon as you find one match
You need to wait until you've tested all the keys and THEN push it
Caleb Martin
@caleb272
Feb 27 2016 01:07
ya that would need another array
demipixel
@demipixel
Feb 27 2016 01:08
Why?
Caleb Martin
@caleb272
Feb 27 2016 01:08
to check all the keys
bitgrower
@bitgrower
Feb 27 2016 01:08
or, you can set a sentinel, @caleb272 ...
Caleb Martin
@caleb272
Feb 27 2016 01:08
what is that
bitgrower
@bitgrower
Feb 27 2016 01:08
actually, it's not a sentinel ... my bad ...
use a boolean ... to see if it's been found
demipixel
@demipixel
Feb 27 2016 01:08
^^^
In the first for-loop, make a "matching" variable and set it to true
Then, if you find a source key that does NOT match a collection key, set it to false
Caleb Martin
@caleb272
Feb 27 2016 01:09
k
demipixel
@demipixel
Feb 27 2016 01:09
If you made it through the keys loop without matching being set to false, you know it was a success
bitgrower
@bitgrower
Feb 27 2016 01:09
so ... for each member of the collection set found = true ... if you find one that isn't, set it to false ... after you go thru the whole loop, you see if it's found or not
demipixel
@demipixel
Feb 27 2016 01:09
If it is, false, you know there was a fail
Richard Corbett
@reacorbett
Feb 27 2016 01:11

is

var Person =  function(living, age, gender){

}

the same as

function Person(living, age, gender){

}

?

demipixel
@demipixel
Feb 27 2016 01:11
@reacorbett Basically yes
Caleb Martin
@caleb272
Feb 27 2016 01:11
  for (var c = 0; c < collection.length; c++) {
var currentCollection = collection[c];
var test = true;
for (var s = 0; s < Object.keys(source).length; s++) {
var currentSourceKey = Object.keys(source)[s];

if (currentCollection[currentSourceKey] != source[currentSourceKey]) {
test = false;
}
}

if (test) {
arr.push(currentCollection);
}
}
ok i think part of this is that i totally misunderstood the challenge i thought i had to check all the keys value with the second arguments key values
demipixel
@demipixel
Feb 27 2016 01:11
That looks correct sir
Caleb Martin
@caleb272
Feb 27 2016 01:11
i have to go thanks @demipixel and @bitgrower and yes it worked
CamperBot
@camperbot
Feb 27 2016 01:11
caleb272 sends brownie points to @demipixel and @bitgrower :sparkles: :thumbsup: :sparkles:
Richard Corbett
@reacorbett
Feb 27 2016 01:11
@demipixel
CamperBot
@camperbot
Feb 27 2016 01:11
:star: 646 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 42 | @demipixel | http://www.freecodecamp.com/demipixel
Richard Corbett
@reacorbett
Feb 27 2016 01:12
thanks
@demipixel thanks
CamperBot
@camperbot
Feb 27 2016 01:12
reacorbett sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles:
:star: 43 | @demipixel | http://www.freecodecamp.com/demipixel
bitgrower
@bitgrower
Feb 27 2016 01:12
reading is an important part of the challenges !!!
demipixel
@demipixel
Feb 27 2016 01:12
@caleb272 @reacorbett np
Caleb Martin
@caleb272
Feb 27 2016 01:12
i totally misunderstood the challenge maybe i will try the convert it to english trick to better understand the challenges for now on
gtg i will be back in 4 hours to hack the next one together
bitgrower
@bitgrower
Feb 27 2016 01:13
english trick ?
demipixel
@demipixel
Feb 27 2016 01:13
@bitgrower He means convert it to english so you can understand the problem
Explain what you're going to do in english without writing any code
CamperBot
@camperbot
Feb 27 2016 01:13
no wiki entry for: what youre going to do in english without writing any code
bitgrower
@bitgrower
Feb 27 2016 01:13
ahhh ...
demipixel
@demipixel
Feb 27 2016 01:14
Explain no wiki entry for: no wiki entry for: no wiki entry for: camperbot
CamperBot
@camperbot
Feb 27 2016 01:14
no wiki entry for: no wiki entry for no wiki entry for no wiki entry for camperbot
bitgrower
@bitgrower
Feb 27 2016 01:14
oh ... LOL ... they should teach that more here ...
Richard Corbett
@reacorbett
Feb 27 2016 01:14
Anyone having a hard time understanding javascript, I found a really good PDF book called " Javascript Enlightenment" by Cody Lindsey. He really breaks it down pretty good.
Its a light read, being under 200 pages.
Rami
@RNwebdk
Feb 27 2016 01:22
(shift+enter for line break) var myStr = "\\ backslast \t tab \t tab \r carriage-return \n newline"; // Change this line
what is wrong with this, it wont get through :(
bitgrower
@bitgrower
Feb 27 2016 01:23
what's the original string @RNwebdk
...or the instructions ?
Rami
@RNwebdk
Feb 27 2016 01:24
@bitgrower Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
bitgrower
@bitgrower
Feb 27 2016 01:25
okay ... so, backlash is a character, not a word ... you just need to escape the characters mentioned ...
Brian van Vlymen
@arduino731
Feb 27 2016 01:25
How would you do new tab in RegExp

var y = "We are the so-called /\t/Vikings from the north.";
bitgrower
@bitgrower
Feb 27 2016 01:26
@arduino731 -- are you wanting to put a tab inside a string ?
Rami
@RNwebdk
Feb 27 2016 01:26
oww u see... thx @bitgrower
CamperBot
@camperbot
Feb 27 2016 01:26
rnwebdk sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 647 | @bitgrower | http://www.freecodecamp.com/bitgrower
Brian van Vlymen
@arduino731
Feb 27 2016 01:26
@RNwebdk I have same thing challenge
@bitgrower yes make a tab for Vikings
bitgrower
@bitgrower
Feb 27 2016 01:27
@arduino731 -- there's regular expressions, and there are characters .. while there are character ... um, expressions, you can use in regular expressions ... using the character expressions doesn't need a regular expression ... a regex is used for pattern matching ...
@arduino -- so, you don't have to encapsulate it in the regexp delimiters of "/<reg expression>/" to use the character expression in a string ...
"this is a tab: \t" ... that's all you have to do ...
Brian van Vlymen
@arduino731
Feb 27 2016 01:30
for the changellenge is not need to be encapsulate it in the RegExp? hmm @bitgrower
Kris Tarling
@KrisTarling
Feb 27 2016 01:30
wow, you know your solution is highly efficient when you need to turn on // noprotect for it to pass!
bitgrower
@bitgrower
Feb 27 2016 01:30
\t <-- that is USED in regular expressions to represent tabs, but it, in itself, is not a regular expression ...
@KrisTarling ... really ?!?
what challenge are you looking at @arduino ?
@Mahin2k
Feb 27 2016 01:31
i still need help
Kris Tarling
@KrisTarling
Feb 27 2016 01:31
@bitgrower Yeah, this is what happens when you try to problem solve with glandular fever
bitgrower
@bitgrower
Feb 27 2016 01:31
well, where are ya at @Mahin2k
@Mahin2k
Feb 27 2016 01:31
function titleCase(str) {
var arr = str.split(' ');

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

return str;

}

titleCase("I'm a little tea pot");
bitgrower
@bitgrower
Feb 27 2016 01:32
@Mahin2k -- WHAT type is arr[i]
what is is pointing to ?
demipixel
@demipixel
Feb 27 2016 01:33
@bitgrower It's a string
bitgrower
@bitgrower
Feb 27 2016 01:33
hmm ... guess they must have changed it ... mine is more like @RNwebdk
demipixel
@demipixel
Feb 27 2016 01:33
Oh were you asking him lol
bitgrower
@bitgrower
Feb 27 2016 01:34
so -- do you understand what it means when we say a string is immutable ?
demipixel
@demipixel
Feb 27 2016 01:34
@Mahin2k I think the best way to do this is:
arr[i] = ...
Brian van Vlymen
@arduino731
Feb 27 2016 01:34
var myStr = "\\ backslash \t tab \t tab \r carriage-return \n newline";
bitgrower
@bitgrower
Feb 27 2016 01:34
@arduino731 -- see e comment I made to @RNwebdk
Rami
@RNwebdk
Feb 27 2016 01:36
@arduino731 \\ \t \t \r \n
do it like this
bitgrower
@bitgrower
Feb 27 2016 01:36
what @demipixel said ... you can change the ENTIRE contents of arr[i], but you cannot change a piece of a string ... you have to use functions which, in essence, copy the string, make changes to it in order to build a new string ...
Brian van Vlymen
@arduino731
Feb 27 2016 01:36
simple as like that @RNwebdk ?
demipixel
@demipixel
Feb 27 2016 01:37
@bitgrower Ya don't need the replace function
bitgrower
@bitgrower
Feb 27 2016 01:37
@arduino731 -- you don't need to put actual words into the string you are escaping ... you are only escaping the special characters
Rami
@RNwebdk
Feb 27 2016 01:37
@arduino731 yeah, i did a derp face as well :P
bitgrower
@bitgrower
Feb 27 2016 01:37
@demipixel -- for what? And where did I bring up the replace function, @demipixel
demipixel
@demipixel
Feb 27 2016 01:38
Oh maybe it was someone else
bitgrower
@bitgrower
Feb 27 2016 01:38
it WAS someone else ... I never brought it up
Brian van Vlymen
@arduino731
Feb 27 2016 01:38
one more question why is the tab encode is not working at all http://www.w3schools.com/js/tryit.asp?filename=tryjs_strings_escape
@RNwebdk @bitgrower
var y = "We are the so-called \tVikings from the north."
bitgrower
@bitgrower
Feb 27 2016 01:39
how do you know it is not ?
demipixel
@demipixel
Feb 27 2016 01:39
@bitgrower Somebody wanted to do @Mahin2k 's problem with:
arr[i] = arr[i].replace(arr[i].charAt(0), arr[i].charAt(0).toUpperCase());
Brian van Vlymen
@arduino731
Feb 27 2016 01:39
or /\t Vikings/
bitgrower
@bitgrower
Feb 27 2016 01:40
ugh, that looks painful, @demipixel
@arduino731 ... the forward slashs denote a regular expression ... a \t is NOT a regular expression ... it can be used in one, but it, itself, is NOT a regular expression ...
demipixel
@demipixel
Feb 27 2016 01:41
@bitgrower And it wouldn't work if you wanted to capitalize any other letter (2nd, 3rd, last, etc)
bitgrower
@bitgrower
Feb 27 2016 01:41
sure it would ... you'd just replace the 0's with a variable, set the variable to the index you desired...
demipixel
@demipixel
Feb 27 2016 01:42
@bitgrower No it wouldn't
Because it replace the first instance of that character
So if you put in "hhello"
And wanted to make the second letter capital
That code would make it "Hhello"
Brian van Vlymen
@arduino731
Feb 27 2016 01:43
@bitgrower ah I got now what is differenance RegExp and not
J Lee
@SoYuMatic
Feb 27 2016 01:43
o man, that was my solution too lol
demipixel
@demipixel
Feb 27 2016 01:43
Sry @SoYuMatic lol
Brian van Vlymen
@arduino731
Feb 27 2016 01:43
thanks @bitgrower :)
CamperBot
@camperbot
Feb 27 2016 01:43
arduino731 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 648 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 27 2016 01:44
LOL ... I'd have to think about that one a bit @demipixel ... but I've been running a fever so I'm not exactly in the best thinking state ...
demipixel
@demipixel
Feb 27 2016 01:44
The reason it bothers me a bit is because it takes advantage of the fact that .replace (without regex) always replaces the first instance
So if you wanted to do the exact same thing but for the last letter, it wouldn't work
Even though that's just a big if because you don't actually have to
Rami
@RNwebdk
Feb 27 2016 01:44
var test = "Give me a black box in the chat ?"
bitgrower
@bitgrower
Feb 27 2016 01:44
yeah ... that sounds about right -- I am not as familiar with replace ... though I am with regexes ... but in different contexts
Rami
@RNwebdk
Feb 27 2016 01:45
oww thats how it works :)
bitgrower
@bitgrower
Feb 27 2016 01:45
congrats, @RNwebdk
J Lee
@SoYuMatic
Feb 27 2016 01:45
couldn't you use shift @demipixel ??
Rami
@RNwebdk
Feb 27 2016 01:45
yeah, thx LOL!
J Lee
@SoYuMatic
Feb 27 2016 01:45
or pop.. whichever, i forgot
demipixel
@demipixel
Feb 27 2016 01:45
It's pop
bitgrower
@bitgrower
Feb 27 2016 01:45
on a string, @SoYuMatic ... nope
demipixel
@demipixel
Feb 27 2016 01:45
^^
Personally, I would prefer:
arr[i] = arr[i][0].toUpperCase() + arr[i].slice(1);
bitgrower
@bitgrower
Feb 27 2016 01:46
that's why all your string operations have to be set to a variable ... unlike the various array methods ...
@demipixel -- makes sense ...
demipixel
@demipixel
Feb 27 2016 01:47
And backwards:
arr[i] = arr[i].slice(0, arr[i].length-1) + arr[i][arr[i].length-1];
A bit less clean but still the same idea nonetheless
bitgrower
@bitgrower
Feb 27 2016 01:47
however, as I pointed out earlier ... some of the test cases have mixed case, so you'd need to lower case the rest of the word ... :)
demipixel
@demipixel
Feb 27 2016 01:47
arr[i] = arr[i][0].toUpperCase() + arr[i].slice(1).toLowerCase();
Done
I think that's my solution
Norman Dela Cruz
@dcnr
Feb 27 2016 01:48
or lower case the whole string first so it's just one operation rather than 1 for each word
demipixel
@demipixel
Feb 27 2016 01:48
Except using a map instead of a for loop
bitgrower
@bitgrower
Feb 27 2016 01:48
yeah ... you're probably intimidating the hell out of a lot of newbies around here, @demipixel
demipixel
@demipixel
Feb 27 2016 01:48
@bitgrower I was hoping no one was paying attention ;)
I'll hush hush now
@dcnr It is only one operation for each word...?
bitgrower
@bitgrower
Feb 27 2016 01:49
a few weeks ago Quincy said they had 2000 new campers every day ... :) it's amazing how many people are here ...listening ... not jumping in ...
demipixel
@demipixel
Feb 27 2016 01:49
I think the reddit post helped boost a lot recently
bitgrower
@bitgrower
Feb 27 2016 01:49
@dcnr -- I like that ...
J Lee
@SoYuMatic
Feb 27 2016 01:49
I am stuck on this json object thing..
bitgrower
@bitgrower
Feb 27 2016 01:50
@demipixel -- this was before they created the sub-reddit ... think it was based mostly on being the most active github project
Norman Dela Cruz
@dcnr
Feb 27 2016 01:50
@demipixel that's one extra toLowerCase() per word, whereas if you do it on the entire string first, then you wouldn't have that one extra function per word
bitgrower
@bitgrower
Feb 27 2016 01:50
^^^^^ I like it @dcnr ... :)
Robert Richey
@0x0936
Feb 27 2016 01:50
:cake:
demipixel
@demipixel
Feb 27 2016 01:50
@bitgrower No, there was a really popular post from /r/learnprogramming that a lot of people in FreeCodeCamp said they were coming from
@dcnr There's only one toLowerCase()...?
Norman Dela Cruz
@dcnr
Feb 27 2016 01:50
@demipixel but it's ran once per word?
bitgrower
@bitgrower
Feb 27 2016 01:51
ack
demipixel
@demipixel
Feb 27 2016 01:51
@dcnr The first one is toUpper
@bitgrower lol
I know this would be abused a lot
J Lee
@SoYuMatic
Feb 27 2016 01:52
If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
if (value !=="" && prop !=== "tracks") {
id[prop];}
bitgrower
@bitgrower
Feb 27 2016 01:52
@demipixel -- I've not heard anyone come in here and say they learned about FCC from /r/learnprogramming ... so I couldn't really say, I have no reference ... I have heard many others mention where they've heard about it ... from friends, from sivers' site ... I think lifehacker ... but don't recall anyone saying anything about /r/learnprogramming or reddit ...
Norman Dela Cruz
@dcnr
Feb 27 2016 01:52
@demipixel lol, I was saying that if you lowercase the entire string, you wouldn't have to lowercase the rest of the word. And since we are working word by word, that would be "uppercase first letter, lowercase the rest, concat" rather than "uppercase, concat"
demipixel
@demipixel
Feb 27 2016 01:52
But what if @camperbot could run code
J Lee
@SoYuMatic
Feb 27 2016 01:52
no? no way..
demipixel
@demipixel
Feb 27 2016 01:52
@bitgrower Just in like the last day or two
J Lee
@SoYuMatic
Feb 27 2016 01:53
that is gibberish right?
bitgrower
@bitgrower
Feb 27 2016 01:53
@demipixel -- see the activity sidebar to the right ?
demipixel
@demipixel
Feb 27 2016 01:53
yeah?
J Lee
@SoYuMatic
Feb 27 2016 01:53
I did re-join after the sub-reddit and new js challenges came up
bitgrower
@bitgrower
Feb 27 2016 01:53
ban ban ban ban ban ... been like that since I've joined gitter ...
J Lee
@SoYuMatic
Feb 27 2016 01:53
cuz i remember the algorithms kicking my ass cuz so many concepts flew out of nowhere
bitgrower
@bitgrower
Feb 27 2016 01:54
YAY !!!! MDN!!!!
demipixel
@demipixel
Feb 27 2016 01:54
@dcnr ???????
function ayy(str) {
str.split(' ').map(word=>word[0].toUpperCase() + word.slice(1).toLowerCase()).join(' ');
}
I mean, you can do .toLowerCase() at the start before the split, but I don't think it really matters
@SoYuMatic Was that a question about the tracks thing?
Norman Dela Cruz
@dcnr
Feb 27 2016 01:55
@demipixel why won't it matter? you are lowercasing PER WORD, rather just once, before the split
Robert Richey
@0x0936
Feb 27 2016 01:55
I think what dcnr is getting at is time complexity. big O stuff
demipixel
@demipixel
Feb 27 2016 01:55
@dcnr Good point
bitgrower
@bitgrower
Feb 27 2016 01:55
so @0x0936 how do you tell how many peeps are in the room .. as opposed to how many are active ?
demipixel
@demipixel
Feb 27 2016 01:55
I meant it's the same number of characters
J Lee
@SoYuMatic
Feb 27 2016 01:56
if (value !=="" && prop !=== "tracks") {
id[prop];} that's my... pseudo code? ish?
demipixel
@demipixel
Feb 27 2016 01:56
I think that's where the confusion came in
J Lee
@SoYuMatic
Feb 27 2016 01:56
"wtf is going on" is what i'm asking lol
demipixel
@demipixel
Feb 27 2016 01:56
@SoYuMatic id[prop] doesn't do anythng
That's like saying "My dog exists. Okay."
Norman Dela Cruz
@dcnr
Feb 27 2016 01:56
@SoYuMatic you have one extra = with "track" too :P
demipixel
@demipixel
Feb 27 2016 01:56
nvm
J Lee
@SoYuMatic
Feb 27 2016 01:56
hard type vs equality?
demipixel
@demipixel
Feb 27 2016 01:57
@SoYuMatic
== to !=
=== to !==
The ! replaces one of the equals
Norman Dela Cruz
@dcnr
Feb 27 2016 01:57
@demipixel !=== is a syntax error...
Robert Richey
@0x0936
Feb 27 2016 01:57
@bitgrower hover the checkmark on the right side of any post to see who has read it. it's good enough to give a ballpark figure, though it's also possible for people to be in room without having joined or 'read' the post. I don't know what multiplier you might apply to adjust for this - perhaps an order of magnitude
demipixel
@demipixel
Feb 27 2016 01:57
@dcnr Don't embarass me in front of everyone, that's why I edited my message :3
Norman Dela Cruz
@dcnr
Feb 27 2016 01:58
lol
demipixel
@demipixel
Feb 27 2016 01:58
Now they'll never believe I'm a good coder *runs off*
J Lee
@SoYuMatic
Feb 27 2016 01:58
O! Well I forgot that that lil bit, right-p
Norman Dela Cruz
@dcnr
Feb 27 2016 01:58
@0x0936 the most I've seen that read by is around 15 or so :(
J Lee
@SoYuMatic
Feb 27 2016 01:58
so if I want the prop argument/parameter to be id.prop ...
bitgrower
@bitgrower
Feb 27 2016 01:59
thanks, @0x0936
CamperBot
@camperbot
Feb 27 2016 01:59
bitgrower sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
J Lee
@SoYuMatic
Feb 27 2016 01:59
the "prop" arg/para to be id["prop"] ...
CamperBot
@camperbot
Feb 27 2016 01:59
:star: 1201 | @0x0936 | http://www.freecodecamp.com/0x0936
bitgrower
@bitgrower
Feb 27 2016 01:59

Now they'll never believe I'm a good coder *runs off*

Humility is an admirable trait in a coder ... :)

demipixel
@demipixel
Feb 27 2016 01:59
@SoYuMatic
item[prop] = value
Norman Dela Cruz
@dcnr
Feb 27 2016 02:00
@bitgrower what no! it's a dog eat dog world out there! :smiling_imp:
demipixel
@demipixel
Feb 27 2016 02:00
what about dog eat dog eat dog?

'dog eat '.repeat(1000)+'dog'

??

Norman Dela Cruz
@dcnr
Feb 27 2016 02:00
$x eat y eat z$
demipixel
@demipixel
Feb 27 2016 02:00
Life's greatest mysteries
Anyway, do you think a "runcode" function of @camperbot would get abused?
Robert Richey
@0x0936
Feb 27 2016 02:01
yes
Norman Dela Cruz
@dcnr
Feb 27 2016 02:01
always
bitgrower
@bitgrower
Feb 27 2016 02:01
ditto what @0x0936 said
Robert Richey
@0x0936
Feb 27 2016 02:01
ditto @bitgrower :)
demipixel
@demipixel
Feb 27 2016 02:01
Assuming it had a max output of like 5 lines
bitgrower
@bitgrower
Feb 27 2016 02:01
not to mention what a wonderful way to spread malware it would be ...
demipixel
@demipixel
Feb 27 2016 02:02
Just eval with a limited scope...?
bitgrower
@bitgrower
Feb 27 2016 02:02
(and yes, you can distribute malware in one line ... )
Robert Richey
@0x0936
Feb 27 2016 02:02
someone had a bot that could eval in main chat a while back
demipixel
@demipixel
Feb 27 2016 02:02
You can make eval secure ya know
J Lee
@SoYuMatic
Feb 27 2016 02:02
How long have you guys been coding? I'm curious
demipixel
@demipixel
Feb 27 2016 02:03
Wait wrong one
bitgrower
@bitgrower
Feb 27 2016 02:03
not exactly seeing hoards of folks clamoring for one ...
bitgrower @bitgrower has the words of Rolling Stones Sympathy for the Devil rolling thru her mind ...
Norman Dela Cruz
@dcnr
Feb 27 2016 02:04
lots of people don't even know/bother formatting code, and I think most people here come for the front end matters
Robert Richey
@0x0936
Feb 27 2016 02:04
@SoYuMatic i'm at the start of year 4 - mostly academic and very sporadic. mostly as a hobbyist trying to go pro
demipixel
@demipixel
Feb 27 2016 02:04
In reality, you can avoid exploits by calling something like the iodene api
dcnr @dcnr slaps @camperbot around a bit with a large trout
demipixel
@demipixel
Feb 27 2016 02:04
Which will run any code you give it
J Lee
@SoYuMatic
Feb 27 2016 02:04
You don't think you could go pro right now?
Norman Dela Cruz
@dcnr
Feb 27 2016 02:04
thanks @camperbot
CamperBot
@camperbot
Feb 27 2016 02:04
dcnr sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1263 | @camperbot | http://www.freecodecamp.com/camperbot
J Lee
@SoYuMatic
Feb 27 2016 02:05
you can't get a job with your knowledge? =[ That's so daunting for me to hear
bitgrower @bitgrower sends @demipixel to the fbi to decode the terrorist's iPhone ...
Robert Richey
@0x0936
Feb 27 2016 02:05
@SoYuMatic focus on the sporadic part of my response ;p
demipixel
@demipixel
Feb 27 2016 02:06
5+ years, past the point where FCC isn't gonna be very useful for me but I'm happy to help out
Norman Dela Cruz
@dcnr
Feb 27 2016 02:06
@SoYuMatic eh it applies to many fields :(
José
@Ledjez
Feb 27 2016 02:06

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
arr = [
[1,2],[3,4],[5,6]
];
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i].length; j++)
product += i * j;
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);

can someone help me figure this out?

demipixel
@demipixel
Feb 27 2016 02:06
@Ledjez
bitgrower
@bitgrower
Feb 27 2016 02:06
@SoYuMatic -- there are many parts which go into getting a job ... not all of them are about technical competence ...
demipixel
@demipixel
Feb 27 2016 02:06
help format
CamperBot
@camperbot
Feb 27 2016 02:06

## :point_right: code formatting [wiki]

### Inline code

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

### Code Block

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

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

J Lee
@SoYuMatic
Feb 27 2016 02:06
I.. I can draw pretty things...
...
Robert Richey
@0x0936
Feb 27 2016 02:06
@SoYuMatic if you can be disciplined and show that you know how to learn something new in a ever changing environment, you will always be hirable
J Lee
@SoYuMatic
Feb 27 2016 02:07
I have a strange internship right now, I am part of a dev team as .. sort of a project manager??
bitgrower
@bitgrower
Feb 27 2016 02:07
people will look at the salaries programmers get ... but .... programmers rarely work 9-5
demipixel
@demipixel
Feb 27 2016 02:07
@Ledjez i and j are indexes, not actual values of the arrays
bitgrower
@bitgrower
Feb 27 2016 02:07
project management is an excellent field to get into ...
J Lee
@SoYuMatic
Feb 27 2016 02:08
but i really wanna code well and some of these guys have HUGE experience
demipixel
@demipixel
Feb 27 2016 02:08
Wish I was at an internship right now ;_;
Hoping to get one this summer
J Lee
@SoYuMatic
Feb 27 2016 02:08
but I am so in over my head
bitgrower
@bitgrower
Feb 27 2016 02:08
programming in general: you know a WHOLE lot about a tiny little bit of a project
@demipixel -- plenty around you to be had ...
demipixel
@demipixel
Feb 27 2016 02:08
@bitgrower Ehhhhh
J Lee
@SoYuMatic
Feb 27 2016 02:09
like.. last 2 months or so.. I had to learn how to set up Vagrant and Vbox with ubuntu trusty etc etc without knowing wtf I'm really doing, then using shell scripts to do things that.. I once again hav eno clue about..
demipixel
@demipixel
Feb 27 2016 02:09
Like I've said elsewhere, these facebook internships and what not what rising sophmores in college
J Lee
@SoYuMatic
Feb 27 2016 02:09
i just like opening up styles.css, hunting down classes, and applying css to things
bitgrower
@bitgrower
Feb 27 2016 02:09
I don't understand what that means ... @demipixel
J Lee
@SoYuMatic
Feb 27 2016 02:09
it's easier and soothing lolol
demipixel
@demipixel
Feb 27 2016 02:09
Most embarassing mispelling of sophmores in my life
@bitgrower i.e. they want people who are getting their bachelor's in CS and are going to be a sophomore next year
bitgrower
@bitgrower
Feb 27 2016 02:10
hmmm ... perhaps ...
J Lee
@SoYuMatic
Feb 27 2016 02:10
yeah cuz when I was in college, we didn't really learn programming this way at all.
bitgrower
@bitgrower
Feb 27 2016 02:10
Norman Dela Cruz
@dcnr
Feb 27 2016 02:10
@SoYuMatic you can web dev without knowing the language as long as you know how to use the frameworks, and that's what usually happens. People learn to use a framework rather than the language
and it works!
demipixel
@demipixel
Feb 27 2016 02:11
@bitgrower ??
J Lee
@SoYuMatic
Feb 27 2016 02:11
I guess I'm surrounded by puritans. I saw my first true javascript doc.ready function! not the jQuery one just today!
Robert Richey
@0x0936
Feb 27 2016 02:11
window.onload = function() { /* stuff */}; ?
bitgrower
@bitgrower
Feb 27 2016 02:11
you have a pre-conception about who they want ... and who they are wiling to hire ... having been on the hiring end, you might be surprised ...
J Lee
@SoYuMatic
Feb 27 2016 02:11
yeah
stuff
Norman Dela Cruz
@dcnr
Feb 27 2016 02:12
I for one advocate VanillaJS, it's an awesome lib
Vanilla JS is a fast, lightweight, cross-platform framework
for building incredible, powerful JavaScript applications.
J Lee
@SoYuMatic
Feb 27 2016 02:12
well, my agency uses a lot of wordpress/php and... yeah...
demipixel
@demipixel
Feb 27 2016 02:12
I've never used yeah before
I've heard it's good
J Lee
@SoYuMatic
Feb 27 2016 02:13
It's too hard, syntax is a nightmare
demipixel
@demipixel
Feb 27 2016 02:13
y ea = yeah
if yah == yeh + yeeee:
yeah
else:
no
I would agree with that statement
bitgrower
@bitgrower
Feb 27 2016 02:14
g'night ... gonna go rest up and see if my body can cure whatever ails me ...
demipixel
@demipixel
Feb 27 2016 02:14
@bitgrower You've been on the hiring end?
Oh darn
Robert Richey
@0x0936
Feb 27 2016 02:14
@bitgrower that's probably my biggest hold up is impostor syndrome. I never really feel ready.
Norman Dela Cruz
@dcnr
Feb 27 2016 02:14
@bitgrower g'night! getwell soon~~ thanks for dropping by
CamperBot
@camperbot
Feb 27 2016 02:14
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 649 | @bitgrower | http://www.freecodecamp.com/bitgrower
Robert Richey
@0x0936
Feb 27 2016 02:14
good night @bitgrower
demipixel
@demipixel
Feb 27 2016 02:15
well I g2g to dinner
cya guys
J Lee
@SoYuMatic
Feb 27 2016 02:15
@dcnr I just went in saying I know nothing. They call me Jon Snow, but I'll work hard and I am from GaTech
Robert Richey
@0x0936
Feb 27 2016 02:15
cya demi
bitgrower
@bitgrower
Feb 27 2016 02:15
oh dang, you had to do that, didn't you, @dcnr ...
J Lee
@SoYuMatic
Feb 27 2016 02:15
they put me on a phone call with a client, I was like.. derp? What's our scope of work etc... froze up.. and then just did css
bitgrower
@bitgrower
Feb 27 2016 02:15
now I want to hang around for another brownie point ... I like round numbers ...
Robert Richey
@0x0936
Feb 27 2016 02:16
thanks @bitgrower
CamperBot
@camperbot
Feb 27 2016 02:16
0x0936 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 650 | @bitgrower | http://www.freecodecamp.com/bitgrower
J Lee
@SoYuMatic
Feb 27 2016 02:16
thanks @bitgrower
CamperBot
@camperbot
Feb 27 2016 02:16
soyumatic sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
J Lee
@SoYuMatic
Feb 27 2016 02:16
lol!
CamperBot
@camperbot
Feb 27 2016 02:16
:star: 651 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 27 2016 02:16
LOL ... yeah, iif you want to impress employers -- know their company & their projects ...
research 'em before you ever talk to them ...
we turned down an MIT grad because they had a misconception of what our company did ...
@SoYuMatic -- and you can also ask THEM questions ...
J Lee
@SoYuMatic
Feb 27 2016 02:18
but I wanna have some chops and a proper portfolio..
José
@Ledjez
Feb 27 2016 02:18
@demipixel so how do i get the value of the array? i guess i forgot
J Lee
@SoYuMatic
Feb 27 2016 02:18
sure I can make a wordpress site but... u know, that's really nothing.
bitgrower
@bitgrower
Feb 27 2016 02:18
you are in a negotiations ... client has something they want done ... many times they've probably been told what to ask, look for ... @Ledjez
array = [1.2.3.4];
newVar = array[0];
@SoYuMatic -- it's a matter of determining if you can fulfill the client's needs ... be reasonably enjoyable to work with, be reliable ...
J Lee
@SoYuMatic
Feb 27 2016 02:20
I can do part 2 and 3, people love me at work, even though I get paid in popcorn pretty much
bitgrower
@bitgrower
Feb 27 2016 02:21
anyway ... I'm outta here ... :) ... See if I can drop my fever ... :)
J Lee
@SoYuMatic
Feb 27 2016 02:22
get well soon
Robert Richey
@0x0936
Feb 27 2016 02:22
see ya bit
J Lee
@SoYuMatic
Feb 27 2016 02:38
When you delete an object property using delete.... what is delete?
is it a method/function or is it a statement? it's new to me and i was looking for it on MDN and couldn't find it
demipixel
@demipixel
Feb 27 2016 02:39
delete x
It's like: typeof x
idk why it isn't delete(x) but it isn't
Just pretend it's a built in function with a weird format
J Lee
@SoYuMatic
Feb 27 2016 02:47
So... on JSON objects name:value pairs
Strict type equality only?
function update(id, prop, value) {
if (value !=="" && prop !== "tracks") {
collection[id][prop] = value;}
if (prop === "tracks" && value !== "" ) {
collection[id].tracks.push(value);
}
if (value === ""){
delete collection[id][prop];}

return collection;
}
Robert Richey
@0x0936
Feb 27 2016 02:47
delete(obj.prop) does work. tested in dev console
J Lee
@SoYuMatic
Feb 27 2016 02:47
I solved that but there was no way I could have without all the hints from console.
demipixel
@demipixel
Feb 27 2016 02:49
@0x0936 No, I'm saying it SHOULD
The correct format is delete obj.prop
@SoYuMatic There are hints in console?
J Lee
@SoYuMatic
Feb 27 2016 02:50

well, errors like

 ReferenceError: tracks is not defined

when I removed the quotes from it etc

Norman Dela Cruz
@dcnr
Feb 27 2016 02:51
@SoYuMatic if you remove the quotes, then tracks would be considered a variable :P
J Lee
@SoYuMatic
Feb 27 2016 02:51

The JSON object contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON.

That statement from MDN...

demipixel
@demipixel
Feb 27 2016 02:51
@SoYuMatic That's called an error, that should appear in the side console. That's not a hint lol
J Lee
@SoYuMatic
Feb 27 2016 02:51
well, let's say I made a ton of errors figuring that one out
Robert Richey
@0x0936
Feb 27 2016 02:52
@demipixel I don't understand what you mean by should, when it does. delete obj.a is equivalent to delete(obj.a)
demipixel
@demipixel
Feb 27 2016 02:52
It's not
wait
dahell
Robert Richey
@0x0936
Feb 27 2016 02:52
seemed to work the same in the console. how are they different
demipixel
@demipixel
Feb 27 2016 02:53
wait what is the point of the space format then
Robert Richey
@0x0936
Feb 27 2016 02:53
alternate syntax. MDN only shows it with a space, but typeof, for example, also supports parens. typeof(var)
demipixel
@demipixel
Feb 27 2016 02:53
yeah
J Lee
@SoYuMatic
Feb 27 2016 02:53
so the JSON object ... when is it not Javascript? Isn't it a javascript notation by definition? When can JS not use JSON?
demipixel
@demipixel
Feb 27 2016 02:53
Well mmf
José
@Ledjez
Feb 27 2016 02:54

js function multiplyAll(arr) {
var product = 1;
// Only change code below this line
arr = [
[1,2],[3,4],[5,6],
];
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i].length; j++)
product = arr[i][j];

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

// Modify values below to test your code
multiplyAll([[5,1],[0.2,4,0.5],[3,9]]);


J Lee
@SoYuMatic
Feb 27 2016 02:54
i am having a hard time wrapping my head around it.
demipixel
@demipixel
Feb 27 2016 02:54
@SoYuMatic Okay, so
And JSON is a string format of that
1) When you can only send text (like a webpage for an API)
2) When you want to transfer data between languages
JSON is just text
Monty
@webdev8183
Feb 27 2016 02:55
Working on confirm the Ending, I think I am close to solving it, but I am stuck on the comparison piece when passing in more than a single character as the target value.
J Lee
@SoYuMatic
Feb 27 2016 02:55
so literally... a notation in the style of JS objects?
demipixel
@demipixel
Feb 27 2016 02:55
@webdev8183 Which problem?
@SoYuMatic I suppose, but
Monty
@webdev8183
Feb 27 2016 02:55

Check if a string (first argument) ends with the given target string (second argument).

String.substr()
demipixel
@demipixel
Feb 27 2016 02:55
Javascript isn't the only language that has arrays formatted like [] and objects as {}
Robert Richey
@0x0936
Feb 27 2016 02:56
@SoYuMatic json is a js object that has been turned into a string
demipixel
@demipixel
Feb 27 2016 02:56
So don't fool yourself into thing json is a js-only thing
@webdev8183 What's the name of it though
Monty
@webdev8183
Feb 27 2016 02:56
Confirm the Ending
demipixel
@demipixel
Feb 27 2016 02:57
bf Confirm The Ending
CamperBot
@camperbot
Feb 27 2016 02:57

## :fire:Bonfire: Confirm the Ending :link:

function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str;
}

end('Bastian', 'n');

Check if a string (first argument) ends with the given target string (second argument).

more info:  bf details | bf links | hint

demipixel
@demipixel
Feb 27 2016 02:57
So watcha have so far?
Monty
@webdev8183
Feb 27 2016 02:58

 js
function end(str,target) {

// "Never give up and good luck will find you."
// -- Falcor
var place;
var type;
var targetsize;

type=typeof str;
console.log(type);
var lengthofString;
lengthofString=str.length;
place=str.indexOf(target);
if (place===lengthofString-1)
return true;
else

return false;
}

end("Bastian", "n");

demipixel
@demipixel
Feb 27 2016 02:59
You need  at the end ;)
Monty
@webdev8183
Feb 27 2016 02:59
ugh I always have trouble with it annoying
function end(str,target) {

// "Never give up and good luck will find you."
// -- Falcor
var place;
var type;
var targetsize;

type=typeof str;
console.log(type);
var lengthofString;
lengthofString=str.length;
place=str.indexOf(target);
if (place===lengthofString-1)
return true;
else

return false;
}

end("Bastian", "n");
'''
CamperBot
@camperbot
Feb 27 2016 03:00
:bulb: to format code use backticks!  more info
demipixel
@demipixel
Feb 27 2016 03:00
@webdev8183 Okay, so, you're really close
str.indexOf gives the position of the START of the string
lengthOfString-1 is at the end of the string

Also you don't need to do

var a;
a = 3;

You can just do

var a = 3;

;)

Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:19
could someone help me with thejavascript challenge...Nesting for Loops..
demipixel
@demipixel
Feb 27 2016 03:19
@Rogue00 Sure
bf Nesting For Loops
CamperBot
@camperbot
Feb 27 2016 03:19
Sorry, can't find a bonfire called nesting for loops. [ Check the map? ]
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:19

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (var i= 0; i < arr.length; i++) {
for (var j= 0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

demipixel
@demipixel
Feb 27 2016 03:20
Do you know how to check the browser console to see the console.log outputs?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:21
i dont
how do i do that?
demipixel
@demipixel
Feb 27 2016 03:21
Right-click on the page
Click "Inspect element"
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:21
o wait..you mean in thechallenges?
demipixel
@demipixel
Feb 27 2016 03:22
Then click "Console"
You might want to clear the console (click the little circle with a slash through it)
Then run your program and console.log() will output whatever is in the ()
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:25
ok i see it..and found my program..lot of stuff here
demipixel
@demipixel
Feb 27 2016 03:25
Yeah, so
Clear it and then run your program
Right now you're outputting arr[i][j]
Now, you want to find the product of everything, correct?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:26
yes
demipixel
@demipixel
Feb 27 2016 03:26
So, to start, do you have any guesses on how you'd do it?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:27
i need to multiply the product value withe ach of the nested values in the array...and send the out put to the console
demipixel
@demipixel
Feb 27 2016 03:30
Okay
So you wnat to keep a running value, product, which stores the current value
So for each number you're given, what are you going to do with it?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:34
need tp multiply each by he product i think...
and then return the end result to the console log
demipixel
@demipixel
Feb 27 2016 03:34
No
You don't actually do console.log
That's just for your personal testing
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:34
ok...
demipixel
@demipixel
Feb 27 2016 03:34
At the end of the function, see how it says return product
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:34
yes
demipixel
@demipixel
Feb 27 2016 03:34
That means "Whoever called this function, give back the value of product"
So then FCC calls your function and checks what it returns
console.log is just to test in case you think something has gone wrong and a variable isn't what you expected it to be
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:35
o ha
but ...thats what it shows to use in the example..
some of these javascript challenges have been wearing me out
Nick Robson
@nickrobson
Feb 27 2016 03:37
@Rogue00 console.log will print out a value, but return doesn't. Instead, it gives the value to whatever called the function.
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:37
so thats why it just returns 1
demipixel
@demipixel
Feb 27 2016 03:38
@Rogue00 If you're not changing product, then product = 1
Nick Robson
@nickrobson
Feb 27 2016 03:38

e.g.

function one() { console.log(1); }
function two() { return 2; }
console.log(one());
console.log('---');
console.log(two());

output:

1 (from inside the one() function)
undefined (from printing what's returned by the one() function [nothing!])
---
2 (from printing what's returned by the two() function)
demipixel
@demipixel
Feb 27 2016 03:38
Therefore return product will return 1 :P
@nickrobson That may be a tad confusing for now :P
Norman Dela Cruz
@dcnr
Feb 27 2016 03:39
@Rogue00 most of the examples serve as templates for the answer, but don't use them as THE answer.They can trip you up at times. For example, those exercises that access objects. People copy the example, but the example and the problem have different solutions :D
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:40
well...ive scoured the net for a good example
ive also spent several hours trying to work something out on my own ....
demipixel
@demipixel
Feb 27 2016 03:41
@Rogue00 So how do we keep changing product to be each arr[i][j] multiplying onto it?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:42
i m overlooking something....most likely right n my face...its just not really clicking yet...i'm beginning to understand how the variables work...very confusing..like learning algebra
Norman Dela Cruz
@dcnr
Feb 27 2016 03:42
@Rogue00 just think of them as 'containers'. The variable name is the name for that container, and it holds the value you assign to it.
demipixel
@demipixel
Feb 27 2016 03:43
^^
Start with a simpler example. Pretend you had the numbers 2, 3, and 5 and the variable product = 1
product = product*2;
Then
product = product*3
Finally
product = product*5
So at the end, product == 30
But how are we generalizing 2, 3, and 5 so we don't have to hardcode those numbers?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:46
is because 2 +3= 5
demipixel
@demipixel
Feb 27 2016 03:46
Well, remember we're multiplying
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:47
im payingattention but i dont know what im supposed to do
demipixel
@demipixel
Feb 27 2016 03:47
var product = 1; // product = 1
product = product*2; // product = 2
product = product*3; // 2*3 = 6
product = product*5 // 6*5 = 30
console.log(product); // Value of product is 30
J Lee
@SoYuMatic
Feb 27 2016 03:49
hey I just finished that one! lol~
Andrew Dutton
@andrew-dutton
Feb 27 2016 03:49
bonfire Seek and Destroy
CamperBot
@camperbot
Feb 27 2016 03:49

## :fire:Bonfire: Seek and Destroy :link:

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

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

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

J Lee
@SoYuMatic
Feb 27 2016 03:50
learn all the lil math JS already has built in for you
sorry i gave you the wrong link @Rogue00
demipixel
@demipixel
Feb 27 2016 03:52
@AndreWaroux need help or just checking it out?
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:53
thank You @SoYuMatic @demipixel @AndreWaroux
CamperBot
@camperbot
Feb 27 2016 03:53
rogue00 sends brownie points to @soyumatic and @demipixel and @andrewaroux :sparkles: :thumbsup: :sparkles:
:star: 279 | @soyumatic | http://www.freecodecamp.com/soyumatic
:star: 45 | @demipixel | http://www.freecodecamp.com/demipixel
:star: 265 | @andrewaroux | http://www.freecodecamp.com/andrewaroux
Norman Dela Cruz
@dcnr
Feb 27 2016 03:58

@Rogue00
Expanding on what @demipixel said:

We're multiplying 2,3, and 5
We have a variable named product that holds the value 1

product = product * 2;

this part product * 2 says we multiply product with 2 and
give the result to product (product = part).
But what is product? product is a variable that currently holds 1
So it's actually like this:

product = product * 2
// 1    =    1    * 2;

Remember, = does not mean "equality", it means assign (or give) the
value on the right of the = to the left.

So after product = product * 2;, product will now be 2.

Moving on to 3:

product = product * 3;

product is now equal to 2 from the previous expression
product = product * 2; so it's actually like this now:

product = product * 3;
// 2    =   2     * 3;

product is now 6.

And lastly with 5:

product = product * 5;
// 6    =    6    * 5;

So our final product is 30;

demipixel
@demipixel
Feb 27 2016 03:58
Not sure if I agree with the "6 = 6 * 5"
More of a "value of product = 6 * 5"
But I'll try not to make it more confusing than it already is ;P
Ghost
@ghost~56bd2077e610378809c105cd
Feb 27 2016 03:59
ok..im following you
Norman Dela Cruz
@dcnr
Feb 27 2016 04:00
Yeah I wanted to just put product = x * y but I thought it would come across as two different products :(
@demipixel

@Rogue00 that's why

product = product * 2;
product = product * 3;
product = product * 5;

is equal to 30. @demipixel is saying it's the same principle with the nested for loop exercise

J Lee
@SoYuMatic
Feb 27 2016 04:02
function largestOfFour(arr) {
// You can do this!
for (var i=0; i<arr.length; i++){
for (var j=0; j<arr[i].length; j++){
var y=0;
var x = arr[i][j];
if( x>= y){
y=x;
}
}
}
return ;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
I feel I'm almost there, but I don't know what to return... help me think through it.
ive solved it before but trying to re-do it and failing... what a miserable feeling
Norman Dela Cruz
@dcnr
Feb 27 2016 04:03
@SoYuMatic you need your final answer to be an array of the largest right? [5, 27, 39, 1001]
J Lee
@SoYuMatic
Feb 27 2016 04:03
yes, so it's an array
i is all the big arrays
Norman Dela Cruz
@dcnr
Feb 27 2016 04:04
@SoYuMatic y will hold the largest for the small inner arrays right?
J Lee
@SoYuMatic
Feb 27 2016 04:05
or the counter for it, so each i represents an iteration through the 4 main arrays, yes, y holds the biggest of every arr[i]
but.. how do i tell the computer that? lol ffffffff
Norman Dela Cruz
@dcnr
Feb 27 2016 04:05
@SoYuMatic yeah so now that you have the largest number, you have to put them in an array because you need to return an array for your answer
J Lee
@SoYuMatic
Feb 27 2016 04:06
return... arr[i]... something y....
do i use push and make an empty array?
Norman Dela Cruz
@dcnr
Feb 27 2016 04:07
@SoYuMatic try it out!
@SoYuMatic but mind where you put that push into your new array, when are you supposed to push y
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:08
@demipixel Yeah, the seek and destroy bonfire is destroying me! lol
demipixel
@demipixel
Feb 27 2016 04:08
bf seek and destroy
CamperBot
@camperbot
Feb 27 2016 04:08

## :fire:Bonfire: Seek and Destroy :link:

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

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

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

demipixel
@demipixel
Feb 27 2016 04:09
CamperBot
@camperbot
Feb 27 2016 04:09
demipixel
@demipixel
Feb 27 2016 04:09
Do you know how to use filter?
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:10
@demipixel so I'm all good with the Arguments object and have set variables using it to get the array... but the filtering action is tough... even after reading through the MDN documentation
demipixel
@demipixel
Feb 27 2016 04:10
Do you know how it works?
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:11
Well no, not really...
demipixel
@demipixel
Feb 27 2016 04:12
Alright, well
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:12
So I'm thinking I need to create a function because filter() requires a function as one of its arguments... is that right?
demipixel
@demipixel
Feb 27 2016 04:12
This is what it does:
var a = [1,2,3,4,5];
a.filter(function(item) {
return item >= 3;
}); // Outputs [3,4,5]
If the function passed returns true, it keeps the elements. Otherwise, it throws the element away
So in the example above, 1 >= 3 is false, so it's no longer in the new array
Caleb Martin
@caleb272
Feb 27 2016 04:13
^ yup
demipixel
@demipixel
Feb 27 2016 04:13
Same with 2
3 >= 3 is true, however, so it stays in
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:13
OK... got that
demipixel
@demipixel
Feb 27 2016 04:13
So for destroyer, you have arr, remove1, and remove2
So
Caleb Martin
@caleb272
Feb 27 2016 04:13
this chat is the best
@demipixel are you doing FCC
demipixel
@demipixel
Feb 27 2016 04:14
return arr.filter(function(item) {
???
});
@caleb272 Eh
I joined 24 hours ago, a little too simple for me though :P
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:14
OK... quick question on the syntax...
demipixel
@demipixel
Feb 27 2016 04:14
Mhm?
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:14
The closing )...
demipixel
@demipixel
Feb 27 2016 04:14
Yep?
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:14
oh... it's right at the end...
the entire function is wrapped in ( )
demipixel
@demipixel
Feb 27 2016 04:15
Yep
The function is a paramater/argument
You're actually passing the function to be used by the filter method
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:15
ahhhhhh....
demipixel
@demipixel
Feb 27 2016 04:15
It's really cool, you'll be seeing much more of this as you get more in depth
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:16
ok... I think I am back on track here... I was getting thrown by this... thinking i neede to create a seperate function and then pass that function in.
demipixel
@demipixel
Feb 27 2016 04:16
Well, you can
Caleb Martin
@caleb272
Feb 27 2016 04:16
@demipixel well thanks for helping out the chat how long have you been deving ?
CamperBot
@camperbot
Feb 27 2016 04:16
caleb272 sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles:
demipixel
@demipixel
Feb 27 2016 04:16
arr.filter(hi);

function hi(item) {
...
}
CamperBot
@camperbot
Feb 27 2016 04:16
:star: 46 | @demipixel | http://www.freecodecamp.com/demipixel
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:16
OK, yep..
demipixel
@demipixel
Feb 27 2016 04:16
But us programmers are lazy and don't want to take up the "name space"
And we don't need to :D
@caleb272 Eh, like 5+ years
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:17
I mean, looking at the sytax on the MDN site was showing what you've shown me... passing the function in to the filter.
Caleb Martin
@caleb272
Feb 27 2016 04:17
ya you can do either a anonymous function or pass it a function ^
Andrew Dutton
@andrew-dutton
Feb 27 2016 04:17
OK... thank you @caleb272 !! I'm gonna have another crack at it ;)
CamperBot
@camperbot
Feb 27 2016 04:17
andrewaroux sends brownie points to @caleb272 :sparkles: :thumbsup: :sparkles:
:star: 292 | @caleb272 | http://www.freecodecamp.com/caleb272
J Lee
@SoYuMatic
Feb 27 2016 04:18
ok i am still lost... and I am getting scope errors and such
Caleb Martin
@caleb272
Feb 27 2016 04:19
with whats ^
J Lee
@SoYuMatic
Feb 27 2016 04:19
function largestOfFour(arr) {
var z=[];
for (var i=0; i<arr.length; i++){
for (var j=0; j<arr[i].length; j++){
var y=0;
var x = arr[i][j];
if( x>= y){
y=x;
arr[i]=y;

}
}
}
return ;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
so i made the empty array, we have the counter for the 4 arrays, i; We have the j for every element inside i. X compares and Y stores the value
and....
i still have that empty array up top
that needs to be populated by the y in every i
Caleb Martin
@caleb272
Feb 27 2016 04:20
i don’t think you are closing your if statement
J Lee
@SoYuMatic
Feb 27 2016 04:21
it's closed, i'm not getting semi-colon errors
Moisés Man
@moigithub
Feb 27 2016 04:22
@SoYuMatic var y=0; should not be there... put above/outside the inner loop
demipixel
@demipixel
Feb 27 2016 04:22
@caleb272 It's closed it's just funky indenting
Caleb Martin
@caleb272
Feb 27 2016 04:23
he should probably fix that it helps when you can see the proper indentation
J Lee
@SoYuMatic
Feb 27 2016 04:23
it's cuz im still trying to figure it out. and @moigithub what am i missing about scope here?
demipixel
@demipixel
Feb 27 2016 04:23
@SoYuMatic Well, what is Y suppose to store?
J Lee
@SoYuMatic
Feb 27 2016 04:23
the largest value in each array
demipixel
@demipixel
Feb 27 2016 04:23
Right
So every time that J-Loop starts
Moisés Man
@moigithub
Feb 27 2016 04:23
on each iteration... u setting Y to 0
so x will be always >= than y
demipixel
@demipixel
Feb 27 2016 04:23
It's erasing the value of Y and setting it back to 0
Moisés Man
@moigithub
Feb 27 2016 04:24
it not keeping the higher num from each group
demipixel
@demipixel
Feb 27 2016 04:24
You want to keep the value of y, so you'll need to place it outside the loop
J Lee
@SoYuMatic
Feb 27 2016 04:24
OOOOOOO
demipixel
@demipixel
Feb 27 2016 04:24
;)
J Lee
@SoYuMatic
Feb 27 2016 04:24
lightbulb!!
Caleb Martin
@caleb272
Feb 27 2016 04:24
haha
demipixel
@demipixel
Feb 27 2016 04:24
Also @SoYuMatic once you get it with this method, I can show you some slicker ways ;)
Moisés Man
@moigithub
Feb 27 2016 04:25
Array.map + Math.max
demipixel
@demipixel
Feb 27 2016 04:25
es6 is great
manicpromod
@manicpromod
Feb 27 2016 04:27
This code is not working , can anybody check

function palindrome(str) {
// Good luck!
var revstr="";
for(i=str.length-1;i>=0;i--){

revstr=revstr+str[i];

}

if(str===revstr) {
return true;
}

else {

return false;

}

}

palindrome("eye");

J Lee
@SoYuMatic
Feb 27 2016 04:27
function largestOfFour(arr) {
var z=[];
for (var i=0; i<arr.length; i++){
var y=0;
for (var j=0; j<arr[i].length; j++){

var x = arr[i][j];
if( x>= y){
y=x;
z[i]=y;

}
}
}
return z;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
LOL OMG I was so stuck on returning arr
demipixel
@demipixel
Feb 27 2016 04:27
@manicpromod
help format
CamperBot
@camperbot
Feb 27 2016 04:27

## :point_right: code formatting [wiki]

### Inline code

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

### Code Block

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

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

demipixel
@demipixel
Feb 27 2016 04:27
@SoYuMatic yo got it?
J Lee
@SoYuMatic
Feb 27 2016 04:27
now let's teach me better ways
yes i passed
demipixel
@demipixel
Feb 27 2016 04:28
Alright
J Lee
@SoYuMatic
Feb 27 2016 04:28
but that was a really convoluted way of thinking
demipixel
@demipixel
Feb 27 2016 04:28
No, your way is the correct way to think about the problem
It's always better to brute force first and fix later
So @caleb272 how long have you been coding/been at FCC?
Moisés Man
@moigithub
Feb 27 2016 04:29
This message was deleted
demipixel
@demipixel
Feb 27 2016 04:29
@moigithub Don't give it away *facepalm*
Also that's not even using the fancy spread operator :S
Moisés Man
@moigithub
Feb 27 2016 04:30
:D
demipixel
@demipixel
Feb 27 2016 04:30
Well you're lucky @SoYuMatic said it was gonna take 3 min lol
J Lee
@SoYuMatic
Feb 27 2016 04:31
arr.map(callback[, thisArg])
Parameters

callback
Function that produces an element of the new Array, taking three arguments:
currentValue
The current element being processed in the array.
index
The index of the current element being processed in the array.
array
The array map was called upon.
thisArg
Optional. Value to use as this when executing callback. Default value is the Window object
So arr.map creates a new array using 3 parameters
that's about as far as I got in comprehension lol
demipixel
@demipixel
Feb 27 2016 04:32
Alright, I can try to explain
arr.map takes one paramater and that is a function
That function gets PASSED 3 paramaters however you don't have to use them all
Here's a quick example to see if you can figure it out for youself:
[1,2,3,4].map(function(item) {
return item+3;
}); // [4,5,6,7]
J Lee
@SoYuMatic
Feb 27 2016 04:33
O ok
demipixel
@demipixel
Feb 27 2016 04:33
Another:
["a", "b", "c"].map(function(item) {
return item + "a";
}); // ["aa", "ba", "ca"]
So for each element, it's calling your function passing it as a paramater
Then, whatever you return, it'll change it to that value
So when "2" gets passed in as the item, you returned item+3 or "2+3" which meant 5
J Lee
@SoYuMatic
Feb 27 2016 04:34
why did they say callback and not just arr.map(function(arg){})
podiumvoting
@podiumvoting
Feb 27 2016 04:34
Ok I need a ton of help on nesting for loops
demipixel
@demipixel
Feb 27 2016 04:34
then function() {} format is called a callback
podiumvoting
@podiumvoting
Feb 27 2016 04:35
why doens't this work
This message was deleted
demipixel
@demipixel
Feb 27 2016 04:35
@podiumvoting haha, @SoYuMatic was stuck on that problem not 5 min ago
podiumvoting
@podiumvoting
Feb 27 2016 04:35
ah i'll go back and look
J Lee
@SoYuMatic
Feb 27 2016 04:36
O, thats a good note to take. A call back is function( ){ }
demipixel
@demipixel
Feb 27 2016 04:36
well
When passed as a paramater
If it's not a paramater, it's not a callback
J Lee
@SoYuMatic
Feb 27 2016 04:36
then it's just a function
but a function that is a parameter is a callback
yes?
demipixel
@demipixel
Feb 27 2016 04:36
basicallllyy
Only if it gets "called back"
J Lee
@SoYuMatic
Feb 27 2016 04:36
like a return or console.log thing?
demipixel
@demipixel
Feb 27 2016 04:37
Well
Take a look at this example:
See if you can guess what it does
function callWithThree(cb) {
return cb(3);
}

console.log(callWithThree(function(num) {
return num*num;
});
1) We call "callWithThree" (inside the console.log) and pass the func(num) {}
2) callWithThree will return after calling func(num) {} (with num=3)
3) the func() returns num*num which is 3*3 which is 9
4) That gets returned to callWithThree which also returns it
5) Returned to console.log and outputs "9"
Monty
@webdev8183
Feb 27 2016 04:40
I am stuck like chuck on on the confirm the ending challenge..
demipixel
@demipixel
Feb 27 2016 04:40
@webdev8183 You were so close
Monty
@webdev8183
Feb 27 2016 04:40
definitely not a happy ending
demipixel
@demipixel
Feb 27 2016 04:40
Let's say you do:
"abcdefg".indexOf("efg")
What will that output?
Monty
@webdev8183
Feb 27 2016 04:41
3
demipixel
@demipixel
Feb 27 2016 04:41
Close
J Lee
@SoYuMatic
Feb 27 2016 04:41
question, what happens if you just do callwithThree? it would return cd not defined?
cb*
demipixel
@demipixel
Feb 27 2016 04:41
@SoYuMatic It would throw an error because it's trying to do undefined(3)
and undefined isn't a function, it's undefined :P
J Lee
@SoYuMatic
Feb 27 2016 04:42
hey! i was sorta close though~
demipixel
@demipixel
Feb 27 2016 04:42
It would say something like
TypeError: cb is not a function
Alright, here's another concept:
Any clue what Math.max does?
Just guess, don't read up on it
J Lee
@SoYuMatic
Feb 27 2016 04:43
i remember vaguely math floor and max
demipixel
@demipixel
Feb 27 2016 04:43
What would Math.max(2,6,3) output
J Lee
@SoYuMatic
Feb 27 2016 04:43
6?
demipixel
@demipixel
Feb 27 2016 04:43
Yup
Okay, so
Norman Dela Cruz
@dcnr
Feb 27 2016 04:44

@webdev8183 you just have to realize the relationship of target to str!
Here's a blatant illustration:

Bastia | n    // str
| n    // target

It's the solution right there :D

demipixel
@demipixel
Feb 27 2016 04:44
What if we had the array [2,6,3]?
We can't just do
Math.max([2,6,3]);`
That just returns NaN
So how do we make 2,6,3 into arguments?
J Lee
@SoYuMatic
Feb 27 2016 04:44
so arr.map(math.max(
we can split the array into
demipixel
@demipixel
Feb 27 2016 04:44
Slow down, we're getting there :P
J Lee
@SoYuMatic