These are chat archives for FreeCodeCamp/Help

6th
Oct 2015
Ryan C.
@marvroots
Oct 06 2015 00:00
@hugoender I did. Nothing seemed to work, so I resest.
Rex Schrader
@SaintPeter
Oct 06 2015 00:01
@huy069 You have the correct code, but you need to put it in a function:
function reverseString(str) {
  // Your code here, modifying str

  return str;
}
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:02
This message was deleted
Chris
@Aoxom
Oct 06 2015 00:02
@marvroots use the "row" element as an example, <div class="row">. just change the class from "row" to that column
Ryan C.
@marvroots
Oct 06 2015 00:03
@Aoxom can you give me an example? Thanks.
CamperBot
@camperbot
Oct 06 2015 00:03
marvroots sends brownie points to @aoxom :sparkles: :thumbsup: :sparkles:
:star: 182 | @aoxom | http://www.freecodecamp.com/aoxom
Chris
@Aoxom
Oct 06 2015 00:05
@marvroots well i suggested using <div class="row"> as your example, and just edit the class out. that "col-xs-6" they provided is literally what you use
and dont forget to close out any divs you make
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:06

@huy069 what Peter said. Also, instead of

var array = string;
array = string.split("").reverse("").join("");

is would be better to just use

var array = string.split("").reverse("").join("");

Basically, when you define "var array = string", you're then tossing out that value and replacing it with "string.split("").reverse("").join("")"... insterestingly, that "array" var doesn't really ever equal an array value, (I'd call it "reversed")

huy069
@huy069
Oct 06 2015 00:06
@SaintPeter thanks so much, it currently say too much recursion, I will have to check again later after work, thanks for your help, apparently i can send a brownie coin to you or something as i saw ppl did it, but I am very new, not sure how
CamperBot
@camperbot
Oct 06 2015 00:06
huy069 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 866 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Oct 06 2015 00:07
@huy069 You cannot/should not use the name reverseString inside your function. That is the function name.
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:08
aaaah, also, ".reverse("")" should be ".reverse()" since it doesn't take arguments
Coira Ellison
@Coira
Oct 06 2015 00:15
@hugoender did you get an answer to your question?
Hugo
@hugoender
Oct 06 2015 00:24
@Coira no
Coira Ellison
@Coira
Oct 06 2015 00:24
i had a go solving it with flexbox http://codepen.io/Coira/pen/gaWwOR
Garrett Schultz
@garettschultz
Oct 06 2015 00:25
Hey everyone, Im wondering if I can get some help? Seems none of these challenges are explained thoroughly enough to give a beginner an understanding of what to do or how to complete the challenge.
I am supposed to Create if and else statements to return the string "heads" if the flip variable is zero, or else return the string "tails" if the flip variable is not zero. But the callenge doesnt explain how to do it or anything, its like im expected to already know how to create an if else statement.
Abe Coronado
@abe03
Oct 06 2015 00:31
Wondering what
Alfonso Balsera Martinez
@AlfonB6
Oct 06 2015 00:31
@gratschultz2013 actually, codeacademy explains it in more depth. But basically
@gratschultz2013 first think of the logic of the question, if tales true, if heads false or vice versa
Abe Coronado
@abe03
Oct 06 2015 00:32
Wondering what's the correct way to copy and paste so that it keeps the colors into this chat?
Alfonso Balsera Martinez
@AlfonB6
Oct 06 2015 00:32
now you have to make the computer understand what is heads and tails
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:32
@abe03 help code format
help code formaty
CamperBot
@camperbot
Oct 06 2015 00:33
no wiki entry for: code formaty
:pencil: click here to create one now!after creating your page type update to reload it here
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:33
help code format
CamperBot
@camperbot
Oct 06 2015 00:33

:point_right: code formatting [wiki]

Inline code

alt text

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

Code Block

``` ⇦ Type 3 backticks and then press [shift + enter ⏎]

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

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

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

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

Michael Havis
@mhavis86
Oct 06 2015 00:33

I'm having trouble with Bonfire Seek and Destroy
```
function destroyer(arr) {
// Remove all the values
var arg = arguments;

return arr.filter(

  function(value, arg){
    for(i = 1; i < arg.length; i++)
       (arr.indexOf(arg[i]) == -1); }
    )

}
```
The biggest problem that I can see is that I'm not able to pass arguments as a parameter to arr.filter().

Herman Fassett
@HermanFassett
Oct 06 2015 00:33
return
Tim Bell
@MindfulBell
Oct 06 2015 00:34
Can I ask for some assistance on Arguments Optional bonfire?
Herman Fassett
@HermanFassett
Oct 06 2015 00:34
No, that one's off limits
Tim Bell
@MindfulBell
Oct 06 2015 00:34
I knew it
F
Herman Fassett
@HermanFassett
Oct 06 2015 00:35
:P
Jk
Abe Coronado
@abe03
Oct 06 2015 00:35
```
Tim Bell
@MindfulBell
Oct 06 2015 00:36
I think I am close, just having trouble understanding the logic of it...
Herman Fassett
@HermanFassett
Oct 06 2015 00:37
The function part?
Tim Bell
@MindfulBell
Oct 06 2015 00:39
Yar. I am reading that part on closure in Eloquent Javascript
but I cannot wrap my head around it.
Abe Coronado
@abe03
Oct 06 2015 00:41
function titleCase(str) {
  //return str.split(" ").map(function(i){return i[0].toUpperCase() + i.substring(1).toLowerCase()}).join(" ");
  var nowArray = str.split(" ");
  for (var i = 0; i < nowArray.length; i++) {
    i[0].toUpperCase();
    i.substring(1).toLowerCase();
  }
  nowArray.join(" ");
  return nowArray;
}

titleCase("I'm a little tea pot", "");
I'm trying to get this to work with a for loop, the commented stuff is the right answer but i only got it cuz i found it somewhere else, i keep getting an error on my `i.substring(1).toLowerCase();' part. Anyone can point me in the right direction?
ugh it didn't comment the stuff for some reason
the line after it's supposed to be commented too
Tim Bell
@MindfulBell
Oct 06 2015 00:43
i0.toUpperCase(); doesn't make sense...
that === 0[0].toUpperCase
Abe Coronado
@abe03
Oct 06 2015 00:46
isn't i[0] the first word of the array "I'm" in this case?
Matt Leonard
@matty22
Oct 06 2015 00:48
i is the variable you are using to iterate the loop. you'd want to put that in the [ ] for the index and the name of your array where you have i in your loop, no?
Tim Bell
@MindfulBell
Oct 06 2015 00:48
I think the use of .map is real important in that "correct me"
correct one
rather
i have to go, but i can look later
Matt Leonard
@matty22
Oct 06 2015 00:50
META question: What's the difference between a waypoint, bonfire, zipline, and base jump?
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:50
@abe03 I think you meant to use nowArray[i] instead of i[0], etc
@matty22 mostly, theory/html, algorithms, front-end, back-end (in that order), I can't find an official definition, but that's close
Abe Coronado
@abe03
Oct 06 2015 00:53
ok i get what you guys are saying @jedpimentel , @matty22 , but wouldn't that just select the word in the array (i'm looping through the array of words) but that is not selecting the first letter of the word to which i can apply the .toUpperCase
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:54
@abe03, yes, that selects the word in the array, and onto that expression you'll attach [0].toUpperCase() and .substring(1).toLowerCase() respectively
Abe Coronado
@abe03
Oct 06 2015 00:55
of course, thank you @jedpimentel
CamperBot
@camperbot
Oct 06 2015 00:55
abe03 sends brownie points to @jedpimentel :sparkles: :thumbsup: :sparkles:
:star: 328 | @jedpimentel | http://www.freecodecamp.com/jedpimentel
Jose E. Pimentel
@jedpimentel
Oct 06 2015 00:56
as-is, "i" is just a counter. since it's a number, not a string, the string methods will be an issue
Hugo
@hugoender
Oct 06 2015 00:59
@Coira the text is still on top and bottom and not to the right and left of the switch
in your codepen
Mitzi Withrow
@mitziw
Oct 06 2015 01:16
@matty22 waypoints = exercises not required for cert, bonfires are like waypoints but they are required, ziplines are fun and required, base-jumps required and look not fun
Taro
@TaroWong
Oct 06 2015 01:31

Hey guys

In layman's terms what is previousVal and currentVal?

Abhishek
@Abhi493
Oct 06 2015 01:31
these r variables name
u can give anyname as u like, it doesnt matter
Hugo
@hugoender
Oct 06 2015 01:32
@TaroWong those are the names that were given to a variable but it can be anything such as var randomVariableNameLOL
Abhishek
@Abhi493
Oct 06 2015 01:32
but the more related name the more easier to remember n use.
or var tarowang
var Abi493 anything
hugeonder can help on bonfire : mutations?
CamperBot
@camperbot
Oct 06 2015 01:34
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Rex Schrader
@SaintPeter
Oct 06 2015 01:35

@mitziw @matty22

Bonfires

Algorithm practice. They're sort of the fundamental practice of programming. They can be quite challenging but are also fun. They're so much fun that there are entire websites devoted to those sorts of programming problems

Ziplines

These are front-end dev projects. They're "web design" with a bit of practical programming thrown in. Some API interactions (For AJAX and such).

Basejump

Basejumps are full stack web development. They'll have you writing both the front end (like ziplines) and the backend (server side). They can be quite challenging. I do think they're fun too. There is definitely a lot to learn there. The FCC cirriculum is not great for the lead-up to fullstack, but it's getting better.

Abhishek
@Abhi493
Oct 06 2015 01:36
@SaintPeter bro my question is how to do one of the challenge name bonfire : mutations on array
Mitzi Withrow
@mitziw
Oct 06 2015 01:36
forgot waypoints @SaintPeter
Rex Schrader
@SaintPeter
Oct 06 2015 01:36
@mitziw Well, waypoints are just for learning stuff. I don't think they're intended to be very challenging, more like demonstrations.
Charlotte
@Charzoe
Oct 06 2015 01:39
function titleCase(str) {  
  strip = str.toLowerCase();
  strip.split(" ");
  for (var i=0; i < strip.length; i++){
    strip.charAt(0).toUpperCase();
  }

  return strip;
}

