26th
May 2017
Nazar Maksymchuk
@MANTENN
May 26 2017 00:00
@ankerpeet hold on
@ankerpeet what is it supposed to return numbers?
the challenge is Falsy Bouncer?
canoid
@canoid
May 26 2017 00:11
Hi, somevody knows how can I use a global variable from a function?
Nazar Maksymchuk
@MANTENN
May 26 2017 00:12
because it says not a number so numbers turn in false
canoid
@canoid
May 26 2017 00:14
nobody?
Nazar Maksymchuk
@MANTENN
May 26 2017 00:14
@canoid you use like anywhere else
Invisii
@Invisii
May 26 2017 00:15
function palindrome(str) {
var pal = str.replace(/[^a-zA-z]+/, "").toLowerCase();
if(pal.split("").reverse().join("") == pal) return true;
else return false;
}
Can someone help me with this?
Nazar Maksymchuk
@MANTENN
May 26 2017 00:15
var global;
function exampleF() {
global = 1; //wihtout var this is global
}
canoid
@canoid
May 26 2017 00:16
mmm... Im using it like that and it doesn't work :(
Nazar Maksymchuk
@MANTENN
May 26 2017 00:16
paste it
canoid
@canoid
May 26 2017 00:16

var count = 0;

function cc(card) {

// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count +=1;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case'A':
count-= 1;
break;
}

if (count >=1) {
return'Bet';
}
else if (count<=0)  {
return 'Hold';
}

// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
from the counting cards challenge
Nazar Maksymchuk
@MANTENN
May 26 2017 00:19
@canoid since you want to reuse the code, put it in side
because then youll have to otherwise set it equal to 0
@canoid it's perfect - that's how its used
your's is not reset
hold on
RyanHuang06
@RyanHuang06
May 26 2017 00:21

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit=(celsius*5/9)-32;
// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(-30);
convertToF(0); WHAT IS WRONG

Nazar Maksymchuk
@MANTENN
May 26 2017 00:21
@canoid your code is perfectly fine, it is the value you are returning
canoid
@canoid
May 26 2017 00:21
it's not working for me xD
Nazar Maksymchuk
@MANTENN
May 26 2017 00:22

@canoid


var count = 0;

function cc(card) {
// Only change code below this line

switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count += 0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
break;
}
if (count <= 0) {
return count + " Hold";
} else {
return count + " Bet";
}
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

that's how I did it
because you are not returning the proper value fcc expects

canoid
@canoid
May 26 2017 00:23
I thought there was no need to put the values of 7,8,9 .-.
Frank McCroy
@fmccroy
May 26 2017 00:24
@RyanHuang06 9/5, plus 32
Nazar Maksymchuk
@MANTENN
May 26 2017 00:24
@canoid "The current count and the player's decision ("Bet" or "Hold") should be separated by a single space."
Frank McCroy
@fmccroy
May 26 2017 00:25
@RyanHuang06 You have MINUS 32
RyanHuang06
@RyanHuang06
May 26 2017 00:25
@fmccroy how do I send brownie points
Nazar Maksymchuk
@MANTENN
May 26 2017 00:25
say thank
Frank McCroy
@fmccroy
May 26 2017 00:25
Type “@fmccroy thanks!” :)
CamperBot
@camperbot
May 26 2017 00:25
sorry fmccroy, you can't send brownie points to yourself! :sparkles: :sparkles:
canoid
@canoid
May 26 2017 00:25
uhh crap i forget that , thanks @MANTENN
CamperBot
@camperbot
May 26 2017 00:25
canoid sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles:
Nazar Maksymchuk
@MANTENN
May 26 2017 00:25
and the at
Invisii
@Invisii
May 26 2017 00:27
can anyone help me with the palindrome challenge?
Nazar Maksymchuk
@MANTENN
May 26 2017 00:28
@Invisii compare the inverse of the string and make sure its lower case/
here is the regex
/[^0-9A-Z]/gi, ""
So if I input mom and it flips it, it will be mom return true else false

@Invisii


function palindrome(str) {
return str.replace(/[^0-9A-Z]/gi, "").toLowerCase() === str.replace(/[^0-9A-Z]/gi, "").toLowerCase().split('').reverse().join('') ? true : false;
}

palindrome("eye");

That's how I did it

@Invisii
function palindrome(str) {
var pal = str.replace(/[^a-zA-z]+/, "").toLowerCase();
if(pal.split("").reverse().join("") == pal)  {return true;
} else {
return false;
}
}
Moisés Man
@moigithub
May 26 2017 00:32
@Invisii ur code looks OK except u need to KEEP numbers too
Nazar Maksymchuk
@MANTENN
May 26 2017 00:32
is fcc built on nodejs?
Moisés Man
@moigithub
May 26 2017 00:33
Invisii
@Invisii
May 26 2017 00:38
I still don't understand what's wrong
RyanHuang06
@RyanHuang06
May 26 2017 00:38

var myStr = "FirstLine \n \SecondLine\ \r ThirdLine"; // Change this line

????

Invisii
@Invisii
May 26 2017 00:38
function palindrome(str) {
var pal = str.replace(/[^a-zA-z0-9]+/, "").toLowerCase();
if(pal.split("").reverse().join("") === pal) return true;
else return false;
}
Nazar Maksymchuk
@MANTENN
May 26 2017 00:38
@Invisii the regex on pal
nvm
Invisii
@Invisii
May 26 2017 00:40
It's giving me errors with "_eye" "A man, a plan, a canal. Panama" "never odd or even" "My age is 0, 0 si ega ym." and "0_0 (: /-\ :) 0-0"
CyberBrick
@CyberBrick
May 26 2017 00:40

I'm a bit stuck on this, Testing Objects for Properties challenge, my problem I believe is Im not entering the correct return statement could someone help? Here is my code.
// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
myObj.hasOwnProperty();
return "";
}

// Test your code by modifying these values