titleCase("I'm a little tea pot");
I feel like I'm missing something really important in my for, but I can't work out what it is.
Levyian
@levyian
Oct 06 2015 01:40
@Charzoe strip.split(" "); returns an array of the string split by spaces, but you need to store it in a variable
James Smith
@matthew02
Oct 06 2015 01:40
@Charzoe Strings are immutable. You can't directly change them. You have to create a new string that is the capitalized beginning character with the remainder of the string concatenated to it.
Plus what @levyian said.
Levyian
@levyian
Oct 06 2015 01:41
@Charzoe and you also need to join the array and return a string
henry fritz
@henryamster
Oct 06 2015 01:54
http://codepen.io/henryamster/pen/BoWbOd when trying to operate on a second number that contains a decimal (the first works fine in all test cases like 4.25*24, just not the other way around), I get "Uncaught SyntaxError: Unexpected number"- is this due to a type error? isn't JS type agnostic? maybe I'm way off altogether?
Mitzi Withrow
@mitziw
Oct 06 2015 01:59
@henryamster looks nice. i don't want to do that one at all
are you "doing math" on a char?
henry fritz
@henryamster
Oct 06 2015 02:03
it can be frustrating that's for sure. I've spent maybe one tenth the time coding compared to aimlessly staring at my console
Herman Fassett
@HermanFassett
Oct 06 2015 02:03
I can code. I can't make ui
henry fritz
@henryamster
Oct 06 2015 02:04
well technically it's an array that's joined, then eval()'d, which I've seen is frowned upon, but the type issue I think comes with the first variable being registered as an int and the second as a float?
Herman Fassett
@HermanFassett
Oct 06 2015 02:04
That's a nice design @henryamster
Mitzi Withrow
@mitziw
Oct 06 2015 02:04
@henryamster yea im 300 exercises in and i'll be suprised if i ever finish
henry fritz
@henryamster
Oct 06 2015 02:04
although as long as it's numeric type I thought JS doesn't care
Herman Fassett
@HermanFassett
Oct 06 2015 02:04
Lol eval()
e.e I know everyone hates on it but it's kinda fun to use
henry fritz
@henryamster
Oct 06 2015 02:05
it is as long as you're controlling the inputted data
CamperBot
@camperbot
Oct 06 2015 02:05
:trollface: troll problems? notify admins here
henry fritz
@henryamster
Oct 06 2015 02:05
:P
Mitzi Withrow
@mitziw
Oct 06 2015 02:06
@henryamster are you controlling?
CamperBot
@camperbot
Oct 06 2015 02:06
:trollface: troll problems? notify admins here
Mitzi Withrow
@mitziw
Oct 06 2015 02:06
wow
Levyian
@levyian
Oct 06 2015 02:08
lol... camperbot too funny
henry fritz
@henryamster
Oct 06 2015 02:09
personally find camperbot's regex matching to be out of controll
CamperBot
@camperbot
Oct 06 2015 02:09
:trollface: troll problems? notify admins here
Brian Ray
@b-rays
Oct 06 2015 02:14
Hello!! I'm having some issues with Slot Machine example in the Javascript tutorial. I inserted this code // Only change code below this line.
selector $(".slot") $($(".slot"[0]).html(slotOne); // Only change code above this line. '' I keep getting this error message: "missing ; before statement". Any help would be greatly appreciated!
Jason Wood
@catapixel
Oct 06 2015 02:15
@brian-ray I'll help. Can you paste in that section of code. Formatted preferrably...
Mitzi Withrow
@mitziw
Oct 06 2015 02:15
hi @brian-ray can you... jesu..
Brian Ray
@b-rays
Oct 06 2015 02:15
Thanks cata. Yes!
CamperBot
@camperbot
Oct 06 2015 02:15
if you want to thank someone, put an @ before their name!
Rex Schrader
@SaintPeter
Oct 06 2015 02:16
@brian-ray Looks like you have an extra $(".slot") up front.
should be:
$($(".slot"[0]).html(slotOne);
Brian Ray
@b-rays
Oct 06 2015 02:18
Thanks @SaintPeter. It now states that "missing ) after argument list"
CamperBot
@camperbot
Oct 06 2015 02:18
brian-ray sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 867 | @saintpeter | http://www.freecodecamp.com/saintpeter
dragontekneo
@dragontekneo
Oct 06 2015 02:18
guys, I'm having a problem regarding our https links in safari browser on windows OS. links that came from our domain secure.gotodo.com doesnt show any display. can I ask a favor to open this image link on your safari browser especially on windows. here's the link: https://secure.gotodo.com/occupancyplus/images/rooms/4eeeef8e7181ee8f60a8bb82191b3a6a.jpg
let me know if it doesn't show on yours too. thanks
CamperBot
@camperbot
Oct 06 2015 02:18
if you want to thank someone, put an @ before their name!
Rex Schrader
@SaintPeter
Oct 06 2015 02:19
@brian-ray Well, if it's missing, I can't see it from the code you shared. Read the following on how to post your formatted code.
wiki format
CamperBot
@camperbot
Oct 06 2015 02:19

:point_right: code formatting [wiki]

Inline code

alt text

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

Code Block

``` ⇦ Type 3 backticks and then press [shift + enter ⏎]

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

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

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

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

Rex Schrader
@SaintPeter
Oct 06 2015 02:20
@dragontekneo Who would willingly use Safari on windows? Or, for that matter, anywhere?
Joseph Cunningham
@Gnasch1972
Oct 06 2015 02:20
@SaintPeter I have to use it on my rubbish phone
Leeia Isabelle
@Leeiaisabelle
Oct 06 2015 02:21
Safari on Windows stopped being updated years ago @dragontekneo
Rex Schrader
@SaintPeter
Oct 06 2015 02:21
@Gnasch1972 You poor bastard. See, that's why I have an Andorid phone
Jason Wood
@catapixel
Oct 06 2015 02:21
@brian-ray you do have an extra parenthesis. Your code should be $($(".slot")[0]).html(slotOne);
dragontekneo
@dragontekneo
Oct 06 2015 02:21
@SaintPeter we we're testing it on Safari since we don't have actual Mac
Ryan C.
@marvroots
Oct 06 2015 02:22
Does anyone know why I have to clear my code every time I move to a new challenge?
Jason Wood
@catapixel
Oct 06 2015 02:23
@marvroots what are the symptoms you're having that cause you to clear your code?
dragontekneo
@dragontekneo
Oct 06 2015 02:23
@Leeiaisabelle is there any way to test websites on safari without mac os?
Rex Schrader
@SaintPeter
Oct 06 2015 02:23
@dragontekneo I know that Codepen has a sister site called "CrossBrowserTesting" or similar. You may start there.
Charlotte
@Charzoe
Oct 06 2015 02:24
function largestOfFour(arr) {
  // You can do this!
  for (var i=0; i < arr.length; i++){
    a = arr.pop();
    b = arr.pop();
    c = arr.pop();
    d = arr.pop();
    for (var i=0; i < a.length; i++){a.sort(function(a, b){return a-b})};
    for (var i=0; i < b.length; i++){b.sort(function(a, b){return a-b})};
    for (var i=0; i < c.length; i++){c.sort(function(a, b){return a-b})};
    for (var i=0; i < d.length; i++){d.sort(function(a, b){return a-b})};
    e = a.pop();
    f = b.pop();
    g = c.pop();
    h = d.pop();
  }
  bigArray = [e, f, g, h]; 
  return bigArray.reverse()  
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], "");
Okay, so this works, thankfully! But I'm about 70% sure this is a disgusting way of doing this...
dragontekneo
@dragontekneo
Oct 06 2015 02:24
@SaintPeter @henryamster thanks, I'll look into it.
CamperBot
@camperbot
Oct 06 2015 02:24
dragontekneo sends brownie points to @saintpeter and @henryamster :sparkles: :thumbsup: :sparkles:
:star: 868 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 274 | @henryamster | http://www.freecodecamp.com/henryamster
dragontekneo
@dragontekneo
Oct 06 2015 02:25
brownie points?
Ryan C.
@marvroots
Oct 06 2015 02:25
@catapixel The box on the bottom left that describes what I'm suppose to accomplish is blank until I clear the code. This before I have done anything else.
Rex Schrader
@SaintPeter
Oct 06 2015 02:25
@Charzoe So . . . nested loops . . your friend.
@Charzoe If you ever find yourself repeating code more than once, you probably missed an opportunity to write a loop
Joseph Cunningham
@Gnasch1972
Oct 06 2015 02:26
Or a function?
Rex Schrader
@SaintPeter
Oct 06 2015 02:26
@Charzoe Also, a function. Your sort function could be pulled out and made into a single instance.
@Gnasch1972 LOL, yes ;)
Jason Wood
@catapixel
Oct 06 2015 02:26
@marvroots which challenge are you working on? I'd like to take a look? Also which browser/OS?
Leeia Isabelle
@Leeiaisabelle
Oct 06 2015 02:26
@dragontekneo you can try what @SaintPeter just said, but I think that the last time that Safari for Windows was updated was on Windows vista....so you may have the browser, but it may not be compatible with newer operating systems and may not have the lastest CSS/HTML features...Even Internet explorer is beginning to be outdated in the CSS/HTML arena
Ryan C.
@marvroots
Oct 06 2015 02:27
@catapixel Use appendTo to Move Elements with jQuery. I use both edge and chrome.
@catapixel It's been doing it for quite a few challenges.
Jason Wood
@catapixel
Oct 06 2015 02:29
@marvroots the instructions are just the stuff below the title and above the run button. The stuff you see after you click run are just the tests that are being run and passing/failing and why. That is the correct behavior.
Jason
@Jauble
Oct 06 2015 02:30
Anyone else have problems with codepen? A lot of times it won't load the page I'm working on
dragontekneo
@dragontekneo
Oct 06 2015 02:30
@Leeiaisabelle thanks for the supporting info.
CamperBot
@camperbot
Oct 06 2015 02:30
dragontekneo sends brownie points to @leeiaisabelle :sparkles: :thumbsup: :sparkles:
:star: 181 | @leeiaisabelle | http://www.freecodecamp.com/leeiaisabelle
Abhishek
@Abhi493
Oct 06 2015 02:31
need help in bonfire where do i belong
heres my code cant figure out the problem
```
CamperBot
@camperbot
Oct 06 2015 02:31
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Leeia Isabelle
@Leeiaisabelle
Oct 06 2015 02:31
you're welcome!
Abhishek
@Abhi493
Oct 06 2015 02:32
function where(arr, num) {
  arr.push(num);
  arr.sort();

  return arr.indexOf(num);
}

where([2, 5, 10], 15);
Jason Wood
@catapixel
Oct 06 2015 02:33
This message was deleted
Ryan C.
@marvroots
Oct 06 2015 02:34
@catapixel The instructions are what I'm not seeing until I hit reset the code.
Jason Wood
@catapixel
Oct 06 2015 02:34
@Abhi493 nope. Sorry. That's not it
blob
@marvroots so you don't see the above until you clear your code or hit run?
Ryan C.
@marvroots
Oct 06 2015 02:37
@catapixel No. Underneath reset help bug
@catapixel buttons
I always hit reset button then it works
Jason Wood
@catapixel
Oct 06 2015 02:38
@Abhi493 your problem is that sort() does an alphabet sort unless you provide a compare function (check documentation) which you need here because you want to sort the numbers in numerical order.
@marvroots the following isn't supposed to show up until you run your code...
blob
@marvroots you are seeing the intended behavior
@marvroots what you are seeing there are the tests being run in order to check to see that you did everything correctly...
Eva
@evasyl1
Oct 06 2015 02:40
Hey, I am on Bonfire : Truncate a String. I have the first two of four checks green. The remaining two seem to be asking me to find a way to exclude non-number values for num, but things like Number.isInteger(), isNaN(),and so on, have not worked.
function truncate(str, num) {
  if(typeof num ==="number"){return str.slice(0, num-3)+"...";
}
  else {return str;}
}
truncate("A-tisket a-tasket A green and yellow basket", 11, "");
Ryan C.
@marvroots
Oct 06 2015 02:41
@catapixel thanks
CamperBot
@camperbot
Oct 06 2015 02:41
marvroots sends brownie points to @catapixel :sparkles: :thumbsup: :sparkles:
:star: 411 | @catapixel | http://www.freecodecamp.com/catapixel
Jason Wood
@catapixel
Oct 06 2015 02:43
@evasyl1 you are only supposed to return a max of "num" characters but your else isn't checking for length of the string at all
Rex Schrader
@SaintPeter
Oct 06 2015 02:43
@evasyl1 I don't understand what you're doing here checking the type of num - it's expected to be a number. What you need to take into account is what happens if the string is shorter or equal to num?
Jason Wood
@catapixel
Oct 06 2015 02:43
@evasyl1 if the string is shorter that num then you are supposed to return the entire string
Eva
@evasyl1
Oct 06 2015 02:44
@catapixel @SaintPeter The examples that aren't working have values of "A-tisket a-tasket A green and yellow basket".length and "A-tisket a-tasket A green and yellow basket".length + 2 for num. The examples with any numerical value for num are working.
Jason Wood
@catapixel
Oct 06 2015 02:47
@evasyl1 That's because in those instances the "num" value is being set to the length of the entire string or longer. In that case you are supposed to return the entire string and not append the ...
Eva
@evasyl1
Oct 06 2015 02:48
@catapixel This is the full text of the test it's running: assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', '"A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2 should return "A-tisket a-tasket A green and yellow basket".');
That's the test that's failing.
Gabe Teninbaum
@GTeninbaum
Oct 06 2015 02:49
I'm working on bootstrap and wondering...is it incorrect to put multiple div elements within a single bracketed element, or should they each get a separate one?
Jason Wood
@catapixel
Oct 06 2015 02:50
@evasyl1 Yes, in this case num = "A-tisket a-tasket A green and yellow basket".length + 2 which is 45. In that case you are supposed to return "A-tisket a-tasket A green and yellow basket" as your answer not "A-tisket a-tasket A green and yellow bas..."
@evasyl1 You are only supposed to truncate the string "if it is longer than the given maximum string length (second argument)."
Eva
@evasyl1
Oct 06 2015 02:56
@catapixel oh, i see that in the instructions now. so is it looking for something like if(str.length>=num.length) ?
Jason Wood
@catapixel
Oct 06 2015 02:57
@evasyl1 Yes, but only greater than (not equal to)
@evasyl1 if(str.length>num)
Eva
@evasyl1
Oct 06 2015 02:58
@catapixel thanks!
CamperBot
@camperbot
Oct 06 2015 02:58
evasyl1 sends brownie points to @catapixel :sparkles: :thumbsup: :sparkles:
:star: 414 | @catapixel | http://www.freecodecamp.com/catapixel
Eva
@evasyl1
Oct 06 2015 02:58
that fixed it.
banto1
@banto1
Oct 06 2015 02:59
it work now
Brett Stark
@brettstark73
Oct 06 2015 03:18
Hello all
Waypoint: Bring your JavaScript Slot Machine to Life
$($(".slot")[0]).html(slotOne); -> I don't get what this is doing? How are we using [0] to access something? .slot is a class, not an array....
EngineeredEdge
@EngineeredEdge
Oct 06 2015 03:20
@brettstark73 $('.slot') returns all elements with class 'slot'
when there are multiple elements, it returns an array
so $('.slot')[0] is the first element in the array
Brett Stark
@brettstark73
Oct 06 2015 03:21
sure...Oh, ok didn't know it returned an array! Thanks.
CamperBot
@camperbot
Oct 06 2015 03:21
if you want to thank someone, put an @ before their name!
Brett Stark
@brettstark73
Oct 06 2015 03:21
Thanks @EngineeredEdge
CamperBot
@camperbot
Oct 06 2015 03:21
brettstark73 sends brownie points to @engineerededge :sparkles: :thumbsup: :sparkles:
:star: 347 | @engineerededge | http://www.freecodecamp.com/engineerededge
Junior Griffiths
@Jegriff23
Oct 06 2015 03:22
Hello All good night, Good Morning, where ever you are.
I am stuck on a waypoint can anyone assist?
EngineeredEdge
@EngineeredEdge
Oct 06 2015 03:23
which waypoint
Junior Griffiths
@Jegriff23
Oct 06 2015 03:24

@EngineeredEdge
Waypoint: Prioritize One Style Over Another
Sometimes your HTML elements will receive multiple styles that conflict with one another.

For example, your h1 element can't be both green and pink at the same time.

Let's see what happens when we create a class that makes text pink, then apply it to an element. Will our class override the body element's color: green; CSS property?

Create a CSS class called pink-text that gives an element the color pink.

Give your h1 element the class of pink-text.

this is what I did: ```
```
<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
    color: pink;

  }
</style>
<h1>Hello World!</h1>
Levyian
@levyian
Oct 06 2015 03:26
@Jegriff23 you need to create a new class with the color pink and apply it to the h1 element
for eg
.new-class {
    color: #ffffff;
}
and apply it via the class attribute on the h1 element
<h1 class="new-class"></h1>
Junior Griffiths
@Jegriff23
Oct 06 2015 03:31
@levyian like this : .pink-text { color: pink; } and then <h1 pink="pink-text"></h1>
DJ
@qualitymanifest
Oct 06 2015 03:33
@Jegriff23 h1 style="pink-text"
other than that, yes
Junior Griffiths
@Jegriff23
Oct 06 2015 03:33
ok @qualitymanifest ill try it
DJ
@qualitymanifest
Oct 06 2015 03:34
whoooops
h1 class="pink text"
brain fart
Levyian
@levyian
Oct 06 2015 03:34
yeah :)
Junior Griffiths
@Jegriff23
Oct 06 2015 03:38
This message was deleted

this is what I put @qualitymanifest : `<style>
body {
background-color: black;
font-family: Monospace;
color: green;
color: pink;
.pink-text { color: pink; }

}
</style>

<h1>Hello World!</h1>
<h1 class="pink text"></h1>

`

<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
    color: pink;
    .pink-text { color: pink; }

  }
</style>
<h1>Hello World!</h1>
<h1 class="pink text"></h1>
Levyian
@levyian
Oct 06 2015 03:40
@Jegriff23 put the new class declaration below that of the body's
body {
   .....
}

.new-class {
  ...
}
DJ
@qualitymanifest
Oct 06 2015 03:40
@Jegriff23 you put your .pink-text class inside your body brackets
it needs to go below them
yeah, that
Levyian
@levyian
Oct 06 2015 03:42
@Jegriff23 and don't forget to remove the extra color:pink from the body's class
Junior Griffiths
@Jegriff23
Oct 06 2015 03:42

@levyian

<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
    color: pink;

  }
   .pink-text { color: pink; }
</style>
<h1>Hello World!</h1>
<h1 class="pink text"></h1>

still didnt work

DJ
@qualitymanifest
Oct 06 2015 03:44
@Jegriff23 you're missing a dash in between pink and text
Jason
@Jauble
Oct 06 2015 03:44
Anyone know why $('p').removeClass('opacity'); isn't working? http://codepen.io/auble220/pen/GpmjGx
Levyian
@levyian
Oct 06 2015 03:45
@Jegriff23 what @qualitymanifest said
Junior Griffiths
@Jegriff23
Oct 06 2015 03:47

thanks @qualitymanifest and @levyian

<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
    color: pink;

  }
   .pink-text { color: pink; }
</style>
<h1>Hello World!</h1>
<h1 class="pink-text"></h1>

it worked

CamperBot
@camperbot
Oct 06 2015 03:47
jegriff23 sends brownie points to @qualitymanifest and @levyian :sparkles: :thumbsup: :sparkles:
:star: 312 | @levyian | http://www.freecodecamp.com/levyian
:star: 250 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Levyian
@levyian
Oct 06 2015 03:48
@Jauble opacity as you have it is an attribute not a class, so you need to modify it via attribute
@Jegriff23 you're welcome :)
Jason
@Jauble
Oct 06 2015 03:48
@levyian Oh I'm an idiot haha
@levyian Thanks
CamperBot
@camperbot
Oct 06 2015 03:48
jauble sends brownie points to @levyian :sparkles: :thumbsup: :sparkles:
:star: 313 | @levyian | http://www.freecodecamp.com/levyian
Levyian
@levyian
Oct 06 2015 03:49
@Jauble simple mistake :)
Chris Phillips
@christoph-phillips
Oct 06 2015 03:51
Hey guys can anyone help me with the weather app, I want to make the button to change the variable of temperature. I know how to get imperial / metric from openweather api but not sure how to change a variable when clicking a button to affect a variable inside my functionto get imperial/metric. Any help much appreciated. http://codepen.io/chris_is_phillips/pen/XmRNNM
Levyian
@levyian
Oct 06 2015 03:56
@christoph-phillips there are a few ways to achieve this, I would suggest creating a function to update the elements from the api. You could pass in the another variable (boolean maybe) that updates the displayed values with imperal/metric depending on true/false. Set the variable to either true/false by default and change it when you button is click, calling the function to update with the new value
Leeia Isabelle
@Leeiaisabelle
Oct 06 2015 03:58
hey all! Can anyone explain (or demonstrate) the pairing process to me...looks like I'm having issues pairing with someone on a bonfire
Prashanth
@dgprashanth
Oct 06 2015 04:01
Guys, Anyone know what happens when a function is inside a for loop, but I also call it inside the for loop, will it run twice?
Levyian
@levyian
Oct 06 2015 04:01
@Leeiaisabelle both parties would need to download the app and have each other as a contact. Then one person shares their screen and the other is able to use mouse and keyboard as well as talk via mic.
@dgprashanth can you post an example
Leeia Isabelle
@Leeiaisabelle
Oct 06 2015 04:05
so we can't just do it in the browser>
Levyian
@levyian
Oct 06 2015 04:07
@Leeiaisabelle the coding will take place in the host's browser, the call/share screen will be via the app
Leeia Isabelle
@Leeiaisabelle
Oct 06 2015 04:07
ok makes sense. I will download the app now
nicyarsky
@nicyarsky
Oct 06 2015 04:11

Having trouble with replacing characters with lower case and the .replace function

string =string.replace(/\s/g, '');

this worked for getting rid of spaces... but I don't really understand it either, just kinda found it on stack overflow. Can anyone help or point me in direction of a turotial of some sort

Levyian
@levyian
Oct 06 2015 04:13
@nicyarsky what the above code does it look for all matches to the regex (/\s/g) and replace it with '' (nothing)
to get lowercase you need to add string = string.toLowerCase() above or below what you already have
Prashanth
@dgprashanth
Oct 06 2015 04:15
@levyian There is 1 for loop, which has the first JSON call, and there are 2 nested functions. The printing happens outside of the for loop. Will this still work? Or should I be including the functions inside of the for loop?
@levyian Forgive the messy code! I am consciously trying to clean it up after I get it to work :)
nicyarsky
@nicyarsky
Oct 06 2015 04:20
@levyian and what exactly does (/\s/g) do? g stands for global right? and s for space? what does the /\ mean?
Levyian
@levyian
Oct 06 2015 04:20
@dgprashanth yeah this would technically work, but having the second call happen x times would result in 2x the amount of calls and could slow down the page load greatly as x increases
Prashanth
@dgprashanth
Oct 06 2015 04:22
@levyian So it would be best to keep the functions out of the for loop to avoid redundant calls, right?
@levyian What about the variables I get in each of the 2 functions? Should I print them out right there as they're obtained, or should I pass it back to the FOR loop?
Levyian
@levyian
Oct 06 2015 04:23
@nicyarsky yes you're right. the first / is how to start a regex expression, \s is space (need the slash) and /g is global meaning not just the first instance but the whole string
nicyarsky
@nicyarsky
Oct 06 2015 04:23
also how would one remove commas and periods using the regex?
Abhishek
@Abhi493
Oct 06 2015 04:26
        anyone can help me on bonfire fancy bouncer
CamperBot
@camperbot
Oct 06 2015 04:26
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Levyian
@levyian
Oct 06 2015 04:26
@dgprashanth no, the function call is good practice, the issue is second getJSON in the update function. Maybe you could refactor your code and make the update function include the for loop (so you only need to call it once) and each time the getJSON is finish, you call the status/done function which updates the html elements
@nicyarsky you could add \W (for non word character) so: (/\s\W/g)
see: http://www.regexr.com/ and check of the cheatsheet on the left for all the cool things you can do (I use this to test my regex expressions)
claire514
@claire514
Oct 06 2015 04:33
Could anyone help me with the Bonfire:Seak and Destroy?
CamperBot
@camperbot
Oct 06 2015 04:33
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Levyian
@levyian
Oct 06 2015 04:33
@Abhi493 sure, which part?
claire514
@claire514
Oct 06 2015 04:33
This is my code, but I don't know what's wrong:

function destroyer(arr) {
// Remove all the values
var array = arguments[0];
for (i=1; i<arguments.length; i++) {
array = array.filter(function(val){
return val != arguments[i];

});

}
return array;

}

DTing
@dting
Oct 06 2015 04:37
@claire514 you are using the arguments objedct inside that callback function for filter
that callback function has its own arguments object
the callback's arguments object will shadow the destroyer function's callback so to get around this you can create a variable with a different name and assign the destroyers arguments object to that variable. then use that variable inside the filter callback
function destroyer() {
  var destroyerArguments = arguments;
  ...
    array.filter(function(val) {
      return val != destroyerArguments[i];
    });
  ...
}
Levyian
@levyian
Oct 06 2015 04:42
@claire514 in addition to what @dting said you could use Array.slice() on the arguments to get the remaining items var destroyerArguments = arguments.slice(1);
Jason
@Jauble
Oct 06 2015 04:45
Anyone know what I'm doing wrong with the tweet button?
vere perrot
@perrot
Oct 06 2015 04:47
Hi,
I study the unit "Zipline: Build a Random Quote Machine".
First I load the page, I get a href element of the tweet button is OK.
But after I click the new quote button, a href element of the tweet button is gone. I don't know why and how to fix it.
Here is my code link:
http://codepen.io/perrot/pen/VvPzGd
DTing
@dting
Oct 06 2015 04:47

actually arguments object doesnt have a slice function. You can do:

var args = [].slice.call(arguments, 1);

If you want an array (excluding the first element) from the arguments object. but in this case it isnt needed since you are just indexing the using the for loop and not using any array functions.

Tejas Dhawade
@Slyrak-45
Oct 06 2015 04:48
<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
why did we have to use this link before changing the font of the particular heading or paragraph? I am new to this coding
Herman Fassett
@HermanFassett
Oct 06 2015 04:49

@Jauble first off since this is codepen, you'll need to add

target="_blank"

To your a element

DTing
@dting
Oct 06 2015 04:49
@Slyrak-45 that font is hosted at that url. it loads it so your page can use it
Levyian
@levyian
Oct 06 2015 04:50
@dting good catch :)
Tejas Dhawade
@Slyrak-45
Oct 06 2015 04:50
@dting ohk got it. Thanks :+1:
CamperBot
@camperbot
Oct 06 2015 04:50
slyrak-45 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1314 | @dting | http://www.freecodecamp.com/dting
Levyian
@levyian
Oct 06 2015 04:50
@Jauble quote is not a variable. Maybe you meant quoteArray?
Jason
@Jauble
Oct 06 2015 04:52
@HermanFassett Thanks. Do you know why this isn't working?
CamperBot
@camperbot
Oct 06 2015 04:52
jauble sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 307 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Jason
@Jauble
Oct 06 2015 04:52
    $('#link').attr('href', "http://twitter.com/home/?status=" + quote[num-  1]);
Herman Fassett
@HermanFassett
Oct 06 2015 04:53
As @levyian quote isn't a variable
Also I'd do ?tweet
$('#link').attr('href', "https://twitter.com/intent/tweet?text=" + quoteArray[num-  1]);
Jason
@Jauble
Oct 06 2015 04:54
Thanks, I just realized that
CamperBot
@camperbot
Oct 06 2015 04:54
if you want to thank someone, put an @ before their name!
Jason
@Jauble
Oct 06 2015 04:54
lol
Thanks @HermanFassett @levyian
CamperBot
@camperbot
Oct 06 2015 04:54
jauble sends brownie points to @hermanfassett and @levyian :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave hermanfassett points
:star: 314 | @levyian | http://www.freecodecamp.com/levyian
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:06
this might sound like a stupid question but I really wanted to know how do you guys comment your code with that black patch behind it?
Devon Jones
@jones-codes
Oct 06 2015 05:08