The example doesn't actually show any return statement
Nazar Maksymchuk
@MANTENN
May 26 2017 00:44
@Invisii regex needs to remove the other special characters its letters and numbers only, no spaces
Invisii
@Invisii
May 26 2017 00:44
@CyberBrick you need to check if the object has the property with .hasOwnProperty, and if it does, you need to return the value of that property
Anker
@ankerpeet
May 26 2017 00:45
@MANTENN its supposed to return an array that filters out all Falsy values
Invisii
@Invisii
May 26 2017 00:45
@MANTENN is it not removing spaces?
Nazar Maksymchuk
@MANTENN
May 26 2017 00:46
@Invisii yes
/[^0-9A-Z]/gi
CyberBrick
@CyberBrick
May 26 2017 00:46
@Invisii I understand that, but I don't understand how to code the return statement
Nazar Maksymchuk
@MANTENN
May 26 2017 00:46
try console.log(pal);
@ankerpeet i found the challenege; working on it
Invisii
@Invisii
May 26 2017 00:48
@CyberBrick have you tried using an if statement?
@MANTENN how do i see the console output?
Jacky
@skywards1910
May 26 2017 00:48
@CyberBrick function checkObj(checkProp) {
if(myObj.hasOwnProperty())
return myObj[checkProp];
else
return "";
}
Nazar Maksymchuk
@MANTENN
May 26 2017 00:49
@Invisii open inspector: you can right click on the page or ctrl shift and i
and go to the console tab
VenkatBandaru
@venkatbandaru99
May 26 2017 00:49
hi guys what is camel case in both declaration when there is a number assigned
Nazar Maksymchuk
@MANTENN
May 26 2017 00:50
@venkatbandaru99 camelCase
first letter is not captilized of the first word
VenkatBandaru
@venkatbandaru99
May 26 2017 00:50
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;
is this correct
?
Nazar Maksymchuk
@MANTENN
May 26 2017 00:51
@venkatbandaru99 I believe so
VenkatBandaru
@venkatbandaru99
May 26 2017 00:51
then I am getting an error that studlyCapVar should use camelCase in both declaration and assignment sections.
Invisii
@Invisii
May 26 2017 00:51
@MANTENN thanks man, figured out what i was doing wrong...i forgot to add the g to the end of the regex
CamperBot
@camperbot
May 26 2017 00:51
invisii sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles:
Nazar Maksymchuk
@MANTENN
May 26 2017 00:51
@venkatbandaru99 change the code above as well
VenkatBandaru
@venkatbandaru99
May 26 2017 00:51
oh thanks
Nazar Maksymchuk
@MANTENN
May 26 2017 00:51
where it is declared but that
var StUdLy.. its something like that
change that too and others
@Invisii even without the g it still works with a plus
VenkatBandaru
@venkatbandaru99
May 26 2017 00:54
thanks Nazar
Nazar Maksymchuk
@MANTENN
May 26 2017 00:55
hope that helps
Robert Arifin
@renkachan
May 26 2017 00:57
guys, can i ask about the streamroller challenge? i am not sure how to do it
Nazar Maksymchuk
@MANTENN
May 26 2017 00:58
danghv
@danghv
May 26 2017 01:01
who can help me out with "Profile Lookup". here is my code:
for(var i = 0; i < contacts.length; i++){
  if(contacts[i].firstName === firstName){
if(contacts[i].hasOwnProperty(prop) === true){
return contacts[i][prop];
}
else{
return "No such property";
}
}
else{
return "No such contact";
}
Nazar Maksymchuk
@MANTENN
May 26 2017 01:01
@danghv move return no such property out of the loop
@renkachan I think you call on the function using if to determine if the input is an array with the for loop
danghv
@danghv
May 26 2017 01:03
and replace by what?
Nazar Maksymchuk
@MANTENN
May 26 2017 01:03
@danghv
  if(contacts[i].firstName === firstName){
if(contacts[i].hasOwnProperty(prop) === true){
return contacts[i][prop];
}
return "No such property";
}
danghv
@danghv
May 26 2017 01:03
@MANTENN and replace by what
Moisés Man
@moigithub
May 26 2017 01:04
@Invisii return exit the function immediatelly
ur code returning no contact on first mismatch... without checking the rest of contacts
Nazar Maksymchuk
@MANTENN
May 26 2017 01:05
@danghv this one has to be outside the looP
return "No such contact";
danghv
@danghv
May 26 2017 01:05
@moigithub yeah, i know that,but i dont know how to do
@MANTENN letmetry
@MANTENN oh yeah, thank you so much
CamperBot
@camperbot
May 26 2017 01:08
danghv sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles:
Nazar Maksymchuk
@MANTENN
May 26 2017 01:11
@ankerpeet did you solve your problem? i posted a link to the solution, i couldn't figure out whats the problem with yours I think its the chain of ands
ROBUSTO8
@ROBUSTO8
May 26 2017 01:19

hi guys, im working on the "Local Weather App" challenge and i was trying to get the temperature to show but, it's not working can anyone tell me why? codepen: https://codepen.io/ROBUSTO/pen/Wjaqab

I'm looking in console and im getting some sort of error but, i have no idea what it means...

Nazar Maksymchuk
@MANTENN
May 26 2017 01:24
CORS?
Cross-Origin?
@ROBUSTO8 use some proxy that pulls data for you and has cross-origin request enabled
ROBUSTO8
@ROBUSTO8
May 26 2017 01:28
@MANTENN oh thanks
CamperBot
@camperbot
May 26 2017 01:28
robusto8 sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles:
ROBUSTO8
@ROBUSTO8
May 26 2017 01:28
that worked
Nazar Maksymchuk
@MANTENN
May 26 2017 01:28
@ROBUSTO8 you can set the cross origin headers too - not sure dark sky has cross origin allow on there part
Jennifer Davis
@davijm
May 26 2017 01:31
Hello, I'm having trouble with: You should use the += operator for each variable. This is what I did: MyVar += 12;
myVar += 9;
myVar += 7;
moshe18
@moshe18
May 26 2017 01:32
Can someone take a look at my code to see if there is anyway to shorten/ optimize it. As it seems to me a little more complicated than it ought to be.
function rot13(str) { // LBH QVQ VG!
var tempString = str.split("");
for(i = 0; i < tempString.length; i++) {
if (tempString[i].charCodeAt() >= 65 && tempString[i].charCodeAt() <= 77) {
tempString[i] = String.fromCharCode(tempString[i].charCodeAt() + 13);
} else if (tempString[i].charCodeAt() >= 78 && tempString[i].charCodeAt() <= 90) {
tempString[i] = String.fromCharCode((tempString[i].charCodeAt() - 13));
}
}
return tempString.join("");
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Nazar Maksymchuk
@MANTENN
May 26 2017 01:33
@davijm what is the challenge?
Jennifer Davis
@davijm
May 26 2017 01:34
@MANTENN Compound Assignment With Augmented Addition
JR Woods
@jrwoods42
May 26 2017 01:34

hello campers! I'm having trouble removing the space before "..." on "truncate sentence" algorithm. Here's my code: function truncateString(str, num) {

var whiteSpace = /\s+/;
var dots = "...".replace(whiteSpace, '');

if(str.length > num && num > 3) {
return str.slice(0,num-2) + dots;

} if(str.length == num || num > str.length) {
return str;
}

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

}

truncateString("Peter Piper picked a peck of pickled peppers", 14);

Nazar Maksymchuk
@MANTENN
May 26 2017 01:35
@davijm you need to do it with variables a b and c, not myVar
d-beloved
@d-beloved
May 26 2017 01:38
hello, how do i remove an item property from an object in javascript. for example, having this....
Jennifer Davis
@davijm
May 26 2017 01:38
@MANTENN var a +=12; something like that?
Nazar Maksymchuk
@MANTENN
May 26 2017 01:38
@d-beloved its like delete
@davijm once it has been declared you no longer need to specify var
unless you want to create a local variable in a function
Somia ♡
May 26 2017 01:39

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj["an entree"]; // Change this line
testObj["the drink"]; // Change this line

whats wrong with my code?
d-beloved
@d-beloved
May 26 2017 01:39
object {items: 4}; and I want to make items to become 3, how do I delete one of it since they are same properties
Nazar Maksymchuk
@MANTENN
May 26 2017 01:39
@somiajagadish you have to set it equal to someting
delete object.item4 ;
Joseph
@revisualize
May 26 2017 01:40
Somia ♡
May 26 2017 01:41
@revisualize Accessing Objects Properties With Bracket Notation
d-beloved
@d-beloved
May 26 2017 01:41
@MANTENN , delete object.items4? that will delete the whole property i guess, i want just one removed
Joseph
@revisualize
May 26 2017 01:41
@somiajagadish Oh, you deleted the variables?
var entreeValue = testObj;   // Change this line
var drinkValue = testObj;    // Change this line
Somia ♡
May 26 2017 01:42
@revisualize yes, because they said to change that line
Jennifer Davis
@davijm
May 26 2017 01:42
@MANTENN It worked,!Thanks for your help!
Joseph
@revisualize
May 26 2017 01:42
@somiajagadish You need to keep the variable declarations.
Nazar Maksymchuk
@MANTENN
May 26 2017 01:42
@d-beloved paste the code and item you want to remove
Somia ♡
May 26 2017 01:42
@revisualize so where do i put the bracket notations?
Nazar Maksymchuk
@MANTENN
May 26 2017 01:43
@somiajagadish you can use dotnotation or bracketnotation
but you have a space
so bracketnotation
Joseph
@revisualize
May 26 2017 01:43
var entreeValue = testObj["an entree"];   // Change this line
var drinkValue = testObj;    // Change this line
Nazar Maksymchuk
@MANTENN
May 26 2017 01:43
obj["prop"]
Joseph
@revisualize
May 26 2017 01:43
@MANTENN The lesson is to use bracket notation.
Somia ♡
May 26 2017 01:44
@revisualize Ohh I get it now! Thanks :)
CamperBot
@camperbot
May 26 2017 01:44
somiajagadish sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4005 | @revisualize |http://www.freecodecamp.com/revisualize
juwels19
@juwels19
May 26 2017 01:45
can someone send the answer to the profile lookup question for javasript
Joseph
@revisualize
May 26 2017 01:45
@juwels19 Have you solved the challenge?
juwels19
@juwels19
May 26 2017 01:45
almost
Nazar Maksymchuk
@MANTENN
May 26 2017 01:45

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
return contacts[i][prop];
} else if (contacts[i].hasOwnProperty(prop) !== true) {
return "No such property";
}
}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
juwels19
@juwels19
May 26 2017 01:46
thx
Joseph
@revisualize
May 26 2017 01:46
@MANTENN That's A solution.
d-beloved
@d-beloved
May 26 2017 01:46
@MANTENN I'm having a function that loops through a string and them if it encounters a character more than once, it should remove one of the letters and place the unique ones in an object and then count the amount of letters that was removed too
Nazar Maksymchuk
@MANTENN
May 26 2017 01:46
@revisualize the person asked for it -_-
Joseph
@revisualize
May 26 2017 01:46
@juwels19 You really should have passed the challenge on your own.
@MANTENN Sure, I personally don't think people should be giving away answers.
Nazar Maksymchuk
@MANTENN
May 26 2017 01:47
@revisualize I dont care if people have my answers.
@revisualize if it others can steal my work and patent it why not give an answer away?
Joseph
@revisualize
May 26 2017 01:48
@MANTENN I don't either. But, I'd rather work through the problem and help someone learn instead of just giving them the answer. But, my personal opinion is just that... mine.
I don't gift away answers. Studies have shown that giving people answers to problems instills an illusionary sense of learning. Because, it only puts information into short-term memory. Of which people think they are learning. Only through a little struggle and repetition that the human brain puts things into long-term memory. I don't know what their end goal is. I don't know if they want to do this as a personal project, hobby, or if they want to move into industry. Because of this, I strongly feel that working with people to allow them to solve problems on their own is a far better outcome than giving away answers. But, others clearly don't agree with my methods for helping people learn.
juwels19
@juwels19
May 26 2017 01:50
@revisualize i did pass it, i was getting a syntax error so i needed a solution to check it with
Joseph
@revisualize
May 26 2017 01:50
@juwels19 I have 5 solutions for that challenge on my github.
Nazar Maksymchuk
@MANTENN
May 26 2017 01:51
because the if was inside which return ed no such property and the first run; thus terminating the loop
Lance
@texas2010
May 26 2017 01:52
@revisualize hi. i was stuck. i plan to ask you for help. but i check shift on mdn again. didnt realized about i doing it wrong. :joy: but did passed it. :P
it was 30 mins ago. pfff
Nazar Maksymchuk
@MANTENN
May 26 2017 01:56
@texas2010 i hate that when it happens to me
Lance
@texas2010
May 26 2017 01:56
yeahhhh forget how to use it. ha.
Nazar Maksymchuk
@MANTENN
May 26 2017 01:56
@texas2010 happend to me on a for loop I did 0 > str.length instead of i; :facepunch:
Lance
@texas2010
May 26 2017 01:57
oh damn.
Nazar Maksymchuk
@MANTENN
May 26 2017 02:00
took me approx 10mins of stress and asked someone for help
the error was completed differinet like arr[i] is not defined and i pasted the for line
brain dead for a few mins i guess
Lance
@texas2010
May 26 2017 02:03
maybe need a nap?
Nazar Maksymchuk
@MANTENN
May 26 2017 02:04
sleept like 5hrs the day before and 6hrs last night
Lance
@texas2010
May 26 2017 02:05
ohhh
i plan to watch course this afternoon but was too tired. was mowing the grass. eh
Nazar Maksymchuk
@MANTENN
May 26 2017 02:06
should have taken a nap
James Roberts
@Erodi
May 26 2017 02:07
has anyone done the wordBlanks challenge recently?
Lance
@texas2010
May 26 2017 02:07
yeah. but i could watch course tomorrow. :P
Nazar Maksymchuk
@MANTENN
May 26 2017 02:07
@Erodi did it on sunday
James Roberts
@Erodi
May 26 2017 02:07
Does it want me to write things in a format like var wordBlanks = 'blah blah blah' +myNoun+ 'blah blah blah' ?
or is it focusing on the backslash hell lesson?
Nazar Maksymchuk
@MANTENN
May 26 2017 02:08
make sure you have a word in between each variable
James Roberts
@Erodi
May 26 2017 02:08
can you give me an example that doesn't spoil the problem?
Stephen James
@sjames1958gm
May 26 2017 02:09
@Erodi It is a string concatenation challenge. You should put the result in the provide variable.
Nazar Maksymchuk
@MANTENN
May 26 2017 02:09
var str = "The " + variable + " another " + variable and on
Stephen James
@sjames1958gm
May 26 2017 02:09
@Erodi 'blah blah blah ' +myNoun this is close just make sure there is a space next to the variables
James Roberts
@Erodi
May 26 2017 02:10
oh, gotcha. thanks @MANTENN and @sjames1958gm ! I'm not sure if I'm just tired or stressed from learning that I
CamperBot
@camperbot
May 26 2017 02:10
erodi sends brownie points to @mantenn and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7489 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
James Roberts
@Erodi
May 26 2017 02:10
**I am going to be jobless soon
trying to code to relax lol
Nazar Maksymchuk
@MANTENN
May 26 2017 02:11
im jobless for 2 years :(
James Roberts
@Erodi
May 26 2017 02:11
but maybe trying to relax by doing javascript wasn't the best idea lol
oh man. I know the feels. been fighting so hard for so long now to find steady work
hopefully I'll find a lot less nonsense in the programming world.
well, as far as employers go that is
Nazar Maksymchuk
@MANTENN
May 26 2017 02:25
@Erodi where I struggled was the regex took me awhile for the palindromes
RyanHuang06
@RyanHuang06
May 26 2017 02:34
var myStr = "FirstLine\n\Secondline\r\Thirdline";
whats wrong
var myStr = "FirstLine \n\ Secondline \r\ Thirdline"; // Change this line
??
Joseph
@revisualize
May 26 2017 02:37
@RyanHuang06 L
@RyanHuang06 You have spaces
@RyanHuang06 You're also escaping the backslash and carriage-return out of order
RyanHuang06
@RyanHuang06
May 26 2017 02:39
var myStr = "FirstLine\n\Secondline\r\Thirdline"; // Change this line
?
Ty Tia
@TyTia77
May 26 2017 02:41
lol
James Roberts
@Erodi
May 26 2017 02:42
@RyanHuang06 All I can say is take a really close look at how they want you to do "\SecondLine\"
Joseph
@revisualize
May 26 2017 02:43
@RyanHuang06 SecondLine vs Secondline .. it should have a L
@RyanHuang06 You're still escaping the backslash carriage-return out of order
James Roberts
@Erodi
May 26 2017 02:44
And I mean a really close look. Be sure that you're escaping the backslahes as part of the phrase
Joseph
@revisualize
May 26 2017 02:44
@RyanHuang06 Also, ThirdLine vs Thirdline
@Erodi You can see how they are doing it by quoting what they wrote.
@RyanHuang06 Now, You're actually not escaping backslashes correctly.
@RyanHuang06 You were before.
James Roberts
@Erodi
May 26 2017 02:45
@revisualize yeah, I got hung up because I was trying to escape the backslashes the wrong way earlier.
Khoa Le
@Zacele
May 26 2017 02:46
hey guys
having some issue here
and it is outside of freecodecamp curriculumm

function filterNumbersFromArray(arr) {
// Write the code that goes here
var arr = arr.filter(function(x){
return typeof x ==='number';
});
console.log(arr);
}

var arr = [1, 'a', 'b', 2];
filterNumbersFromArray(arr);

for (var i = 0; i < arr.length; i++)
console.log(arr[i]);
why is my arr cannot load the arr has already been filtered
the function I had filteried all the non number
but when loop through the arr it has return the old arr :(
RyanHuang06
@RyanHuang06
May 26 2017 02:50

var myStr = "FirstLine\n\SecondLine\rThirdline"; // Change this line

?

var myStr = "FirstLine\n\SecondLine\rThirdline"; // Change this line
Joseph
@revisualize
May 26 2017 02:51
@RyanHuang06 You need to read what I wrote.
@RyanHuang06 You didn't make all of the changes.
Claudio Restifo
@Marmiz
May 26 2017 02:52
@Zacele you called both the variable and the filtered array arr.
and one of the variable is global, so is a mismatch name
Khoa Le
@Zacele
May 26 2017 02:53

function filterNumbersFromArray(arr) {
// Write the code that goes here
arr = arr.filter(function(x){
return typeof x ==='number';
});
console.log(arr);
}

var arr = [1, 'a', 'b', 2];
filterNumbersFromArray(arr);

for (var i = 0; i < arr.length; i++)
console.log(arr[i]);
if I did this
it still the same output
cannot assign the arr into the filtered arr
Claudio Restifo
@Marmiz
May 26 2017 02:56

@Zacele


function filterNumbersFromArray(arr) {
// Write the code that goes here
var arr = arr.filter(function(x){ .  // scoped variable, visible only to the function instance
return typeof x ==='number';
});
console.log(arr);
}

var arr = [1, 'a', 'b', 2];  //global variable
filterNumbersFromArray(arr);

for (var i = 0; i < arr.length; i++) //which one o you think this arr is? The scoped or the global?
console.log(arr[i]);



Khoa Le
@Zacele
May 26 2017 02:57
@Marmiz so how could we update the filtered arr into the global array has provided
James Roberts
@Erodi
May 26 2017 02:59
Do I have to define what the wordBlanks (myNoun,myAdjective, etc) are before I build the string?
Joseph
@revisualize
May 26 2017 03:00

@RyanHuang06 You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n \\ SecondLine backslash carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ \r ThirdLine
You have to follow the instructions and remove all of the spaces
Then assign that to myStr as a string.

This lesson is not trying to teach you how to get some green check marks to pass onto the next lesson. It is trying to teach you a really valuable skill. If you have a string in JavaScript that is instantiated with double quotes (") (Example: var myStr = "Hello World";) you can also instantiate a string with single quotes (') (Example: var myStr = 'Hello World';)

How do you add a " to that string? Let's say you instantiated the string with double quotes and you want to put in a quote that someone said. You have to use an escape character.
Example: var myQuote = "Happy Feet said, \"I really like the rhythm.\"";
Or what happens if you want to add a tab to your string? You can't really add 3 spaces and expect it to show up as a tab. You have to use the escape character for a tab (\t).

OR let's say your trying to output a bunch of text and paragraphs within your JavaScript string. You can't really just make a bunch of variables.
var myParagraph1 = "a bunch of characters";
var myParagraph2 = "a bunch more characters";
I mean you could... but, why not just:
var myStr = "A bunch of characters/sentences.\nThe second paragraph of characters and sentences.";

Manish Giri
@Manish-Giri
May 26 2017 03:00
@Erodi no
they're already setup when the function gets called.
James Roberts
@Erodi
May 26 2017 03:04
I tried doing something like:
var myStr = "blah blah" +myNoun+ "blah blah" +myAdjective+ "blah blah" +myVerb+ "blah blah" +myAdverb+ "blah";
and that was incorrect
Joseph
@revisualize
May 26 2017 03:05
@Erodi because of spaces
Manish Giri
@Manish-Giri
May 26 2017 03:05
@Erodi need spaces
James Roberts
@Erodi
May 26 2017 03:05
spaces between the plus signs?
Joseph
@revisualize
May 26 2017 03:05
@Erodi blah blahdogblah blahveryblah blah
Claudio Restifo
@Marmiz
May 26 2017 03:05
@Zacele you can either assign a new variable to the returned filtered values or, re-assign the arr. (i personally suggest the 1st)

function filterNumbersFromArray(arr) {
// Write the code that goes here
return arr.filter(function(x){ .  // here I can just return the filtered values
return typeof x ==='number';
});
}

var arr = [1, 'a', 'b', 2];  //global variable
var x = filterNumbersFromArray(arr);
console.log(x)
/* or if you want to reassign:
* arr = filterNumbersFromArray(arr);
*/
Manish Giri
@Manish-Giri
May 26 2017 03:05
@Erodi "Hello" + " " + "world"
Claudio Restifo
@Marmiz
May 26 2017 03:07
@revisualize you should place that explanation into a gits book and link it everytime someone ask :)
Joseph
@revisualize
May 26 2017 03:07
Khoa Le
@Zacele
May 26 2017 03:14
@Marmiz
WHY IT keep telling me that it fail to test it
Ogundele Olumide
@Lumexralph
May 26 2017 03:18
Good Morning
jdaquino
@jdaquino
May 26 2017 03:18
good morning, good evening
Ogundele Olumide
@Lumexralph
May 26 2017 03:18
@jdaquino all accepted :smile:
Claudio Restifo
@Marmiz
May 26 2017 03:19
@Zacele idk. I have no idea what that program is tasting agianst nor how it works. Maybe you should only write a function and avoid writing array or other variables.
Khoa Le
@Zacele
May 26 2017 03:20
@Marmiz I try everything man
Cascarr Alejandro Ihesie
@cascarr
May 26 2017 03:22
please I need help with this..

function titleCase(str) {

var myString = str.toLowerCase().split('');

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

var subString = myString[i].split('');

for (var j=0; j < subString.length; j++) {

subString[0] = subString[0].toUpperCase();
}

myString[i] = subString.join('');

}

return myString.join('');
}

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

jdaquino
@jdaquino
May 26 2017 03:24
Can someone help me understand the requisite for the Truncate-A-String challenge?
Ogundele Olumide
@Lumexralph
May 26 2017 03:24
@cascarr if you're to change the first character of every word to caps, your split should not be according to characters but spaces
@cascarr good morning
RyanHuang06
@RyanHuang06
May 26 2017 03:26
@revisualize still doesn't work
Claudio Restifo
@Marmiz
May 26 2017 03:26
@Zacele It probably just want you to write a function to use to filter:
function filterN(x) {
return typeof x === 'number'
}

[1,2,3].filter(filterN); // [1,2,3]
[1, 'a', 2, 'b'].filter(filterN) // [1,2]
['a', 'b', 'c'].filter(filterN) //[]
Cascarr Alejandro Ihesie
@cascarr
May 26 2017 03:26
@Lumexralph good morning.. how are you? let me try that.
RyanHuang06
@RyanHuang06
May 26 2017 03:27
var myStr = "FirstLine\n\SecondLine\\rThirdline"; // Change this line
still cant do it
Ogundele Olumide
@Lumexralph
May 26 2017 03:27
@RyanHuang06 Thirdline => ThirdLine
RyanHuang06
@RyanHuang06
May 26 2017 03:30
@Lumexralph doesn't make new lines
Ogundele Olumide
@Lumexralph
May 26 2017 03:31
@RyanHuang06 i don't understand, your code seems okay apart from the spelling, have you escaped backslash?
@cascarr I'm good, thanks
CamperBot
@camperbot
May 26 2017 03:31
lumexralph sends brownie points to @cascarr :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
May 26 2017 03:31
@RyanHuang06 remember that to see a backslash you need to escape them
Khoa Le
@Zacele
May 26 2017 03:32
@Marmiz
Claudio Restifo
@Marmiz
May 26 2017 03:32
Or in other word to see this: "\" i need to escape it first
@Zacele I think you're not following the logic here...
Masaki
@masaki1223
May 26 2017 03:33

function telephoneCheck(str) {
// Good luck!
if(str.indexOf(1)===0){
var testStr=str.split(/[-\s*!a-z&#()1]/).join('').split('');

var remainders=testStr.splice(0,10);
if(testStr.length!==0||remainders.length<10){
return false;
}

}
else if(str.indexOf(1)<0){//not including 1
var newStr=str.split(/[-\s%$()]/).join('').split(''); var remainder=newStr.splice(0,10); if(newStr.length!==0||remainder.length<10){ return false; } } else{ return false; } return true; } telephoneCheck("(555-555-5555"); Hello guys, I'm having a trouble in classifying parentheses in two cases: normal use (num) and as a object (num. Any advice would be appreciated! Khoa Le @Zacele May 26 2017 03:34  function filterNumbersFromArray(arr) { // Write the code that goes here return arr.filter(function(x){ return typeof x ==='number' && x%1 === 0; }); } var arr = [1, 4.06,true,'a', , 4, 2]; arr = filterNumbersFromArray(arr); for(var i=0; i < arr.length ;i++){ console.log(arr [i]); } Claudio Restifo @Marmiz May 26 2017 03:35 @Zacele does this: function filterNumbersFromArray(arr) { // Write the code that goes here return arr.filter(function(x){ return typeof x ==='number' && x%1 === 0; }); } and this: function filterN(x) { return typeof x === 'number' } seems the same to you? In the second case I wrote a function that the filter method will use to test each element of the array against. Look at the docs! Jonathan Mancia @jonmancia May 26 2017 03:35 What am I doing wrong? I can't seem to map over this data :( my browser crashes [{"value":"ACURA","title":"Acura","models":[{"value":"CL_MODELS","title":"CL Models (4)"},{"value":"2.2CL","title":" - 2.2CL"},{"value":"2.3CL","title":" - 2.3CL"},{"value":"3.0CL","title":" - 3.0CL"},{"value":"3.2CL","title":" - 3.2CL"},{"value":"ILX","title":"ILX"},{"value":"INTEG","title":"Integra"},{"value":"LEGEND","title":"Legend"},{"value":"MDX","title":"MDX"},{"value":"NSX","title":"NSX"},{"value":"RDX","title":"RDX"},{"value":"RL_MODELS","title":"RL Models (2)"},{"value":"3.5RL","title":" - 3.5 RL"},{"value":"RL","title":" - RL"},{"value":"RSX","title":"RSX"},{"value":"SLX","title":"SLX"},{"value":"TL_MODELS","title":"TL Models (3)"},{"value":"2.5TL","title":" - 2.5TL"},{"value":"3.2TL","title":" - 3.2TL"},{"value":"TL","title":" - TL"},{"value":"TSX","title":"TSX"},{"value":"VIGOR","title":"Vigor"},{"value":"ZDX","title":"ZDX"},{"value":"ACUOTH","title":"Other Acura Models"}] modelList = modelList.map( (model, i) => { return (<option value={model["models"]}>{model["models"]}</option>) }) Zachary Orona-Calvert @TheTRUEHoohah May 26 2017 03:36 @TheTRUEHoohah hey guys how would i record clicks on an element in JS then compare them to a set array its for the simon says game Claudio Restifo @Marmiz May 26 2017 03:36 @TheTRUEHoohah if the click pass a value, than you can indexOf the value to the array for example Zachary Orona-Calvert @TheTRUEHoohah May 26 2017 03:37 so the indexOf? Jonathan Mancia @jonmancia May 26 2017 03:38 What I am doing wrong? I’ve tried the following as well and had not luck modelList = modelList.map( (model, i) => { return (<option value={model["models"]["title"]}>{model["models"]["title"]}</option>) }) Khoa Le @Zacele May 26 2017 03:40 @Marmiz so what is ur suggestion Nazar Maksymchuk @MANTENN May 26 2017 03:44 GOT IT MYSELF. No need Claudio Restifo @Marmiz May 26 2017 03:45 @Zacele I can re-write it as such and still produce the same output as you. Imho the instruction are way too vague: function filterNumbersFromArray(arr) { // Write the code that goes here return typeof arr === 'number' && arr%1 === 0; } [1, 4.06,true,'a', , 4, 2].filter(filterNumbersFromArray); Zachary Orona-Calvert @TheTRUEHoohah May 26 2017 03:46 i'm stuck on the part where i record the previous turn and compare it to the challenge given to the user on the simon says challenge this is my JS so far$(document).ready(function(){
var turns = [];
var counts = [];
var colors = ["blue","green","red","yellow"];
function Win() {
if(
counts===20){
reset();}}
turns.push(colors[Math.floor(Math.random() * colors.length)]);
var level = turns.length;
$('.level').text(level); } var levels(){ } function reset(){ turns=[]; } }); Victor Chastinet @VChastinet May 26 2017 03:53 tryed realy hard to use a "for" loop, but after hours i gave up and did the "hard" way, passed the test but it's really limited... any thoughts on how to solve this loop? function destroyer(arr) { var seeker = arguments; var newArr = []; var test = ""; arr = arr.filter(function (destroyer) { return destroyer != seeker[1] && destroyer != seeker[2] && destroyer != seeker[3]; /*for (var i=1; i<seeker.length; i++){ if (destroyer !== seeker[i]){ newArr.push(destroyer); } }*/ }); return arr; } destroyer([3, 5, 1, 2, 2], 2, 3, 5); thanks! Ogundele Olumide @Lumexralph May 26 2017 03:53 @VChastinet you can use indexOf method RyanHuang06 @RyanHuang06 May 26 2017 03:54 guess there's a bug Victor Chastinet @VChastinet May 26 2017 03:55 @Lumexralph as an 'if' conditional? Ogundele Olumide @Lumexralph May 26 2017 03:55 @VChastinet yes @RyanHuang06 where? Claudio Restifo @Marmiz May 26 2017 03:58 @RyanHuang06 have you updated the string with the escaped backslash? Andrew Saganda @asaganda May 26 2017 04:07 need some assistance with profile lookup assignment. Once i have the 1st for loop setup to get inside the contacts array, how do i set up the 2nd loop to iterate over the objects? CamperBot @camperbot May 26 2017 04:07 :bulb: to format code use backticks!  more info Ogundele Olumide @Lumexralph May 26 2017 04:08 @asaganda you don't need a 2nd loop @asaganda you just need to check the object's properties Garo @Garabed96 May 26 2017 04:09 @sjames1958gm @Blauelf thanks CamperBot @camperbot May 26 2017 04:09 garabed96 sends brownie points to @sjames1958gm and @blauelf :sparkles: :thumbsup: :sparkles: :star2: 4245 | @blauelf |http://www.freecodecamp.com/blauelf :star2: 7490 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Victor Chastinet @VChastinet May 26 2017 04:09 @Lumexralph i guess the indexOf is not working either, i'm ending up with the same problem... i think i'm doing something wrong with the expression, not the conditional... but thanks for the tip. CamperBot @camperbot May 26 2017 04:09 vchastinet sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles: :star2: 1819 | @lumexralph |http://www.freecodecamp.com/lumexralph Garo @Garabed96 May 26 2017 04:09 this is so fucked up I got an alogrithm to work without even knowing wtf i did Keith Thor @kthor May 26 2017 04:09 What am i doing wrong here? It just spits the same unfiltered array back out at me. When i console.log the val that fails, it gives me the right value. ''' function destroyer(arr) { // Remove all the values var filteredArr = arguments[0].filter(function(val){ var passes = true; var i = 1; while(passes && i < arguments.length){ if (val === arguments[i]) passes = false; else i++; } return passes; }); return filteredArr; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); ''' CamperBot @camperbot May 26 2017 04:09 :bulb: to format code use backticks!  more info Ogundele Olumide @Lumexralph May 26 2017 04:10 @Garabed96 :joy best you try to know Garo @Garabed96 May 26 2017 04:10 @Lumexralph I plan on it, worst part is I don't feel good about it lol Ogundele Olumide @Lumexralph May 26 2017 04:11 @Garabed96 :smile: Claudio Restifo @Marmiz May 26 2017 04:15 @Zacele any update? Now I feel like I'm part of it ^^ RyanHuang06 @RyanHuang06 May 26 2017 04:15 var myStr = "Learning to code is" += someAdjective; it says "bad assignment" whoops I mean var myStr = "Learning to code is" += someAdjective; Claudio Restifo @Marmiz May 26 2017 04:16 @RyanHuang06 you don't need the = to reassign a value. simply concatenate the adjective Victor Chastinet @VChastinet May 26 2017 04:16 @kthor if you use the arguments expression it will return the arguments of the nearest function (in that case the filter function) you need to transform the arguments you want into a array or assign it to a var. jdaquino @jdaquino May 26 2017 04:17 "is" + someAdjective; Keith Thor @kthor May 26 2017 04:19 @VChastinet oh man i totally missed that lol, thanks CamperBot @camperbot May 26 2017 04:19 kthor sends brownie points to @vchastinet :sparkles: :thumbsup: :sparkles: :cookie: 253 | @vchastinet |http://www.freecodecamp.com/vchastinet Alexey M @AerospaceEngineerBadAss May 26 2017 04:20 hi guys i was hoping someone could help me out here Markus Ivancsics @ivancsicsmarkus May 26 2017 04:20 @AerospaceEngineerBadAss Hello! What do you have? Alexey M @AerospaceEngineerBadAss May 26 2017 04:21 trying to post a picture to show you the code Nick Forlivio @whackdev May 26 2017 04:21 use 3 backticks  Alexey M @AerospaceEngineerBadAss May 26 2017 04:21 sorry did it twice new to posting here Nick Forlivio @whackdev May 26 2017 04:21 then copy paste code and thre more backticks Alexey M @AerospaceEngineerBadAss May 26 2017 04:22 i have it passing everything for the mutation test except this last one it keeps coming out true but don't understand why, in my head it should return false Nick Forlivio @whackdev May 26 2017 04:23 @AerospaceEngineerBadAss all the criteria evaluates to true @AerospaceEngineerBadAss you don't need the duplicate assignments you can just add var to the lower three Alexey M @AerospaceEngineerBadAss May 26 2017 04:24 i would think when the y is passed it would return false if i pass the y by itself it returns false Andrew Saganda @asaganda May 26 2017 04:27 @Lumexralph something like this: if (firstName === contacts[i].firstName) { ? Jacky @skywards1910 May 26 2017 04:28 hello, I dont understand why firt function work but the second one doesn't work: const flatten = arr => arr.reduce( (acc, val) => acc.concat( Array.isArray(val) ? flatten(val) : val ), [] ); function flatten(arr){ arr.reduce(function(acc, val){ acc.concat(Array.isArray(val)?flatten(val) : val); },[]); }; Nick Forlivio @whackdev May 26 2017 04:29 @AerospaceEngineerBadAss my solution is almost exactly what you have I'm trying to spot the difference Alexey M @AerospaceEngineerBadAss May 26 2017 04:29 thanks nick your help would be very appreciated, its driving me crazy Andrew Saganda @asaganda May 26 2017 04:29 @Lumexralph still around? Ogundele Olumide @Lumexralph May 26 2017 04:30 @asaganda yes @asaganda you're on track Nick Forlivio @whackdev May 26 2017 04:30 @AerospaceEngineerBadAss I figured it out @AerospaceEngineerBadAss the problem is the if condition, and the split method Alexey M @AerospaceEngineerBadAss May 26 2017 04:31 @whackdev what did you see, i'm thinking it has to do that i'm always over riding the last value Jacky @skywards1910 May 26 2017 04:31 const flatten = arr => arr.reduce( (acc, val) => acc.concat( Array.isArray(val) ? flatten(val) : val ), [] ); function flatten(arr){ arr.reduce(function(acc, val){ acc.concat(Array.isArray(val)?flatten(val) : val); },[]); }; can somebody explain to me why the first function work well but the second doesn't work. Nick Forlivio @whackdev May 26 2017 04:31 @AerospaceEngineerBadAss it is it's the last value because of the split @AerospaceEngineerBadAss you can do it without that completely Markus Ivancsics @ivancsicsmarkus May 26 2017 04:32 @skywards1910 the second one is a function. You have to call it: flatten(arrName) (arrName here is arr) Alexey M @AerospaceEngineerBadAss May 26 2017 04:32 @whackdev would it be ok to share your code so that i can glimpse it Nick Forlivio @whackdev May 26 2017 04:33 @AerospaceEngineerBadAss try starting with the two variables:  var base = arr[0].toLowerCase(); var sub = arr[1].toLowerCase(); @AerospaceEngineerBadAss then compare them with the indexOf method Andrew Saganda @asaganda May 26 2017 04:34 @Lumexralph is this a valid statement: if (firstName === contacts[i].firstName && prop === contacts[i].hasOwnProperty[prop]) { return contacts[i].firstName[prop]; } ? Alexey M @AerospaceEngineerBadAss May 26 2017 04:34 i see what you did, i'll try that now, still don't fully understand why that would make a difference Jacky @skywards1910 May 26 2017 04:34 @ivancsicsmarkus i know that. I mean when I invoke function: flatter(arrName). The first work, the second does not work. Nick Forlivio @whackdev May 26 2017 04:35 @AerospaceEngineerBadAss because the splice returns another array by the seporator and you are using a string to compare but you just need to compare the two items your are provided Markus Ivancsics @ivancsicsmarkus May 26 2017 04:35 @skywards1910 add a line (maybe): function flatten(arr){ arr.reduce(function(acc, val){ acc.concat(Array.isArray(val)?flatten(val) : val); return acc; },[]); }; Alexey M @AerospaceEngineerBadAss May 26 2017 04:36 @whackdev thanks for your help mate CamperBot @camperbot May 26 2017 04:36 aerospaceengineerbadass sends brownie points to @whackdev :sparkles: :thumbsup: :sparkles: :cookie: 279 | @whackdev |http://www.freecodecamp.com/whackdev Nick Forlivio @whackdev May 26 2017 04:36 @AerospaceEngineerBadAss :+1: Markus Ivancsics @ivancsicsmarkus May 26 2017 04:36 @skywards1910 now? Andrew Saganda @asaganda May 26 2017 04:37 @Lumexralph i'm definitely missing something..I added more to the code but i know it's not solving it for (var i = 0; i < contacts.length; i++) { if (firstName === contacts[i].firstName && prop === contacts[i].hasOwnProperty[prop]) { return contacts[i].firstName[prop]; } } return "no such contact" Jacky @skywards1910 May 26 2017 04:40 @ivancsicsmarkus No, you must see definition of 'Array.prototype.reduce' function. I don't understand different when using arrow (=>) and anonymous function in here Markus Ivancsics @ivancsicsmarkus May 26 2017 04:40 @asaganda this would return: contacts[i]’s firstName’s property. You have to return contact[i]’s property. @skywards1910 Could you give me an array to test? Ogundele Olumide @Lumexralph May 26 2017 04:41 @asaganda when you check if firstName parameter is equal to firstName property you need another condition nested to check if that object has a property prop.... if true you return the value of that prop in the object but if it's not true you return no such property as required Jacky @skywards1910 May 26 2017 04:41 @ivancsicsmarkus full source code from mozilla : var sum = [0, 1, 2, 3].reduce(function(acc, val) { return acc + val; }, 0); // sum is 6 var list1 = [[0, 1], [2, 3], [4, 5]]; var list2 = [0, [1, [2, [3, [4, [5]]]]]]; const flatten = arr => arr.reduce( (acc, val) => acc.concat( Array.isArray(val) ? flatten(val) : val ), [] ); // function flatten(arr){ // arr.reduce(function(acc, val){ // acc.concat(Array.isArray(val)?flatten(val) : val); // },[]); // }; console.log(flatten(list1)); // returns [0, 1, 2, 3, 4, 5] flatten(list2); // returns [0, 1, 2, 3, 4, 5] Ogundele Olumide @Lumexralph May 26 2017 04:42 @asaganda then you must allow your loop to be done looking through contacts array before returning no such contact Joy Bhalla @JoyBhalla May 26 2017 05:03 var myStr="\FirstLine\n\SecondLine\r\ThirdLine\"; "myStr should have encoded text with the proper escape sequences and no spacing." what am i doing wrong ? lesleywayne @Lwave May 26 2017 05:05 Joy Bhalla @JoyBhalla May 26 2017 05:06 remove the dot after 35 lesleywayne @Lwave May 26 2017 05:06 ..no i need the number that gives me 2 Joy Bhalla @JoyBhalla May 26 2017 05:06 33 change 35 to 33 you'll get 2 Moisés Man @moigithub May 26 2017 05:08 re-read instructions escaped backslashes should be around SecondLine @JoyBhalla Joy Bhalla @JoyBhalla May 26 2017 05:09 @moigithub Got it,Thanks for the help! CamperBot @camperbot May 26 2017 05:09 joybhalla sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles: :star2: 3261 | @moigithub |http://www.freecodecamp.com/moigithub Aniculaesei @Aniculaesei May 26 2017 05:09 Can somebody tell me please why my h1 element are not in a row?Thank you <!doctype html> <html> <head> <meta charset = "utf-8"> <title>Random Quote Machine</title> <metaname=”viewport”content=”width=device-width, initial-scale=1″> <link rel="stylesheet" href="normalize.css"> <link rel="stylesheet" href="main.css"> <script src = "script.js"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div class = "container-fluid"> <div class = "row"> <div class = "col-xs-4"> <h1>Bow</h1> </div> <div class = "col-xs-4"> <h1>Mow</h1> </div> <div class = "col-xs-4"> <h1>Pow</h1> </div> </div> </div> </body> </html> Nazar Maksymchuk @MANTENN May 26 2017 05:13 anyone has a better solution? function truncateString(str, num) { // Clear out that junk in your trunk if(str.length !== num ) { if ( num <= 3 ) { return str.slice(0, num) + "..."; } else if ( str.length >= num ) { return str.slice(0, num-3) + "..."; } } return str; } truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length); Trunucate the String challenge Markus Kiili @Masd925 May 26 2017 05:16 @MANTENN I did it like this. function truncateString(str, num) { if (str.length>num) { if (num <=3) str = str.substr(0,num); else str = str.substr(0,num-3); str += '...'; } return str; } Nazar Maksymchuk @MANTENN May 26 2017 05:17 @Masd925 nearly identical to mine except without curly braces; not familiar with that, whats the method called? Markus Kiili @Masd925 May 26 2017 05:18 @MANTENN Do you mean using if and else without code block braces? Nazar Maksymchuk @MANTENN May 26 2017 05:18 @Masd925 yes indeed Markus Kiili @Masd925 May 26 2017 05:18 @MANTENN If there is only one statement on the block, braces are optional. Xarri Jorge @xarrijorge May 26 2017 05:18 @Masd925 yeah, it works if you are returning a single line. Nazar Maksymchuk @MANTENN May 26 2017 05:19 id still like to know what its called :\ Xarri Jorge @xarrijorge May 26 2017 05:19 Nazar Maksymchuk @MANTENN May 26 2017 05:21 @kodinglife they have no name :), great news I guess less to memorize more to learn or less memory wasted on defintions Masaki @masaki1223 May 26 2017 05:21 what is the difference between | and || in regex? Xarri Jorge @xarrijorge May 26 2017 05:22 @MANTENN Yeah, it is just a styling preference. I prefer the full {} though for every statement Nazar Maksymchuk @MANTENN May 26 2017 05:22 @kodinglife I can see why and its not recommened but still nice to know @masaki1223 I think there is no difference I have a tool bookmarked to experiment with regex Xarri Jorge @xarrijorge May 26 2017 05:23 @MANTENN Yeah, MDN is my go reference Nazar Maksymchuk @MANTENN May 26 2017 05:24 @kodinglife I'd still have more than one reference because I'd still have trouble understanding one thing and being frustated would set you off-schedule/plans @masaki1223 it takes in numbers? and single characters(letters)? chameleon07 @chameleon07 May 26 2017 05:31 function rot13(str) { // LBH QVQ VG! arr = str.split(" ").map(function(val){return val.split("");}); for (i = 0; i < arr.length; i++){ for (j = 0; j < arr[i].length; j++){ if ( arr[i][j].charCodeAt() < 65){ continue; } else{arr[i][j] = arr[i][j].charCodeAt();} } } return arr.map(function(val){ for (i = 0; i < val.length; i++){ if (val[i] < 65){ continue; } else if (val[i] + 13 > 90){ val[i] = String.fromCharCode(val[i] - 13); } else { val[i] = String.fromCharCode(val[i] + 13);} } return val.join(""); }).join(" "); } // Change the inputs below to test rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK."); Why do the exclamation marks, periods, and question marks get represented as a red dot? Nazar Maksymchuk @MANTENN May 26 2017 05:32 @chameleon07 make it morereadable? Markus Kiili @Masd925 May 26 2017 05:32 @chameleon07 An easier way is to use an array of characters and map them. No need to consider words here. Nazar Maksymchuk @MANTENN May 26 2017 05:32 anyone know how I can parse instagrams explore feed? i have the url I have to pass a bunch of parameters chameleon07 @chameleon07 May 26 2017 05:34 @Masd925 True true... I made it more complicated this way.... Thanks for the tip heh CamperBot @camperbot May 26 2017 05:34 chameleon07 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 4138 | @masd925 |http://www.freecodecamp.com/masd925 Markus Kiili @Masd925 May 26 2017 05:35 @chameleon07 You need to check if the character is at range A-Z and only map it if it is. Others you leave be. Nazar Maksymchuk @MANTENN May 26 2017 05:36 @Masd925 the filter function should the job or replace Markus Kiili @Masd925 May 26 2017 05:37 @MANTENN Using map or replace is simplest. Nazar Maksymchuk @MANTENN May 26 2017 05:37 @Masd925 don't remember much of them - guess I have to use them more often .map I do This the only career that doesn't require you to memorize a lot of definitions, instead you memorize them by utilizing right? chameleon07 @chameleon07 May 26 2017 05:39 Thank you guys :thumbsup: Markus Kiili @Masd925 May 26 2017 05:39 @MANTENN I write notebooks of stuff I don't wan't to memorize. Nazar Maksymchuk @MANTENN May 26 2017 05:40 @Masd925 you are saying you memorize stuff you dont want to? Markus Kiili @Masd925 May 26 2017 05:40 @MANTENN No, I write down things I don't wan't to memorize. Nazar Maksymchuk @MANTENN May 26 2017 05:40 @Masd925 I guess I should make myself a website: one that I can reference later down the road: thanks CamperBot @camperbot May 26 2017 05:40 mantenn sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 4139 | @masd925 |http://www.freecodecamp.com/masd925 Nazar Maksymchuk @MANTENN May 26 2017 05:40 local one though at first. Markus Kiili @Masd925 May 26 2017 05:41 @MANTENN Yeah, whatever suits you. Nazar Maksymchuk @MANTENN May 26 2017 05:41 @Masd925 I dont have a big desk or a place to store my notebooks - it would be a hassle. even then my brother puts his computer, phone and headphones - no room almost var xmlhttp= new XMLHttpRequest(); var url="https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS?redirectlocale=en-US&redirectslug=HTTP_access_control"; xmlhttp.open("GET",url,false); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); xmlhttp.send(); This is cool :) I know how to do it except cors part setting the asynchronus value to true would mean it would be connected to the server and I could get realtime updates right? Markus Kiili @Masd925 May 26 2017 05:48 @MANTENN Async set to false would mean that the code execution would wait for the response to come, so the page would be blocked for some time. Not good usually. Nazar Maksymchuk @MANTENN May 26 2017 05:48 @Masd925 i read something about asynchronus requests vs synchronus? something with an s @Masd925 what you said, now I remember how does facebook update the feed? realtime calls each second? PhoenixFarhan @PhoenixFarhan May 26 2017 05:50  //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { for (var j = 0; j< contacts[i].length; j++) { if ((contacts.firstName === "firstName") && (contacts[j] === "prop")){ return [prop]; } }} / else if (contacts !== "firstName") { return "No such contact"; } else if (contacts !== "prop"){ return "No such property"; } // Only change code above this line } / } // Change these values to test your function lookUpProfile("Sherlock", "likes");  Ive been struggling with this for a few days now i cannot seem to figure out how to proceed Nazar Maksymchuk @MANTENN May 26 2017 05:51 @PhoenixFarhan move one return statement ouf the loop return "No such property"; Markus Kiili @Masd925 May 26 2017 05:51 @PhoenixFarhan One loop through contacts array is enough. Nazar Maksymchuk @MANTENN May 26 2017 05:51 and what @Masd925 said PhoenixFarhan @PhoenixFarhan May 26 2017 05:53 hmm so:  //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if ((contacts.firstName === "firstName") && (contacts[j] === "prop")){ return [prop]; } else if (contacts !== "firstName") { return "No such contact"; } else if (contacts !== "prop"){ return "No such property"; } // Only change code above this line } } // Change these values to test your function lookUpProfile("Sherlock", "likes"); Nazar Maksymchuk @MANTENN May 26 2017 05:53 move the else if (contacts !== "prop") PhoenixFarhan @PhoenixFarhan May 26 2017 05:54 this still does not work; 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" Nazar Maksymchuk @MANTENN May 26 2017 05:54 out of the for loop Markus Kiili @Masd925 May 26 2017 05:54 @PhoenixFarhan None of the conditions is right. Nazar Maksymchuk @MANTENN May 26 2017 05:54 where you have "prop" you should use contacts.hasOwnProperty(prop) Markus Kiili @Masd925 May 26 2017 05:55 @MANTENN contacts[i].hasOwnProperty(prop) Nazar Maksymchuk @MANTENN May 26 2017 05:55 yes, ^^^ Markus Kiili @Masd925 May 26 2017 05:55 @PhoenixFarhan First if should compare === the first name of the looped contact with the firstName parameter. PhoenixFarhan @PhoenixFarhan May 26 2017 05:56 kk Thanks @MANTENN @Masd925 I did not know you could use .hasOwnProperty that way CamperBot @camperbot May 26 2017 05:56 phoenixfarhan sends brownie points to @mantenn and @masd925 :sparkles: :thumbsup: :sparkles: :star2: 4140 | @masd925 |http://www.freecodecamp.com/masd925 :cookie: 279 | @mantenn |http://www.freecodecamp.com/mantenn noelachica @noelachica May 26 2017 06:19 How can I extract the array from this variable? destroyer([1, 2, 3, 1, 2, 3], 2, 3) Nazar Maksymchuk @MANTENN May 26 2017 06:20 what ever the pararmeter is in the functiond declaration Markus Kiili @Masd925 May 26 2017 06:20 @noelachica That array is stored in the parameter arr and rest of the arguments you need to get from the arguments object. arguments[0] is the same as arr. noelachica @noelachica May 26 2017 06:21 Yes but all are inside arr no Markus Kiili @Masd925 May 26 2017 06:21 @noelachica No. noelachica @noelachica May 26 2017 06:21 I already did that, and it turns out that it takes the first value!, And I think the same as you Markus Kiili @Masd925 May 26 2017 06:22 @noelachica You need to use the arguments object. Read up on it. One parameter catches only one argument. noelachica @noelachica May 26 2017 06:22 But then it is called distinct from arr? Markus Kiili @Masd925 May 26 2017 06:23 @noelachica Using arr is not enough. It only stores the first passed argument. On that call arr would be [1,2,3,1,2,3] noelachica @noelachica May 26 2017 06:24 How would it be then? Markus Kiili @Masd925 May 26 2017 06:24 arguments[1] would be 2 and arguments[2] would be 3. Nazar Maksymchuk @MANTENN May 26 2017 06:24 @masd925 does facebook call the server to retrieve an update for the feed each second? Markus Kiili @Masd925 May 26 2017 06:24 So you need to loop the arguments from the arguments object. jmariomejiap @jmariomejiap May 26 2017 06:25 @noelachica your function has only one parameter declared or expected (which is an array) but using the arguments object the function can access more arguments. Nazar Maksymchuk @MANTENN May 26 2017 06:25 I dont use it but I want to know how it's done. noelachica @noelachica May 26 2017 06:26 And how to access those arguments that I'm flipping Markus Kiili @Masd925 May 26 2017 06:26 @noelachica You can use arguments[i] and arguments.length. It is an array-like object. noelachica @noelachica May 26 2017 06:26 arr.from ¿ jmariomejiap @jmariomejiap May 26 2017 06:26 @noelachica so you can select those "arguments" like you would in an array.... literally arguments[1] Markus Kiili @Masd925 May 26 2017 06:26 @noelachica It is also possible to turn the arguments object into an array. noelachica @noelachica May 26 2017 06:29 I still do not understand how the array of the arr variable would be extracted with the arguments. Because I'm trying and it gives me everything wrong Nazar Maksymchuk @MANTENN May 26 2017 06:29 Connection "keep-alive this is in the headers Markus Kiili @Masd925 May 26 2017 06:31 @noelachica You can access the passed array using arr. Rest of the arguments you can access by looping arguments object from index 1. Nazar Maksymchuk @MANTENN May 26 2017 06:31 make sense and event listens to a response from the server, pretty cool noelachica @noelachica May 26 2017 06:32 Could you write me what would it be? It's that it's costing me to understand you more because I'm Spanish hahaha Nazar Maksymchuk @MANTENN May 26 2017 06:33 @noelachica arr is the parameter you specified, so when ever you have only two inputs you want be able to access it with a parameter instead youll need to use arguementssince its an array you use dot notation to access an array, the second arguement would be arguements[1] Markus Kiili @Masd925 May 26 2017 06:33 @noelachica There should be a helpful link there about the arguments object. Read it first. Vivek @vivekmittal7 May 26 2017 06:33 function getIndexToIns(arr, num) { // Find my place in this sorted array. var placeholder; var result = arr.sort(); for (var i=0; i<result.length; i++){ if (arr[i]==num){ placeholder = i; } else if (arr[i] < num) { placeholder = i+1; } }return placeholder; someone help me getIndexToIns([10, 20, 30, 40, 50], 30) Nazar Maksymchuk @MANTENN May 26 2017 06:34 haven't done that not sure I can help :\ or have i? Vivek @vivekmittal7 May 26 2017 06:35 this code works but this doesnt getIndexToIns([3,10,5],3 ); Nazar Maksymchuk @MANTENN May 26 2017 06:35 @vivekmittal7 I know you are trying to complete the challenge what is it? ahh I remember Markus Kiili @Masd925 May 26 2017 06:35 @vivekmittal7 The default sort does not sort numerically. It sorts as text. noelachica @noelachica May 26 2017 06:35 :'( Markus Kiili @Masd925 May 26 2017 06:36 [5,31,1,12].sort(); // [ 1, 12, 31, 5 ] @vivekmittal7 The solution is simple if you first push num into arr and then sort. Nazar Maksymchuk @MANTENN May 26 2017 06:37 @Masd925 do you know what the challenge is? Markus Kiili @Masd925 May 26 2017 06:38 @MANTENN Yes, Where do I belong. Nazar Maksymchuk @MANTENN May 26 2017 06:38 @Masd925 I remember the arrays but my solution was more simpler. jmariomejiap @jmariomejiap May 26 2017 06:38 @noelachica hopefully this help you a bit function sayHello (name) { var firstName = name; var lastName = arguments[1]; console.log("Hello Mr.", firstName, lastName); } sayHello("mario", "mejia") noelachica @noelachica May 26 2017 06:39 function destroyer(arr) { var array = arr[0]; var arrayFinal = []; var contiene = false; //var variable = arr.from(arguments); for(var i =1; i < arr.length;i++){ for(var j = 0; j < arguments.length; j++){ if(arr[i] === arguments[j]){ arr.splice(i,i); } }  } I think I've already caught it. But I do not understand why this is so, I had never seen it Markus Kiili @Masd925 May 26 2017 06:39 @noelachica Mutating the array you iterate over with for leads to :cry: Nazar Maksymchuk @MANTENN May 26 2017 06:40 Basic Algorithm Scripting - 50hrs took me less and im more than half way like 1 day noelachica @noelachica May 26 2017 06:40 By the way as it was so that the code was seen better in the chat? If it is incomplete, I'm still testing haha jmariomejiap @jmariomejiap May 26 2017 06:41 @noelachica note that when I call the function my last argument "mejia" is not expected (or defined) but using the arguments object i can catch it. Markus Kiili @Masd925 May 26 2017 06:41 @noelachica You need to loop arr from index 0. noelachica @noelachica May 26 2017 06:41 From 0 arr why? Nazar Maksymchuk @MANTENN May 26 2017 06:42 @noelachica its because the loop starts at 0, to access the first item in array you need to use 0 second 1 and so on Markus Kiili @Masd925 May 26 2017 06:42 @noelachica On this call destroyer([1, 2, 3, 1, 2, 3], 2, 3) the arr would be [1, 2, 3, 1, 2, 3]. You need to check all the array elements, so loop arr from index 0. noelachica @noelachica May 26 2017 06:42 oks Ivan Leo @yaaaas May 26 2017 06:43 Hey guys, I need some help with the "Stand in Line assignment" Currently this is my code function nextInLine(arr, item) { // Your code here testArr.push(item); var x = testArr.shift(); return y; // Change this line } I'm trying to build to use shift on x in the event that it is an array. How might I go about doing this? Markus Kiili @Masd925 May 26 2017 06:43 @yaaaas Use arr and item, not testArr. Nazar Maksymchuk @MANTENN May 26 2017 06:44 use arr instead of testArr and item when you push Ivan Leo @yaaaas May 26 2017 06:44 Ahh I see Thanks so much @MANTENN ! CamperBot @camperbot May 26 2017 06:44 yaaaas sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles: :cookie: 280 | @mantenn |http://www.freecodecamp.com/mantenn Nazar Maksymchuk @MANTENN May 26 2017 06:44 return x; y is not a valid variable Vivek @vivekmittal7 May 26 2017 07:00 @Masd925 thanks CamperBot @camperbot May 26 2017 07:00 vivekmittal7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 4141 | @masd925 |http://www.freecodecamp.com/masd925 Saif Ur Rahman @saifsmailbox98 May 26 2017 07:01 The array method reduce is used to iterate through an array and condense it into one value. What does it mean? reduce Nazar Maksymchuk @MANTENN May 26 2017 07:01 produce an array with results that match the condition Vivek @vivekmittal7 May 26 2017 07:02 @saifsmailbox98 bro it takes every item of array and does calculation as defined by you Markus Kiili @Masd925 May 26 2017 07:02 @saifsmailbox98 Reduce is the general array iterator method. You can define any array iteration with it. Saif Ur Rahman @saifsmailbox98 May 26 2017 07:02 @vivekmittal7 so what is map used for then? Nazar Maksymchuk @MANTENN May 26 2017 07:03 return every item with array lets say * 2 Markus Kiili @Masd925 May 26 2017 07:03 @saifsmailbox98 Map is used when you wan't to transform each array element somehow. The number of element stay the same. Saif Ur Rahman @saifsmailbox98 May 26 2017 07:03 okay, thank you guys @MANTENN @vivekmittal7 @Masd925 CamperBot @camperbot May 26 2017 07:03 saifsmailbox98 sends brownie points to @mantenn and @vivekmittal7 and @masd925 :sparkles: :thumbsup: :sparkles: :cookie: 281 | @mantenn |http://www.freecodecamp.com/mantenn :cookie: 256 | @vivekmittal7 |http://www.freecodecamp.com/vivekmittal7 :star2: 4142 | @masd925 |http://www.freecodecamp.com/masd925 Vivek @vivekmittal7 May 26 2017 07:04 @saifsmailbox98 it gives aggregate of the result of every operation Saif Ur Rahman @saifsmailbox98 May 26 2017 07:04 okay Nazar Maksymchuk @MANTENN May 26 2017 07:05 Why characters in silicon valley have friend-relationships when they're in trouble. Vivek @vivekmittal7 May 26 2017 07:06 does anyone here know any site other than mdn which explains javascript in easy langugage for dummies Nazar Maksymchuk @MANTENN May 26 2017 07:06 Baghead is like a person - who doesn't use there logic, like who does not use their brain in the real world; kind of like a speaking monkey. Markus Kiili @Masd925 May 26 2017 07:08 @vivekmittal7 Don't know, but try to avoid W3Schools JS material. Nazar Maksymchuk @MANTENN May 26 2017 07:08 why Vivek @vivekmittal7 May 26 2017 07:09 @Masd925 but it is easier than mdn Markus Kiili @Masd925 May 26 2017 07:10 Full of errors especially on harder topics. Written by person(s) that don't really understand JS. Fine for checking basic stuff like method syntax etc. Nazar Maksymchuk @MANTENN May 26 2017 07:10 well yeah - its fine for basic stuff: is fien a german word? Vivek @vivekmittal7 May 26 2017 07:10 @Masd925 ok Nazar Maksymchuk @MANTENN May 26 2017 07:10 nah Markus Kiili @Masd925 May 26 2017 07:11 @vivekmittal7 I started JS with w3schools and had to unlearn a lot later. Nazar Maksymchuk @MANTENN May 26 2017 07:11 i started by modifying scripts XD tabs vs spaces? Vivek @vivekmittal7 May 26 2017 07:13 @Masd925 is it just me or you also think mdn is really tough Markus Kiili @Masd925 May 26 2017 07:13 @vivekmittal7 Tough at first but accurate information. You could try reading some JS book? Vivek @vivekmittal7 May 26 2017 07:14 @Masd925 ok thanks CamperBot @camperbot May 26 2017 07:14 vivekmittal7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :warning: vivekmittal7 already gave masd925 points Vivek @vivekmittal7 May 26 2017 07:17 function compare(a, b) { if (a is less than b by some ordering criterion) { return -1; } if (a is greater than b by the ordering criterion) { return 1; } // a must be equal to b return 0; } is it possible to write the whole statement in if argument, like the above code Nazar Maksymchuk @MANTENN May 26 2017 07:17 yes Manish Giri @Manish-Giri May 26 2017 07:17 you could do a < b ? -1: 1; maybe add another ternary to fit in the 0 Vivek @vivekmittal7 May 26 2017 07:23 @Manish-Giri what is this ? used for? Markus Kiili @Masd925 May 26 2017 07:30 @vivekmittal7 One of the best ways to obscure good code. Fine for simple enough expressions. Khalamari @Khalamari May 26 2017 07:30 why does this say: this is not defined at child? i don't understand this class stuff. class boss { constructor() { this.width = 25; } } class child extends boss { constructor() { this.width = 100; } } var entity = new child() console.log(entity) Nazar Maksymchuk @MANTENN May 26 2017 07:32 Tabs are more better than spaces. Markus Kiili @Masd925 May 26 2017 07:34 @MANTENN Do you mean code indentation? Nazar Maksymchuk @MANTENN May 26 2017 07:34 yes Markus Kiili @Masd925 May 26 2017 07:34 @MANTENN Spaces are prefferred because different editors show tabs differently. Nazar Maksymchuk @MANTENN May 26 2017 07:35 ok cool. tabs are more quicker unless you use spaces twice then your accuracy of indentation on each line is in question Legacy @punyparker May 26 2017 07:40 https://dev.twitter.com/web/tweet-button/parameters How do I set the text parameter using a variable??? Nazar Maksymchuk @MANTENN May 26 2017 07:41 what text link? Legacy @punyparker May 26 2017 07:41 Tried this var tweetText =$("#quote-cont").text() $("#tweet").attr("data-text", tweetText); But it doesn't work arjav2002 @arjav2002 May 26 2017 07:41 what is an area code in a US telephone number? Nazar Maksymchuk @MANTENN May 26 2017 07:41 url?text= + variable Legacy @punyparker May 26 2017 07:41 Ah @MANTENN but I mean in the HTML part using JS Nazar Maksymchuk @MANTENN May 26 2017 07:43 var el = document.getElementById('idtagwithoutthepound').href="https://twitter.com/tweet?text=" + text; Yanek Yuk @yanekyuk May 26 2017 07:51 Hi. I am stuck at this. var myCar = new Car(); myCar.nickname = "Somename"; Fails at third and fourth objective. Markus Kiili @Masd925 May 26 2017 07:51 @yanekyuk That part seems fine. Nazar Maksymchuk @MANTENN May 26 2017 07:52 that's what I think Markus Kiili @Masd925 May 26 2017 07:52 @yanekyuk Try resetting the challenge. Make sure you didn't touch the code above. Yanek Yuk @yanekyuk May 26 2017 07:53 @Masd925 Ok. I think I was missing some character as I decided to write here from the beginning. Now it works. Or After reset it is okay now. Thanks. CamperBot @camperbot May 26 2017 07:53 yanekyuk sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 4143 | @masd925 |http://www.freecodecamp.com/masd925 Markus Kiili @Masd925 May 26 2017 07:53 @yanekyuk :+1: Legacy @punyparker May 26 2017 07:56 @MANTENN It's not working. Check this https://codepen.io/1Want/pen/XRoBVm/?editors=1010 Nazar Maksymchuk @MANTENN May 26 2017 07:57 Most likely api randprs101 @randprs101 May 26 2017 07:58 Hey everyone! There's this site that really helped understand javascript better and I wanted to share it with you so it can possibly benefit you as well: watchandcode.com :) Nazar Maksymchuk @MANTENN May 26 2017 07:59 ok document.createElement("a").href="https://twitter.com/tweet?text=" + tweetText; capture it in a variable wait... $("#tweet").attr("href", "https://twitter.com/tweet?text=" + tweetText);
jquery way
codepen is overwriting
Legacy
@punyparker
May 26 2017 08:07
Overwriting? What do you mean?? @MANTENN
Nazar Maksymchuk
@MANTENN
May 26 2017 08:08
ok i see the problem
the id you selected is not an id of the anchor tag
nvm
i might have deleted it
Lenarey S. Torririt
@Lengzki
May 26 2017 08:09
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
• You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

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

Code:
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Blauelf
@Blauelf
May 26 2017 08:10
@MANTENN I don't think createElement without an assignment makes much sense. The created element would still need to be attached to the DOM at some place.
Legacy
@punyparker
May 26 2017 08:11
@MANTENN it's an id, that I'm sure
Nazar Maksymchuk
@MANTENN
May 26 2017 08:12
@Blauelf yeah I know I just gave an id because it returns can not set href of null
so does that mean the text is null
Blauelf
@Blauelf
May 26 2017 08:13
@MANTENN Means the part before .href returns null (maybe you used getElementById with an invalid ID)
Nazar Maksymchuk
@MANTENN
May 26 2017 08:13
valid id i doubled checled
Legacy
@punyparker
May 26 2017 08:14
So what's wrong with it? @MANTENN
Nazar Maksymchuk
@MANTENN
May 26 2017 08:16
I log the document with id it returns null
Legacy
@punyparker
May 26 2017 08:17
Yeah. I've been trying for hours.
Nazar Maksymchuk
@MANTENN
May 26 2017 08:17
Cannot set property 'href' of null
so its the id
it can not find it
        try {
}
catch (e) {
console.log(e);
}
tried to catch the error :\
Blauelf
@Blauelf
May 26 2017 08:18
There is no element of id "tweet" in the DOM.
Nazar Maksymchuk
@MANTENN
May 26 2017 08:18
@Blauelf how does codepen work?
Blauelf
@Blauelf
May 26 2017 08:19
If the Javascript removes the element of id "tweet", CodePen would not intervene.
Nazar Maksymchuk
@MANTENN
May 26 2017 08:19
its in an iframe, so it should find it hmm
I inspected the element
<a href="https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fs.codepen.io%2Fboomerang%2FiFrameKey-47573a06-1fde-f015-9e55-08042a6d10f6%2Findex.html%3Feditors%3D1010&amp;ref_src=twsrc%5Etfw&amp;tw_p=tweetbutton&amp;url=https%3A%2F%2Fcodepen.io%2F1Want%2Ffull%2FXRoBVm%2F" class="btn" id="b"><i></i><span class="label" id="l">Tweet</span></a>
no id.
luckystrikerr1
@luckystrikerr1
May 26 2017 08:20
guys, https://www.freecodecamp.com/challenges/understand-string-immutability what am i doing wrong here >
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World";
myStr[0] = "H"; // Fix Me
Nazar Maksymchuk
@MANTENN
May 26 2017 08:21
myStr[0] = "H"; // Fix Me remove it
luckystrikerr1
@luckystrikerr1
May 26 2017 08:21
@MANTENN ohh ty
CamperBot
@camperbot
May 26 2017 08:21
luckystrikerr1 sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles:
Vishvesh
@V1shvesh
May 26 2017 08:21
Can anyone help me with the "No Repeats Please" challenge??
Nazar Maksymchuk
@MANTENN
May 26 2017 08:22
yes the twitter api overwrites the button
nvm
Blauelf
@Blauelf
May 26 2017 08:27
@MANTENN Where does that iFrame come from? Wouldn't it be a security problem if you could directly manipulate links in an iFrame?
Nazar Maksymchuk
@MANTENN
May 26 2017 08:27
TBH I have no clue
What was thinking is doing it by parents element and then .childNode
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
fjs.parentNode.insertBefore(js, fjs);

t._e = [];
t._e.push(f);
};

return t;
});
can we use on change to see how it changes?
Blauelf
@Blauelf
May 26 2017 08:31
Yeah, found that now. I'm not sure how to change its message, though.
And I don't see any twitter widget.
Nazar Maksymchuk
@MANTENN
May 26 2017 08:32
using opera to inspect - based on chrome cant inspect anything on it with firefox
im going to monitor the execution on sources tab.
by creating break points
not sure if thats the right word
Rick Willcox
@willcoxDev
May 26 2017 08:33
if anyone wants to walk through some problems together
come hang out in my stream, https://www.twitch.tv/road_to_employable
Nazar Maksymchuk
@MANTENN
May 26 2017 08:34
@willcoxDev @punyparker needs help
https://codepen.io/1Want/pen/XRoBVm/
Tiago Correia
@tiagocorreiaalmeida
May 26 2017 08:37
can't understand this exercise if anyone is avaible to help ghere
Blauelf
@Blauelf
May 26 2017 08:38

@tiagocorreiaalmeida Two parts.

1. For certain values of card, increment or decrement global variable count
2. Return a string built from count and either Bet or Hold, depending on value of count. There should be one space between number and word.

Do not mix the two parts.

Jopee
@jopeemahmen
May 26 2017 08:40
Hi All, anyone willing to help me on the "Golf Code" challenge? Just a hint o tips would be appreciated (not direct answers). Thanks a lot!
Jeremy
May 26 2017 08:40
Nazar Maksymchuk
@MANTENN
May 26 2017 08:40
@Blauelf removed it. link changes - thought it was my code phew
Jeremy
May 26 2017 08:41
Hello chat! I'm stuck on challenge 171, Stand in Line. I'm getting an 'Out of stack space error'. Code above ^^ Many thanks!
Tiago Correia
@tiagocorreiaalmeida
May 26 2017 08:41
Jeremy
May 26 2017 08:42
@tiagocorreiaalmeida Yes I have. I thought I was suppose to use pop and push for this one.
Nazar Maksymchuk
@MANTENN
May 26 2017 08:42
@punyparker remove the call for the twitter widget, it changes the button as a result it does not get modified
Tiago Correia
@tiagocorreiaalmeida
May 26 2017 08:42
show me the exercise
Blauelf
@Blauelf
May 26 2017 08:42
@MANTENN I don't know the twitter widget, I would have changed links.
Jeremy
May 26 2017 08:43
@MANTENN That seems to have gotten rid of the error.

@tiagocorreiaalmeida Stand in Line
In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Nazar Maksymchuk
@MANTENN
May 26 2017 08:43
@Blauelf it changes the button and assigns a new id called b
but it then get's overwritten :\
document.getElementById('b').href="https://twitter.com/tweet?text=" + tweetText; should work but they have a listener I can see it - my theory
they could use event capturing.
Tiago Correia
@tiagocorreiaalmeida
May 26 2017 08:45
what's the exercise name? but im pretty sure about the part that you need to use shift for the second aprt of the exercise
but the push is right
you just need to change pop
Blauelf
@Blauelf
May 26 2017 08:45
@JeremySchade You should use arr (an array) and item (a soon-to-be array element) within the function, and not at all do recursive calls (calling the same function again). Also, functions need some parentheses to be called...
Nazar Maksymchuk
@MANTENN
May 26 2017 08:45
yes on the html
Jeremy
May 26 2017 08:46
@tiagocorreiaalmeida 'Stand in Line'
Tiago Correia
@tiagocorreiaalmeida
May 26 2017 08:46
just like I told you
try to focus you dont need to create a new array
Nazar Maksymchuk
@MANTENN
May 26 2017 08:47
Blauelf
@Blauelf
May 26 2017 08:47
@MANTENN Firefox dev edition :D
Jeremy
May 26 2017 08:47
@tiagocorreiaalmeida @Blauelf I see what you're saying, thank you.
CamperBot
@camperbot
May 26 2017 08:47
jeremyschade sends brownie points to @tiagocorreiaalmeida and @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4246 | @blauelf |http://www.freecodecamp.com/blauelf
Nazar Maksymchuk
@MANTENN
May 26 2017 08:47
@Blauelf yes, my favorite has useful tools :)
Tiago Correia
@tiagocorreiaalmeida
May 26 2017 08:47
you have arr and you need to add item to the end
arr.push(item);
and then it asks you to return the value you remove from the staert
so
return ...
hope you got it
gl
Blauelf
@Blauelf
May 26 2017 08:48
@MANTENN Has search across all files returned? (one of my favourite features of the debugger)
Nazar Maksymchuk
@MANTENN
May 26 2017 08:48
@Blauelf what search?
Vedant Kashyap
@vedant15188
May 26 2017 08:49
Hey guys I'm doing the TwitchTV Project and I'm stuck... I can't set the color of my list groups according to their corresponding channels live status here is the code snippet
var channels=["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

function showAll() {
console.log("showing all");
for (var i=0; i<channels.length; i++) {
$.getJSON("https://wind-bow.glitch.me/twitch-api/streams/"+channels[i],function (liveStatus) { console.log(JSON.stringify(liveStatus)+"\n\n\n\n"); if (liveStatus.stream!=null)$("#"+channels[i]).css("background-color","#82da6b");
else
$("#"+channels[i]).css("background-color","#c13f36"); }); } } Nazar Maksymchuk @MANTENN May 26 2017 08:49 its in the debugger for js or go to settings for more tools Blauelf @Blauelf May 26 2017 08:49 "across all files", used as !search term in Firefox up to version 52, I think. Nazar Maksymchuk @MANTENN May 26 2017 08:50 @Blauelf what do you mean by all files sources? Blauelf @Blauelf May 26 2017 08:51 Yeah, if I know some script targets element with id "stage3", I can search !stage3 and find the one of hundreds of Javascripts. Nazar Maksymchuk @MANTENN May 26 2017 08:51 im not that advanced but I love it. so far. Blauelf @Blauelf May 26 2017 08:51 No, in the search field of the debugger. Nazar Maksymchuk @MANTENN May 26 2017 08:52 yes i can Got to go to sleep, Peace have to get up at 7 Its been a great day. @Blauelf thanks for the tip CamperBot @camperbot May 26 2017 08:56 mantenn sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star2: 4247 | @blauelf |http://www.freecodecamp.com/blauelf Nasridean @Nasridean May 26 2017 08:57 Hi, everyone! I'm stuck on "Iterate Through an Array with a For Loop" challenge. // Example var ourArr = [ 9, 10, 11, 12]; var ourTotal = 0; for (var i = 0; i < ourArr.length; i++) { ourTotal += ourArr[i]; } // Setup var myArr = [ 2, 3, 4, 5, 6]; // Only change code below this line var total = 0; for (var i = 0; i < myArr.legth; i++) { total =total + myArr[i]; } heroiczero @heroiczero May 26 2017 08:58 @Nasridean length misspelled Vedant Kashyap @vedant15188 May 26 2017 08:58 Hey guys I'm doing the TwitchTV Project and I'm stuck... I can't set the color of my list groups according to their corresponding channels live status here is the code snippet  var channels=["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]; function showAll() { console.log("showing all"); for (var i=0; i<channels.length; i++) {$.getJSON("https://wind-bow.glitch.me/twitch-api/streams/"+channels[i],function (liveStatus) {
console.log(JSON.stringify(liveStatus)+"\n\n\n\n");
if (liveStatus.stream!=null)
$("#"+channels[i]).css("background-color","#82da6b"); else$("#"+channels[i]).css("background-color","#c13f36");
});
}
}