```

``

Your code in between the squigglies

the bottom line should be 3 as well
those should be on your keyboard right below your escape key
@Slyrak-45
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:10
Okay so <here I can paste my code> hope I am right
@jones-codes
Devon Jones
@jones-codes
Oct 06 2015 05:12
Yeah it shows up differently when you do it on the same line, keep the squigglies on their own line and it'll give you the black background
in my experience, people are more inclined to help you when your code looks A1 lol
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:15
lol yeah thanks :smile:
CamperBot
@camperbot
Oct 06 2015 05:15
if you want to thank someone, put an @ before their name!
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:15
This message was deleted
@jones-codes
Devon Jones
@jones-codes
Oct 06 2015 05:15
No worries
Where you at in the course ??
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:16
at 16th waypoint in HTML5 @jones-codes
Devon Jones
@jones-codes
Oct 06 2015 05:17
Nice, any prior experience?
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:18
None. Started from scratch.
I was browsing through different websites but this one captivated me. @jones-codes
Devon Jones
@jones-codes
Oct 06 2015 05:19
Awesome, you chose right, my friend
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:19
@jones-codes Yeah :smile:
Devon Jones
@jones-codes
Oct 06 2015 05:20
I've tried and been through a few different ones, and they are all useful
But I think this a solid place to have as a "home"
I'm reading books on JS, watching tutorials when I come across confusing stuff, etc. But I think this is a great place to keep me grounded
Tejas Dhawade
@Slyrak-45
Oct 06 2015 05:23
@jones-codes totally agreed
azaleas
@azaleas
Oct 06 2015 05:26
help bonfire no repeats
CamperBot
@camperbot
Oct 06 2015 05:26

:point_right: bonfire no repeats please [wiki]

Problem Explanation:

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

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

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about bonfire no repeats please on the FCC Wiki

Jason
@Jauble
Oct 06 2015 05:37
Hey @jones-codes
Prashanth
@dgprashanth
Oct 06 2015 05:40
Guys, Is this a good way to dynamically change the destination for a variable in a for loop?
$('#name'+i).html(name);
$('#name'+i).html(name);
My idea is for every turn, it will be like #name0, #name1,#name2... etc
justindobbs
@justindobbs
Oct 06 2015 05:43
it's not something people usually do
Prashanth
@dgprashanth
Oct 06 2015 05:43
@justindobbs Could you explain a better way? I seem to have run out of ideas to dynamically change the destination
@justindobbs Not to mention the fact that it's not working? :/
justindobbs
@justindobbs
Oct 06 2015 05:44
what are you trying to do specifically?
If you check out the code, I have dynamically created templates with ids where the content can go sit
For example, if you change #name'+i to #name0, you will see all the results sit on the first button
justindobbs
@justindobbs
Oct 06 2015 05:45
you would want to select the elements by their index
Prashanth
@dgprashanth
Oct 06 2015 05:45
I need every loop to print on one button and move onto the next button and paste the next element in that one
As in..?
Devon Jones
@jones-codes
Oct 06 2015 05:46
hey how's it going @Jauble
justindobbs
@justindobbs
Oct 06 2015 05:47
use $([elem class Name]).each() would work
if i understand you correctly
Jason
@Jauble
Oct 06 2015 05:51
@jones-codes Not bad. Finally figured out how to scroll down into different sections on my portfolio. Took a break to start my random quote generator. Just figured out how to get the tweet button to work. How's your portfolio comin?
Devon Jones
@jones-codes
Oct 06 2015 05:54
Ahhh took a break, that makes me feel better lol. I saw you talking about the quote earlier and thought you finished the portfolio. I was like no wayyy I'm strugglin
It's ok, having an unproductive night lol. Just want to set up the "active" jQuery class changes in my navbar before I got to bed
I'm realizing I retained ZERO jQuery smh
Vayl
@Vayl
Oct 06 2015 06:13

Hey guys, doing basic javascript course and I'm discovering arrays and such. This kind of sentence keeps coming back:
// Push the numbers zero through four to myArray using a "while loop".

What the hell does it mean, "zero through four" ?

This is the example they gave:
var ourArray = [];

var i = 0;

while(i < 5) {

  ourArray.push(i);

  i++;

}
Jason
@Jauble
Oct 06 2015 06:14
@jones-codes No way, I'll probably be working on that for a while lol. I know what you mean about jQuery. That's why whenever I start a new course or book or anything I always start at the beginning, even though it can feel like a waste of time to go back over everything, because what I forgot comes back and what I didn't just gets reinforced.
@Vayl 0, 1, 2, 3, 4
Vayl
@Vayl
Oct 06 2015 06:16
as simple as that huh @Jauble ? Thanks :)
CamperBot
@camperbot
Oct 06 2015 06:16
vayl sends brownie points to @jauble :sparkles: :thumbsup: :sparkles:
:star: 198 | @jauble | http://www.freecodecamp.com/jauble
Vayl
@Vayl
Oct 06 2015 06:16
simpler question even, does "i++" mean even numbers?
of i?
Jason
@Jauble
Oct 06 2015 06:17
@Vayl No problem :smile:
i++ means you increment i meaning you add 1 to i. It's the same as i = i + 1;
Vayl
@Vayl
Oct 06 2015 06:18
oh okay
so why do they add it here then I don't understand
Like what would this code do:
var myArray = [];
var i = 0;
while (i <= 4) {
  myArray.push(i);
  i++;
}
Devon Jones
@jones-codes
Oct 06 2015 06:21
They add it so that the while loop will eventually close when i reaches 5
Jason
@Jauble
Oct 06 2015 06:21
So at first i = 0. While i is less than 5, we push the number that i represents onto the array. Then we add 1 to i. We keep doing that until i = 4
Vayl
@Vayl
Oct 06 2015 06:22
oh. So if i = 4 it won't run the function then?
it would just stop?
Jason
@Jauble
Oct 06 2015 06:22
@Vayl that code will do the same thing. It's just another way to write it.
I will run when i = 4 and then stop
Vayl
@Vayl
Oct 06 2015 06:23
okay @Jauble , thanks.
CamperBot
@camperbot
Oct 06 2015 06:23
vayl sends brownie points to @jauble :sparkles: :thumbsup: :sparkles:
:warning: vayl already gave jauble points
Devon Jones
@jones-codes
Oct 06 2015 06:23
@Jauble Yeah I hear you on that, I think that was my problem. I already had some limited experience with jQuery so I just kind of flew through those waypoints. And every time I look at it it seems so easy I'm like "I got this"
Jason
@Jauble
Oct 06 2015 06:24
because when it goes through, it will add 1 to i and i will be 5 so it won't run
Devon Jones
@jones-codes
Oct 06 2015 06:25
and I just picked up A Smarter Way to Learn JS, and I can hardly bear the first few chapters
dude has like 20 online exercises for every chapter
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:26
how does one make the twitter share text match the current quote in random quote machine?
Devon Jones
@jones-codes
Oct 06 2015 06:26
first 3 chapters have been like strings, alerts, and numbers...cmon I can't sit through 20 exercises on how to declare a string lol
Jason
@Jauble
Oct 06 2015 06:26
@jones-codes Lol I went through the HTML & CSS one and I'm like 75% through the JS one. He's supposed to come out with a jQuery book pretty soon
@Vayl No problem
Devon Jones
@jones-codes
Oct 06 2015 06:27
ahh really? How did you like them? specifically the JS one
Vayl
@Vayl
Oct 06 2015 06:28
Would you recommend "A Smarter Way To Learn JS"?
Jason
@Jauble
Oct 06 2015 06:28
I like them. I like all the practice lol
@Vayl I would
Vayl
@Vayl
Oct 06 2015 06:28
so u kind of buy the book and then practice on ur own?
that's the system?
Jason
@Jauble
Oct 06 2015 06:29
@jones-codes When I started on them I was just finishing up CodeCademy so I was looking for something to keep me busy
Devon Jones
@jones-codes
Oct 06 2015 06:30
Alright I'll stick with it. The other book I'm reading is Eloquent Javascript..that one never fails to make me feel like an idiot
zac247
@zac247
Oct 06 2015 06:31
@jones-codes have you tried the headfirst javascript?They have a very different approach
Devon Jones
@jones-codes
Oct 06 2015 06:32
Sounds like I've glossed over it in a list of resources, but no haven't tried it
you reccomend??
Jason
@Jauble
Oct 06 2015 06:33
@Vayl Ya. You go online to do the quizzes. There's 20 questions for each chapter. The JS book has 89 chapters. http://asmarterwaytolearn.com/
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:34
have any of you guys tried Eloquent JS? Isn't that supposed to be a good book?
Jason
@Jauble
Oct 06 2015 06:35
@Vayl I just bought that like a week ago lol. I bought Head First Web Design too cause it was really cheap lol
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:35
It's pretty good for a free resource - http://eloquentjavascript.net/
Devon Jones
@jones-codes
Oct 06 2015 06:35
I'm on Chapter 3 or 4 of Eloquent JS
It feels awesome, but I'm lost already...
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:37
How does one ask for a pair in FreeCodeCamp... Nobody seems to be responding to my request. :worried:
@jones-codes I stopped following it at Chapter 3.
Devon Jones
@jones-codes
Oct 06 2015 06:38
I prefer "taking a break" but yeah I've stopped too lol
not sure, never paired before
Jason
@Jauble
Oct 06 2015 06:38
@jones-codes I just started Head First JS it's pretty basic so far, but I like it. They make it kind of fun, and not so dull. I bookmarked Eloquent JS a while back. I'll have to check it out
@thedigitalmonk I've never tried pairing either. Have you tried the LetsPair room?
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:39
Yeah I tried that room. No response @Jauble
Devon Jones
@jones-codes
Oct 06 2015 06:40
I've heard nothing but great things about it, and it feels really good as I read it. But so much has flown over my head in ch. 3 it feels useless to read
Jason
@Jauble
Oct 06 2015 06:41
@thedigitalmonk Keep trying. I've see people in the other rooms asking to pair every so often, so I know there's other people looking to pair
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:42
There are books which trick you into learning the basics and then there are books that get you to think like a programmer. Eloquent JS falls in to the latter category. So the exercises are a little taxing. Sometimes you forget the solution as soon as you solve the problem. But I guess more than knowing the answer the guy wants you to learn how to think in a direction that leads you to the answers. Pretty frustrating sometimes. Especially because I am not very good at math based thinking.
@Jauble I need very little help actually. Just need to get the goddamn twitter button to work in the Random Quote Machine exercise. Did you manage to do it?
Jason
@Jauble
Oct 06 2015 06:43
Hmm.. maybe they'll go back over that stuff in future chapters. Sometimes I'll see stuff that I don't get at first and then after reading for a while it'll start to make sense
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:44
Did you build the Random Quote Machine @jones-codes ?
Jason
@Jauble
Oct 06 2015 06:44
@thedigitalmonk Lol I was gonna respond to that, but we started talking about books and I totally forgot lol
@thedigitalmonk Check this out first
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:46
@Jauble that guys shows a way to do it if you set the text yourself. The issue here is that the text changes when I click on the get quote button so the share text has to change too.
Devon Jones
@jones-codes
Oct 06 2015 06:46
@thedigitalmonk Yeah that makes sense. The exercises are almost secondary the words on the page are just straight up Greek to me. My brain starts to hurt if I manage to decipher one sentence
I'm exaggerating but barely lol
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:47
I am THIS close to figuring this out.
Devon Jones
@jones-codes
Oct 06 2015 06:47
no, I'm on the portfolio zipline, good luck though.
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 06:47
Oh damn. Just one exercise away.
Jason
@Jauble
Oct 06 2015 06:48
@thedigitalmonk This is what I did if you wanna check it out http://codepen.io/auble220/pen/GpmjGx
Devon Jones
@jones-codes
Oct 06 2015 06:48
yeah where @Jauble SHOULD be cough
Jason
@Jauble
Oct 06 2015 06:49
@jones-codes I needed a break! lol
@jones-codes I wanna keep working on it for a while. I actually think it should've been further along in the course. I have a feeling there's things I'll pick up that I want to add later.
Devon Jones
@jones-codes
Oct 06 2015 06:53
@Jauble haha Yeah I hear you, I thought it was a little early too. But it'll be nice to already have somewhere to link up all the ziplines too
I just want to get it functioning and laid out right before I move on. I need to stop tinkering with the CSS
Jason
@Jauble
Oct 06 2015 06:59
@jones-codes That's true. I am glad I have it started, so I can add to it as I go along
Ye
@kamiye
Oct 06 2015 07:13
Hi
Jason
@Jauble
Oct 06 2015 07:21
Hey @kamiye
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 07:22
Guys can you tell me where I am going wrong with the twitter button?
Jason
@Jauble
Oct 06 2015 07:26
@thedigitalmonk That looks more complex than it needs to be. Did you look at my code?
Yosafat Ariel
@yoskakomba
Oct 06 2015 07:27
Hi guys, please help me with simple explanation about this http://freecodecamp.com/challenges/waypoint-iterate-over-arrays-with-map
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 07:30
@Jauble I did look at your code. I am actually using that API to get the quotes instead of taking it from an array.
I am getting the quote just not able to put it in the data-text attribute of the tweet link
@yoskakomba basically the map function will go through each value in the array and do something you mention inside the function.
//here's an array
var array = [1,2,3,4,5];


// 
array = array.map(function(val){
// the function takes one argument 'val' which is a value in the array
  return val+3;
  // this takes the value and adds 3 to the value and puts it back in the array. You get a new array where each value is the value plus 3. so [1,2,3,4,5] becomes [1+3,2+3,3+3,4+3,5+3] i.e [4,5,6,7,8]
});
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 07:36
Just for the sake of semantics - map is a 'method' of the array object.
Jason
@Jauble
Oct 06 2015 07:37
@yoskakomba this is what they give you:
array = array.map(function(val){

  return val+1;

});
Yosafat Ariel
@yoskakomba
Oct 06 2015 07:38
yes, thanks @thedigitalmonk @Jauble , now I'm getting there
CamperBot
@camperbot
Oct 06 2015 07:38
yoskakomba sends brownie points to @thedigitalmonk and @jauble :sparkles: :thumbsup: :sparkles:
:star: 220 | @thedigitalmonk | http://www.freecodecamp.com/thedigitalmonk
:star: 199 | @jauble | http://www.freecodecamp.com/jauble
Jason
@Jauble
Oct 06 2015 07:40
@yoskakomba Say our array = [1, 2, 3, 4]; It will iterate over the array and add 1 to each number in the array (val in this case). So your result will be array = [2, 4, 6, 8]
@yoskakomba No problem :smile:
@thedigitalmonk I'm not really sure what you're doing with the JSON and stuff
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 07:45
@Jauble they said we could use the forismatic API to get the quotes so basically I am using $.getJSON to get a quote from that website. On .done() I am running a function called update which updates the text of the quote and on failure there is a standard failure function. It's quite simple actually. The only issue is I am not able to get the quote to show up in the data-text attribute of the twitter link.
Jason
@Jauble
Oct 06 2015 07:45
It looks like that's opening up communication with twitters api, but I haven't gotten to all that yet
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 07:45
Didn't you give the Forismatic route a try? It could help you learn how to use an API and how to use JSON
Jason
@Jauble
Oct 06 2015 07:46
@thedigitalmonk If it mentioned that I didn't see it. I'll try it though. I'm sure it will be a good thing to know
Jason
@Jauble
Oct 06 2015 07:52
@thedigitalmonk I see the link you were talking about. Thanks for mentioning it
CamperBot
@camperbot
Oct 06 2015 07:52
jauble sends brownie points to @thedigitalmonk :sparkles: :thumbsup: :sparkles:
:star: 221 | @thedigitalmonk | http://www.freecodecamp.com/thedigitalmonk
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 07:53
@Jauble see if you can get the twitter link to work with that method. I just can't seem to figure it out...
Jason
@Jauble
Oct 06 2015 08:00
This is the link they give for their jsonp usage example: http://api.forismatic.com/api/jsonp/. It looks like it's in Russian or something lol
@thedigitalmonk I don't think I'll have time to mess with that tonight
Shair Mir
@ShairMir
Oct 06 2015 08:17
bf mutation
CamperBot
@camperbot
Oct 06 2015 08:17

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

mutation(['hello', 'hey']);

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

Shair Mir
@ShairMir
Oct 06 2015 08:17
bf hint
CamperBot
@camperbot
Oct 06 2015 08:17
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Rob Simpson
@pertrai1
Oct 06 2015 09:07
Hey, totally lost in Diff Two Arrays: I have this so far but can't wrap my head around how to eliminate those that are the same:
function diff(arr1, arr2) {
var newArr = [];
var newArr1 = arr1.slice(0);
var newArr2 = arr2.slice(0);
var newConcat = newArr1.concat(newArr2);
newConcat.filter(function(value, index, array) {

})
console.log(newConcat);
return newArr;
}
diff([1,2,3,5], [1,2,3,4,5]);
azaleas
@azaleas
Oct 06 2015 09:23

Hi fellow campers, right now I'm doing No repeats bonfire and I got the code for recursive function, actually I just wrote it from the pseudo code + some articles online. It works well, but I don't really get how it works. So, I'd really appreciate the walk through for the code:

function permAlone(str) {

  arr = str.split("");

  result = [];

  perm(arr, arr.length);
  return result;

  function perm(string, length){
    if (length == 1){
      result.push(string.join(""));
    }

    else {
      for (var i=0; i < length; i++){
       perm(string, length-1);

        if(length % 2 == 0){
         swap(string, i, length-1); 
         }

        else{
         swap(string, 0, length-1);
        }
      }


    }
  }

  function swap(array, first, second){
    var temp = array[first];
    array[first] = array[second];
    array[second] = temp;
  }
}

permAlone('aab');

It's just the permution, I'm not expecting the solution for the bonfire.. My question is, how this function ends up with all the permutaions, even though I have only one push function? Also, the perm function is called three times? (according to the for loop)..I just don't want to be a code junkie:D

PatrykKozyra
@PatrykKozyra
Oct 06 2015 09:56
help Waypoint: Learn how Script Tags and Document Ready Work
CamperBot
@camperbot
Oct 06 2015 09:56

:point_right: waypoint learn how script tags and document ready work [wiki]

Learn how Script Tags and Document Ready Work

For some reason FCC likes to introduce jQuery before JavaScript itself.

To add JS to your HTML, you need a script tag. Your browser will run any JavaScript inside a script element, including jQuery.

Inside your script element, add this code: $(document).ready(function() { to your script. Then close it on the following line (still inside your script element) with: });

<script> $(document).ready(function(){

});</script>

:pencil: read more about waypoint learn how script tags and document ready work on the FCC Wiki

Michael Cheung
@m6cheung
Oct 06 2015 10:48
anyone up to help me with some jquery/.
?
specifically, if I add extra dom elements to the page by pressing a button, how do I manipulate those new DOM elements?
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 10:48
@m6cheung what's the problem?
Michael Cheung
@m6cheung
Oct 06 2015 10:49
@thedigitalmonk can I show you what I'm working on?
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 10:49
sure
so when I press Add course a new line is created
I want to be able to add the input values of the units together
thanks in advance for responding by the way I really appreciate it
CamperBot
@camperbot
Oct 06 2015 10:50
if you want to thank someone, put an @ before their name!
Michael Cheung
@m6cheung
Oct 06 2015 10:50
@thedigitalmonk thank you!
CamperBot
@camperbot
Oct 06 2015 10:50
m6cheung sends brownie points to @thedigitalmonk :sparkles: :thumbsup: :sparkles:
:star: 223 | @thedigitalmonk | http://www.freecodecamp.com/thedigitalmonk
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 10:50
where do you want to show the result?
Michael Cheung
@m6cheung
Oct 06 2015 10:50
so when I put number in the units
and a grade on the grade
a result pops up
in
<div class='result'>
      <h3 id="gpa">GPA</h3>
    </div>
it gets changed by
$units.keyup(function() {
  $gpa.text((($grade.val() * $(this).val()) / $(this).val()).toFixed(2));  
});

$grade.change(function() {
    $gpa.text((($units.val() * $(this).val()) / $units.val()).toFixed(2));
    $('.result').show();
});
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 10:51
Oh I see
@m6cheung I am afraid I don't know enough to help you.
Michael Cheung
@m6cheung
Oct 06 2015 10:55
@thedigitalmonk aww.. it's ok thanks though!
CamperBot
@camperbot
Oct 06 2015 10:55
m6cheung sends brownie points to @thedigitalmonk :sparkles: :thumbsup: :sparkles:
:warning: m6cheung already gave thedigitalmonk points
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 11:00
What's a good API for the local weather Zipline?
DTing
@dting
Oct 06 2015 11:01
@thedigitalmonk i used open weather map but a lot of people said simpleweatherjs.com is easier to use
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 11:01
checking out simpleweatherjs
pappilino
@pappilino
Oct 06 2015 11:22
function mutation(arr) {
  var haystack = arr[0];
  var needle = arr[1];
  var smallerNeedle = arr[1].split('');
    for (var i = 0; i < smallerNeedle.length; i++) {
        if (haystack.indexOf(smallerNeedle[i]) != -1) {
            return true;
        }
        else {
            return false;
        }
    }

}

mutation(["hello", "hey"], "");
someone please help me check my nesting if...
Blauelf
@Blauelf
Oct 06 2015 11:24
It should be the other way around, check for ==-1 and return false, and after the for-loop return true.
pappilino
@pappilino
Oct 06 2015 11:25
function mutation(arr) {
  var haystack = arr[0];
  var needle = arr[1];
  var smallerNeedle = arr[1].split('');
    for (var i = 0; i < smallerNeedle.length; i++) {
        if (haystack.indexOf(smallerNeedle[i]) == -1) {
            return false;
        }
        else {
            return true;
        }
    }

}

mutation(["hello", "hey"], "");
changed to this, getting the same thing
Blauelf
@Blauelf
Oct 06 2015 11:25
Do not return true in the else path. Return true after the for-loop.
mukul dilwaria
@dilwaria
Oct 06 2015 11:26
hey can any one tell me
Blauelf
@Blauelf
Oct 06 2015 11:26
You won't return true just because you found one character of needle in haystack.
mukul dilwaria
@dilwaria
Oct 06 2015 11:26
how to solve thhis

Waypoint: Target the same element with multiple jQuery Selectors
Now you know three ways of targeting elements: by type: $("button"), by class: $(".btn"), and by id $("#target1").

Use each of these jQuery selectors to target your button element with the class btn and the id target1.

Use the addClass() jQuery function to give the element one new class for each selector: animated, shake, and btn-primary.

pappilino
@pappilino
Oct 06 2015 11:27
This message was deleted
Aleksandar B.
@aleksandar-b
Oct 06 2015 11:28
Can someone give me hints about Simon Game? Or pseudocode.. I think I know, but just to check.
Blauelf
@Blauelf
Oct 06 2015 11:28
@pappilino You wouldn't even need to split the needle, as strings are somewhat array-like and support string[index] addressing.
pappilino
@pappilino
Oct 06 2015 11:29
ah
h4r1m4u
@h4r1m4u
Oct 06 2015 11:30
@dilwaria write three separate jQuery statements. the 1st one will target the element by type, the 2nd by class, the 3rd by id. each of these statements then adds one class (animate, shake and btn-primary respectively) to the target.
pappilino
@pappilino
Oct 06 2015 11:30
funny... i modified to code a bit to lowercase the haystack n needle, it didn't work, but now it works after i delete the needle splitting code. why?
@h4r1m4u u from indonesia bro?
h4r1m4u
@h4r1m4u
Oct 06 2015 11:31
@pappilino nah. but i do harimau silat :)
pappilino
@pappilino
Oct 06 2015 11:32
ic. ur id sounds indonesian :P
h4r1m4u
@h4r1m4u
Oct 06 2015 11:32
yeah, it's an indonesian martial art
mukul dilwaria
@dilwaria
Oct 06 2015 11:32
thanks boss!!
CamperBot
@camperbot
Oct 06 2015 11:32
if you want to thank someone, put an @ before their name!
pappilino
@pappilino
Oct 06 2015 11:32
i know, i'm indonesian
Blauelf
@Blauelf
Oct 06 2015 11:32
@pappilino You did not split needle but arr[1].
BTW, strings are so array-like, even this should work:
function mutation(arr) {
  var haystack = arr[0].toLowerCase();
  var needle = arr[1].toLowerCase();
  return Array.prototype.every.call(needle, function(c) { return haystack.indexOf(c)!==-1; });
}
h4r1m4u
@h4r1m4u
Oct 06 2015 11:33
@dilwaria you're welcome
pappilino
@pappilino
Oct 06 2015 11:34
 return Array.prototype.every.call(needle,
don't understand prototype.every.call ...
["hello", "hey"]
var needle = arr[1].split('');
i thought this is supposed to split the needle?
DTing
@dting
Oct 06 2015 11:34
The problem with your code as is, is that you have a for loop that always returns. it will never make it to the second iteration
pappilino
@pappilino
Oct 06 2015 11:35
thx @dting ,checking ur link
CamperBot
@camperbot
Oct 06 2015 11:35
pappilino sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1317 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Oct 06 2015 11:35
    for (var i = 0; i < smallerNeedle.length; i++) { // this will never reach the second value of i
        if (haystack.indexOf(smallerNeedle[i]) == -1) {
            return false;
        }  else { // instead of else here, you can move this return true outside the for loop
            return true;
        }
    }
pappilino
@pappilino
Oct 06 2015 11:36
function mutation(arr) {
  var haystack = arr[0].toLowerCase();
  var needle = arr[1].toLowerCase();
  var smallerNeedle = arr[1].split('');
    for (var i = 0; i < smallerNeedle.length; i++) {
        if (haystack.indexOf(smallerNeedle[i]) == -1) {
            return false;
        }
    }
    return true;

}

mutation(["hello", "hey"], "");
this doesn't work
function mutation(arr) {
  var haystack = arr[0].toLowerCase();
  var needle = arr[1].toLowerCase();
    for (var i = 0; i < needle.length; i++) {
        if (haystack.indexOf(needle[i]) == -1) {
            return false;
        }
    }
    return true;

}

mutation(["hello", "hey"], "");
but this works
Blauelf
@Blauelf
Oct 06 2015 11:37
@pappilino It splits arr[1], but not needle (and you probably applied toLowerCase() only to that one).
Usually, each array inherits a method every(fn), that returns true if fn(elem) is true for all elements. So I use the method that would be attached to an array and use it on the array-like string needle. That's what call is doing, it calls the function and sets its "this" to the object I supply.
pappilino
@pappilino
Oct 06 2015 11:37
why though? i just change it into array in the first code and it doesn't work. with string it works
DTing
@dting
Oct 06 2015 11:38

@Blauelf got it you need to use if you want to split

  var needle = arr[1].toLowerCase();
  var smallerNeedle = needle.split('');

or

  var needles = arr[1].toLowerCase().split('');
Blauelf
@Blauelf
Oct 06 2015 11:38
Yeah, that's the way.
pappilino
@pappilino
Oct 06 2015 11:39
but i did lowercased the needle before splitting it
DTing
@dting
Oct 06 2015 11:39
strings are immutable
toLowerCase only returns the lowercase version of that string
it doesnt change the string in arr[1] to lowerCase
and since use arr[1].split('') to set the value of smallerNeedle, you have upper case strings in smallerNeedle
pappilino
@pappilino
Oct 06 2015 11:40
ah...i get it now.....
so by saying string is immutable, that also means that strings in an array are also immutable?
Blauelf
@Blauelf
Oct 06 2015 11:40
@dting [ and ] are special markdown characters, you need to escape them in standard text
DTing
@dting
Oct 06 2015 11:41
strings are immutable period
pappilino
@pappilino
Oct 06 2015 11:42
got it
thanks @Blauelf and @dting
CamperBot
@camperbot
Oct 06 2015 11:42
pappilino sends brownie points to @blauelf and @dting :sparkles: :thumbsup: :sparkles:
:warning: pappilino already gave dting points
:star: 328 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Oct 06 2015 11:42
You can get another string and store it in the same variable. But never change the string.
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 12:07
Hi guys, care to check my weather app? Please send across a screenshot in private chat. I want to know if it works for your location. Thanks. http://codepen.io/thedigitalmonk/full/xwddBz/
Joshua Peeling
@ElSquash
Oct 06 2015 12:09
Hey guys! I have a quick question, I am doing the first 800 hours of practice, and I'm on the Object Oriented and Functional Programming section. I got to number 7 where we're using the .filter() method on arrays. In the exercise, the statement inside the anonymous function passed into filter() says return val <= 5; How does this exactly work? Is it a conditional returning true or false? Because it shows the output as only keeping the numbers in the array that are less than five. Any explanation? Thanks!
Blauelf
@Blauelf
Oct 06 2015 12:12
.filter() calls the given function for every element, and where this function returns true (or a truly value as in Boolean(value)==true) the element is included in the returned array. Does not change the original array.
You may also consult the MDN docs for Array.filter()
Andrés Cifuentes
@dinga99
Oct 06 2015 12:13
Hi!, i'm having a problem in the Simon Zipline
I don't know how i can handle the users click events. Trying with an event loop, but Jquery.click() its summing up a lot a variable
Justin
@Justintlai
Oct 06 2015 12:33
I'm wondering if someone can help me understand why FCC is not accepting my solution?
Harvey
@harvey56
Oct 06 2015 12:33
hey! question on the steamroller bonfire (part 8):
I can solve the problem but with adding an extra variable to the steamroller function, as in function steamroller(arr, temp). Is it still right ? did you manage to solve the problem sticking exactly to the given input format ?
Jason Wood
@catapixel
Oct 06 2015 12:34
@Justintlai Which problem are you working on and what does your code look like?
Blauelf
@Blauelf
Oct 06 2015 12:35
@harvey56 Yes, it is perfectly possible to do it without an extra parameter.
Justin
@Justintlai
Oct 06 2015 12:36

@catapixel this is my code for Bonfire: Search and Replace

function myReplace(str, before, after) {

   //first make sure all the cases match between before and after
   after = ((before[0] === before[0].toUpperCase()) ? after[0].toUpperCase() : after[0].toLowerCase()) + after.substring(1);

  return str.replace(before, after); 
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");

The result I get seems to match what they want - maybe i've missed something really stupid :/

Juan Riquelme
@soulchainer
Oct 06 2015 12:36
wiki format
CamperBot
@camperbot
Oct 06 2015 12:36

:point_right: code formatting [wiki]

Inline code

alt text

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

Code Block

``` ⇦ Type 3 backticks and then press [shift + enter ⏎]

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

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

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

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

Juan Riquelme
@soulchainer
Oct 06 2015 12:36
backticks in separate lines.
Harvey
@harvey56
Oct 06 2015 12:36
@Blauelf thanks. have to think harder then ...
CamperBot
@camperbot
Oct 06 2015 12:36
harvey56 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 329 | @blauelf | http://www.freecodecamp.com/blauelf
Jason Wood
@catapixel
Oct 06 2015 12:40
@Justintlai you need to use regex in your replace method because you need to replace the substitution word "globally" / every occurrence. Your current code doesn't do that.
supasheva
@supasheva
Oct 06 2015 12:40
Hey fellas
having issues with the palindrome problem in javascript
Justin
@Justintlai
Oct 06 2015 12:41
@catapixel okay! Thanks for the heads up :) I'll give that a go.
CamperBot
@camperbot
Oct 06 2015 12:41
justintlai sends brownie points to @catapixel :sparkles: :thumbsup: :sparkles:
:star: 415 | @catapixel | http://www.freecodecamp.com/catapixel
Jason Wood
@catapixel
Oct 06 2015 12:41
@supasheva what's the problem and what does your code look like?
supasheva
@supasheva
Oct 06 2015 12:43

var x =str.replace(/[^A-Z0-9]/ig, "").toLowerCase();

return str==x.split('').reverse().join('');

whoops
how do i paste code
Jason Wood
@catapixel
Oct 06 2015 12:43
This message was deleted
supasheva
@supasheva
Oct 06 2015 12:43
but yea basically that is it @catapixel
Jason Wood
@catapixel
Oct 06 2015 12:44
This message was deleted
Blauelf
@Blauelf
Oct 06 2015 12:47
@catapixel /[^A-Z0-9]/ig should remove enough, don't you think?
Jason Wood
@catapixel
Oct 06 2015 12:48
This message was deleted
Blauelf
@Blauelf
Oct 06 2015 12:50
@catapixel The mistake is comparing str and x.split('').... and not x and x.split('')....
The regex is good.
Jason Wood
@catapixel
Oct 06 2015 12:51
@Blauelf you are correct. I missed the "i" in the regex. @supasheva ^
@supasheva The only change is in your return line. Swap what @Blauelf points out and you've got a working solution with no other changes needed
supasheva
@supasheva
Oct 06 2015 12:56
ermm
i see what you are saying

so should it be str.replace(/[^A-Z0-9]/ig, "").toLowerCase();

return str==str.split('').reverse().join('');

Jason Wood
@catapixel
Oct 06 2015 12:57
@supasheva return x==x.split('').reverse().join(''); is correct 'x' not 'str'
supasheva
@supasheva
Oct 06 2015 12:58
ok
the issue i have is
some of it is working
but "race car"
is not returning true
now that is cause the original is race car so i guess
i have to remove the spaces in the original?
Jason Wood
@catapixel
Oct 06 2015 12:59
@supasheva That's because str doesn't have your replacement of non-word characters
@supasheva To figure out whether it's a palindrome you can't consider spaces. That's correct
@supasheva You have removed the spaces, etc. in "x" already so that's what you should compare to
supasheva
@supasheva
Oct 06 2015 13:00

var x = str;
x.replace(/[^A-Z0-9]/ig,"").toLowerCase();

str.replace(/[^A-Z0-9]/ig,"").toLowerCase();

return str==x.split('').reverse().join('');

shouldn't that be ok
cause i am replacing the spaces in the original
and then comparing
unless i am not supposed to replace the spaces
Jason Wood
@catapixel
Oct 06 2015 13:02
@supasheva your original code was fine. It was the compare in the return line that was off. That was the only thing
@supasheva your working code is
function palindrome(str) {
  var x =str.replace(/[^A-Z0-9]/ig, "").toLowerCase();
return x==x.split('').reverse().join('');
}
supasheva
@supasheva
Oct 06 2015 13:03
ok
wow
hm
but that isn't elegant right
is there a cleaner way?
Jason Wood
@catapixel
Oct 06 2015 13:04
@supasheva the first line takes the original string, strips all of the extra characters out, and converts to lowercase. Then the second line compares that value against its reverse for "truth"
Harry Gill
@mygnu
Oct 06 2015 13:04
Bonfire: Smallest Common Multiple
CamperBot
@camperbot
Oct 06 2015 13:04

:fire:Bonfire: Smallest Common Multiple :link:

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

Find the smallest number that is evenly divisible by all numbers in the provided range.

more info:  bf details | bf links | hint

Harry Gill
@mygnu
Oct 06 2015 13:04
bf hint
CamperBot
@camperbot
Oct 06 2015 13:04
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
noobstar
@namsir
Oct 06 2015 13:05
copy and paste won't get you anywhere.
Jason Wood
@catapixel
Oct 06 2015 13:05
@supasheva you could do it all in one line but the way you've done it is more readable
supasheva
@supasheva
Oct 06 2015 13:07
thanks @catapixel
CamperBot
@camperbot
Oct 06 2015 13:07
supasheva sends brownie points to @catapixel :sparkles: :thumbsup: :sparkles:
:star: 416 | @catapixel | http://www.freecodecamp.com/catapixel
Jason Wood
@catapixel
Oct 06 2015 13:07
@supasheva np :thumbsup:
Skip Hendriks
@SkipHendriks
Oct 06 2015 13:16

I'm having trouble with getting json data with a service and then using it inside of a controller. (Twitchtv JSON API)

var app = angular.module('twitchApp', []);

app.controller('TwitchController', function($scope, userService) {

        $scope.account = {};

        var promise = userService;
        promise.then(function(data) {
                console.log(data.data._links.channel);
                $scope.account = data.data;
        });
        console.log($scope.account);
});

app.service("userService", function($http, $q) {

        var promise_test = $http.get('https://api.twitch.tv/kraken/streams/freecodecamp.json')
        return promise_test;
});

How do I get the promise results into the $scope?
The log inside the promise.then() shows the data, but $scope.account stays empty.