can anyone help me on this?? please????

Blauelf
@Blauelf
May 26 2017 08:58
@MANTENN In my regular Firefox, what I mean looks like
Nasridean
@Nasridean
May 26 2017 08:59
@heroiczero oh, really!
Thank you!
CamperBot
@camperbot
May 26 2017 08:59
nasridean sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1308 | @heroiczero |http://www.freecodecamp.com/heroiczero
Blauelf
@Blauelf
May 26 2017 09:00
@MANTENN I search for !facebook and find the lines where "facebook" appears over all the files. In this example, the files are all minified, so everything is line 1 :(
arjav2002
@arjav2002
May 26 2017 09:02
I am confused but why should the symetric difference between these 3 sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) should return a set of [1, 4, 5]?
Markus Kiili
@Masd925
May 26 2017 09:02
@arjav2002 First you symDiff the first two and then the result with the third etc.
[1, 2, 5], [2, 3, 5], [3, 4, 5] -> [1,3],[3,4,5] -> [1,4,5]
Blauelf
@Blauelf
May 26 2017 09:05
@arjav2002 Combine them pairwise, in any order, like sym(arr1, arr2, arr3) equals sym(arr1, sym(arr2, arr3)) or sym(sym(arr1, arr2), arr3) or sym(arr2, sym(arr3, arr1)) or any combination ($2\cdot3!=12$ variations possible in this case)
Yanek Yuk
@yanekyuk
May 26 2017 09:05
Hi. What is factorializing?. Searching on Google leads me to solutions, as if it is only asked by people after they see it on freeCodeCamp :smile: I don't want solution, I just want to understand what it is.
Markus Kiili
@Masd925
May 26 2017 09:06
@yanekyuk Factorial of for example 10 is 10*9*8*7*6*5*4*3*2*1
Blauelf
@Blauelf
May 26 2017 09:06
@yanekyuk Two definitions.
1. Iterative. $n!=1\cdot2\cdot\ldots\cdot n$
2. Recursive $0!=1$ and $n!=n\cdot(n-1)!$
Yanek Yuk
@yanekyuk
May 26 2017 09:07
@Masd925 So the factorial of 2 is 2 and 3 is 6 and 4 is 24?
Markus Kiili
@Masd925
May 26 2017 09:07
@yanekyuk Yes.
Use a loop of some kind.
Yanek Yuk
@yanekyuk
May 26 2017 09:07
Okay it is actually simple. Just a problem understanding what it is :) thanks @Masd925
CamperBot
@camperbot
May 26 2017 09:07
yanekyuk sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4144 | @masd925 |http://www.freecodecamp.com/masd925
Yanek Yuk
@yanekyuk
May 26 2017 09:08
@Blauelf This is exactly how I failed to understand :smile:
Vedant Kashyap
@vedant15188
May 26 2017 09:08
Hey guys I'm doing the TwitchTV Project and I'm stuck... I can't set the color of my list groups according to their corresponding channels live status here is the code snippet
var channels=["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

function showAll() {
console.log("showing all");
for (var i=0; i<channels.length; i++) {
$.getJSON("https://wind-bow.glitch.me/twitch-api/streams/"+channels[i],function (liveStatus) { console.log(JSON.stringify(liveStatus)+"\n\n\n\n"); if (liveStatus.stream!=null)$("#"+channels[i]).css("background-color","#82da6b");
else
\$("#"+channels[i]).css("background-color","#c13f36");
});
}
}
Sidharth Bansal
@SidharthBansal
May 26 2017 09:08
can anyone help me ?
with falsy bouncy
i worte this
function bouncer(arr) {
arr.filter(function(val){return val!=true;});// Don't show a false ID to this bouncer.
return arr;
}
Markus Kiili
@Masd925
May 26 2017 09:09
@vedant15188 All those callback function use the same variable i that is at channels.length when the callbacks execute later.
Sidharth Bansal
@SidharthBansal
May 26 2017 09:09
https://www.freecodecamp.com/challenges/falsy-bouncer#?solution=%0Afunction bouncer(arr) {%0A arr.filter(function(val){return val!%3Dtrue%3B})%3B%2F%2F Don't show a false ID to this bouncer.%0A return arr%3B%0A}%0A%0Abouncer([7%2C "ate"%2C ""%2C false%2C 9])%3B%0A
Blauelf
@Blauelf
May 26 2017 09:10
@yanekyuk Factorial n! is for example the number of different orders for n differentiable elements. You could place 3 different billiard balls in a line in 3! or 6 different ways. For four balls, there are 24 ways, for five already 120, and so on.
Vedant Kashyap
@vedant15188
May 26 2017 09:10
@Masd925 then how do i do this i mean? :/
without the looping? that will be lenghty
Sonny
@ynnossence
May 26 2017 09:11
@SidharthBansal just return all falsy (null,0,undefined, NaN etc)
Markus Kiili
@Masd925
May 26 2017 09:11
@vedant15188 You could make a function that does the ajax call and is passed the index or the channel name as an argument. That would be one way.
Yanek Yuk
@yanekyuk
May 26 2017 09:11
@Blauelf this explanation is good. I remember now. thank you!
CamperBot
@camperbot
May 26 2017 09:11
yanekyuk sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4248 | @blauelf |http://www.freecodecamp.com/blauelf
Legacy
@punyparker
May 26 2017 09:12
@MANTENN wait what?
@Blauelf the anchor has an id of "tweet"
Blauelf
@Blauelf
May 26 2017 09:15
@punyparker Not sure about their time zone, but I think it's maybe 2.15am in Carifornia.
@punyparker Well, the anchor in your HTML has one, but the DOM is dynamic, and the twitter widget script seems to change that.
Legacy
@punyparker
May 26 2017 09:16
@Blauelf What do you mean time zone? When were we talking about time zones?
@Blauelf wait, the widget makes it static?
Blauelf
@Blauelf
May 26 2017 09:18
@punyparker About time zones: :point_up: 26. Mai 2017 10:52
@punyparker The widget does things. I just haven't read the documentation, so I cannot say what it does. Seems to provide some API through the window.twttr object.
Legacy
@punyparker
May 26 2017 09:19
@Blauelf I guess the solution is to remove it?
Blauelf
@Blauelf
May 26 2017 09:20
Maybe it can be used for that, but there are solutions without.
Saif Ur Rahman
@saifsmailbox98
May 26 2017 09:22
var sum = [0, 1, 2, 3].reduce(function(acc, val) {
return acc + val;
}, 0);
// sum is 6
what if the acc is a predefined variable and its value is 100 ?
René
@RenevandenHeuvel
May 26 2017 09:25
Does anyone know how to indent the second line after a glyphion in bootstrap?
Markus Kiili
@Masd925
May 26 2017 09:26
@saifsmailbox98 acc is the callback function parameter. It would shadow any variable with same name.
Rick Willcox
@willcoxDev
May 26 2017 09:26
How do I pass a variable into an arguement that is a function?
dropElements([1, 2, 3], function(n) {return n < 3; });
I want to pass a variable to N in the drop elements function this has got me stumped
Markus Kiili
@Masd925
May 26 2017 09:27
@willcoxDev You just use the function parameters arr, func that hold those array and function.
Saif Ur Rahman
@saifsmailbox98
May 26 2017 09:28
@Masd925 okay, is there any way to define parameter's default value if not passed through calling statement
Rick Willcox
@willcoxDev
May 26 2017 09:28
@Masd925 can you give an example pls
Saif Ur Rahman
@saifsmailbox98
May 26 2017 09:28
like
 function(acc=100, val)
Markus Kiili
@Masd925
May 26 2017 09:28
@willcoxDev if(func(arr[0])){...}
Rick Willcox
@willcoxDev
May 26 2017 09:28
oh
ok that makes sense
Blauelf
@Blauelf
May 26 2017 09:29

@saifsmailbox98 You mean like

var sum = [0, 1, 2, 3].reduce(function(acc, val) {
return acc + val;
}, 100);
// sum is 106

?

Rick Willcox
@willcoxDev
May 26 2017 09:29
ty
Saif Ur Rahman
@saifsmailbox98
May 26 2017 09:30
@Blauelf i don't understand why you used , 100);
to pass a function and 100 in reduce.
Jeremy
May 26 2017 09:30
Blauelf
@Blauelf
May 26 2017 09:30
@saifsmailbox98 That last argument is the initial value for acc
Jeremy
May 26 2017 09:30
Thanks, folks!
Saif Ur Rahman
@saifsmailbox98
May 26 2017 09:31
@Blauelf okay, but acc in defined only inside the function.
Blauelf
@Blauelf
May 26 2017 09:31
@saifsmailbox98 If you don't provide that argument, reduce uses the first array element and starts the loop at the second. Which does or does not make much of a difference, depending on case. Without an explicit initial value, reduce cannot process empty arrays.
@saifsmailbox98 acc receives some value when the callback is called by reduce.
Markus Kiili
@Masd925
May 26 2017 09:33
@saifsmailbox98 You don't call that callback function. You give it to reduce and it uses it under the hood during the iteration.
Saif Ur Rahman
@saifsmailbox98
May 26 2017 09:36
okay, i'll try my best to understand these methods. Are there any websites related to these?
Blauelf
@Blauelf
May 26 2017 09:38
I found the MDN docs on reduce useful, but I'm used to reading technical documentation...
Yanek Yuk
@yanekyuk
May 26 2017 09:40
Hi. I passed this but I am not happy about the way I used regex:
var replace = str.replace(/[(]|[)]|-|[/]|[,]|[.]|_| |/g, '');
As I don't usually see this long regexes
Blauelf
@Blauelf
May 26 2017 09:41
@yanekyuk You could have used one character set like [()\-\/\\,._ ], or defined the list by defining what's not in there, like [^0-9A-Za-z]
Rick Willcox
@willcoxDev
May 26 2017 09:42
function dropElements(arr, func) {
var array = arr;
for(var i=0; i < arr.length;i++){
if(func(array[i])) {
return arr;
}
else{
arr.shift();
}
}
return array;

}

dropElements([1, 2, 3, 4], function(n) {return n > 5;});
How come when I arr.shift() it is also removing the first index of array? I make array = arr at the start however The code should never go back to that point. I have stepped through it in an ide and I do not understand at all.
Yanek Yuk
@yanekyuk
May 26 2017 09:44
@Blauelf OK. I replace [()\-\/\\,._ ] to [()-/\,._ ] and it still works. Is there special reason put so many \?
Blauelf
@Blauelf
May 26 2017 09:44
@yanekyuk Or, a bit more cryptic than explicitly stating letters and digits, you could combine non-word characters \W (essentially like [^0-9A-Za-z_]) with an underscore, like [\W_] or \W|_.
Markus Kiili
@Masd925
May 26 2017 09:44
@willcoxDev var array=arr; <- both variables point to the same array.
Rick Willcox
@willcoxDev
May 26 2017 09:44
you mena in memory
?
how do I make it its own array
ramarcinek
@ramarcinek
May 26 2017 09:44

Hello! :)