CamperBot
@camperbot
Oct 06 2015 13:16
:trollface: troll problems? notify admins here
Justin
@Justintlai
Oct 06 2015 13:17
@catapixel hey I had a look at regexp but it's still not liking my solution...
function myReplace(str, before, after) {

 var re = new RegExp(before,"gi");
 after = ((before[0] === before[0].toUpperCase()) ? after[0].toUpperCase() : after[0].toLowerCase()) + after.substring(1);

 return str.replace(re, after);

}
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Blauelf
@Blauelf
Oct 06 2015 13:19
@Justintlai I think the casing should match the replaced word inside str, not anything in before.
Herman Fassett
@HermanFassett
Oct 06 2015 13:22
@Justintlai I don't think regex is even necessary since you're only replacing one word
Also you should only need an if statement, no else,
Jason Wood
@catapixel
Oct 06 2015 13:24
@Blauelf the casing of after has to be changed to match the casing of before to pass all tests
noobstar
@namsir
Oct 06 2015 13:24
is there a shortest way to lower case all items in an array?
i know a loop will do...just wondering if there's a shorter way
Jason Wood
@catapixel
Oct 06 2015 13:25
@namsir just do it before you convert it to an array or switch it back to a string with join, toLowerCase, and the split it again
noobstar
@namsir
Oct 06 2015 13:26
gotcha :)
saves me 2 lines
lol
Justin
@Justintlai
Oct 06 2015 13:26
@HermanFassett originally I didn't have RegExp but the solution won't pass FCC :( and even with the RegExp it still doesn't like it so i'm stunned as to what the issue really is. Admittedly it could be refined code for sure
noobstar
@namsir
Oct 06 2015 13:26
@catapixel thanks
CamperBot
@camperbot
Oct 06 2015 13:26
namsir sends brownie points to @catapixel :sparkles: :thumbsup: :sparkles:
:star: 417 | @catapixel | http://www.freecodecamp.com/catapixel
Herman Fassett
@HermanFassett
Oct 06 2015 13:27
Hmm
The code works outside of FCC I think
Oh, my passing code doesn't work either
Blauelf
@Blauelf
Oct 06 2015 13:28

@catapixel In the test cases, both always match, but it is indeed not exactly specified. So this would also work:

function replace(str, before, after) {
  return str.split(' ').map(function(word){
    if(word.toLowerCase()===before.toLowerCase())
      return (word[0].toLowerCase()===word[0]?after[0].toLowerCase():after[0].toUpperCase())+after.slice(1);
    else
      return word;
  }).join(' ');
}

It matches case-insensitive and preserves the case as it was in the string, not in the before.

Jason Wood
@catapixel
Oct 06 2015 13:29
@Justintlai Sorry. Just reran the code you pasted and saw the problem. You renamed the function and the test. Change the function name back to 'replace' and the same in the call line and your code will pass as written
Herman Fassett
@HermanFassett
Oct 06 2015 13:29
Lol
Jason Wood
@catapixel
Oct 06 2015 13:30
@Justintlai right now you are calling it myReplace so all the tests will fail as they are calling replace
Herman Fassett
@HermanFassett
Oct 06 2015 13:30
Yeah it's testing for function name replace
It used to be myReplace I think
Blauelf
@Blauelf
Oct 06 2015 13:30
I think myReplace is the actual default code, and does not match the test cases.
Herman Fassett
@HermanFassett
Oct 06 2015 13:31
That's not good
Looks like it's already reported
Justin
@Justintlai
Oct 06 2015 13:32
Omg haha - this is defintely a bug - I reset my code a hundred times to be sure and it must have done it automatically :(
Jason Wood
@catapixel
Oct 06 2015 13:32
@HermanFassett @Blauelf lol! You're right. I reset the code and it swapped to myReplace once I swapped that back out with replace everything passes
Blauelf
@Blauelf
Oct 06 2015 13:33
@catapixel I would find it more logical if you had to adapt to the casing in str, as I believe replace("He eats breakfast.","he","she") should return "She eats breakfast.".
Justin
@Justintlai
Oct 06 2015 13:33
@catapixel @HermanFassett @Blauelf thanks for spotting the issue!
CamperBot
@camperbot
Oct 06 2015 13:33
justintlai sends brownie points to @catapixel and @hermanfassett and @blauelf :sparkles: :thumbsup: :sparkles:
:warning: justintlai already gave catapixel points
:star: 330 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 308 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Oct 06 2015 13:33
True @Blauelf but it doesn't test like that
Jason Wood
@catapixel
Oct 06 2015 13:33
@Blauelf I agree that would be more logical
Blauelf
@Blauelf
Oct 06 2015 13:34
There is no test that makes any difference for the two approaches.
Skip Hendriks
@SkipHendriks
Oct 06 2015 13:34
No one capable of helping me with the Angular issue?
Jason Wood
@catapixel
Oct 06 2015 13:35
@Blauelf That's true but the Note "Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'" would suggest you should pay attention to before in case it did...
@SkipHendriks I haven't fought that battle yet. Sorry
@Blauelf as it's written if the sentence contained both "book" and "Book" and you were told to replace "Book" it would make a difference
Blauelf
@Blauelf
Oct 06 2015 13:38
@catapixel So in my example (replace("He eats breakfast.","he","she") should return "She eats breakfast."), I would want to have "He" replaced by "She" and preserve the case of the word I replaced. The text is not clear about whether that replacement should happen.
Herman Fassett
@HermanFassett
Oct 06 2015 13:39
I think he's saying that replace("He eats breakfast.","he","she") Would return "He eats breakfast" since before is lowercase
Jason Wood
@catapixel
Oct 06 2015 13:39
@Blauelf I agree. I'm just suggesting that because the call out the casing of the word being replaced specifically in the note, in your example "He" should not be replaced as it is not an exact match
Blauelf
@Blauelf
Oct 06 2015 13:39
And I think it's not clear based on the task description.
Jason Wood
@catapixel
Oct 06 2015 13:39
@HermanFassett yes I think that is the way it should work as written
@Blauelf maybe a place for improvement/clarification. Either way I'm happy it doesn't make a difference in the tests. I still don't like the ambiguity and it appears neither do you :wink:
Blauelf
@Blauelf
Oct 06 2015 13:42
As any word would begin with an uppercase letter when in the beginning of a sentence, I think my example should match. But maybe the answer should read "She skips breakfast."... :P
Jason Wood
@catapixel
Oct 06 2015 13:42
@blauelf lol :+1:
noobstar
@namsir
Oct 06 2015 14:00
anyone know a site like fcc but for php?
Ramon Liriano
@lirianore
Oct 06 2015 14:13
function palindrome(str) {
  var newStr = str.toLowerCase().replace(/\W/g, "");
  var reverse = newStr.split("").reverse().join("");
  return newStr == reverse;
}

palindrome("eye");
I'm missing one test to pass...
assert(palindrome("0_0 (: /-\ :) 0-0") === true, '"0_0 (: /-\ :) 0-0" should return true.');"0_0 (: /-\ :) 0-0" should return true.
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:13
@lirianore you should improve your regex
it isn't quite right
Ashanti Perkins
@Mrperkins
Oct 06 2015 14:14
Hello
Ramon Liriano
@lirianore
Oct 06 2015 14:14
@EngineeredEdge yeah that's what has been eating me alive lol.
DTing
@dting
Oct 06 2015 14:15
@lirianore its close, you just need to also remove underscore
\W is [^A-Za-z0-9_] which means it will not match _ for replacement
Ashanti Perkins
@Mrperkins
Oct 06 2015 14:16
How do i give my img element the "smaller-image" class?
Ramon Liriano
@lirianore
Oct 06 2015 14:16
oOOo
Aleksander Gębicki
@Takumar
Oct 06 2015 14:17
@Mrperkins you have to insert inside the tag <img ...> sentence class="name_of_your_class"
Juan Riquelme
@soulchainer
Oct 06 2015 14:17

@Mrperkins

<img class="smaller-image" src="...">

Ô_ó

EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:18
@dting 's regex is close, but still a little too complicated, assuming you run replace AFTER .toLowerString
Ashanti Perkins
@Mrperkins
Oct 06 2015 14:20
thanks! sorry for the simple question, its my first day lol
CamperBot
@camperbot
Oct 06 2015 14:20
if you want to thank someone, put an @ before their name!
Aleksander Gębicki
@Takumar
Oct 06 2015 14:21
@Mrperkins you're welcome, everyone started someday :-)
Juan Riquelme
@soulchainer
Oct 06 2015 14:21
@Mrperkins Keep on it ;)
Robert Richey
@0x0936
Oct 06 2015 14:21
@SkipHendriks I simplified your code a bit to show a working example at this forked pen
DTing
@dting
Oct 06 2015 14:26
i was just explaining what \W that @lirianore uses represents. Hopefully he can come up with a regex for the solution himself.
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:27
@lirianore regex101.com is a good sandbox for finding the regex that you need
KristyCat
@KristyCat
Oct 06 2015 14:35

var Car = function() {
this.wheels = 4;
};

// Only change code below this line.
var myCar = new Car();

//Add the property "engines" to myCar, and make it a number.

// Only change code above this line.
(function() {return JSON.stringify(myCar);})();

need help on this one
everythign i have tried doesnt work
tva10
@tva10
Oct 06 2015 14:36
@KristyCat if you want to create engines variable in myCar you need myCar.engines=10;
or other number
DTing
@dting
Oct 06 2015 14:36
add engines to the myCar instance of the Car class
KristyCat
@KristyCat
Oct 06 2015 14:37
wouldnt that erase the wheels property?
DTing
@dting
Oct 06 2015 14:37
no
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:37
@KristyCat an object can have many properties!
KristyCat
@KristyCat
Oct 06 2015 14:39
i know but it specifically wants me to keep the wheels property while only adding engine to myCar
tva10
@tva10
Oct 06 2015 14:39
yes
you need only add new property
and save previous instance of mycar
DTing
@dting
Oct 06 2015 14:40
myCar.engines = 10; is assigning 10 to the engines property of the myCar instance of Car
that instance will still have the wheels property from using the car constructor
Robert Richey
@0x0936
Oct 06 2015 14:40
@KristyCat add properties to an object using dot notation
// an empty object
var myObject = {};

// no longer empty
myObject.food = "apple";

// added another property
myObject.color = "red";
KristyCat
@KristyCat
Oct 06 2015 14:41
ah, ok
tva10
@tva10
Oct 06 2015 14:41
so brackets will work too myObject['food']='lemon'
Ramon Liriano
@lirianore
Oct 06 2015 14:42
@dting @EngineeredEdge I don't see where I can just add on to my regex like \W(_) or \W+_ . Is there not a way to just add exception for single char.
or I guess I can just write out the full expression /all exceptions/
Moisés Man
@moigithub
Oct 06 2015 14:44
@lirianore http://regex101.com
Mike G.
@mgraham134
Oct 06 2015 14:44
Can someone answer a quick question about bootstrap?
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:44
@lirianore do you know what [^abc] matches
DTing
@dting
Oct 06 2015 14:44
@lirianore you can use brackets [] or another possiblity for or is the pipe |
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:45
@lirianore do you know what [a-d] matches?
@mgraham134 yes what's up
@lirianore , to answer those quetsions, look at the docs I sent you, it will explicitly tell you
Mike G.
@mgraham134
Oct 06 2015 14:46
@lirianore I'm trying to add another class to my button but when I add the btn-block class its not running. I separated them with a space
Ramon Liriano
@lirianore
Oct 06 2015 14:46
@EngineeredEdge matches char a - d
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:47
and what does [^abc] match?
@mgraham134 are they both contained in a single set of quotes?
<div class='class1 class2'> </div>
noobstar
@namsir
Oct 06 2015 14:47
@EngineeredEdge anything but a,b, or c
Moisés Man
@moigithub
Oct 06 2015 14:47
<element class="red big rounded"> hello world </element>
Robert Richey
@0x0936
Oct 06 2015 14:48
@mgraham134 let's see your code
Ramon Liriano
@lirianore
Oct 06 2015 14:48
@EngineeredEdge anything not ^
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:48
@lirianore not '^'?
noobstar
@namsir
Oct 06 2015 14:48
[^\^]
anything in the square brackets will only return 1 value.
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:49
@namsir, I'm helping @lirianore not actually asking the question :P
noobstar
@namsir
Oct 06 2015 14:49
@EngineeredEdge lol hah...
Mike G.
@mgraham134
Oct 06 2015 14:49
Thanks @lirianore @0x0936 that was the issue. I had them inside separate quotes. Please don't mind my noob quesion haha
CamperBot
@camperbot
Oct 06 2015 14:49
mgraham134 sends brownie points to @lirianore and @0x0936 :sparkles: :thumbsup: :sparkles:
:star: 227 | @lirianore | http://www.freecodecamp.com/lirianore
:star: 235 | @0x0936 | http://www.freecodecamp.com/0x0936
noobstar
@namsir
Oct 06 2015 14:50
linda.com has a very detail tutorial for regular expressions.
i've learned it from there.
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:50
@lirianore did you figure out what [^abc] matches?
Robert Richey
@0x0936
Oct 06 2015 14:50
@mgraham134 no mind at all. we all started from humble beginnings - I still have a lot to learn as well
Ramon Liriano
@lirianore
Oct 06 2015 14:50
@EngineeredEdge not abc, I'm on there. I tested few different ways. I think I'm over thinking it. I'm trying to set a perfect match to _ and remove it.
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:50
well
you know how to define a range of letters (nad it works for numbers too)
and you only want letters and numbers left
Ramon Liriano
@lirianore
Oct 06 2015 14:51
ah
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:51
so how do you match everything that is not a letter or a number
Mike G.
@mgraham134
Oct 06 2015 14:51
@0x0936 We'll be laughing at these moments in the near future after mastery.
Ramon Liriano
@lirianore
Oct 06 2015 14:51
So set it to only allow anything that's number and letters.
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:51
or if your using .replace
noobstar
@namsir
Oct 06 2015 14:51
anyone point me to the right direction with Bonfire: Seek and Destroy ? Do i use loop with filter?
Moisés Man
@moigithub
Oct 06 2015 14:51
@lirianore IF its a "special " regex symbol (like dot or parenthesis) u need to escape it, so regex treat it like a "character" itself
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:51
you probably want to match everything that is NOT a letter or a number, and replace it with the empty string ''
DTing
@dting
Oct 06 2015 14:51
@namsir or a filter with a loop
there are several ways to solve that challenge
noobstar
@namsir
Oct 06 2015 14:52
i can do it with a loop...just wonder if there anything else beside loop
DTing
@dting
Oct 06 2015 14:52
filter with a callback function that uses IndexOf is another common way people solve that one
Ramon Liriano
@lirianore
Oct 06 2015 14:52
so [^A-Za-z0-9]
noobstar
@namsir
Oct 06 2015 14:52
oh ok.
Moisés Man
@moigithub
Oct 06 2015 14:52
filter have a loop "inside"
noobstar
@namsir
Oct 06 2015 14:53
thanks @dting
CamperBot
@camperbot
Oct 06 2015 14:53
namsir sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1320 | @dting | http://www.freecodecamp.com/dting
noobstar
@namsir
Oct 06 2015 14:53
yeah filter has a callback
DTing
@dting
Oct 06 2015 14:53
@lirianore you can consider that you already lowercased the string and remove some of the regex
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:53
@lirianore !! does it work! and @dting has good advice
Moisés Man
@moigithub
Oct 06 2015 14:53
@lirianore u can also use i flag (to ignore case) then u no need to specify Upper AND lowercases
Ramon Liriano
@lirianore
Oct 06 2015 14:53
ah worked on regex101.com
[^a-z0-9] since i already did toLowerCase
Robert Richey
@0x0936
Oct 06 2015 14:54
@lirianore :+1:
Ramon Liriano
@lirianore
Oct 06 2015 14:54
basically find anything not number / letter and replace with space. Man i feel dumb lmao.
@0x0936 @moigithub @EngineeredEdge @dting Thanks!
CamperBot
@camperbot
Oct 06 2015 14:55
lirianore sends brownie points to @0x0936 and @moigithub and @engineerededge and @dting :sparkles: :thumbsup: :sparkles:
:star: 348 | @engineerededge | http://www.freecodecamp.com/engineerededge
:star: 236 | @0x0936 | http://www.freecodecamp.com/0x0936
:star: 363 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 1321 | @dting | http://www.freecodecamp.com/dting
Robert Richey
@0x0936
Oct 06 2015 14:55
@lirianore bonus points if you can figure it out using shorthand regex :)
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:55
@lirianore are you replacing it with a space or an empty string?
Ramon Liriano
@lirianore
Oct 06 2015 14:56
empty string
EngineeredEdge
@EngineeredEdge
Oct 06 2015 14:56
@0x0936 there's something shorter than [^a-z0-9] ?
DTing
@dting
Oct 06 2015 14:56
when i mentioned you were close earlier you can also do /\W|_/g or /[\W_]/g
Robert Richey
@0x0936
Oct 06 2015 14:56
^
Blauelf
@Blauelf
Oct 06 2015 15:00
It is not exactly equal. \W on English systems should match "ö", while it should not on German systems (same for "é" in French). None of the test cases uses other characters than A-Z, though, so no effect of that difference.
javaNewbTL
@javaNewbTL
Oct 06 2015 15:02
Hello Everyone, I am working on "Waypoint: Inherit Styles from the Body Element" and when I create my h1 tag as follows: <h1>Hello World</h1> it is not confirming that I have created an h1 element
CamperBot
@camperbot
Oct 06 2015 15:02

welcome to FreeCodeCamp @javaNewbTL!

Blauelf
@Blauelf
Oct 06 2015 15:04
Which of the tests fail?
Robert Richey
@0x0936
Oct 06 2015 15:04
Welcome @javaNewbTL did you modify the existing h1 tag or did you add an h1 tag with 'Hello World'?
CamperBot
@camperbot
Oct 06 2015 15:04

welcome to FreeCodeCamp @0x0936!

Aleksander Gębicki
@Takumar
Oct 06 2015 15:04
@javaNewbTL Have you added <body> ... </body> section to the text? You have to insert your header between <body> tags.
Robert Richey
@0x0936
Oct 06 2015 15:04
silly @camperbot
Blauelf
@Blauelf
Oct 06 2015 15:05
@Takumar No need for that...
javaNewbTL
@javaNewbTL
Oct 06 2015 15:05
yes it looks like <body> <h1> Hello World </h1> </body>
Robert Richey
@0x0936
Oct 06 2015 15:05
@Takumar it's the first waypoint. only an h1 tag is used
Aleksander Gębicki
@Takumar
Oct 06 2015 15:06
@0x0936 no, @javaNewbTL is more advanced, it is waypoint: 48 . But @Blauelf you are right, in that exercise <body> it is not needed :-(
javaNewbTL
@javaNewbTL
Oct 06 2015 15:08
<style>
body {
background-color: black;
color: green;
font-family: Monospace;
}
<h1 class="font-family, color"> Hello World </h1>

</style>
this doesn't seem to work either
Blauelf
@Blauelf
Oct 06 2015 15:08
You should put <h1> outside your <style>
Aleksander Gębicki
@Takumar
Oct 06 2015 15:08
@javaNewbTL and here you are, header should be placed after </style>.
tva10
@tva10
Oct 06 2015 15:08
@javaNewbTL remove class from that h1 tag
Robert Richey
@0x0936
Oct 06 2015 15:08
<style>
  body {
    background-color: black;
    color: green;
    font-family: Monospace;
  }  

</style>
<h1>Hello World</h1>
javaNewbTL
@javaNewbTL
Oct 06 2015 15:09
ah, interesting! Thank you @Takumar @0x0936 @Blauelf @tva10
CamperBot
@camperbot
Oct 06 2015 15:09
javanewbtl sends brownie points to @takumar and @0x0936 and @blauelf and @tva10 :sparkles: :thumbsup: :sparkles:
:star: 398 | @takumar | http://www.freecodecamp.com/takumar
:star: 237 | @0x0936 | http://www.freecodecamp.com/0x0936
:star: 290 | @tva10 | http://www.freecodecamp.com/tva10
:star: 331 | @blauelf | http://www.freecodecamp.com/blauelf
Aleksander Gębicki
@Takumar
Oct 06 2015 15:10
@javaNewbTL: the structure of HTML document in short is:
<html>
<head>
  <style> .... </style>
</head>
<body>
    <h1>Header 1</h1>
    <p>sample paragraph</p>
     ....
</body>
</html>
Blauelf
@Blauelf
Oct 06 2015 15:13

And the best/worst of it: This will still work for compatibility reasons (original HTML did not require any <html> or <body>)

<style> .... </style>
<p>sample paragraph</p>
....

Not that I recommend this style, probably increases load when DOM-building.

Browsers fixing all your bad HTML while building a DOM tree can create really interesting errors. Ever forgot a closing </b>?
noobstar
@namsir
Oct 06 2015 15:24
can anyone help me out...i got an error saying filter is not a function.
function destroyer(arr) {
  // Remove all the values
  var finalArr = [];
  var firstArr = arr[0];

      finalArr = firstArr.filter(function(value, index, array){
          for(i = 1; i < firstArr.length; i++){
              if(firstArr[i].indexOf(value) === value){
                  return value;
              }
          }
      });



  return finalArr;
}
TypeError: firstArr.filter is not a function
Blauelf
@Blauelf
Oct 06 2015 15:25
firstArr is the first element of arr. Is that itself an array?
noobstar
@namsir
Oct 06 2015 15:26
yes it is
lol
let me do a typeof check
i see now ;x
it is a number.
Blauelf
@Blauelf
Oct 06 2015 15:27
I think you might have arr as an array of primitive numbers instead...
Run your filter on arr itself, not arr[0]. You might have to deal with the arguments object, though.
noobstar
@namsir
Oct 06 2015 15:28
is there a type converter in javascript?
Blauelf
@Blauelf
Oct 06 2015 15:28
Sure. What do you want to convert to?
noobstar
@namsir
Oct 06 2015 15:28
to array object
Robert Richey
@0x0936
Oct 06 2015 15:28
@namsir arr is the first argument to destroyer. the test case is passing 3 arguments. you get at those by iterating over arguments
Blauelf
@Blauelf
Oct 06 2015 15:29
Number to array cast? What should that one do?
noobstar
@namsir
Oct 06 2015 15:29
turn firstArr into array
Blauelf
@Blauelf
Oct 06 2015 15:29
It is a number. What do you think does an array help you with?
noobstar
@namsir
Oct 06 2015 15:30
so i can apply the filter method to it
Blauelf
@Blauelf
Oct 06 2015 15:30
Use filter() on arr, and read about arguments object.
noobstar
@namsir
Oct 06 2015 15:31
how do i iterate on unlimited args?
using do while?
Blauelf
@Blauelf
Oct 06 2015 15:31
Unlimited? How can that be?
arguments has a .length property.
Robert Richey
@0x0936
Oct 06 2015 15:32
for (var i = 1; i < arguments.length; ++i) { // do something with arguments[i]
noobstar
@namsir
Oct 06 2015 15:32
ohhhh
yeah forgot about that lol
thanks for a reminder
CamperBot
@camperbot
Oct 06 2015 15:32
if you want to thank someone, put an @ before their name!
noobstar
@namsir
Oct 06 2015 15:32
@Blauelf thanks :)
CamperBot
@camperbot
Oct 06 2015 15:32
namsir sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 332 | @blauelf | http://www.freecodecamp.com/blauelf
noobstar
@namsir
Oct 06 2015 15:32
@0x0936 thanks you too for your effort :D
Blauelf
@Blauelf
Oct 06 2015 15:32
And you might run into the problem that your inner function has its own arguments object, so just create a variable in the outer function and use that in the inner function.
noobstar
@namsir
Oct 06 2015 15:33
i want to see how that works first...i want to see where the problem is
then move to the next step of solving it.
Robert Richey
@0x0936
Oct 06 2015 15:33
I created an args empty array then pushed all values of arguments - after the first - onto args, then used args in filter
noobstar
@namsir
Oct 06 2015 15:34
@0x0936 yes, that is a long way.....there's a shorter way that i want to achieve :D
Robert Richey
@0x0936
Oct 06 2015 15:34
my solution is 2 lines
noobstar
@namsir
Oct 06 2015 15:35
uses more resources.
Blauelf
@Blauelf
Oct 06 2015 15:35
Mine is, too. At least I could instantly write a two-liner for that bf.
noobstar
@namsir
Oct 06 2015 15:35
thanks guys :D
CamperBot
@camperbot
Oct 06 2015 15:35
if you want to thank someone, put an @ before their name!
noobstar
@namsir
Oct 06 2015 15:36
you can convert that firstArr into an array :)
firstArr = Array(arr[0]) ;
DTing
@dting
Oct 06 2015 15:36
the first argument is already an array
noobstar
@namsir
Oct 06 2015 15:36
but let me try without create an additional array
Blauelf
@Blauelf
Oct 06 2015 15:36
@0x0936 ES6 with rest arguments can make it a one-liner as you don't have to deal with arguments any more.
DTing
@dting
Oct 06 2015 15:36
you are taking the first element out of that array and putting it in an array
Robert Richey
@0x0936
Oct 06 2015 15:37
@Blauelf cool :)
noobstar
@namsir
Oct 06 2015 15:37
@dting yes
DTing
@dting
Oct 06 2015 15:37
why would you do that?
haha
arr is not the same thing as the arguments object
Blauelf
@Blauelf
Oct 06 2015 15:37
@0x0936 ES6 version
function destroyer(arr,...targets) {
  return arr.filter(x=>!targets.some(y=>x===y));
}
DTing
@dting
Oct 06 2015 15:37
arr is a named parameter for the first argument the function is invoked with
Robert Richey
@0x0936
Oct 06 2015 15:38
ah, the spread operator. yep!
noobstar
@namsir
Oct 06 2015 15:38
yeah i've heard about that change in ES6
Blauelf
@Blauelf
Oct 06 2015 15:38
It's rest argument here.
DTing
@dting
Oct 06 2015 15:39
function destroyer(arr) {
   console.log(arr === arguments[0]);
}
Gary Wong
@gary-w
Oct 06 2015 15:39
wiki
CamperBot
@camperbot
Oct 06 2015 15:39
usage:
wiki $topic info on that topic
topics for a list of topics
Gary Wong
@gary-w
Oct 06 2015 15:39
wiki code
CamperBot
@camperbot
Oct 06 2015 15:39

:point_right: -----

undefined
:pencil: -----
Blauelf
@Blauelf
Oct 06 2015 15:41
@dting Probably off-spec, but call that function with NaN :P
DTing
@dting
Oct 06 2015 15:42
ya
Blauelf
@Blauelf
Oct 06 2015 15:43
The only value I currently remember that does not equal itself.
Gary Wong
@gary-w
Oct 06 2015 15:45
Question on Anonymous Object... how does "this" work in the commented part?
    <script>
        function createPerson(firstName, lastName) {
            return 
                {
                firstName: firstName,
                lastName: lastName,
                getFullName: function() {
                    return this.firstName + " " + this.lastName; // how odes "this" work here?
                },

                greet: function(person) {
                    alert("Hi, " + person.getFullName() +
                          " I am " + this.getFullName());
                }
            };
        };

        var mZucka = createPerson("m", "Zucka");
        var sJobs = createPerson("s", "Jobs");

        mZucka.greet(sJobs);

    </script>
supasheva
@supasheva
Oct 06 2015 15:46
guys
i am having issues with Bonfire:Seek and Destroy

function destroyer(arr) {

for (var i=1;i<arguments.length;i++){
for (var j=0;j<arr.length;j++){
if (arr[j]===arguments[i]) arr.splice(j,1);
}
}
return arr;
}

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

oh snap
Blauelf
@Blauelf
Oct 06 2015 15:48
@gary-w createPerson returns an object that also has functions as properties. When called as person.getFullName(), this gets the object person as a value. You can also insert another person as to be placed as this, for example mZucka.getFullName.call(sJobs) would have mZucka give you sJobs' name ;)
supasheva
@supasheva
Oct 06 2015 15:48
still don't know how to input code
DTing
@dting
Oct 06 2015 15:48
help formatting
CamperBot
@camperbot
Oct 06 2015 15:48

:point_right: code formatting [wiki]

Inline code

alt text

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

Code Block

``` ⇦ Type 3 backticks and then press [shift + enter ⏎]

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

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

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

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

DTing
@dting
Oct 06 2015 15:48
@supasheva you are changing the size of an array you are iterating
causing you to skip elements
consider making an array and pushing elements to that array if they should be in your results or using the filter function
supasheva
@supasheva
Oct 06 2015 15:51
gracias @dting
thank you @dting
CamperBot
@camperbot
Oct 06 2015 15:51
supasheva sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1323 | @dting | http://www.freecodecamp.com/dting
supasheva
@supasheva
Oct 06 2015 15:51
Fantastic
Gary Wong
@gary-w
Oct 06 2015 15:52
thanks @Blauelf , i get the "person.getFullName" part, how about "this.FirstName" / "this.LastName" / "this.getFullName" part... are mZucka and sJobs being stored temporarily somewhere as the objects when the function createPerson is called?
CamperBot
@camperbot
Oct 06 2015 15:52
gary-w sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 333 | @blauelf | http://www.freecodecamp.com/blauelf
Gary Wong
@gary-w
Oct 06 2015 15:52
as new objects*
Blauelf
@Blauelf
Oct 06 2015 15:53
@gary-w createPerson returns a new Object when called, if it is that what you ask.
Those objects are then stored in mZucka and sJobs, respectively.
Gary Wong
@gary-w
Oct 06 2015 15:58
@Blauelf tx, i'm trying to work out the flow in my head. can i say that when createPerson is called, "this" is always referring to an empty object like this _
CamperBot
@camperbot
Oct 06 2015 15:58
gary-w sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: gary-w already gave blauelf points
Gary Wong
@gary-w
Oct 06 2015 15:59
so this part will be like
            return var _ =  {
                firstName: firstName,
                lastName: lastName,
                getFullName: function() {
                    return _.firstName + " " + _.lastName;
                },
Blauelf
@Blauelf
Oct 06 2015 15:59
If you call a function as object.function(), it gets object as the value of this.
Just that this will be set on calling the function.
There is for example a second parameter to the filter() function, defining what this should be inside the function that is given as the first parameter.
Gary Wong
@gary-w
Oct 06 2015 16:04
thanks @Blauelf i think i kinda understand how this works. appreciated :)
CamperBot
@camperbot
Oct 06 2015 16:04
gary-w sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: gary-w already gave blauelf points
Blauelf
@Blauelf
Oct 06 2015 16:09
Once you understand apply() and call(), you are a master of this, and lines like var args=Array.prototype.slice.call(arguments); will be no more difficult than var a=0; ;)
Lanie Molinar
@LivingForGod1991
Oct 06 2015 16:21

Hi. I know I'm doing something wrong here but don't know what. Can someone please help?
)<style>.red-text {color: red;} .font-size {font-size: 16px}</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text" class="font-size">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text" class="font-size">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Raji von Arx
@kemosabe73
Oct 06 2015 16:21
Hi guys, I am now in Bonfire: Search and Replace.

My problem with my code is that it says replace is not defined. But when I look at the returned string it looks correct.

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

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");

Raji von Arx
@kemosabe73
Oct 06 2015 16:30
function myReplace(str, before, after) {
 var re = new RegExp(before,"g");
 return str.replace(re, after);
}
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
tva10
@tva10
Oct 06 2015 16:35
@kemosabe73 rename your myReplacefunction to replace
@kemosabe73 there are another testcases in task
Raji von Arx
@kemosabe73
Oct 06 2015 16:36
@tva10 thanks
CamperBot
@camperbot
Oct 06 2015 16:36
kemosabe73 sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:star: 291 | @tva10 | http://www.freecodecamp.com/tva10
tva10
@tva10
Oct 06 2015 16:37
@kemosabe73 and last, in your code you need to add copying letters case of replaced word.
Raji von Arx
@kemosabe73
Oct 06 2015 16:37
Quite disappointed with that error. @tva10
tva10
@tva10
Oct 06 2015 16:38
@kemosabe73 sometimes replaced word start from UpperCase, and you need copy this UpperCase to your after
Raji von Arx
@kemosabe73
Oct 06 2015 16:40
@tva10 Yes. I've noticed that we should include case-sensitivity. Thanks once agains.
CamperBot
@camperbot
Oct 06 2015 16:40
kemosabe73 sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:warning: kemosabe73 already gave tva10 points
tva10
@tva10
Oct 06 2015 16:40
No problem ))
Jacob
@ILoveEngineering
Oct 06 2015 16:50
I am trying to nest my text input element into a form element. Please help.
Thomson Muriyadan
@thedigitalmonk
Oct 06 2015 16:52
this Pomodoro Timer zipline looks very complicated. Any tips on getting started?
Prashanth
@dgprashanth
Oct 06 2015 16:55
@thedigitalmonk I would advise just forget about neat design and all that. Just focus on figuring out the timer code !
Tim Bell
@MindfulBell
Oct 06 2015 16:55
@thedigitalmonk lots of fetal position
Levyian
@levyian
Oct 06 2015 17:08
@ILoveEngineering can you show us what you have?
Lanie Molinar
@LivingForGod1991
Oct 06 2015 17:33

Hi. I know I'm doing something wrong here but don't know what. Can someone please help? Sorry if you already saw this message. I wasn't sure it went through since no one answered.
)<style>.red-text {color: red;} .font-size {font-size: 16px}</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text" class="font-size">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text" class="font-size">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Ariel
@ArielLeslie
Oct 06 2015 17:36
exlain formatting
wiki format
CamperBot
@camperbot
Oct 06 2015 17:36

:point_right: code formatting [wiki]

Inline code

alt text

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

Code Block

``` ⇦ Type 3 backticks and then press [shift + enter ⏎]

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

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

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

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

Ariel
@ArielLeslie
Oct 06 2015 17:37
@LivingForGod1991 :point_up_2:
javaNewbTL
@javaNewbTL
Oct 06 2015 17:39

'''

<style>
body {
background-color: black;
font-family: Monospace;
color: green;
.pink-text { color: pink; };
}
</style>

<h1 class="pink-text">Hello World!</h1>
'''