var Bike = function(){
var gear = 1;

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

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

};

var myCar = new Car();

var myBike = new Bike();

What can be wrong? I cannot pass the challenge.

Markus Kiili
@Masd925
May 26 2017 09:44
@willcoxDev var array = arr.slice();
Blauelf
@Blauelf
May 26 2017 09:45
@yanekyuk I think I wanted to escape the special characters. For example, in a set, - defines a range.
Rick Willcox
@willcoxDev
May 26 2017 09:45
var array= []
array = arr?
would this also work or does this just do the same thing as before
Blauelf
@Blauelf
May 26 2017 09:45
@ramarcinek setGear should set, not add-assign to, gear
Markus Kiili
@Masd925
May 26 2017 09:46
@willcoxDev Slice makes a copy of the array.
Yanek Yuk
@yanekyuk
May 26 2017 09:46
@Blauelf But it's not necessary as in this situation they are already inside [ ]?
tahaqutbuddin
@tahaqutbuddin
May 26 2017 09:46

// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr = 'This is the start.' + ' This is the end. ';
what is the prob over here???

???
ramarcinek
@ramarcinek
May 26 2017 09:46
Oh :)
Blauelf
@Blauelf
May 26 2017 09:47
@yanekyuk )-/ is very different from )\-/ in that the first version defines a range from ) to /, while the second lists three characters.
tahaqutbuddin
@tahaqutbuddin
May 26 2017 09:47
???
Blauelf
@Blauelf
May 26 2017 09:48
@yanekyuk As / are used to limit the regular expression literal, at least in theory they should not appear within the expression.
Legacy
@punyparker
May 26 2017 09:48
@Blauelf @MANTENN Thanks! I got it done https://codepen.io/1Want/full/XRoBVm/
CamperBot
@camperbot
May 26 2017 09:48
punyparker sends brownie points to @blauelf and @mantenn :sparkles: :thumbsup: :sparkles:
:star2: 4249 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
May 26 2017 09:48
@tahaqutbuddin Closely look at spaces in your strings. Those are obviously not very visible in the output, but still make tests fail.
Legacy
@punyparker
May 26 2017 09:48
@Blauelf How do I make FCC look like night mode?
Yanek Yuk
@yanekyuk
May 26 2017 09:49
@Blauelf thank you very much :+1:
CamperBot
@camperbot
May 26 2017 09:49
yanekyuk sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: yanekyuk already gave blauelf points
Blauelf
@Blauelf
May 26 2017 09:49
@punyparker Profile->settings->night mode (strangely also affects how your profile looks for others)
Legacy
@punyparker
May 26 2017 09:50
@Blauelf thanks, it works. What do you mean it affects how other view your profile?
CamperBot
@camperbot
May 26 2017 09:50
punyparker sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: punyparker already gave blauelf points
Blauelf
@Blauelf
May 26 2017 09:52
@punyparker Compare my profile with night mode on to for example that of @Masd925 with night mode off.
Rick Willcox
@willcoxDev
May 26 2017 09:52
if I drop every element from an array does that = null or false or []?
and can i test it by going if (!arr)
Legacy
@punyparker
May 26 2017 09:53
@Blauelf You're missing projects
Otherwise, it's exactly the same just inverse
https://codepen.io/freeCodeCamp/full/bELRjV Is this example working for anyone else?
Blauelf
@Blauelf
May 26 2017 09:54
@punyparker I meant the night mode. I have it switched on, while @Masd925 has not. And the view is based on the user's settings, not yours, which I find really odd.
Legacy
@punyparker
May 26 2017 09:54
When I run it, it's blank with just a comma.
shedlerman
@shedlerman
May 26 2017 09:55