CamperBot
@camperbot
Oct 06 2015 17:39
:bulb: to format code use backticks! ``` more info
javaNewbTL
@javaNewbTL
Oct 06 2015 17:39
testing
<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
    .pink-text { color: pink; };
  }
</style>
<h1 class="pink-text">Hello World!</h1>
Hey it worked! now why does my code suck?
Chris
@Shifthawke
Oct 06 2015 17:40
@LivingForGod1991 What's the way point sweety? Link it for us?
.pink-text { color: pink; }; @javaNewbTL
whoops nvm thought you were talking 2 me
Chris
@Shifthawke
Oct 06 2015 17:44
lol good anyway
Lanie Molinar
@LivingForGod1991
Oct 06 2015 17:44
Chris
@Shifthawke
Oct 06 2015 17:44
Your error is in thte sentence I gave you. too many ; @javaNewbTL
Jonathan Lee Slew
@jlslew
Oct 06 2015 17:45
@javaNewbTL css doesn't allow nested rules
@javaNewbTL pull the pink-text out of body
body {}
.pink-text {}
Chris
@Shifthawke
Oct 06 2015 17:46
@LivingForGod1991 You only need one class sweety. So you would only need to separate the two classes by space. So like
<p class="Monkey squares:green horses:blue"</p>
@jlslew That too lol I completely forgot about that lol.
javaNewbTL
@javaNewbTL
Oct 06 2015 17:49
TY @jlslew @Shifthawke
it worked!
Chris
@Shifthawke
Oct 06 2015 17:49
Np. @javaNewbTL
javaNewbTL
@javaNewbTL
Oct 06 2015 17:50
thank you @jlslew @Shifthawke
CamperBot
@camperbot
Oct 06 2015 17:50
javanewbtl sends brownie points to @jlslew and @shifthawke :sparkles: :thumbsup: :sparkles:
:star: 379 | @shifthawke | http://www.freecodecamp.com/shifthawke
:star: 277 | @jlslew | http://www.freecodecamp.com/jlslew
Chris
@Shifthawke
Oct 06 2015 17:50
Yay for brownies.
@LivingForGod1991 Did you get it?
Brian van Vlymen
@arduino731
Oct 06 2015 17:50
Hello is looking ok with the pic logo http://codepen.io/ironheartbj18/pen/RWVxex?editors=110
Lanie Molinar
@LivingForGod1991
Oct 06 2015 17:51

@Shifthawke I tried this, but it's still not working. What's still wrong with it? <style>.red-text {color: red;} .font-size {font-size: 16px}</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text" "font-size">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text" "font-size">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Chris
@Shifthawke
Oct 06 2015 17:51
I'm going to pm you
Craig Kofoed
@hIGH-aND-mIGHTY
Oct 06 2015 18:06
I could use some help on some finishing touches for the random quote generator. I am hitting the forismatic api then able to display the appropriate properties on page. I would like to insert "Unknown" when there is an empty string for the quoteAuthor.
Jonathan Lee Slew
@jlslew
Oct 06 2015 18:10
@hIGH-aND-mIGHTY maybe something like this
function placeQuote(quote) {
    // check if quoteAuthor is empty then assign unknown to quoteAuthor
   $('#response').html(...);
}
Bill
@kirah1314
Oct 06 2015 18:30
@hIGH-aND-mIGHTY I used this:
  if (data.quoteAuthor === '') {
          data.quoteAuthor = "Anonymous"
        }
h4r1m4u
@h4r1m4u
Oct 06 2015 18:31
@hIGH-aND-mIGHTY the way i do it is that i check the response object in the success portion of the ajax call. if the author is empty, i insert it into the response object there.
@kirah1314 here's a simpler way:
if (!data.quoteAuthor) {
 ...
}
Bill
@kirah1314
Oct 06 2015 18:33
@h4r1m4u thanks
CamperBot
@camperbot
Oct 06 2015 18:33
kirah1314 sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 190 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
h4r1m4u
@h4r1m4u
Oct 06 2015 18:33
:+1:
Craig Kofoed
@hIGH-aND-mIGHTY
Oct 06 2015 18:37
@jlslew thank you!
CamperBot
@camperbot
Oct 06 2015 18:37
high-and-mighty sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 278 | @jlslew | http://www.freecodecamp.com/jlslew
Craig Kofoed
@hIGH-aND-mIGHTY
Oct 06 2015 18:37
@kirah1314 thank you
Pekmen
@Pekmen
Oct 06 2015 18:39
check 1,2,3
why is there billing in options? Is this chat free or what?
Herman Fassett
@HermanFassett
Oct 06 2015 18:41
Click to find out
x)
h4r1m4u
@h4r1m4u
Oct 06 2015 18:41
the basic account is free. if you're an organization and need extras, it's $5/user
just check the gitter.im website
Pekmen
@Pekmen
Oct 06 2015 18:42
kk, thanks
CamperBot
@camperbot
Oct 06 2015 18:42
if you want to thank someone, put an @ before their name!
Herman Fassett
@HermanFassett
Oct 06 2015 18:42
Basically it's just the amount of people in a private room allowed I think
h4r1m4u
@h4r1m4u
Oct 06 2015 18:42
yep. 25 vs unlimited
Pekmen
@Pekmen
Oct 06 2015 18:43
So if I want to pair program with somebody I create private room, right?
h4r1m4u
@h4r1m4u
Oct 06 2015 18:46
yeah, you'd chat with them privately
mhbm
@mhbm
Oct 06 2015 18:46
I need help for exercise bonfire steamroller
CamperBot
@camperbot
Oct 06 2015 18:46
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Rex Schrader
@SaintPeter
Oct 06 2015 18:47
@mhbm Got code?
mhbm
@mhbm
Oct 06 2015 18:48
My works works in another compiler

My code :

var answer = [];

    function verifyArray(arr) {
        for (var i = 0; i < arr.length; i++) {
            if (Array.isArray(arr[i])) {
                for (var j = 0; j < arr[i].length; j++) {
                    if (!Array.isArray(arr[i][j])) {
                        answer.push(arr[i][j]);
                    } else
                        verifyArray(arr[i][j]);
                }
            } else
                answer.push(arr[i])
        }
    }

    function steamroller(arr) {
        // I'm a steamroller, baby

        verifyArray(arr);
        return answer;
    }

    steamroller([[['a']], [['b']]]);
The answer is right...but my code is wrong
i dont know why this error
Rex Schrader
@SaintPeter
Oct 06 2015 18:50
Man, that's a bit ugly
What is the error?
h4r1m4u
@h4r1m4u
Oct 06 2015 18:50

in

 } else
                        verifyArray(arr[i][j]);
                }

are you missing the opening { ?

mhbm
@mhbm
Oct 06 2015 18:51
the program output is right... but does not show that it is right
@SaintPeter why ugly?
Rex Schrader
@SaintPeter
Oct 06 2015 18:52
@mhbm Just a bit deep. I don't see the need for multiple inner loops.
@mhbm Here is the problem: Your "answer" is a global variable. That means that the code works fine the first time you run it, but each subsequent time it will continue to append on answer
@mhbm So you need to reset it at the start of the function call, before you call verifyAnswer
Noel Sufrin
@stimpygato
Oct 06 2015 18:55
@LivingForGod1991 You're defining a class called .red-text correctly, but in your HTML tags, you're adding two class calls in each HTML tag. One correctly: class="red-text", and the other redundant and erroneous call: class="font-size" (which you've already defined in the .red-text style definition). Hope this helps!
mhbm
@mhbm
Oct 06 2015 18:55
@SaintPeter i did your last hint
and works
:smile:
thanks
CamperBot
@camperbot
Oct 06 2015 18:55
if you want to thank someone, put an @ before their name!
Noel Sufrin
@stimpygato
Oct 06 2015 18:55
@camperbot Thanks!
CamperBot
@camperbot
Oct 06 2015 18:55
stimpygato sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
Noel Sufrin
@stimpygato
Oct 06 2015 18:56
WTG Camperbot ;)
CamperBot
@camperbot
Oct 06 2015 18:56
:star: 297 | @camperbot | http://www.freecodecamp.com/camperbot
Noel Sufrin
@stimpygato
Oct 06 2015 18:56
Don't mind me, I'm just hanging with the AI here ;)
Ain't that right CB? @camperbot
TRIVIA: DID YOU KNOW... that if you took every vein in your body and lined them up end-to-end, you'd be dead. #themoreyouknow
Charlotte
@Charzoe
Oct 06 2015 19:03
Ugh, my brain hurts from trying to work this out:
function truncate(str, num) {
  // Clear out that junk in your trunk
  hmWords = str.split(" ").length;
  words = str.split(" ");
  if(hmWords > num){
    words = words.slice(0-num);
    words.toString();
  } else {
    return str;
  }
  return words+"...";
}
truncate("A-tisket a-tasket A green and yellow basket", 11, "");
Any ideas?
Rex Schrader
@SaintPeter
Oct 06 2015 19:05
@Charzoe Hint 1: Don't break your string into words. There is simply no need. Secondly, you need to take the length of the string (IE: str.length) - compare against num and make a decision on what to do. Think about what the possibilities of that comparison would be.
Brett Miller
@Brman85
Oct 06 2015 19:07
what are waypoint and bonfire?
Rex Schrader
@SaintPeter
Oct 06 2015 19:08
@Brman85 A waypoint is one of the educational points. They're optional, but have some small amount of work for you to do to validate that you understand. A Bonfire is required and is algorithm training. They require a lot more thinking.
noobstar
@namsir
Oct 06 2015 19:09
did anyone finished the Slasher Flick want to give a helping hand?
Rex Schrader
@SaintPeter
Oct 06 2015 19:09
@namsir I'm happy to help
@namsir Got some code?
Charlotte
@Charzoe
Oct 06 2015 19:10
Hm.... maybe using the number of spaces to see how many words there are?
noobstar
@namsir
Oct 06 2015 19:10
@SaintPeter sweet..... i plan to use sort with a call back to truly sort the array.
@SaintPeter what should i do next? a loop with if then conditions?
hold on...
fcc didn't sync up all my work...
Rex Schrader
@SaintPeter
Oct 06 2015 19:11
@namsir Actually, don't do either of those things. For Slasher flic, all you're doing is removing elements from the beginning of the array. You can do that with .slice or .splice
noobstar
@namsir
Oct 06 2015 19:12
@SaintPeter i meant Bonfire: where do i belong
Rex Schrader
@SaintPeter
Oct 06 2015 19:12
@namsir ok, for that one you don't actually have to put the value inside the array.
@namsir You just need to loop through until you find out where it SHOULD go
noobstar
@namsir
Oct 06 2015 19:13
@SaintPeter yeah just return the index.
@SaintPeter so you suggesting a loop with some if then conditions?
Rex Schrader
@SaintPeter
Oct 06 2015 19:13
@namsir Precisely.
noobstar
@namsir
Oct 06 2015 19:14
@SaintPeter is there another way to code it?
SaintPeter @SaintPeter ponders this for a moment
noobstar
@namsir
Oct 06 2015 19:14
@SaintPeter i knew i could do it with for loop with 3 if then statements. Just wonder if is there any other way to do it?
Rex Schrader
@SaintPeter
Oct 06 2015 19:14
@namsir Yes, there are several other ways you could do it, but all of them are less effecient
@namsir wait, 3?
@namsir You only need 1.
noobstar
@namsir
Oct 06 2015 19:15
1 ?
Rex Schrader
@SaintPeter
Oct 06 2015 19:16
@namsir Just 1.
noobstar
@namsir
Oct 06 2015 19:16
hmmm....let me code it real quick and let you exam it. I didn't start it yet.
Rex Schrader
@SaintPeter
Oct 06 2015 19:16
@namsir What condition is true when you are at the location where the number will go? There is only one test you need to make.
Charlotte
@Charzoe
Oct 06 2015 19:18
function truncate(str, num) {
  // Clear out that junk in your trunk
  wordsNum = str.search(/\s/g);
  if(wordsNum > num){
    str.slice(0-num);
    return str+"...";
  } else {
    return str;
  }  
}
truncate("A-tisket a-tasket A green and yellow basket", 11, "");
For some reason my regex is returning 8 here, and I can't see why?
noobstar
@namsir
Oct 06 2015 19:18
[10, 20, 30, 40, 50], 35 should return 3 and [10, 20, 30, 40, 50], 30) should return 2
Rex Schrader
@SaintPeter
Oct 06 2015 19:19
@namsir Correct.
noobstar
@namsir
Oct 06 2015 19:19
there right there are 2 conditions am i correct?
plus [40, 60,], 50 should return 1
Rex Schrader
@SaintPeter
Oct 06 2015 19:20
@Charzoe Not sure I understand what the regex is for? You're supposed to be looking at the length of the string. use str.length
@namsir Yeeees . .. but the point is not to hard-code the answer. The point is to solve it in the general case. You're going to have variables, not actual numbers.
Charlotte
@Charzoe
Oct 06 2015 19:21
But isn't the counter for how many words long it should be?
Rex Schrader
@SaintPeter
Oct 06 2015 19:21
@namsir If you are looping through the array, examining the numbers one at a time, when do you know it's good to stop.
@Charzoe Go re-read the instructions.
Jason
@Jauble
Oct 06 2015 19:21
@SaintPeter For my Random Quote Generator I put my quotes into variables and then put those into an array (it seemed odd to put long quotes into an array). Someone mentioned that I should just put them directly into the array. It would be a little easier that way. They also mentioned that the browser would have to search for the variables, which I'm not sure is the case, since they're stored in memory. Is that the way to go? This is how I have it now: http://codepen.io/auble220/pen/GpmjGx
Charlotte
@Charzoe
Oct 06 2015 19:21
It really seems to imply it's words....
"A-tisket a-tasket A green and yellow basket", 1 should return "A-tisket...".');"A-tisket a-tasket A green and yellow basket", 1 should return "A-tisket...".
Rex Schrader
@SaintPeter
Oct 06 2015 19:23
@Jauble I concur with whomever said that you should just put the quotes in the array. It is kinda double work for the computer to put it into a string, then put the string into an array.
@Charzoe ok, let me re-check my sanity
@Charzoe "Truncate a string (first argument) if it is longer than the given maximum string length (second argument). "
Jason
@Jauble
Oct 06 2015 19:25
@SaintPeter Thanks!
CamperBot
@camperbot
Oct 06 2015 19:25
jauble sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 876 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Oct 06 2015 19:25
@Charzoe A string is characters/letters/spaces - not words.

@Jauble Note that you can put each array element on its own line, or add them one a a time:

var myQuotes = [];
myQuotes[0] = "Here is the first quote";
myQuotes[1] = "Here is the second";

or

var myQuotes = [ 
   "First Quotes!",
   "Second Quotes
];
Jason
@Jauble
Oct 06 2015 19:30
@SaintPeter Didn't think about that. Thanks
CamperBot
@camperbot
Oct 06 2015 19:30
jauble sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave saintpeter points
h4r1m4u
@h4r1m4u
Oct 06 2015 19:30
@Jauble i would suggest to store the quotes as objects in an array. each quote will have text and author as property. that will allow you to style the quote text and author differently on the page (if needed). so something like:
var myQuotes = [
  {'text': 'The quote text goes here.', 'author': 'Author 1'},
  {'text': 'Another quote text goes here.', 'author': 'Author 2'},
  {'text': 'Yet another quote.', 'author': 'Author 3'}
]
Charlotte
@Charzoe
Oct 06 2015 19:30
Then something like this should work, right? This was the first set-up I tried:
function truncate(str, num) {
  // Clear out that junk in your trunk
   if(str.length > num){
    str.slice(0-num);
    return str+"...";
  } else {
    return str;
  }  
}
truncate("A-tisket a-tasket A green and yellow basket", 11, "");
But str.slice doesn't seem to be doing its job
Rex Schrader
@SaintPeter
Oct 06 2015 19:31
@Charzoe You are so very close. In Javascript, Strings are immutable, meaning they can't be changed once created. All string related funcitons return a NEW string. If you want to change str you must set it equal to the new value.
Jason
@Jauble
Oct 06 2015 19:31
@h4r1m4u Interesting. Thanks