// Example
var firstNameLength = 0;

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.lenght;

Legacy
@punyparker
May 26 2017 09:55
Ah correct. @Blauelf
That's weird
Vivek
@vivekmittal7
May 26 2017 09:56
what does this prototype mean in methods like string.prototype.charCodeAt
Blauelf
@Blauelf
May 26 2017 09:56
@punyparker That pen broke when CodePen switched to HTTPS. Now, it's accessing HTTP from an HTTPS site, which is not allowed.
Legacy
@punyparker
May 26 2017 09:56
ah, they need to fix this.
Dan Ess
@dropbeardan
May 26 2017 09:56
@vivekmittal7 prototype is an old javascript method for declaring classes
Blauelf
@Blauelf
May 26 2017 09:58

@vivekmittal7 Should be String.prototype (it's an object that all string objects know, if you say str.charCodeAt, str does not have any charCodeAt property, so it's searched for in the prototype chain, and found at String.prototype)

When calling a function as a method, the this object is set to the object you call the method on. str.charCodeAt(i) would call String.prototype.charCodeAt with this set to str and an argument of i.

Vivek
@vivekmittal7
May 26 2017 09:59
@Blauelf @punyparker thank you
CamperBot
@camperbot
May 26 2017 09:59
:star2: 4250 | @blauelf |http://www.freecodecamp.com/blauelf
vivekmittal7 sends brownie points to @blauelf and @punyparker :sparkles: :thumbsup: :sparkles:
lydjenkins
@lydjenkins
May 26 2017 10:00
Hey, can anyone help with this? I originally had it working - added the else statement and now I am getting nothing but errors!m
function getFirstPython(list) {
var list1 = [];
while (i = 0; i < list1.length; i++) {
if (list1[i].language === 'Python') {
return list1[i].firstName + ", " + list1[i].country;
} else {
return "No Python";
}
}
console.log(getFirstPython());
Blauelf
@Blauelf
May 26 2017 10:02
@punyparker CodePen were pretty proud of being able to provide their service all over HTTPS, but sadly API providers not necessarily like encryption for some reason (yes, encryption needs a few more resources, but main problems come with setting up an infrastructure with many names over one IP address). If you pay for the services, then most do provide an encrypted API endpoint, though. Kindof "freemium".
fxceptioN
@fxceptioN
May 26 2017 10:03
I'm stuck on counting cards lesson, I think the variable number is resetting? my code is

var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2,3,4,5,6) {
return count + 1 + " Bet";
} else if (card == 7,8,9){
return count + 0 + " Hold";
} else if (card == 10, 'J', 'Q', 'K', 'A') {
return count - 1 + " Hold";
} else

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');
Blauelf
@Blauelf
May 26 2017 10:04
@fxceptioN Comma operator is not what you want.
fxceptioN
@fxceptioN
May 26 2017 10:05
Okay thank you. I'll try and figure it out
Blauelf
@Blauelf
May 26 2017 10:05
@fxceptioN There are two parts that should be kept separate.
1. For certain values of card, increment or decrement global variable count
2. Return a string built from count and either Bet or Hold (solely depending on value of count and not at all on card), with one space between number and word.
Vivek
@vivekmittal7
May 26 2017 10:06
@fxceptioN you need to write your code in a way so that it adds +1 to value of count every time cc() is below 7 and -1 when it is more than 9
Blauelf
@Blauelf
May 26 2017 10:06
@vivekmittal7 You meant card, not cc()
fxceptioN
@fxceptioN
May 26 2017 10:07
So basically I'm way off right now.
Vivek
@vivekmittal7
May 26 2017 10:07
@Blauelf yes, thanks
CamperBot
@camperbot
May 26 2017 10:07
vivekmittal7 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: vivekmittal7 already gave blauelf points
Blauelf
@Blauelf
May 26 2017 10:07
@fxceptioN Basically, yes. You could however use a similar if-elseif structure for the first part. And a separate if-else (or ternary operator) for the second part.
fxceptioN
@fxceptioN
May 26 2017 10:09
Okay, Thank you @Blauelf I'll check out previous lessons to see what I could have possibly missed
CamperBot
@camperbot
May 26 2017 10:09
fxception sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4251 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
May 26 2017 10:09
There are many ways to solve that one, an if-elseif chain (maybe using ||` to combine multiple comparisons, or define ranges, or use indexOf on an array of cards) is one way, others use switch like in Multiple Identical Options in Switch Statements, I used maths instead (ugly implicit type conversions included)