These are chat archives for FreeCodeCamp/Help

14th
Aug 2015
Cristián Berríos
@crisberrios
Aug 14 2015 00:00
I'm not sure about the regex
but the capture groups between parenthesis
if you want to use them
then on the 2nd argument you have to call them using $1, $2 etc
so right now you're replacing whatever matches with a dash
instead of doing A-B
Samuel Hunter
@MathManiac0
Aug 14 2015 00:02
What's lurk mode?
Victoria G.
@GzkV
Aug 14 2015 00:02
tried that too
 str=str.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
Jorge Almeida
@Jorgixhallo
Aug 14 2015 00:02
explain rtfm
CamperBot
@camperbot
Aug 14 2015 00:02

:point_right: rtfm [wiki]

RTFM is an initialism for the expression "Read The F**king Manual"

RTFM Comic

:pencil: read more about rtfm on the FCC Wiki

SojournerOctocat
@SojournerOctocat
Aug 14 2015 00:03
str = str.replace(/([a-z])([A-Z])/g, '$1-$2');
@GzkV … ^
Victoria G.
@GzkV
Aug 14 2015 00:06

Okay. For reference, my code looks like this now :

function spinalCase(str) {
 str = str.replace(/\s/g, "-").toLowerCase(); //Spaces
  str = str.replace(/_/g, "-").toLowerCase();//underscores
 str= str.replace(/([a-z])([A-Z])/g, '$1-$2');
  return str;
}

And the camelcase check won't pass, and I am deeply confused.

it just spits out the "this is spinal tap" lowercase, no spaces
Cristián Berríos
@crisberrios
Aug 14 2015 00:07
ok... you use toLowerCase on the 1st 2
so aB becomes ab
then it never gets separated
Victoria G.
@GzkV
Aug 14 2015 00:08
!
SojournerOctocat
@SojournerOctocat
Aug 14 2015 00:08
@GzkV I used if statements for the different tests.
If the string contained spaces, I used one regex; if the string contained underscores, a different regex.
Victoria G.
@GzkV
Aug 14 2015 00:10
yes. -that- makes sense. I should have realised it was running it through those first.
Thank you all so much for your help.
hakosl
@hakosl
Aug 14 2015 00:10
I'm stuck on bonfire: sum all odd fibonacci numbers, all test cases pass except for the last one.
'''
CamperBot
@camperbot
Aug 14 2015 00:10
:bulb: to format code use backticks! ``` more info
hakosl
@hakosl
Aug 14 2015 00:11
my code:
function sumFibs(num) {
  fibonacciNumbers = [1, 1];
  while(fibonacciNumbers.slice(-2).reduce(function(previousValue, currentValue){
      return previousValue + currentValue;                                                  
    }) < num){

    fibonacciNumbers.push(fibonacciNumbers.slice(-2).reduce(function(previousValue, currentValue){
      return previousValue + currentValue;                                                  
    }));
  }
  console.log(fibonacciNumbers);
  return fibonacciNumbers.filter(function(element){
    return element % 2 !== 0 || element === 1;  
  }).reduce( function(previousValue, currentValue){
    return previousValue + currentValue;        
  });
}

sumFibs(75025);
Alex Litel
@alexlitel
Aug 14 2015 00:13

I am on the bonfire for Finders Keepers and I am finding myself stuck.

function find(arr, func) {
var num =0;
  arr.some(function(num){ if (num % 2 === 0) {
    console.log(num);
    return num; } });  

//  return num;
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; });

is not working

hakosl
@hakosl
Aug 14 2015 00:14
seems like a bug to me since all the other text cases expect me to not to count the fibonacci number if it is larger than num
but the last test case expects me to. the last test case passes if i do:
function sumFibs(num) {
  fibonacciNumbers = [1, 1];
  while(fibonacciNumbers.slice(-1).reduce(function(previousValue, currentValue){
      return previousValue + currentValue;                                                  
    }) < num){

    fibonacciNumbers.push(fibonacciNumbers.slice(-2).reduce(function(previousValue, currentValue){
      return previousValue + currentValue;                                                  
    }));
  }
  console.log(fibonacciNumbers);
  return fibonacciNumbers.filter(function(element){
    return element % 2 !== 0 || element === 1;  
  }).reduce( function(previousValue, currentValue){
    return previousValue + currentValue;        
  });
}

sumFibs(75025);
Catherine Kleimeier
@cakleimeier
Aug 14 2015 00:15
Hi all, I'm on Convert HTML Entities and am having some problems. My code works for about half the cases, and I'm not sure what the problem is. Could you help? Here's my code:
<function convert(str) {

  str= str.replace(/&/, '&amp;').replace(/</, '&lt;').replace(/>/, '&gt;').replace(/""/, '&#34;');

  return str;
}

convert('Dolce & Gabbana');>
hakosl
@hakosl
Aug 14 2015 00:16
Is your problem with the cases with < @cakleimeier ?
Alex Litel
@alexlitel
Aug 14 2015 00:17
@cakleimeier You need to replace the other characters with the HTML values, which are in the link.
Catherine Kleimeier
@cakleimeier
Aug 14 2015 00:17
Yeah, it is. Also, sorry about the paste format error. I haven't posted much yet.
Jose M Viloria
@josevill
Aug 14 2015 00:17
Hi there, i'm having some issues with the Largest of Four Bonfire, can someone give me a hand?
hakosl
@hakosl
Aug 14 2015 00:19
try the other html values i was stuck on that for a while to
Catherine Kleimeier
@cakleimeier
Aug 14 2015 00:19
@hakosl Ok, I'll try that. Thanks. :)
Jose M Viloria
@josevill
Aug 14 2015 00:19
function largestOfFour(arr) {
  /* Must return array with 4 values in it, each value will be the highest inside every sub-array.*/
  var highest = [];
  for (i = 0; i < 4; i++) {
    for(j = 0; j < 4; j++){
      if (arr[i][j] > highest[i])
      { highest.push(arr[i][j]); }
    }
  }
  // Returns highest values array.
  return highest;
}
This is what i have, i feel like my error is in that If statement. The comparison is wrong, i think.
S
@svahora
Aug 14 2015 00:20
anyone have advice on where I can get explanations for the solutions on jhusain's tutorial of functional programming?
hakosl
@hakosl
Aug 14 2015 00:20
i can't really remember what i did to fix it, try pasting the characters in the test cases
S
@svahora
Aug 14 2015 00:23
I dont understand his solution for #4
Catherine Kleimeier
@cakleimeier
Aug 14 2015 00:25
@hakosl So, I'm on the right track with my solution, but there's something funny about the HTML codes for the characters that this will accept?
Derek Frankel
@TuvyaYis
Aug 14 2015 00:26
hi,,, why will the following code crash...
var myCondition = true;
var soloLoop = function(){
  while(myCondition);
  console.log("Looped once!");
  myCondition = false;  
};

soloLoop();
hakosl
@hakosl
Aug 14 2015 00:27
try copypasting the characters in the test examples into your code @cakleimeier
Catherine Kleimeier
@cakleimeier
Aug 14 2015 00:29
Ok, I'll try it.
Kolloom
@Kolloom
Aug 14 2015 00:56
@TuvyaYis you didn't enclose the change of myCondition inside the while loop
S
@svahora
Aug 14 2015 00:57
@TuvyaYis you forgot the first {
Kolloom
@Kolloom
Aug 14 2015 00:57
do this
while(condition) {
    //statement 
}
S
@svahora
Aug 14 2015 01:07
Can someone please help me with the "JHusain Functional Programming" tutorial? ... I can't understand his solution for Ex. 4? My solution worked, but his solution makes no sense to me.
Derek Frankel
@TuvyaYis
Aug 14 2015 01:09
@Kolloom @svahora TY
Matt Everson
@matteverson
Aug 14 2015 01:48
What's his solution say?
Nevermind, that was an old message
Craig McKenna
@craigdmckenna
Aug 14 2015 01:54
Does anyone know of a resource that can help me with the bonfire: Where art thou?
I have read through the recommended MDN resources and I'm stuck.
Thanks!
CamperBot
@camperbot
Aug 14 2015 01:54
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
lutovinov
@lutovinov
Aug 14 2015 01:56
find js
Donavin Northrup
@dnorthrupva
Aug 14 2015 02:05
function repeat(str, num) {
if (num < 0){
return "";
}
else{
return str.repeat(num);
}
}

repeat('abc', 3);
Isn't working, and I can't see why. Any input?
Craig McKenna
@craigdmckenna
Aug 14 2015 02:08
@dnorthrupva, is this a bonfire?
Donavin Northrup
@dnorthrupva
Aug 14 2015 02:10
It is, yea.
Trying to help someone, and I don't see anything wrong with her code, but it's telling her 'undefined is not a function'. I'm not sure what the system might be trying to pull in the background.
Craig McKenna
@craigdmckenna
Aug 14 2015 02:17
You shouldn't call the function inside itself like that.
How about a loop that runs the same number of times as the num parameter?
Matt Everson
@matteverson
Aug 14 2015 02:22
You can call a function within itself, but for this purpose you'd be decrementing num every time you did it (--num), and repeat isn't added to the String prototype so you can't call it as str.repeat(). You'd use repeat(str, num), then change the function to do the actual concatenation.
Craig McKenna
@craigdmckenna
Aug 14 2015 02:27
@matteverson Cool!
Rafael J. Rodriguez
@Rafase282
Aug 14 2015 02:32
well, anyone else working on the practice functional programming waypoint?
RC Maples
@rcmaples
Aug 14 2015 02:33
Hey, anyone available to look over my code on Arguments Optional bonfire? Can pair if it’ll help.
Rex Schrader
@SaintPeter
Aug 14 2015 02:52
@rcmaples I can take a look if you'd like
(somewhat belatedly)
RC Maples
@rcmaples
Aug 14 2015 02:52
Sweet!
Rex Schrader
@SaintPeter
Aug 14 2015 02:53
You know how to post code?
RC Maples
@rcmaples
Aug 14 2015 02:53
function check(cArg){
    if (typeof cArg === 'number'){
        return true;
    } 
}

function add(arg1,arg2){
    var sum = 0;

    if(!check(arg1) || !check(arg2)){
        //console.log('undefined');
        return undefined;
    } else if (check(arg1) && check(arg2)){
        sum = (arg1+arg2);
        //console.log(sum);
    } else {
        if (arguments.length<1){
            if(!check(arg1)){
                return undefined;
            } else{
                sum = arg1+arg1;
            }
    }

    }
    return sum;
}

add(2,3); //5
console.log(add((2),(3))); //works here, but not on FCC
add('string'); //undefined
add(2,'3'); //undefined
add(2)([3]); //ERR TypeError: undefined is not a function
Rex Schrader
@SaintPeter
Aug 14 2015 02:54
@rcmaples You're almost there, but you're missing an element of the problem. You need to return a function, not a sum.
For the last case
Christopher Stewart
@cjstewart13
Aug 14 2015 02:54
Hey I'm having trouble with palindromes. Here's what I've got.
function palindrome(str) {
  // Good luck!
  str.toLowerCase();

  function reverseString(str) {
     var newString = str.split('');
     newString.reverse();
     var newerString = newString.join('');


      return newerString;
  }

  var reversedString = reverseString;

  if (reversedString === str){ 

    return true;

  } else {

    return false;

  }

}



palindrome("eye");
Rex Schrader
@SaintPeter
Aug 14 2015 02:55

@rcmaples Where you're saying:

 } else{
                sum = arg1+arg1;
            }

You instead need to return a function which takes a single argument and adds arg1 to it.

RC Maples
@rcmaples
Aug 14 2015 02:55
@SaintPeter so instead of sum = arg1+arg1 on the last one, return add(arg1,arg1)?
Rex Schrader
@SaintPeter
Aug 14 2015 02:56
@cjstewart13 Yeah, you need to remove non-alphabetic characters from your string, including spaces, commas, etc.
RC Maples
@rcmaples
Aug 14 2015 02:56
@SaintPeter Oooh! Got what you’re saying now.
Rex Schrader
@SaintPeter
Aug 14 2015 02:57
@rcmaples Nope - you can't return add, because it's not defined. You need to actually return a function. Like this:
return function(myVariable) {  /* do some stuff here to return the sum */ };
Christopher Stewart
@cjstewart13
Aug 14 2015 02:57
@SaintPeter I haven't even gotten to that point. I was just running to see if I could get to detect something. Its just returning as undefined
Rex Schrader
@SaintPeter
Aug 14 2015 02:58
@cjstewart13 Do me a favor - hover over on your code above, click the "edit" button, and put ``` on a line of it's own at the top and at the bottom.
@cjstewart13 You can do shift-enter to get an new line
Christopher Stewart
@cjstewart13
Aug 14 2015 02:59
done
Rex Schrader
@SaintPeter
Aug 14 2015 03:00

@cjstewart13 Perfect.
Ok, the problem is here:

var reversedString = reverseString;

You're not actually CALLING your function reverseString - you need to call it and pass in your string, like this:

var reversedString = reverseString(str);
@cjstewart13 What you're actually saying currently is "reversedString is equal to the function reverseStrign"
Christopher Stewart
@cjstewart13
Aug 14 2015 03:03
@SaintPeter Thanks! now i tested to see if my lowercase method worked and it hasn't. i capitalized an e in eye and it returned false
Rex Schrader
@SaintPeter
Aug 14 2015 03:04
@cjstewart13 Ah - that's because strings in Javascript are immutable. .toLowerCase RETURNS a string, it doesn't transform a string it's called on. You need to assign the value it returned to a new variable (or the same variable)
wiki immutable
CamperBot
@camperbot
Aug 14 2015 03:04

:point_right: js immutable [wiki]

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

Christopher Stewart
@cjstewart13
Aug 14 2015 03:05
@SaintPeter Now I see that in the documentation...... why can't the documentation ever be clear
Rex Schrader
@SaintPeter
Aug 14 2015 03:06
@cjstewart13 Why can't all our vision be hindsight? ;)
Christopher Stewart
@cjstewart13
Aug 14 2015 03:07
@SaintPeter Thats more accurate. Now I have to get rid of the spaces. I know I need to use string.replace(), but I'm having a hard time grasping how to implement it
RC Maples
@rcmaples
Aug 14 2015 03:07
Thanks for the help @SaintPeter :+1:
CamperBot
@camperbot
Aug 14 2015 03:07
rcmaples sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
hey @rcmaples if you found this info helpful :point_right: consider adding a wiki article!
:star: 18 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Aug 14 2015 03:08

@cjstewart13 Well, there are two ways you can do it: With a string literal, ie:

var myStr = str.replace(' ', '');

Or with a regular expression, like this:

var myStr = str.replace(/\s/g,'');
The regular expression is going to be WAY more flexible. You can write one to capture anything you want to remove.
Christopher Stewart
@cjstewart13
Aug 14 2015 03:10
@SaintPeter That is so much clearer. I have to be honest. I skipped some of the regular expressions. I had a hard time understanding them. Probably going to find a book/person who will sit down and teach me to learn those regex's better.
Rex Schrader
@SaintPeter
Aug 14 2015 03:11
@cjstewart13 If you want to start up on them again, I may be able to provide guidance. Like your vegtables, you need to learn RegExp because they're "good for you"
Chris
@Bloodmail
Aug 14 2015 03:11
I need help with Largest number bonfire. Who can pair with me?
CamperBot
@camperbot
Aug 14 2015 03:11
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Rex Schrader
@SaintPeter
Aug 14 2015 03:12
@cjstewart13 Seriosuly, though, once you GET them, you'll be like OMFG, these are AWESOME . . . up until that moment, though, you'll be like "These are useless and hard."
@Bloodmail I've got ~20 mins if you want
Christopher Stewart
@cjstewart13
Aug 14 2015 03:13

@SaintPeter LOL thanks! And one last thing before I go and try and fiddle some. Can I put multiple items in the replace area?

eg) (" ", " , " "?"), "")

Rex Schrader
@SaintPeter
Aug 14 2015 03:14
@cjstewart13 Nope, but you can chain them and you can do a regexp like /[ ,?]/
Christopher Stewart
@cjstewart13
Aug 14 2015 03:15
@SaintPeter Thank you so much for your help!
Daniel Chavez
@redpandapirate
Aug 14 2015 03:38
/lark
Feners4
@Feners4
Aug 14 2015 03:42
help with displaying a search icon in http://codepen.io/Feners4/pen/ZGZORX
CamperBot
@camperbot
Aug 14 2015 03:42
no wiki entry for: with displaying a search icon in httpcodepeniofeners4penzgzorx
:pencil: click here to create one now!after creating your page type update to reload it here
S. Solomon
@SHSolomon
Aug 14 2015 03:43
IS there a way to check that we are coding in the best possible way??? I am getting my code to work, but I am concerned that my code is not always as concise as it should be. For example: for the Spinal Tap bonfire I had six different statements that manipulated the string. I'm sure there is a better way to do it.
Matt Everson
@matteverson
Aug 14 2015 03:45
@SHSolomon To a degree, yes. You can ask people to share their solutions, or check profile pages yourself (until the next update anyway)
@Feners4 There might be one in fontawesome, but I see there's one for sure in this CSS font: http://cdnjs.com/libraries/foundicons
Feners4
@Feners4
Aug 14 2015 03:50
@matteverson how can I use this?
or how can I apply it to my app?
Matt Everson
@matteverson
Aug 14 2015 03:51
Add it like you would add fontawesome. Check out the early waypoints, there was one on using that.
Christian Gill
@gillchristian
Aug 14 2015 03:53
Guys anybody can share a Screen Hero account? Invitation are needed now :(
Matt Everson
@matteverson
Aug 14 2015 03:53
@gillchristian You can sign up without an invite through the downloaded app
Christian Gill
@gillchristian
Aug 14 2015 03:54
Where can I down load it?
Matt Everson
@matteverson
Aug 14 2015 03:54
Just download from the link in the waypoint, sign up, and you should be golden.
Christian Gill
@gillchristian
Aug 14 2015 03:55
ohh ok
thanks
SojournerOctocat
@SojournerOctocat
Aug 14 2015 04:01
@gillchristian If you need an invite, PM me your email address and I'll send you one.
Chocobowings
@chocobowings
Aug 14 2015 04:09
Hi guys, I am working on bonfire Friendly Date Ranges. Should i be doing anything fancy or just a few if,else statements is fine ?. I am a bit confuse...
Matt Everson
@matteverson
Aug 14 2015 04:09
@chocobowings There's quite a few special cases, some if statements will be necessary.
Chocobowings
@chocobowings
Aug 14 2015 04:12
@matteverson Thanks. It is just that the way I am approaching it I feel like it just looks messy. Can you check my code ?
SojournerOctocat
@SojournerOctocat
Aug 14 2015 04:12
function steamroller(arr) {
  return arr.reduce(function (flat, toFlatten) {
      console.log(flat.concat(Array.isArray(toFlatten) ? steamroller (toFlatten) : toFlatten));
    return flat.concat(Array.isArray(toFlatten) ? steamroller (toFlatten) : toFlatten);
  }, []);
}

steamroller([1, [2], [3, [[4]]]]);
shows
[ 1 ]
[ 2 ]
[ 1, 2 ]
[ 2 ]
[ 3 ]
[ 4 ]
[ 4 ]
[ 4 ]
[ 3, 4 ]
[ 4 ]
[ 4 ]
[ 4 ]
[ 1, 2, 3, 4 ]
[ 3 ]
[ 4 ]
[ 4 ]
[ 4 ]
[ 3, 4 ]
[ 4 ]
[ 4 ]
[ 4 ]
=> [ 1, 2, 3, 4 ]
Matt Everson
@matteverson
Aug 14 2015 04:12
@chocobowings Sure, PM it to me
SojournerOctocat
@SojournerOctocat
Aug 14 2015 04:13
Why is it going through the array elements so many times?
Adam Teece
@adamteece
Aug 14 2015 04:16
Having some trouble with Intro to Objects II lesson 5
var james = {
    job: "programmer",
    married: false
};

// set to the first property name of "james"
var aProperty = "job";

// print the value of the first property of "james" 
// using the variable "aProperty"
console.log(james[aProperty]);
What am I doing wrong?
Rex Schrader
@SaintPeter
Aug 14 2015 04:25
@adamteece Humm, that looks right. What error do you get?
Matt Everson
@matteverson
Aug 14 2015 04:25
@SojournerOctocat Due to the recursion we're seeing the output of the "final" flattening of an array twice.
Alex Litel
@alexlitel
Aug 14 2015 04:28
On the arguments optional bonfire and not sure what I'm doing wrong.
function add() {


  if (typeof arguments[0] === "number" && typeof arguments[1] === "number" ) {
    var q = arguments[0];
    var r = arguments[1];

    var sum = q + r;
    return sum;
  } else {
    return undefined;
  } 
}
  //for (var i; i<arguments.length; i++) {
  //sum += arguments;
  //}


add(2,3);
Three tests pass but I am getting expect(add(2)(3)).to.equal(5);add(...) is not a function and expect(add(2)(3)).to.be.undefined;add(...) is not a function
S
@svahora
Aug 14 2015 04:30
yes, the "add(2)(3)" is a doozy... its not the same as "add(2,3)"
@alexlitel if you are following the FCC map, I'm not sure if you've come across a situation where you would have learned what you have to do in this problem
@alexlitel you will have to check the arguments.length value and then return another function with 1 parameter which will be the 3 in the "add(2)(3)" case.
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:33
function mutation(arr) {
 var arr1 = arr[0].toLowerCase();
 var arr2 = arr[1].toLowerCase();
 if (arr1.length<arr2.length) {
   return false;
 }
 arr2=arr2.split('');
 console.log(arr2.length);
 for (var i=0; i<arr2.length;i++) {
   if (arr1.indexOf(arr2[i])===-1) {
     return false;
   }
 }
 return true;
}

mutation(['Hello', 'hey']);
Anyone know why this is failing Mary == Army?
It shouldn’t be.
Chocobowings
@chocobowings
Aug 14 2015 04:35
@dnorthrupva In this case Army is Aarmy that's why
@dnorthrupva You are not matching all the characters in the second argument
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:37
Yea, I see now.
If it was Aarmy, Mary it’d be true.
But my code won’t work reverse.
Matt Huijsse
@mistamadd001
Aug 14 2015 04:37
anyone here play screeps?
Chocobowings
@chocobowings
Aug 14 2015 04:37
@dnorthrupva Right
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:38
Time to re-evaluate it before I un-DRY myself.
Alex Litel
@alexlitel
Aug 14 2015 04:38
@svahora I'm still kind of lost. What should the function be doing?
@svahora Would the else if be "else if (arguments.length === 2)"?
S
@svahora
Aug 14 2015 04:39
no, you'd want to check if there was only 1
because it is invoking add(2) first
since theres only 1 argument you want to invoke another function for (3)
... i think, thats how I did it, want to see my code with comments?
Alex Litel
@alexlitel
Aug 14 2015 04:41
Yes.
Alex Litel
@alexlitel
Aug 14 2015 04:42
@svahora Thanks
S
@svahora
Aug 14 2015 04:42
@alexlitel np
let me know if it doesnt make sense
Adam Teece
@adamteece
Aug 14 2015 04:43
@SaintPeter It was saying I wasn’t outputting the correct value to the console. I refreshed the page and it worked.
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:49
I’m struggling to understand the expressions array.filter() wants - Can someone give me an example?
Alex Litel
@alexlitel
Aug 14 2015 04:50
@svahora I'm a little confused as to how you are getting the number of the second value/the num value. Isn't arguments[0] whatever is in the first parentheses?
S
@svahora
Aug 14 2015 04:51
num = 2 in this case
and then x = 3
if (arguments.length === 1) {
return function(x)...
SojournerOctocat
@SojournerOctocat
Aug 14 2015 04:52
@dnorthrupva I have trouble understanding that too. This is how i used it in one of hte bonfires:
function bouncer(arr) {
   return arr.filter(function(elem){
        return elem;
   });
}
bouncer([7, 'ate', '', false, 9]);
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:53
Hmmm…. That code confuses me, a bit.
S
@svahora
Aug 14 2015 04:53
@dnorthrupva which problem are you on?
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:53
I’m no the Bonfire: Bouncer. The one he linked he result for.
on*^
I was thinking just return bouncer.filter(false), but I feel like that isn’t a true expression?
S
@svahora
Aug 14 2015 04:54
i did not use filter in that one
sometimes, the suggestions in the more info section aren't always the best... at least for me
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:54
Yea, I didn’t think so either. I’d just neber used .filter so I thought “Maybe I should."
S
@svahora
Aug 14 2015 04:55
don't worry, you'll get a chance to learn it later
just try solving these bonfires best you can
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:56
I originally passed it just by assigning it to a boolean specifically based on a .splice of the array.
S
@svahora
Aug 14 2015 04:56
@dnorthrupva in Algorithm Scripting and in functional programming you'll be using filter
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:56
But the filter threw me off, haha
S
@svahora
Aug 14 2015 04:56
yah i used splice as well
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:56
@svahora Ahhh, so the later stuff. Algorithm, ugh.
S
@svahora
Aug 14 2015 04:57
yah, but it gets better... you'll finally see practicality
i just started functional programming... and its been what i've been waiting for
parsing through JSON data
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:57
That’s good. JS is def where I struggle. Ruby, Python, jQ I could see very quickly “Oh, I can’t wait to do X with this.” but JS I’m just like “Well, I mean… It’ll help me learn Angular, Node, and Meteor more in depth… maybe…"
S
@svahora
Aug 14 2015 04:58
did you use any noSQL DBs yet
have you used*
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:58
Nuh-uh.
S
@svahora
Aug 14 2015 04:58
oh okay... well functional programming will show you how to parse through JSON
Donavin Northrup
@dnorthrupva
Aug 14 2015 04:59
That’s good, I’m not even overly familiar with JSON. I just see that term all over my networking team, and a lot of job postings we put out.
S
@svahora
Aug 14 2015 04:59
and noSQL looks a lot like json, at least MongoDB does
its just objects really
objects within objects within objects...
and arrays
Donavin Northrup
@dnorthrupva
Aug 14 2015 05:01
Niiice. I’ll have to dredge through these bonfires. Sometimes my code works, I have no idea why; So I then spend time reverse engineering it to figure it out.
Had a couple “Ah ha!” moments.
Not many.
Luis Felipe López G.
@luishendrix92
Aug 14 2015 05:02
@dnorthrupva Tell it to the duck, the all mighty god.
Duck Debugging
S
@svahora
Aug 14 2015 05:02
whats great about the bonfires is they all get saved... so you can look back on your code to reference a similar problem you may have had
Goodnight!
Robert
@rc242
Aug 14 2015 05:10
any quick questions before I go crash?
been afk doing working on a zipline and other projects, so I've been a bit quiet.
Adam
@pcguy730
Aug 14 2015 06:10
Hi - I'm on waypoint style text inputs as form controls I believe I did everything it asked of me correctly but it's not turning green but the i element closing tag one. Can someone look at my code?
@Lin-H
Aug 14 2015 06:12
@pcguy730 paste the code here
Adam
@pcguy730
Aug 14 2015 06:13
<input class='form-control' placeholder='cat photo URL' required>
<button class='btn btn-primary'><i class='fa fa-paper-plane'>Submit</i></button>
@Lin-H
Aug 14 2015 06:15
try
<button class='btn btn-primary'><i class='fa fa-paper-plane'></i>Submit</button>
just put the Submit out of the i tag
Adam
@pcguy730
Aug 14 2015 06:19
No difference
@Lin-H
Aug 14 2015 06:19
and
<input class='form-control' type='text' placeholder='cat photo URL' required>
Adam
@pcguy730
Aug 14 2015 06:20
Ok, putting the type back in worked for that. The button is still red.
Got it, put the type back for button as well. All green now. Thanks for the help.
@Lin-H
Aug 14 2015 06:21
you are welcome :smile:
Teejay Parker
@TeejayParker
Aug 14 2015 08:15
http://redd.it/3gy75m <-- for those that might know this stuff...
vaidap
@vaidap
Aug 14 2015 08:16
Hey guys! Going to continue bonfires for a bit. I'm at 16 (Where art thou) :)
Abhisek Pattnaik
@abhisekp
Aug 14 2015 08:39
@vaidap beware! Read the instructions carefully
@vaidap have you solved the Where art thou bonfire?
Matthew Barber
@Honno
Aug 14 2015 08:45
Hey, someone mind checking something out for me? Weird problem with my quote generator
http://codepen.io/Honno/pen/WvWXVp/ Sometimes a new quote isn't displayed, and the debugger proves that the interpreter isn't going to the bit where it should
waiiit
I've confused myself now haha
vaidap
@vaidap
Aug 14 2015 08:49
@abhisekp still working on it! objects :(
Shane
@KHam0425
Aug 14 2015 08:51
Any way to suppress notifications on mobile? It's 4am, and my phone is blowing up from gitter :(
Pass the property to has own property
And use getprooertynames...then just match the value of the property
vaidap
@vaidap
Aug 14 2015 08:54
just realised that i could use hasownproperty!
for some reason i reaaally wanted to use arrays?
thanks! trying to fix it now
Shane
@KHam0425
Aug 14 2015 08:55
You'll still need to iterate the array to match the key value pair, I think
Aleksandar B.
@aleksandar-b
Aug 14 2015 08:56

I don't know what is the task in Bonfire Inventory Updates. CaN someone explain me what this means

"Compare and update inventory stored in a 2d array against a second 2d array of a fresh delivery. Update current inventory item quantity, and if an item cannot be found, add the new item and quantity into the inventory array in alphabetical order.
"

Shane
@KHam0425
Aug 14 2015 08:56
Or, you have to use it recursively. I forget what I did the other day
@samosale first number is quantity on hand, item is item
Aleksandar B.
@aleksandar-b
Aug 14 2015 09:04
@thief425 What this sentence means: "Compare and update inventory stored in a 2d array against a second 2d array of a fresh delivery"
Shane
@KHam0425
Aug 14 2015 09:05
2nd array is a new shipment. If arr20 == arr10 { arr3[0][0] = arr2[0][0] + arr1[0][0]; arr30 = arr10;} else {arr3.push arr2[0];}
Except you should be using i and j instead of 0 and 1, and you should use nested for loops.
Aleksandar B.
@aleksandar-b
Aug 14 2015 09:10
@thief425 I thought I should first convert them to object...
Shane
@KHam0425
Aug 14 2015 09:10
Start with known inventory,arr1, for the items in arr1, aka arri, for items in new shipment, arr2, aka arr[0][j], what matches the old inventory in the new delivery? If it's something you already have in stock, add the quantity of items in the delivery to the quantity already on hand.
They're already objects
Aleksandar B.
@aleksandar-b
Aug 14 2015 09:11
Can you help me here : https://coderpad.io/R7P4N9H6
Shane
@KHam0425
Aug 14 2015 09:12
You
Krishaan Khubchand
@KrishaanKhubchand
Aug 14 2015 09:30
```
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .smaller-image {
    width: 100px;
  }
  .thick-green-border {
    border-color: green; 
    border-width: 10px;
    border-style: solid;
  }
</style>

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

<img class='smaller-image' 'thick-green-border'
     src='https://bit.ly/fcc-kittens'/>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
anybody know what's wrong?
Your img element should have the class "thick-green-border".
Give your image a border width of 10px.
it says i'm missing that
Abhisek Pattnaik
@abhisekp
Aug 14 2015 09:50
@thief425 I've a question for you.
@thief425 Why did you loot them mischievously? :japanese_ogre: :stuck_out_tongue_winking_eye:
Marie Pelletier
@Marie000
Aug 14 2015 10:30
Good morning! Anybody here? I'm working on Sum All Primes and I cannot figure out why my code does not work. Right now I am just trying to create an array with prime numbers. I will worry about the sum later.
 function sumPrimes(num) {
  var arr = [];
  var result = false;
  function testprime(x){  
  for (i=2; i<num; i++){
     if (x%i===0){
       result = false;
       break;
     } 
    else {
       result = true;
    }    
  }

 for (y=2; y<num; y++) {
   testprime(y);
   if (result === true) {
     arr.push(y);
   }
 }
  }

  return arr;
}

sumPrimes(10);
justinunderhill
@justinunderhill
Aug 14 2015 10:35
@Marie000 , how did you copy that line of code into the chat, I'm struggling to do the same
Marie Pelletier
@Marie000
Aug 14 2015 10:36
@justinunderhill you need to click on the little chat icon on the right of what you are writing, it will turn into a keyboard. then put " " (without the quotes), change line, copy your code and put "" again.
then click on the keyboard icon to return to chat and press enter to submit.
@KrishaanKhubchand when you have multiple classes on an html element, they should all be inside the same quotation marks. for example: <p class="class1 class2">
justinunderhill
@justinunderhill
Aug 14 2015 10:43

"function reverseString(str) {
return str;
}

reverseString('hello');
"

Marie Pelletier
@Marie000
Aug 14 2015 10:43
@justinunderhill oops. I didn't notice my instructions did not work well. You need [```] to quote (let's see if that works)
put that at the beginning and the end of your quote, without the square brackets.
sorry, they disappeared when I put them in quotation marks.
justinunderhill
@justinunderhill
Aug 14 2015 10:45

[function reverseString(str) {
return str;
}

reverseString('hello');
]

I'm sorry @Marie000 , I'm not getting it
Marie Pelletier
@Marie000
Aug 14 2015 10:46
on my last message, do you see something inside the square brackets^
?
Ming Kim
@mingkim
Aug 14 2015 10:46
@Marie000 Try this one!
function testprime(x){  
  for (i=2; i<num; i++){
     if (x%i===0){
       return false;
       break;
     } 
    else {
       return true;
    }    
  }
}

 function sumPrimes(num) {
  var arr = [];
  for (y=2; y<num; y++) {
    if (testprime(y); === true) {
     arr.push(y);
    }
  }
  return arr;
}

sumPrimes(10);
justinunderhill
@justinunderhill
Aug 14 2015 10:47
@Marie000 , yeah those '''
CamperBot
@camperbot
Aug 14 2015 10:47
:bulb: to format code use backticks! ``` more info
Marie Pelletier
@Marie000
Aug 14 2015 10:48
they're not single quotes... they are more angled back. You should have then at the left of 1 on your keyboard.
justinunderhill
@justinunderhill
Aug 14 2015 10:48
```
Ming Kim
@mingkim
Aug 14 2015 10:48
yes
Marie Pelletier
@Marie000
Aug 14 2015 10:49
@justinunderhill that's it. put three before your quote and three after.
justinunderhill
@justinunderhill
Aug 14 2015 10:49

```function reverseString(str) {
return str;
}

reverseString('hello');
```

I'm a dum dum, I still don't get it, how do we copy the code from the Bonfire?
Ming Kim
@mingkim
Aug 14 2015 10:50
@Marie000 I'm sorry this is right.
 function testprime(x, num){  
  for (var i=2; i<num; i++){
     if (x%i===0){
       return false;
       break;
     } 
    else {
       return true;
    }    
  }
}

 function sumPrimes(num) {
  var arr = [];
  for (y=2; y<num; y++) {
    if (testprime(y, num); === true) {
     arr.push(y);
    }
  }
  return arr;
}

sumPrimes(10);
@justinunderhill You should start new line after ```.
justinunderhill
@justinunderhill
Aug 14 2015 10:51
oh okay
function reverseString(str) {
  return str;
}

reverseString('hello');
Ming Kim
@mingkim
Aug 14 2015 10:51
Use shift + Enter
yes!
justinunderhill
@justinunderhill
Aug 14 2015 10:51
ta daa
Ming Kim
@mingkim
Aug 14 2015 10:51
X)
justinunderhill
@justinunderhill
Aug 14 2015 10:52
Thanks for the help @mingkim and @Marie000 , much appreciated
CamperBot
@camperbot
Aug 14 2015 10:52
justinunderhill sends brownie points to @mingkim and @marie000 :sparkles: :thumbsup: :sparkles:
hey @justinunderhill if you found this info helpful :point_right: consider adding a wiki article!
justinunderhill
@justinunderhill
Aug 14 2015 10:52
now back to the challenge at hand, how do I solve that?
Ming Kim
@mingkim
Aug 14 2015 10:52
wow thank you
Martin Morissette
@studur
Aug 14 2015 10:52
@mingkim In fact, you only have to test primes up to floor(sqrt(num)) because any factor below the sqrt(num) will have another factor over. I learned that from projectEuler
Marie Pelletier
@Marie000
Aug 14 2015 10:52
but will the test function not exit after the first test returns true? for example, 9 would not divide by 2, so the result would be true instead of continuing to test with 3?
I thought return would automatically take you out of a loop
@justinunderhill look at the "more information" on your left. You will need to look up how to split your string into an array, reverse the array and join it back into a string.
Martin Morissette
@studur
Aug 14 2015 10:57
@Marie000 It's a second function. Notice that we run the sumPrimes(10) function at the end of the file. This sumPrimes() function calls the testprime() function within a for loop a number of times. It is a common way to program. You can then reuse your code (in this case the testprime() function) somewhere else whithout rewriting it every time.
Tim Millar
@tim-millar
Aug 14 2015 10:59
@justinunderhill strings are like arrays, so you can index into them:
> var str = "hello"
> str[0] // => "h"
Strings also have a length property
So that's one way.
Marie Pelletier
@Marie000
Aug 14 2015 11:02
@studur I know that the testprime() function will run multiple times, but wont it run once per number we are testing? (will test if 2, 3, 4, 5, 6, 7, 8, 9, 10) are prime numbers. How will it test for multiple dividers for each numbers without exiting the testprime() function?
Tim Millar
@tim-millar
Aug 14 2015 11:02
The page itself refers to split, reverse and join. That's another.
If you're especially adventurous, you could try to write it with reduce.
Stein Gee
@Stiino0
Aug 14 2015 11:04
Bonfire Diff
CamperBot
@camperbot
Aug 14 2015 11:04

:fire:Bonfire: Diff Two Arrays :link:

function diff(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Compare two arrays and return a new array with any items not found in both of the original arrays.

more info:  bf details | bf links | hint

Stein Gee
@Stiino0
Aug 14 2015 11:04
Guys I have the following code, I want to filter everything that isn't found in the array or only once with filter... I'm stuck :D
function diff(arr1, arr2) {
  var concat = arr1.concat(arr2).sort();
  var newArr = [];

  newArr = concat.filter(function (a){
    a.indexOf(a)<=1;
  });

  return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
It gives the error
expected an assignment and instead saw an expression
Tim Millar
@tim-millar
Aug 14 2015 11:06
your function doesn't return anything
Stein Gee
@Stiino0
Aug 14 2015 11:06
just saw it :D
Tim Millar
@tim-millar
Aug 14 2015 11:06
the function literal being passed to filter
Stein Gee
@Stiino0
Aug 14 2015 11:06
function diff(arr1, arr2) {
  var concat = arr1.concat(arr2).sort();
  var newArr = [];

  newArr = concat.filter(function (a){
    return concat.indexOf(a)<=1;
  });

  return newArr;
}
however this returns [1,1]
so basically the first value of my merged array
Do you see what I'm trying to do? :D
but failing :(
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:10
@Stiino0 first, sort without a callback uses string for comparission, you need to pass your own function
Stein Gee
@Stiino0
Aug 14 2015 11:11
a function in the sort?
Stein Gee
@Stiino0
Aug 14 2015 11:11
I just wanted to put the 1 and 1 next to each other
so basically with a sort?
ps I don't speak polish :p
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:12
eh, yeah, auto redirects...
Stein Gee
@Stiino0
Aug 14 2015 11:14
Is it really necessary to change the sort();
because it outputs the code fine
in an array
where I want it
justinunderhill
@justinunderhill
Aug 14 2015 11:16
Thanks @Marie000 and @tim-millar
CamperBot
@camperbot
Aug 14 2015 11:16
justinunderhill sends brownie points to @marie000 and @tim-millar :sparkles: :thumbsup: :sparkles:
hey @justinunderhill if you found this info helpful :point_right: consider adding a wiki article!
Martin Morissette
@studur
Aug 14 2015 11:20
@Marie000 Here's the code again :
function testprime(x, num){  
  for (var i=2; i<num; i++){
     if (x%i===0){   //this part test x against all dividers from 2 to num
       return false; // if it is false then the loop is exited and returns false
       break;
     } 
    else {
       return true;
    }    
  }
}

 function sumPrimes(num) {
  var arr = [];
  for (y=2; y<num; y++) {  //this will test all numbers from 2 to num 
    if (testprime(y, num); === true) { //if the current num is prime...
     arr.push(y);  // push it to the array
    } 
  }  /* here, all the numbers up to num have been tested with the
 testprime() function */
  return arr;
}

sumPrimes(10);
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:21
[3,2,1].sort();
[1, 2, 3]

[11,22,121].sort();
[11, 121, 22]
@Stiino0 it's up to you..
Martin Morissette
@studur
Aug 14 2015 11:23
The function testprime() is called on EVERY number of the sumPrimes() y for loop. When the testprime() function is done it returns true or false. The if statement checks if the testprime() function returns true or false and take the appropriate action.
Marie Pelletier
@Marie000
Aug 14 2015 11:23
thanks @studur but it tells me that 9 is a prime number.
CamperBot
@camperbot
Aug 14 2015 11:23
marie000 sends brownie points to @studur :sparkles: :thumbsup: :sparkles:
hey @marie000 if you found this info helpful :point_right: consider adding a wiki article!
Marie Pelletier
@Marie000
Aug 14 2015 11:25
so it stops the loop after testing if divisible by 2
Martin Morissette
@studur
Aug 14 2015 11:25
Yeah... I think the testprime function here is wrong... Here mine
function premier(num){


var prime;
for (i=3; i<num-1;i++)
    {
 if (num%i !== 0 )
        {
            prime=true;
        }
            else
        {
            prime=false;
            i=num;
        }
    }
  return prime;  
}
function sumPrimes(num){
var number=3;
  var primes = [];
while (number<=num) {
    if (premier(number)) {
      primes.push(number);  
      console.log(number);
        }
        number=number+2;
}
  var sum = 5;
  for (s in primes){

    sum += primes[s];
  }
  return sum;
}
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:32
@studur you exclude 2 from dividers in your for loop?
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:37
function prime(num) {
   if (num < 2) return false;
   var prime = true;
   for (var i = 2; i < num; i++)  {
       prime = prime && (num % i !== 0);
       if (!prime) return false;
   }
   return prime;
}
i'm not so good with algorithms, so someone check it
maybe this, bit more efficent
Sudeepto
@Sudeepto
Aug 14 2015 11:49
@kmiasko You are using the variable name prime that is also the name of your function.
function primeCheck(num) {
   if (num < 2) return false;
   var prime = true;
   for (var i = 2; i < num; i++)  {
       prime = prime && (num % i !== 0);
       if (!prime) return false;
   }
   return prime;
}

primeCheck(23);
returns true :smile:
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:51
@Sudeepto yeah, it's bad but doesn't affect function
Sudeepto
@Sudeepto
Aug 14 2015 11:55

I never said that your algo is wrong . And 23 is a prime number and that's why I called the function with that argument.

In this case the identifier used for both the funtion and the local variable prime is fine. But it is a bad practice and that's what I wanted to tell you.

@kmiasko
Krzysztof Miąsko
@kmiasko
Aug 14 2015 11:58
Yeah i've tought that you've spotted some bug or smth, nevermind :)
Stein Gee
@Stiino0
Aug 14 2015 12:01
@kmiasko that's true about the ordering, however it was more of a visual, I don't actually want to sort correctly, but mainly make sure that every "pair" get's next to eachother
[1,2,3,5,1,2,3,4,5] --> [1,1,2,2,3,3,4,5,5]
Krzysztof Miąsko
@kmiasko
Aug 14 2015 12:04
y u do dis? :D
Stein Gee
@Stiino0
Aug 14 2015 12:04
It looks better than the first
My method of thinking is, I concat both of them, then use filter to look up the value(s) who only appear once in total
Here's what I have right now :)
function diff(arr1, arr2) {
  var concat = arr1.concat(arr2).sort();
  var newArr = [];

  newArr = concat.filter(function (a){
    return concat.indexOf(a)<1;
  });

  return newArr;
}
which returns only [1,1] which is the start of my array
:(
I thought .filter loops through every part of an array
I'm probably using it incorrect
Krzysztof Miąsko
@kmiasko
Aug 14 2015 12:08
@Stiino0 have you took a look at other tests? There are strings, mixed string with numbers, and i bet they expect exact order for the tests
you'll have problem with this approach imho
This message was deleted
This message was deleted
Stein Gee
@Stiino0
Aug 14 2015 12:16
Did I take a look at other tests?
What other tests :)
Krzysztof Miąsko
@kmiasko
Aug 14 2015 12:17
All the tests.. Nevermind.
Stein Gee
@Stiino0
Aug 14 2015 12:20
You mean other challenges?
Bonfires?
Martin Morissette
@studur
Aug 14 2015 12:20
@kmiasko Yes, I dont test for division by 1 (obviously) and I test only odd numbers since even numbers are not prime. I start with 3and I increment the number by 2 (number=numer+2) every loop. I did not implement this testprime loop to test dividers up to floor(sqrt(num)) but it would be more efficient.
Matt Everson
@matteverson
Aug 14 2015 13:45
good morning
rayner-villalba-coderoad-com
@rayner-villalba-coderoad-com
Aug 14 2015 13:47
hi everybody
Stein Gee
@Stiino0
Aug 14 2015 13:58
ah man my code is beginning to look messed up :D
I only need to have the last check verified, then my code works lol
This can definitely become better code :p can anyone find the last check needed for Bonfire http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays
function diff(arr1, arr2) {
  var array = arr1.concat(arr2).sort();
  var a = [], b = [];
  var prev;
  var result = [];

  for (i=0;i<array.length;i++){
    if (array[i] !== prev){
      a.push(array[i]);
      b.push(1);
    } else {
      b[b.length-1]++;
    }
    prev = array[i];
  }

  for (i=0;i<b.length;i++){
    if (b[i]<=1){
      result.push(a[i]);
    }
  }
  return result;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
I only need to show the entire array if every element is showing twice
assert.deepEqual(diff([], ['snuffleupagus', 'cookie monster', 'elmo']), ['snuffleupagus', 'cookie monster', 'elmo'], 'empty array');empty array: expected [ Array(3) ] to deeply equal [ Array(3) ]
gravesr1993
@gravesr1993
Aug 14 2015 14:23
could someone help me with bonfire make a person? I'm not sure I understand how they want to do sets and i'm not 100% sure how to introduce private variables into the pseudoclasses of JS
var Person = function(fullname) {
  var obj={getFullName:function(){return fullname;}, 
           getFirstName:function(){return fullname.split(' ')[0];},
           getLastName:function(){return fullname.split(' ')[1];},
           setFirstName:function(first){fullname.split(' ')[0]=first;},
           setLastName:function(last){fullname.split(' ')[1]=last;},
           setFullName:function(firstAndLast){fullname=firstAndLast;}
          };
  return obj;
};
var bob = new Person('Bob Ross');
bob.getFullName();
CamperBot
@camperbot
Aug 14 2015 14:23
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
justindobbs
@justindobbs
Aug 14 2015 14:39
have you tried using this.getFullName[...]
Aleksandar B.
@aleksandar-b
Aug 14 2015 14:40
@QuincyLarson should I learn Underscore.js?
Hoaxed
@Hoaxed
Aug 14 2015 14:49
Hey all
Sudeepto
@Sudeepto
Aug 14 2015 14:49

@gravesr1993 You can only have 6 members of Person class.
The members functions should be defined using the this identifier.

For first name , you can declare a private variable first and likewise last for surname .

Then use both first and last in your member functions.

Mike Moss
@MMux
Aug 14 2015 14:50
working on the weather zipline: I just added a little icon to reload the page, and for some reason in the codepen, it gives me a white screen; but not in a full page preview. Not sure what's happening. Has anyone had this happen?
http://s.codepen.io/MMux/debug/RPdYmZ?
Sudeepto
@Sudeepto
Aug 14 2015 14:51

Also you don't need that obj function. Remove it and define your member functions directly inside the Person function , using the this identifier i.e.

this.functionName = function() { // your code } ;
@gravesr1993

gravesr1993
@gravesr1993
Aug 14 2015 14:56
This message was deleted
gravesr1993
@gravesr1993
Aug 14 2015 15:01
got it with this, thanks for the help
var Person = function(fullname) {
  firstName=fullname.split(' ')[0];
  lastName=fullname.split(' ')[1];
  this.getFullName=function(){return firstName+(' ')+lastName;};
  this.getFirstName=function(){return firstName;};
  this.getLastName=function(){return lastName;};
  this.setFirstName=function(first){firstName=first;};
  this.setLastName=function(last){lastName=last;};
  this.setFullName=function(firstAndLast){firstName=firstAndLast.split(' ')[0];lastName=firstAndLast.split(' ')[1];};
  return this;
};
var bob = new Person('Bob Ross');
rbunz
@rbunz08
Aug 14 2015 15:05
HEELPP I have just spent forever on this code and it has disappeared from the screen!! Anyways to get it back??? It did not save on my profile!!!
I have tried ctrl z and paste in case...
is there like a console history?? or javascript history on the bonfires??
Feners4
@Feners4
Aug 14 2015 15:17
can I get some help with displaying a search icon, for some reason I cant get it to work...http://codepen.io/Feners4/pen/ZGZORX
Javier
@jalonso087
Aug 14 2015 15:17
bonfire dna pairing
CamperBot
@camperbot
Aug 14 2015 15:17

:fire:Bonfire: DNA Pairing :link:

function pair(str) {
 return str;
}

pair("GCG");

The DNA strand is missing the pairing element. Match each character with the missing element and return the results as a 2d array.

more info:  bf details | bf links | hint

Javier
@jalonso087
Aug 14 2015 15:17
bf details
CamperBot
@camperbot
Aug 14 2015 15:17

:fire:Bonfire: DNA Pairing :link:

function pair(str) {
 return str;
}

pair("GCG");
The DNA strand is missing the pairing element. Match each character with the missing element and return the results as a 2d array.
<a href="http://en.wikipedia.org/wiki/Base_pair">Base pairs</a> are a pair of AT and CG. Match the missing element to the provided character.
Return the provided character as the first element in each array.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Sudeepto
@Sudeepto
Aug 14 2015 15:17
@rbunz08 you mean you failed to save the bonfire code??
Javier
@jalonso087
Aug 14 2015 15:17
hint
CamperBot
@camperbot
Aug 14 2015 15:17
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Tyler St. Onge
@tylerstonge
Aug 14 2015 16:05
What is going on when you call a function like func(3)(2)?
Oh I figured it out I think.
Matthew Senko
@mpskierbg
Aug 14 2015 16:11

hey i have this code:

range = [1,2,3,4,5];
 var n = range.length, a = Math.abs(range[0]);
    for (var j = 1; j < n; j++)
     { var b = Math.abs(range[j]), c = a;
       while (a && b){ a > b ? a %= b : b %= a; } 
       a = Math.abs(c*range[j])/(a+b);
     }
    return a;

can you walk me through it?

rbunz
@rbunz08
Aug 14 2015 16:34
@Sudeepto yep :'( But i wrote it again and better than before...
@mpskierbg You can def clean up the code a bit... you have over complicated it..
@mpskierbg Give me a minute... Ill clean it up and add some comments to try and explain...
Matthew Senko
@mpskierbg
Aug 14 2015 16:36
@rbunz08 awesome thanks.
rbunz
@rbunz08
Aug 14 2015 16:38
@mpskierbg have you tried the code and it works?
Matthew Senko
@mpskierbg
Aug 14 2015 16:38
yeah it works.
rbunz
@rbunz08
Aug 14 2015 16:38
@mpskierbg k
Matthew Senko
@mpskierbg
Aug 14 2015 16:39
it finds the smallest common multiple of all the values in range.
galacticfan
@galacticfan
Aug 14 2015 16:39
Wasup guys
Christopher Stewart
@cjstewart13
Aug 14 2015 16:50

hey I'm working on the Palindrome bonfire and have the following code.

function palindrome(str) {
  // Good luck!
  str = str.toLowerCase().replace(/([\.\s,]+)+/, "");

  function reverseString(str) {
     var newString = str.split('');
     newString.reverse();
     var newerString = newString.join('');


      return newerString;
  }

  var reversedString = reverseString(str);
 // var compressedString = reversedString.replace(' ', '');

  if (reversedString === str){ 

    return true;

  } else {

    return false;

  }


}



palindrome("eye");

I'm working on removing all non alphabet characters. I can't find a pattern that deletes ALL instances of a space comma or period etc. For example it will delete all spaces between "race car" but as soon as I add a space after that, it returns false since there are multiple spaces like in "a man a plan a canal Panama"

galacticfan
@galacticfan
Aug 14 2015 16:54
you need to make it recursive
Christopher Stewart
@cjstewart13
Aug 14 2015 16:54
so instead of making a variable, do I need to make a function to do that?
galacticfan
@galacticfan
Aug 14 2015 16:55
the regex expression can be made recursive using /([\.\s,]+)+/g
by placing a 'g' on the end
Christopher Stewart
@cjstewart13
Aug 14 2015 16:55
what does the g do?
galacticfan
@galacticfan
Aug 14 2015 16:55
makes it recursive and so all of your spaces will be removed
rbunz
@rbunz08
Aug 14 2015 16:55
@mpskierbg try looking at this... I think I have gotten all the symbols correct.. let me know if it makes sense.. I think it still has a lot of repeated code
range = [1,2,3,4,5];
 var a = Math.abs(range[0]);  // a is taking the absolute value (non-negative) of the first number in the 'range' array (in this case the 1)

    for (var j = 1; j < range.length; j++) { //starting at the second number in the array until the end of the array; one at a time 
     var b = Math.abs(range[j]);  // b will take the absolute value of that number
     var c = a;                   // c will equal a
     while (a && b){              // while a and b
       a > b ? a %= b : b %= a;   // if a is greater than b than return the remainder of a/b if it is not that return the remainder of b/a
     } 
       a = Math.abs(c*range[j])/(a+b); // a is then equal to the absolute value of c times the number used in b all divided by (a plus b)
     }

    return a;  // return to the computer a
Christopher Stewart
@cjstewart13
Aug 14 2015 16:56
Thank you @galacticfan!
CamperBot
@camperbot
Aug 14 2015 16:56
cjstewart13 sends brownie points to @galacticfan :sparkles: :thumbsup: :sparkles:
hey @cjstewart13 if you found this info helpful :point_right: consider adding a wiki article!
galacticfan
@galacticfan
Aug 14 2015 17:01
@cjstewart13 You could make it even simpler and just select all non-alphanumeric characters and use /[\W]/g
Matthew Senko
@mpskierbg
Aug 14 2015 17:02
@rbunz08 thanks, no i guess i dont understnad how that gets the smallest common multiple. but for now i will be okay just knowing that it does. thanks.
rbunz
@rbunz08
Aug 14 2015 17:03
@mpskierbg Im going to try that bonfire now.. Ill play with it and let you know if I come up with something else..
Matthew Senko
@mpskierbg
Aug 14 2015 17:03
ok cool.
Dayne Wright
@daynewright
Aug 14 2015 17:13
Hi everyone…
This message was deleted
rbunz
@rbunz08
Aug 14 2015 17:26
This is going to seem really silly but Im having a major "Brain fart" lol
How do you print out a list of numbers
??
I have put this and its not working...
 var i = 0;
  for (i = 0; i > 5; i++) {
   console.log(i);
  }
Sudeepto
@Sudeepto
Aug 14 2015 17:27
i < 5
:smile:
galacticfan
@galacticfan
Aug 14 2015 17:27
^ +1
rbunz
@rbunz08
Aug 14 2015 17:27
omg
lol
wow
Hoaxed
@Hoaxed
Aug 14 2015 17:28
hi all, I'm working on css way point.

`

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}
.image-smaller{
width: 100px
}
h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
</style>

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

<img src='https://bit.ly/fcc-kittens'/>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

woops
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }
  .image-smaller{
    width: 100px
  }
  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
</style>

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

<img src='https://bit.ly/fcc-kittens'/>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
I'm having trouble deciding whether I should be putting the img source inside of the class or if the class just applies to the img src after ?
galacticfan
@galacticfan
Aug 14 2015 17:30
which class are you talking about, the red-text class?
KARTHIGAA VIJAYAKUMAR
@karthigaav
Aug 14 2015 17:31
@Hoaxed It should be like <img class='' src=''/>
Hoaxed
@Hoaxed
Aug 14 2015 17:32
the instructions are
Your img element should have the class "smaller-image".
Your image should be 100 pixels wide.
Nancy J. Melucci
@drnanjo
Aug 14 2015 17:33
Screenhero new accounts are disabled during the merge. I would be grateful if someone would invite me.
My email address is drnanjo@aol.com. Thanks.
KARTHIGAA VIJAYAKUMAR
@karthigaav
Aug 14 2015 17:33
<img class='smaller-image' src=''/>
<style>
Hoaxed
@Hoaxed
Aug 14 2015 17:33
Thank you @karthigaav I'll try that
CamperBot
@camperbot
Aug 14 2015 17:33
hoaxed sends brownie points to @karthigaav :sparkles: :thumbsup: :sparkles:
hey @hoaxed if you found this info helpful :point_right: consider adding a wiki article!
KARTHIGAA VIJAYAKUMAR
@karthigaav
Aug 14 2015 17:34
ur welcome @Hoaxed
jb299
@jb299
Aug 14 2015 17:34
@drnanjo sent invite
David Suilea
@Foryah
Aug 14 2015 17:35
any python guru here ? :)
Donavin Northrup
@dnorthrupva
Aug 14 2015 17:43
@drnanjo I just registered last night, no error. Wonder why you're getting one.
having trouble with this challenge
ErickX93
@ErickX93
Aug 14 2015 17:52
blob
Cordoba84
@fcordoba84
Aug 14 2015 17:52
can any one help
ErickX93
@ErickX93
Aug 14 2015 17:52
Why doesn't this work?
Cordoba84
@fcordoba84
Aug 14 2015 18:01
any one
M Used
@mildused
Aug 14 2015 18:02
@fcordoba84 I can
Cordoba84
@fcordoba84
Aug 14 2015 18:03
ok how
M Used
@mildused
Aug 14 2015 18:03
post your code here;)
Cordoba84
@fcordoba84
Aug 14 2015 18:04

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
</style>

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

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

M Used
@mildused
Aug 14 2015 18:04
whoa
surround that with ```
Cordoba84
@fcordoba84
Aug 14 2015 18:04
lol
Rex Schrader
@SaintPeter
Aug 14 2015 18:04
wiki format
CamperBot
@camperbot
Aug 14 2015 18:04

:point_right: code formatting [wiki]

Inline code

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

Code Block

``` ⇦ Type 3 backticks, 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

M Used
@mildused
Aug 14 2015 18:04
@SaintPeter Thank you
Rex Schrader
@SaintPeter
Aug 14 2015 18:05
@ErickX93 Are you still looking for help?
Cordoba84
@fcordoba84
Aug 14 2015 18:07
yes
Rex Schrader
@SaintPeter
Aug 14 2015 18:08
@fcordoba84 Can you edit your code above to add ``` before and after, as described in the wiki entry above?
@fcordoba84 hover over the entry, click edit, use shift-enter to add new lines
Cordoba84
@fcordoba84
Aug 14 2015 18:09
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
</style>

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

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
cool
Rex Schrader
@SaintPeter
Aug 14 2015 18:09
@fcordoba84 Perfect. What is your issue?
Cordoba84
@fcordoba84
Aug 14 2015 18:10
Create an "urgently-red" class that gives an element the font-color of red, but add !important to the class to ensure the element is rendered as being red. Immediately below your "urgently-red" class declaration, create a "blue-text" class that gives an element the font-color of blue. Apply both classes to your h2 element.
an this is what im supposed to do
Rex Schrader
@SaintPeter
Aug 14 2015 18:12
@fcordoba84 Ok, do you know how to create a new class and where to put it?
Cordoba84
@fcordoba84
Aug 14 2015 18:12
how to create yes where to put it no
Rex Schrader
@SaintPeter
Aug 14 2015 18:13
Classes go inside the <style> tags
Like the .red-text class
Cordoba84
@fcordoba84
Aug 14 2015 18:14
ok
let me try
ErickX93
@ErickX93
Aug 14 2015 18:27
can someone help me? :D
William Wagner
@wcwagner
Aug 14 2015 18:27
@ErickX93 With what
fullstackquest
@fullstackquest
Aug 14 2015 18:27
I need help with Waypoint: Responsively Style Checkboxes. Stuck on: Wrap each of your checkboxes inside its own div with the class "col-xs-4".
ErickX93
@ErickX93
Aug 14 2015 18:28
blob
Why exactly is this code not working?
i mean, it should split the code in arrays of "size", but it doesn't , it returns the initial array
William Wagner
@wcwagner
Aug 14 2015 18:30
Is arr[i][j-i*size] a valid index? When you use two brackets like that it's to access a two dimensional array
Rex Schrader
@SaintPeter
Aug 14 2015 18:31
@ErickX93 I'm not sure why it's not working other than "Math is hard and your code is too complex" - I think you're trying to solve it mathematically and it's really easy to make mistakes. I can't even really follow what exactly you're doing there.
fullstackquest
@fullstackquest
Aug 14 2015 18:31
Oops - sorry. Please ignore previous request. Figured it out.
William Wagner
@wcwagner
Aug 14 2015 18:31
@ErickX93 And I think its preferred to copy paste your code in here, rather than screenshot it. If you copy/pasted I could test it myself without retyping it
Rex Schrader
@SaintPeter
Aug 14 2015 18:32
@ErickX93 My preferred analogy for this problem: Imagine you have a jug of water and you're filling up cups one at a time. How do you keep from overflowing a cup? What do you do with a cup once it is full? I suggest that you can easily solve this problem with a single loop.
wiki format
CamperBot
@camperbot
Aug 14 2015 18:32

:point_right: code formatting [wiki]

Inline code

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

Code Block

``` ⇦ Type 3 backticks, 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

William Wagner
@wcwagner
Aug 14 2015 18:33
Hey @SaintPeter I'm working on the twitch zipline and I have a couple questions. Do you mind looking at them?
Rex Schrader
@SaintPeter
Aug 14 2015 18:33
@Stfyou Sure - private chat me or head over to the Zipline chatroom
William Wagner
@wcwagner
Aug 14 2015 18:34
@SaintPeter Didn't even know there was a zipline chatroom, am i correct in assuming it's Freecodecamp/zipline?
Cordoba84
@fcordoba84
Aug 14 2015 18:37
im missing this
Your h2 element should have the class "blue-text".
Your h2 element should have the class "urgently-red".

``` <link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
!important: <style> .urgently-red { color: red !important; }
</style>

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

<h3 class='blue-text'>CatPhotoApp</h3>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Rex Schrader
@SaintPeter
Aug 14 2015 18:38
@fcordoba84 Ok, do you know how to add a class Or classes to an HTML element?
Cordoba84
@fcordoba84
Aug 14 2015 18:38

```<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
!important: <style> .urgently-red { color: red !important; }
</style>

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

<h3 class='blue-text'>CatPhotoApp</h3>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>```

Rex Schrader
@SaintPeter
Aug 14 2015 18:39
@fcordoba84 Also, you onlu need one set of <style> tags. They're already there.
Cordoba84
@fcordoba84
Aug 14 2015 18:39
no idea
Rex Schrader
@SaintPeter
Aug 14 2015 18:39
@fcordoba84
<h2 class='red-text'>CatPhotoApp</h2>
Cordoba84
@fcordoba84
Aug 14 2015 18:39
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
!important: <style> .urgently-red { color: red !important; }
</style>
<h2 class='red-text'>CatPhotoApp</h2>
<h3 class='blue-text'>CatPhotoApp</h3>
<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
Rex Schrader
@SaintPeter
Aug 14 2015 18:40
@fcordoba84 You can add more than one class by seperating them by spaces within the quote marks: <h2 class="classOne classTwo">
Cordoba84
@fcordoba84
Aug 14 2015 18:43

'''

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
!important: <style> .urgently-red { color: red !important; }
</style>

<h2 class='red-text'>CatPhotoApp</h2>
<h2 class='blue-text'>CatPhotoApp</h2>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
'''

CamperBot
@camperbot
Aug 14 2015 18:43
:bulb: to format code use backticks! ``` more info
Rex Schrader
@SaintPeter
Aug 14 2015 18:46

@fcordoba84

!important: <style> .urgently-red { color: red !important; }
</style>

This is wrong. Remover the leading !important and the <style>. You already opened your style way above and the !important directive is in the correct location after the color: red

Cody Bouscaren
@codybousc
Aug 14 2015 18:52
Anyone have any advice on how to approach Bonfire #27, Sorted Union? I've started with two different approaches, but both seem to be sucking me down a nonsensical rabbit hole!
Cordoba84
@fcordoba84
Aug 14 2015 18:52
where should i place Your h2 element should have the class "urgently-red".
Rex Schrader
@SaintPeter
Aug 14 2015 18:53
@codybousc Well, you have to pull in the arguments object, then you need to concat all of the args, then you need to remove dupes.
gravesr1993
@gravesr1993
Aug 14 2015 19:06
for bonfire Map the Debris should I consider earth round or elliptical? it gives earth as a radius
Lauren
@midori87
Aug 14 2015 19:08
I am trying to do waypoint 27, and use .smaller-image to resize, but it isnt working. I am not sure where I should be putting this
Meredith Wiegman
@mwiegman
Aug 14 2015 19:09
I'm on the first section of Codecademy's "Building an Address Book". The editor has an example of an object "bob". It says "We have Bob's information stored in an associative array named bob." This looks the same as the object literal notation. Why do they call it an associative array here, but object literal notation elsewhere?
@midori87 On waypoint 27, the objective is to add alt text. The class "smaller-image" is already added to the img tag. You should add the alt text to the image like this: alt="A cute orange cat lying on its back"
Rex Schrader
@SaintPeter
Aug 14 2015 19:13
@mwiegman an associative array is a special case of object literal notation
@gravesr1993 You need to add the earth radius to the avgAlt - for an orbit you can genralize an elepise by taking the average altitude/orbit
ronald
@ronstarcool
Aug 14 2015 19:14
anyone here to help me on the bf: flatten array?
the steamroller
Lauren
@midori87
Aug 14 2015 19:14
It wants me to "Create a class called smaller-image and use it to resize the image so that it's only 100 pixels wide."
Meredith Wiegman
@mwiegman
Aug 14 2015 19:14
@SaintPeter Thanks for the answer! I did see that explanation on MDN, I was just wondering why they switched their terminology.
Rex Schrader
@SaintPeter
Aug 14 2015 19:16
@mwiegman Moslty because Code Academy is not very good :D - Also, for people who know a bunch of different languages, an associative array is pretty common.
Cordoba84
@fcordoba84
Aug 14 2015 19:18
hi
i finally did it can u proof read it? @SaintPeter
Meredith Wiegman
@mwiegman
Aug 14 2015 19:20
@midori87 I see that is the objective of waypoint 19: Your img element should have the class "smaller-image". So you would add the class to the img tag like this: <img class="smaller-image" src='https://bit.ly/fcc-kittens'/>. Then add a class selector to the style section like this: .smaller-image { width: 100px; }
Clayton
@cjg040103
Aug 14 2015 19:21
does camperbot do waypoints?
Waypoint: Build an Address Book
guess not...
Meredith Wiegman
@mwiegman
Aug 14 2015 19:23
@SaintPeter Codecademy is not very good? Do you have other suggestions for basic JavaScript training?
Cordoba84
@fcordoba84
Aug 14 2015 19:24
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
  .urgently-red { color: red !important; } 

</style>

<h2 class='urgently-red'>CatPhotoApp</h2>

<h2 class='red-text!'>CatPhotoApp</h2>

<h2 class='blue-text'>CatPhotoApp</h2>




<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
Lauren
@midori87
Aug 14 2015 19:25
@mwiegman awesome thanks!
Christopher Stewart
@cjstewart13
Aug 14 2015 19:31
Ok I was so close to getting this on my own. I am working on Bonfire: Title Case a String and I have managed to capitalize the first letter of every string. However the string is just the first letter of every word. I know where the code is going wrong (in the for loop in the if function) How do I go about fixing it.
function titleCase(str) {
  var lowercase = str.toLowerCase();
  var array = lowercase.split(" ");

  for (i = 0; i < array.length; i++) {
    if (array[i].charAt(0) != array[i].charAt(0).toUpperCase()) {
      array[i] = array[i].charAt(0).toUpperCase();
    }
  }
  array = array.join(" ");
  return array;
}

titleCase("I'm a little tea pot");
Liz Rezes
@queenlizo
Aug 14 2015 19:33
Hi, all. I'm wondering why this is saying that true is not a function. I'm on BF Finders Keepers. Thanks!
function find(arr, func) {
  var num = 0;
  var myNum = 0;
  for (i=0; i<=arr.length; i++) {
     if (arr.some(func(i)) === true);
     return i;
  }
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
fullstackquest
@fullstackquest
Aug 14 2015 19:33
Need help with Waypoint: Style Text Inputs as Form Controls. This part - Give the text input in your form the class "form-control" Here's my code:
<input class='form control' type='text' placeholder='cat photo URL' required>
<button class='btn btn-primary' type="submit"><i class="fa fa-paper-plane"></i>Submit</button>
</form>
Juan Martínez
@jbmartinez
Aug 14 2015 19:35
@cjstewart13 strings are immutable in javascript
@cjstewart13 you're assigning just the first character of every word
@cjstewart13 use slice or substring and concatenate the rest of the word to the first letter you converted to upper case
Christopher Stewart
@cjstewart13
Aug 14 2015 19:38
thanks!
Juan Martínez
@jbmartinez
Aug 14 2015 19:39
@cjstewart13 no problem
Christopher Stewart
@cjstewart13
Aug 14 2015 19:40
@jbmartinez so where would I apply the substring? to the left or the right of the assignment
Juan Martínez
@jbmartinez
Aug 14 2015 19:42
@cjstewart13 to the right: array[i] = first_letter + rest_of_the_word
Christopher Stewart
@cjstewart13
Aug 14 2015 19:42
Awesome
Juan Martínez
@jbmartinez
Aug 14 2015 19:42
@cjstewart13 the rest of the word is what you get with slice, substr or substring
@queenlizo some is expecting a function, you're passing a boolean value
Christopher Stewart
@cjstewart13
Aug 14 2015 19:44

so it would look something like:

array[i] = array[i].charAt(0).toUpperCase() + array[i].substring(1);

Liz Rezes
@queenlizo
Aug 14 2015 19:44
@jbmartinez Ah. But I have the variable func in there, which is a function
Juan Martínez
@jbmartinez
Aug 14 2015 19:45
@cjstewart13 it looks fine, try it :smile:
Christopher Stewart
@cjstewart13
Aug 14 2015 19:45
@jbmartinez THANK YOU! IT WORKED! It's always one tiny thing that I'm missing
Juan Martínez
@jbmartinez
Aug 14 2015 19:46
@queenlizo you're calling the function which returns a value, it's better to pass the function
@cjstewart13 great!
Liz Rezes
@queenlizo
Aug 14 2015 19:46
Oh, ok. thanks!
Juan Martínez
@jbmartinez
Aug 14 2015 19:47
@queenlizo func() is a function call, func is the function itself
gravesr1993
@gravesr1993
Aug 14 2015 19:47
@SaintPeter it took earth as a circle as the answer, this was my solution
function orbitalPeriod(arr) {
  arrLocal=[];
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  for(var i=0;i<arr.length;i++){
    //Orbital period = 2pi*sqrt(a^3/GM)
    //a = radius
    var nameOfThing=arr[i].name;
    var orbitalPeriodTime=Math.round(2*Math.PI*Math.sqrt(Math.pow(earthRadius+arr[i].avgAlt,3)/GM));
    var obj={name : nameOfThing,orbitalPeriod : orbitalPeriodTime};
    arrLocal.push(obj);
  }
  return arrLocal;
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);
Liz Rezes
@queenlizo
Aug 14 2015 19:47
@jbmartinez Oooh. That makes sense
Cordoba84
@fcordoba84
Aug 14 2015 19:52
hi what am i doing wrong here with the picture border
Dayne Wright
@daynewright
Aug 14 2015 19:54

ok…which on of these are the better way to solve this problem?

#1

function truncate(str, num) {
  var newStr = str;
    if(!Number.isInteger(num)){
      num = num.length;
    }

    if(num < str.length){
      newStr = str.slice(0,num-3) + '...';
    } 
  return newStr;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

#2

function truncate(str, num) {
  if(Number.isInteger(num)){
    if(!(num == str.length || num > str.length)){
        num = num-3;
      str = str.slice(-str.length, num).concat('...');
    }
   }
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
Juan Martínez
@jbmartinez
Aug 14 2015 19:54
@fullstackquest the dash is missing in class='form control'
fullstackquest
@fullstackquest
Aug 14 2015 19:55
@jbmartinez Thank you so much! Can't believe I missed that.
Juan Martínez
@jbmartinez
Aug 14 2015 19:57
@Daynewr I found the first one more readable
Cordoba84
@fcordoba84
Aug 14 2015 20:01
.thick-green-border { border-color: green; border-width: 10px; border-style: solid; } </style> <h2 class='red-text'>CatPhotoApp</h2> <img class='smaller-image' src='https://bit.ly/fcc-kittens' border= 'thick-green-border' />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .smaller-image {
    width: 100px;
  }
  .thick-green-border { 
     border-color: green;
     border-width: 10px;
     border-style: solid; } 
</style>

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

<img class='smaller-image' src='https://bit.ly/fcc-kittens' border= 'thick-green-border'  />

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
Juan Martínez
@jbmartinez
Aug 14 2015 20:04
@fcordoba84 thick-green-border is a class, use it in the same way as smaller-image
Cordoba84
@fcordoba84
Aug 14 2015 20:04
help with the border what did i do wrong?
CamperBot
@camperbot
Aug 14 2015 20:04
no wiki entry for: with the border what did i do wrong
:pencil: click here to create one now!after creating your page type update to reload it here
Hoaxed
@Hoaxed
Aug 14 2015 20:06
@fcordoba84 you don't need border = thick-green-border
Cordoba84
@fcordoba84
Aug 14 2015 20:07
@jbmartinez like this
<img class='smaller-image' src='https://bit.ly/fcc-kittens' class2= 'thick-green-border'  />
Hoaxed
@Hoaxed
Aug 14 2015 20:07
even easier try img class ='smaller-image' 'thick-green-border'
Juan Martínez
@jbmartinez
Aug 14 2015 20:07
@fcordoba84 class="smaller-image thick-green-border"
@fcordoba84 separate classes with spaces, all of the classes should be in an unique class attribute
Cordoba84
@fcordoba84
Aug 14 2015 20:10
ok border doesnt came up
Juan Martínez
@jbmartinez
Aug 14 2015 20:10
@fcordoba84 show me your code, please
Cordoba84
@fcordoba84
Aug 14 2015 20:10
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .smaller-image {
    width: 100px;
  }
  .thick-green-border { 
     border-color: green;
     border-width: 10px;
     border-style: solid; } 
</style>

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

<img class='smaller-image thick-green-border' src='https://bit.ly/fcc-kittens'    />

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
Hoaxed
@Hoaxed
Aug 14 2015 20:12
@fcordoba84 <img class='smaller-image thick-green-border' should be class= 'smaller-image' 'thick-green-border'
Juan Martínez
@jbmartinez
Aug 14 2015 20:12
@Hoaxed nope
Hoaxed
@Hoaxed
Aug 14 2015 20:12
apologies if I'm wrong then
Cordoba84
@fcordoba84
Aug 14 2015 20:13
so why doesnt the border come up in the picture
Juan Martínez
@jbmartinez
Aug 14 2015 20:13
@fcordoba84 I just tested and worked fine here
Hoaxed
@Hoaxed
Aug 14 2015 20:14
I just went back and looked at my old code. It should be
<img class='smaller-image thick-green-border' src='https://bit.ly/fcc-kittens'/>
Cordoba84
@fcordoba84
Aug 14 2015 20:15
yea @jbmartinez @Hoaxed i was missing img infront of border style
thanks alot
Juan Martínez
@jbmartinez
Aug 14 2015 20:15
@fcordoba84 no problem
Cordoba84
@fcordoba84
Aug 14 2015 20:15
for the help of to the next challenge
ErickX93
@ErickX93
Aug 14 2015 20:17
guys, i've solved this problem, but it doesn't look like very good design ... (though it does work) :

function chunk(arr, size) {
for(var i=0; i<arr.length/size; i++)
{
arr[i]=arr.slice(isize,(i+1)size);
}

arr = arr.slice(0, Math.ceil(arr.length/size));

return arr;
}

chunk(['a', 'b', 'c', 'd'], 2);

any tips?
Christopher Stewart
@cjstewart13
Aug 14 2015 20:29
Ok. At that point where its something simple again. I'm working on Return Largest Numbers in Arrays and I've got the loops going to where they are looking through each array for the largest number, but its only returning the largest number in the last array. It's almost like one of the loops is not retaining the numbers as it goes along.
function largestOfFour(arr) {
  // You can do this!
  var subArrays = arr[0];
  var largestNumbers = 0;

  for (i = 0; i < arr.length; i++) {
    subArrays = arr[i];

  }

  for (j = 0; j < subArrays.length; j++) {
      if (subArrays[j] > largestNumbers) {
        largestNumbers = subArrays[j];
      }

 }


  return largestNumbers;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen Woods
@stephenwoods
Aug 14 2015 20:38
Looking for some help on Bonfire: Inventory Update...anyone available to take a look?
CamperBot
@camperbot
Aug 14 2015 20:38
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 20:38
@cjstewart13 Hey! your code is almost right. In the first for loop, you iterate over all of the arrays and assign them to subArrays. But after that loop finishes, the last array is the one that stays in subArrays
You should check the largest value in the array right after assigning it to subArrays
Christopher Stewart
@cjstewart13
Aug 14 2015 20:40
instead of the if statement being in the second for loop, it should be in the first?
@arturts
Stephen Woods
@stephenwoods
Aug 14 2015 20:41
Looking for help on the bonfire "Inventory Update" if anyone has a minute to take a look I'd appreciate it. It looks like the array isn't getting sorted alphabetically correctly and I can't figure out why.
function inventory(arr1, arr2) {
  var itemsToPush = [];
  for(var i=0; i<arr2.length; i++) {
    var updated = false;
    for(var j=0; j<arr1.length; j++) {
      if(arr2[i][1] == arr1[j][1]) {
        arr1[j][0] += arr2[i][0];
        updated = true;
        break;
      }
    }
    if(!updated) {
      itemsToPush.push(arr2[i]);
    }
  }
  var result = arr1.concat(itemsToPush).sort();
  for(var k=0; k<result.length; k++) {
    console.log(result[k][0] + result[k][1]);
  }
  return arr1.concat(itemsToPush).sort();
}

// Example inventory lists
var curInv = [
    [21, 'Bowling Ball'],
    [2, 'Dirty Sock'],
    [1, 'Hair Pin'],
    [5, 'Microphone']
];

var newInv = [
    [2, 'Hair Pin'],
    [3, 'Half-Eaten Apple'],
    [67, 'Bowling Ball'],
    [7, 'Toothpaste']
];

inventory(curInv, newInv);
CamperBot
@camperbot
Aug 14 2015 20:41
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
ErickX93
@ErickX93
Aug 14 2015 20:42

guys, what's the difference between :

arr.splice(); and arr = arr.splice();

or any other function

Artur de Oliveira Tsuda
@arturts
Aug 14 2015 20:42
@cjstewart13 the whole second for loop should be after subArrays = arr[i];
Stephen Woods
@stephenwoods
Aug 14 2015 20:43
@ErickX93 I believe splice() actually modifies the array, so you wouldn't need to reassign it. It depends on if the function actually modifies the 'this' operator it's working on.
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:43
@ErickX93 arr.splice(); does not alter the original array so it has to be assigned to a new value
Victor
@Evaderei
Aug 14 2015 20:43
what was the acronym for getting help again?
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:43
or an existing variable
ErickX93
@ErickX93
Aug 14 2015 20:43
thank you
so there are functions that modify the array or string, and you don't need to assign it to a new variable, and functions that don't right?
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:45
@ErickX93 the googlestring "javascript mdn array <arrayfunction>" always does it for me when i cant remember what it returns and what it alters
ErickX93
@ErickX93
Aug 14 2015 20:45
oh, i got it
what is a googlestring?
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:46
a string to put into google :)
Christopher Stewart
@cjstewart13
Aug 14 2015 20:47
@arturts I tried that and it only returned the largest number in the fourth array
ErickX93
@ErickX93
Aug 14 2015 20:47
well, i figured as much, but it doesn't show me anything :smile:
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:47
javascript array splice mdn
Coira Ellison
@Coira
Aug 14 2015 20:47
@cjstewart13 largestNumber needs to be an array
ErickX93
@ErickX93
Aug 14 2015 20:47
or was it a complex joke which translates to "google it"? :smile:
oh got it
thank you
Christopher Stewart
@cjstewart13
Aug 14 2015 20:49
@Coira I defined largestNumber as an empty array and it still returns the same value
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:50
well, more like 'read mdn' it often gives a more detailed answer
Coira Ellison
@Coira
Aug 14 2015 20:50
@cjstewart13 use a different variable (e.g. largest) to keep track of the largest number
Jakob Dahl
@saadanerdetbare
Aug 14 2015 20:50
they have a huge resource on javascript
Coira Ellison
@Coira
Aug 14 2015 20:50
@cjstewart13 then largestNumber.push(largest)
Christopher Stewart
@cjstewart13
Aug 14 2015 20:51
ok! @Coira
Coira Ellison
@Coira
Aug 14 2015 20:51
@cjstewart13 there are a couple of other things you need to do to your code, but it's along those lines
Christopher Stewart
@cjstewart13
Aug 14 2015 20:52
@Coira What else do I have to do
@Coira because just making a 3rd variable for the array and inserting the push method, that worked
ALINATSUI
@ALINATSUI
Aug 14 2015 20:54
Need help with bf Return Largest Numbers In Arrays
Coira Ellison
@Coira
Aug 14 2015 20:55
@cjstewart13 ok cool, it was the nested loop thing, i think @arturts mentioned it tho
ALINATSUI
@ALINATSUI
Aug 14 2015 20:55
function largestOfFour(arr) {
  var arr1 = [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];

  for(var i=0; i<arr.length; i++) {
    Math.max.apply(arr1);
    console.log(arr1);
  }
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Any hints on how to approach this problem?
Christopher Stewart
@cjstewart13
Aug 14 2015 20:56
@ALINATSUI I just did that one. I can screen hero with you to solve it
ALINATSUI
@ALINATSUI
Aug 14 2015 20:57
sure, that would be great. Let me install screen hero
Coira Ellison
@Coira
Aug 14 2015 21:01
@ALINATSUI Math.max, that's a nice way of doing it!
Stephen Woods
@stephenwoods
Aug 14 2015 21:02
If anyone was curious about the answer to my bonfire issue I was having above, it was because sort was using the first element of the array, which was the number instead of the description.
ALINATSUI
@ALINATSUI
Aug 14 2015 21:02
Hey @Coira. Yeah, i mean, using this method should be easy...
Lightwaves
@Lightwaves
Aug 14 2015 21:05

@ALINATSUI that is a good way of doing it. Going to give you a few hints.
first Math.max.apply returns the largest element in an array.
currently you are trying to do it on an array of arrays. you want each individual array in that nested array.

you are going to have to store the value Math.max.apply returns and put it somewhere.

Look at what the bonfire specifically wants for you to return.

You are on the right track good job!

Coira Ellison
@Coira
Aug 14 2015 21:08
@ALINATSUI also, have a look at the mdn page on Math.max(), as your missing a small thing when you call it
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 21:08
@cjstewart13 Oh, I think I misunderstood you. You want the function to return the largest element in each of the arrays, right? So you are expecting '[5, 27, 39, 1001]'?
Also, if you're new to programming languages, my advice would be to implement your own function to return the largest element in an array, and then use it in your code.
Lightwaves
@Lightwaves
Aug 14 2015 21:14
^^^
ALINATSUI
@ALINATSUI
Aug 14 2015 21:37
thanks @cjstewart13
CamperBot
@camperbot
Aug 14 2015 21:37
alinatsui sends brownie points to @cjstewart13 :sparkles: :thumbsup: :sparkles:
hey @alinatsui if you found this info helpful :point_right: consider adding a wiki article!
ALINATSUI
@ALINATSUI
Aug 14 2015 21:38
@coira I've spent some time at the Math.max page, but what else was I missing?
Coira Ellison
@Coira
Aug 14 2015 21:38
@ALINATSUI I tried it using Math.max.apply(null, newArr) which worked for me
Christopher Stewart
@cjstewart13
Aug 14 2015 21:38
@arturts YeahThats what coria helped with using the Array.push() method. Thank you for your help!
Coira Ellison
@Coira
Aug 14 2015 21:39
@ALINATSUI did you get it working without null?
Dayne Wright
@daynewright
Aug 14 2015 21:40
Hey guys… Looking for a little help on just understanding a few things :)
function findLongestWord(str) {
    var newArr = str.split(' ');
    var holder = '';
    newArr.filter(function(word){
           if(word.length > holder.length){
               holder = word;
           }
        return holder;
    });
  return holder.length;
}

findLongestWord('The quick brown fox jumped over the lazy dog’);
I am just confused how I can get the answer on holder.length when it is returned through the filter.
I thought that it would make that newArr
Coira Ellison
@Coira
Aug 14 2015 21:42
@Daynewr don't use filter, use forEach (or a plain for loop)
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 21:42
@ALINATSUI remember that Math.max() takes integers as input, not an array. To use an array, you have to do like @Coira said.
Dayne Wright
@daynewright
Aug 14 2015 21:42
@Coira I am going back through these and trying to use FP to just understand it more
Juan Martínez
@jbmartinez
Aug 14 2015 21:43
anyone completed Get Set for Basejumps?
ALINATSUI
@ALINATSUI
Aug 14 2015 21:43
@Coira, I didn't quite understand what null means.
Coira Ellison
@Coira
Aug 14 2015 21:43
@Daynewr ah, use forEach then, filter removes (or adds? can't remember off the top of my head) items when your passed in function returns true
ALINATSUI
@ALINATSUI
Aug 14 2015 21:43
thanks arturts
Dayne Wright
@daynewright
Aug 14 2015 21:44
@Coira ahh..that makes sense. So if it returns true it adds it. Got it. Ok
That would be why all of the items still end up in the array
Coira Ellison
@Coira
Aug 14 2015 21:45
@Daynewr and you don't need to return holder, as you declared it out of the filter loop, so it still exists when it's finished
Mike Taylor
@sealocal
Aug 14 2015 21:45
Is there an appropriate place to share a job description with campers?
Dayne Wright
@daynewright
Aug 14 2015 21:45
ok
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 21:46
@Daynewr while your method works, it's better practice to use a for loop, or forEach for readability! :)
Dayne Wright
@daynewright
Aug 14 2015 21:46
@arturts definitely understand.
Coira Ellison
@Coira
Aug 14 2015 21:46
@ALINATSUI have you done the object oriented stuff on udacity yet? it gets explained there (better than I could do), all to do with js's strange context stuff
Dayne Wright
@daynewright
Aug 14 2015 21:47
Just trying to go through these and see how it works with functional programming. Maybe not the best for some of these.
ALINATSUI
@ALINATSUI
Aug 14 2015 21:47
nope, I didn't do the udacity yet. All in good time I guess.
Cody Bouscaren
@codybousc
Aug 14 2015 21:48

Hi all, I'm a bit confused what Bonfire #28, Convert HTML entities is asking me to do. If you run the initial code given, the tests are

assert.strictEqual(convert('Dolce & Gabbana'), 'Dolce & Gabbana', 'should escape characters');should escape characters: expected 'Dolce & Gabbana' to equal 'Dolce & Gabbana'

assert.strictEqual(convert('Hamburgers < Pizza < Tacos'), 'Hamburgers < Pizza < Tacos', 'should escape characters');should escape characters: expected 'Hamburgers < Pizza < Tacos' to equal 'Hamburgers < Pizza < Tacos'

assert.strictEqual(convert('Sixty > twelve'), 'Sixty > twelve', 'should escape characters');should escape characters: expected 'Sixty > twelve' to equal 'Sixty > twelve'

assert.strictEqual(convert('Stuff in "quotation marks"'), 'Stuff in "quotation marks"', 'should escape characters');should escape characters: expected 'Stuff in "quotation marks"' to equal 'Stuff in "quotation marks"'

assert.strictEqual(convert("Shindler's List"), 'Shindler's List', 'should escape characters');should escape characters: expected 'Shindler\'s List' to equal 'Shindler's List'

assert.strictEqual(convert('<>'), '<>', 'should escape characters');should escape characters: expected '<>' to equal '<>'

The only 'altered' output that I see is the second to last Shindler's List test. I'm obviously missing something. Any insight?

Coira Ellison
@Coira
Aug 14 2015 21:49
@Daynewr I think it's a good idea
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 21:49
Dayne Wright
@daynewright
Aug 14 2015 21:51
@Coira Thanks. I can see how fitler adds no value over forEach in how I have it written now.
Cody Bouscaren
@codybousc
Aug 14 2015 21:52
This message was deleted
Coira Ellison
@Coira
Aug 14 2015 21:53
This message was deleted
CamperBot
@camperbot
Aug 14 2015 21:53
Sorry, can't find a bonfire called convert html entiets. [ Check the map? ]
Coira Ellison
@Coira
Aug 14 2015 21:54
bonfire convert html entities
CamperBot
@camperbot
Aug 14 2015 21:54

:fire:Bonfire: Convert HTML Entities :link:

function convert(str) {
  // &colon;&rpar;
  return str;
}

convert('Dolce & Gabbana');

Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities.

more info:  bf details | bf links | hint

Coira Ellison
@Coira
Aug 14 2015 21:54
@codybousc replace the characters with the html codes
Cody Bouscaren
@codybousc
Aug 14 2015 21:56

@Coira something like this?

function convert(str) {
  for(var i = 0; i < str.length; i++){
      if (str[i] === "&") {
         var charIndex = str.indexOf(str[i]);
         var splitStr = str.split("");
         if(charIndex !== -1) {
             splitStr[charIndex] = "&#38"; 
             var newStr = splitStr.join("");
         }  
  }
}
  return newStr;
}

console.log(convert('Dolce & Gabbana'));

This returns "Dolce &#38 Gabbana"

And so far only tests for "&"
Coira Ellison
@Coira
Aug 14 2015 21:57
& would be replaced with &
& amp ;
without spaces
Cody Bouscaren
@codybousc
Aug 14 2015 21:58
replaced with itself?
Coira Ellison
@Coira
Aug 14 2015 21:58
& amp ;
under the column html name
Cody Bouscaren
@codybousc
Aug 14 2015 22:00

@Coira like this?

function convert(str) {
  for(var i = 0; i < str.length; i++){
      if (str[i] === "&") {
         var charIndex = str.indexOf(str[i]);
         var splitStr = str.split("");
         if(charIndex !== -1) {
             splitStr[charIndex] = "& amp ;"; 
             var newStr = splitStr.join("");
         }  
  }
}
  return newStr;
}

console.log(convert('Dolce & Gabbana'));

This function returns "Dolce & amp ; Gabbana"

I'm sorry, but I'm super confused
Coira Ellison
@Coira
Aug 14 2015 22:01
whenever i paste the code in here it gets replaced with it's character!
Cody Bouscaren
@codybousc
Aug 14 2015 22:02
i think you have to paste it within the three ` deals
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:03
@codybousc I think you don't need charIndex at all, since you already have i
no need for the nested if statement, too
Coira Ellison
@Coira
Aug 14 2015 22:05
ok, remove the spaces before and after amp
that's the string your meant to replace & with
Cody Bouscaren
@codybousc
Aug 14 2015 22:06
@arturts first things first! i'm still trying to figure out what to replace & with
@Coira , when i do that the function returns 'Dolce &amp Gabbana'
Coira Ellison
@Coira
Aug 14 2015 22:07
does it pass the first test?
Cody Bouscaren
@codybousc
Aug 14 2015 22:08

@Coira

function convert(str) {
  for(var i = 0; i < str.length; i++){
      if (str[i] === "&") {
         var charIndex = str.indexOf(str[i]);
         var splitStr = str.split("");
         if(charIndex !== -1) {
             splitStr[charIndex] = "&amp";; 
             var newStr = splitStr.join("");
         }  
  }
}
  return newStr;
}

console.log(convert('Dolce & Gabbana'));

This is what you're saying I should do, yes?

Coira Ellison
@Coira
Aug 14 2015 22:08
yeah i think so, that's the string i used in my solution
oh, one of the semi-colons needs to be in the quotes
Cody Bouscaren
@codybousc
Aug 14 2015 22:09
pheeeew
@Coira thank you
Coira Ellison
@Coira
Aug 14 2015 22:09
np, that one was a pain!
Cody Bouscaren
@codybousc
Aug 14 2015 22:10
the tests were a little deceiving
yeah, i've got a few more characters to go!
Christopher Stewart
@cjstewart13
Aug 14 2015 22:12
Hey I'm working on bf repeat a string. I have no idea why my code won't work
function repeat(str, num) {
  // repeat after me
 if (num >= 0) {
    str = str.repeat(num);
  }else{
    return "";
  }
  return str;
}

repeat('abc', 3);
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:14
@cjstewart13 try giving another name to your function
Christopher Stewart
@cjstewart13
Aug 14 2015 22:16

@arturts Tried that. Still gives me this same error

undefined is not a function (evaluating 'str.repeat(num)')

the argument for repeat should be referencing the num argument in repeat
Coira Ellison
@Coira
Aug 14 2015 22:17
huh, i tried your code out, works fine for me
Christopher Stewart
@cjstewart13
Aug 14 2015 22:17
Really? thats weird
Coira Ellison
@Coira
Aug 14 2015 22:17
maybe browser problem? i tried in chrome and ffox
Rich Churcher
@richchurcher
Aug 14 2015 22:17
Repeat is an ES6 function which your browser might not implement...
Christopher Stewart
@cjstewart13
Aug 14 2015 22:18
ahhh. so safari is the bad egg
in the spirit of the exercise, should I figure out another way to do it?
I was wondering why the set up was so easy.....
Coira Ellison
@Coira
Aug 14 2015 22:19
more loops I guess
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:20
@cjstewart13 At a first glance, I would just concatenate the string n times
Do you guys know if javascript have '+=', '*=', '/=' etc syntax to strings/numbers? I'm more of a python guy
Juan Martínez
@jbmartinez
Aug 14 2015 22:22
hi!
fares red
@fareshnd
Aug 14 2015 22:22
hi
Juan Martínez
@jbmartinez
Aug 14 2015 22:23
anyone completed get set for basejumps?
@arturts yes, it has
Clayton
@cjg040103
Aug 14 2015 22:24
what's wrong here?
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}
function list() {
    var contactsLength = contacts.length;
    for(var i = 0; i < contactsLength; i++) {
        printPerson(contacts[i]);
}
list();
the list function specifically
fares red
@fareshnd
Aug 14 2015 22:24
how we can change the widh of image (keep it smaller .like 100px ) tell me the code please
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:24
@cjg040103 you forgot a closing bracket
Clayton
@cjg040103
Aug 14 2015 22:25
im stupid
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:25
@cjg040103 heheh no, you're not. Happens all the time
Clayton
@cjg040103
Aug 14 2015 22:25
@arturts thanks!
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:25
@cjg040103 no problem!
Josh Cronkhite
@joshcronkhite
Aug 14 2015 22:26
Hey campers! Bonfire: Spinal Tap Case bugged? It looks like the data being tested includes things like “thisisspinaltap”. This is technically one word as spaces denote words, right? So we are failing the test that asks us to replace spaces with dashes. Anyone else experience this or can confirm this is a bug? Maybe we don’t understand the instructions? I thought they were pretty clear. @Karnblack
Liz Rezes
@queenlizo
Aug 14 2015 22:27
@joshcronkhite it's not a bug. You can solve it to meet all of the requirements
dormouss
@dormouss
Aug 14 2015 22:27
Hi folks. I'd like to test my TeamViewer setup. I asked in the TeamViewer room but no one seems to be around. Anyone here care to help?
Josh Cronkhite
@joshcronkhite
Aug 14 2015 22:30
Thanks, @queenlizo! The instructions read, "Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.” So if “thisisspinaltap” is passed, there are no words that provide spaces to replace with dashes? What am I missing here from an instruction standpoint. I don’t want the answer, just some clarity on the instructions if possible.
CamperBot
@camperbot
Aug 14 2015 22:30
joshcronkhite sends brownie points to @queenlizo :sparkles: :thumbsup: :sparkles:
hey @joshcronkhite if you found this info helpful :point_right: consider adding a wiki article!
Mike Berry
@Karnblack
Aug 14 2015 22:31
@queenlizo @joshcronkhite It seems that you have to hard-code some words into your code so it will pass that specific test.
Coira Ellison
@Coira
Aug 14 2015 22:31
@joshcronkhite I don't have a "thisisspinaltap" test, but i do have a "thisIsSpinalTap" test (i.e. upper case)
Liz Rezes
@queenlizo
Aug 14 2015 22:32
@Karnblack nope. You can do it without doing that
Just use your regular expressions
Josh Cronkhite
@joshcronkhite
Aug 14 2015 22:33
@Coira Ah! I think we were looking at the string converted to lowercase, not the initial value. Smacking head now. Thanks for the help!
fares red
@fareshnd
Aug 14 2015 22:33
please help me please
Mike Berry
@Karnblack
Aug 14 2015 22:34
Thanks! @queenlizo Thanks! @Coira
CamperBot
@camperbot
Aug 14 2015 22:34
karnblack sends brownie points to @queenlizo and @coira :sparkles: :thumbsup: :sparkles:
hey @karnblack if you found this info helpful :point_right: consider adding a wiki article!
Liz Rezes
@queenlizo
Aug 14 2015 22:34
@Karnblack no problem!
@joshcronkhite yep!
Coira Ellison
@Coira
Aug 14 2015 22:35
:) np, and thanks for the brownie points!
fares red
@fareshnd
Aug 14 2015 22:35
howa we change the width of image
for keep it smaller
Coira Ellison
@Coira
Aug 14 2015 22:36
hi @fareshnd what code do you have so far?
Cody Bouscaren
@codybousc
Aug 14 2015 22:36
@Coira any clue how to check for multiple occurrences of a symbol?
Coira Ellison
@Coira
Aug 14 2015 22:36
are you using regex?
Cody Bouscaren
@codybousc
Aug 14 2015 22:36
i probably should be
Nic Galluzzo
@ngalluzzo
Aug 14 2015 22:37
cuz I’m a /g
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:37
@codybousc I think it's + or *, if you're using regex
Coira Ellison
@Coira
Aug 14 2015 22:38
oh yeah + or * if the symbols next to each other
or /g like @ngalluzzo said to check the whole string :)
Cody Bouscaren
@codybousc
Aug 14 2015 22:38
@arturts @Coira Ok, i think i'm going to have to redo the whole thing using regex
i've just kind of avoiding learning the regex so far and generally goog it when i really need it
Coira Ellison
@Coira
Aug 14 2015 22:39
I used replace, but I don't know if that's an optimal solution
fares red
@fareshnd
Aug 14 2015 22:39
'<style> .larger-image { width: 500px; } </style>.'
Coira Ellison
@Coira
Aug 14 2015 22:40
This message was deleted
fares red
@fareshnd
Aug 14 2015 22:41
<style> .smaller-image { width: 100px; } </style>. why it's not corect
???
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:41
@codybousc heheh that's what I've been doing so far. I'm definitely not a fan of regex.
Coira Ellison
@Coira
Aug 14 2015 22:41
so something like str.replace(/&/g, "newstr");
Cody Bouscaren
@codybousc
Aug 14 2015 22:45
so no need to loop through the string?
there's one benefit to using regex!
Omar
@oab00
Aug 14 2015 22:45
@fareshnd did u add the smaller-image class to the html img ?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:45
@codybousc what is the exercise asking you to do?
Cody Bouscaren
@codybousc
Aug 14 2015 22:46
it's Bonfire#28
"Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities."
but there are multiple occurrences of a few of the characters
fares red
@fareshnd
Aug 14 2015 22:47
yes
i add
Omar
@oab00
Aug 14 2015 22:48
can u copy the code here?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:48
@codybousc If you do like @Coira said, there's no need to loop.
fares red
@fareshnd
Aug 14 2015 22:48
yes
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:49
@codybousc though there are loops involved behind the curtains.
Cordoba84
@fcordoba84
Aug 14 2015 22:49

´´´

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}

.smaller-image {
width: 100px;
}
</style>

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

<p> <a href='#'><img src='https://bit.ly/fcc-kittens'></a>.</p>

<img class='smaller-image thick-green-border' src='https://bit.ly/fcc-kittens'/>

<p class='red-text'>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'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
´´´

fares red
@fareshnd
Aug 14 2015 22:49
<img class='smaller-image'/> <style> .larger-image { width: 500px; } </style>.`
Cordoba84
@fcordoba84
Aug 14 2015 22:50
can any one tell me how can i make the picture a link with out adding another pic with link
Cody Bouscaren
@codybousc
Aug 14 2015 22:50
@arturts i'm definitely going to try the .replace/regex approach!
seems to be the most straightforward approach
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:51
@fcordoba84 Do you mean without the "<a href='#'> ..."?
Cordoba84
@fcordoba84
Aug 14 2015 22:52
with the # but i get two images in display just want one to show off dont know why is duplicating the image @arturts
i apologyze if dont explain my self right new athis coding
Omar
@oab00
Aug 14 2015 22:52
@fareshnd where's .smaller-image inside style?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:52
@codybousc yeah, that's one of the cases where I think using regex is ok. Looping would probably make the code too cluttered
Cordoba84
@fcordoba84
Aug 14 2015 22:53
yes @arturts
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:53
@fcordoba84 take a look at the line below the '<a>' tag, you have another '<img>' tag with the same image
fares red
@fareshnd
Aug 14 2015 22:57
thank
i solved the problm (...)
Cordoba84
@fcordoba84
Aug 14 2015 22:57
ty @arturts
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 22:58
@fcordoba84 no problem!
fares red
@fareshnd
Aug 14 2015 22:58
@oab00 thaks
Omar
@oab00
Aug 14 2015 22:59
np :)
dormouss
@dormouss
Aug 14 2015 22:59
Well, this is a little frustrating... I need to put a "g" after a regex to make it match all the patterns. But that's not what the template in the documentation shows. It shows the flags coming after everything else.
Or I'm reading the documentation wrong. Which is also a distinct possibility.
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:01
@dormouss what is the documentation you're talking about?
dormouss
@dormouss
Aug 14 2015 23:02
@arturts The MDN documentation for String.prototype.replace().
The syntax at the top says: str.replace(regexp|substr, newSubStr|function[, flags])
Moisés Man
@moigithub
Aug 14 2015 23:03
| <-- bar means OR
[] <-- means optional
dormouss
@dormouss
Aug 14 2015 23:03
And apparently, to get my regex to work, I need to add a /g flag after regexp.
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:04
@dormouss "Note: The flags argument does not work in v8 Core (Chrome and Node.js)."
dormouss
@dormouss
Aug 14 2015 23:04
Right. So I would interpret that to mean that the g should come at the end of the function call.
Moisés Man
@moigithub
Aug 14 2015 23:04
/[a-z]/g
"urstring".replace(/[a-z]/g, "X")
dormouss
@dormouss
Aug 14 2015 23:05
The way I'm reading the syntax, it should be: "urstring".replace(/[a-z], "X", g) <-- note the g at the end, after another comma in the list of parameters passed to the replace function.
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:05
Yes, but the flags argument is deprecated
see the thumbsdown next to 'flags' in the documentation
dormouss
@dormouss
Aug 14 2015 23:07
So my regex
'''
var iPalindromeI = str.toLowerCase().replace(/\W+/, '')
'''
only matches the first non-character.
CamperBot
@camperbot
Aug 14 2015 23:07
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Aug 14 2015 23:07
that syntax with 3rd param (flag) have a ! (bang) saying its not standarized
dormouss
@dormouss
Aug 14 2015 23:07

So my regex

 var iPalindromeI = str.toLowerCase().replace(/\W+/, '')

only matches the first non-character.

Moisés Man
@moigithub
Aug 14 2015 23:07
add g after last /
dormouss
@dormouss
Aug 14 2015 23:08
But where is that documented? That's my quandry.
Moisés Man
@moigithub
Aug 14 2015 23:08
thats regex
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:08
There are two icons next to the 'flags' parameter doc
place your mouse over them
your cursor, I mean
or whatever they're called in english, idk hahah
dormouss
@dormouss
Aug 14 2015 23:10
Maybe I'm using the wrong terminology? What's the term for the "g" that follows the closing slash in the regex?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:11
it is a flag, but you should include it in your regex pattern, and not on the flags parameter
dormouss
@dormouss
Aug 14 2015 23:11
Ah. So this is a regex thing I'm missing, unrelated to .replace()?
viznev
@viznev
Aug 14 2015 23:11
@dormouss global search flag
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:12
not exactly, different languages will use different methods to implement regex
viznev
@viznev
Aug 14 2015 23:12
@arturts are you saying that in reference to what I'm saying?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:13
sometimes methods get deprecated, or the parameter flags in this case
dormouss
@dormouss
Aug 14 2015 23:13
However, I just noticed a link to the JavaScript/ECMAscript regex notes, and its syntax is new RegExp(pattern[, flags])
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:13
@viznev I was replying to @dormouss , sorry heheh
dormouss
@dormouss
Aug 14 2015 23:13
Understanding has dawned, a little.
viznev
@viznev
Aug 14 2015 23:13
@arturts np! was just wondering haha
dormouss
@dormouss
Aug 14 2015 23:13
I need to attach the /g flag to the regex, not to the replace().
I think I got it. The lesson is, RTFM. :)
Thanks everyone for your help.
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:14
@dormouss 'Literal and constructor notations are possible:'
so, you could use '/<your regex here>/<your flags here>' or use the constructor like 'new RegExp(pattern[, flags])'
@dormouss heheh great!
dormouss
@dormouss
Aug 14 2015 23:15
How do I send brownie points?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:16
what's that?
Omar
@oab00
Aug 14 2015 23:16
thanks @oab00
CamperBot
@camperbot
Aug 14 2015 23:16
sorry oab00, you can't send brownie points to yourself! :sparkles: :sparkles:
Omar
@oab00
Aug 14 2015 23:16
:sob:
dormouss
@dormouss
Aug 14 2015 23:17
thanks @arturts @viznev @moigithub
CamperBot
@camperbot
Aug 14 2015 23:17
dormouss sends brownie points to @arturts and @viznev and @moigithub :sparkles: :thumbsup: :sparkles:
hey @dormouss if you found this info helpful :point_right: consider adding a wiki article!
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:18
oh hehehe
viznev
@viznev
Aug 14 2015 23:18
that's kinda cool haha
Cody Bouscaren
@codybousc
Aug 14 2015 23:34
@arturts any idea how to check for "<>" ?
in a string?
or anyone else?
viznev
@viznev
Aug 14 2015 23:37
@codybousc using a regex?
Cody Bouscaren
@codybousc
Aug 14 2015 23:38
@viznev yes please
viznev
@viznev
Aug 14 2015 23:40
@codybousc well /<>/g should work
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:42
for anyone using regex: https://regex101.com/ is pretty cool
Cody Bouscaren
@codybousc
Aug 14 2015 23:43
@viznev this would probably be much easier if i actually knew how to use regex, but i don't. soooo, i've also got to catch it with conditionals which is proving to be difficult. Any thoughts on how to catch it?
function convert(str) {
    for(var i = 0; i < str.length; i++) {
         if(str[i] === "&") {
          var newStr = str.replace(/&/g, "&amp;"); 
        }
         else if (str[i] === "<" && str[i + 1] === ">") {
          var newStr = str.replace(/<>/g, "Tbone"); 
       }
        else if (str[i] === "<") {
          var newStr = str.replace(/</g, "&lt;"); 
        }
        else if (str[i] === ">") {
          var newStr = str.replace(/>/g, "&gt;"); 
       }  
       else if (str.indexOf('"') >= 0) {
          var newStr = str.replace(/['"]+/g, "&quot;");
       }
       else if (str.indexOf("'") >= 0) {
          var newStr = str.replace(/'/g, '&apos;');
       }

    }
  return newStr;
}

console.log(convert("Tommy <> Suzzy Rick"));
so far all of them work except for the <>
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:44
@codybousc you don't need to test if a certain character is '&' or '<', etc
@codybousc you can just use the replace
Cody Bouscaren
@codybousc
Aug 14 2015 23:45
@arturts with one long regex statement?
viznev
@viznev
Aug 14 2015 23:45
@codybousc do you have to do else if?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:45
@codybousc one for each case
viznev
@viznev
Aug 14 2015 23:45
@codybousc you could catch 'em all if you just did if
Cody Bouscaren
@codybousc
Aug 14 2015 23:45
@viznev what do you mean?
@arturts i'm a bit lost here!
viznev
@viznev
Aug 14 2015 23:46
@codybousc nvm, I see what you're doing now, that won't work
Cody Bouscaren
@codybousc
Aug 14 2015 23:46
aren't i using one for each case?
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:47
@codybousc I think you can even chain the .replace()'s like
var result = str.replace(<your regex and replacement here>).replace(<your regex and replacement here>).replace(<your regex and replacement here>);
Richard Viramontes
@rviramontes
Aug 14 2015 23:47
Does anyone know if screen hero will work with wine on Linux and the website says I need an invite if anyone wants to send me o e it would
Sorry if an
Moisés Man
@moigithub
Aug 14 2015 23:47
using "g" flag on regex will replace all ocurrences of whatever regex u replacing....
"hello world".replace(/l/g, "X") <-- will return "heXXo worXd"
so no need to iterate (for/loop) on al ur characters
Cody Bouscaren
@codybousc
Aug 14 2015 23:48
@arturts huh
Richard Viramontes
@rviramontes
Aug 14 2015 23:48
Send me one*
SojournerOctocat
@SojournerOctocat
Aug 14 2015 23:48
@rviramontes I don't know if it works on Wine. If it doesn't, you can use TeamViewer or sites like kobra.io
viznev
@viznev
Aug 14 2015 23:48
@rviramontes last I saw it doesn't have linux support still
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:49
@codybousc and I'm not even sure if the chain of .replace()'s are needed at all, I wonder if there is a way to replace them all at once.
Cody Bouscaren
@codybousc
Aug 14 2015 23:50
@arturts i bet you can write one kick ass regex statement that would do it. that would take me several hours of study to figure out regex though ;)
Moisés Man
@moigithub
Aug 14 2015 23:52
another way instead chain replace.. would be using callback... and check the characters inside the CB
Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:53
@codybousc hah I actually avoid regex at all costs with the excuse that 'regex can take exponential time', because I'm too lazy to use it
Moisés Man
@moigithub
Aug 14 2015 23:53
"hello world".replace(/[lo]/g,function(a){
   // console.log(a);
    switch (a) {
        case "l":
            return "L";
            break;
        case "o":
            return "O";
            break;
    }
})
CamperBot
@camperbot
Aug 14 2015 23:53

welcome to FreeCodeCamp @moigithub!

Artur de Oliveira Tsuda
@arturts
Aug 14 2015 23:54
@moigithub Ah ha! that's a great idea
viznev
@viznev
Aug 14 2015 23:55
@codybousc the reason it's doing that is because it's still evaluating the rest of the string, so it completely resets the variable every single time
This message was deleted
function convert(str) {
    for(var i = 0; i < str.length; i++) {
        if(str[i] === "&") {
          str = str.replace(/&/g, "&amp;"); 
        } else if (str[i] === "<" && str[i + 1] === ">") {
          str = str.replace(/<>/g, "Tbone"); 
        } else if (str[i] === "<") {
          str = str.replace(/</g, "&lt;"); 
        } else if (str[i] === ">") {
          str = str.replace(/>/g, "&gt;"); 
        } else if (str.indexOf('"') >= 0) {
          str = str.replace(/['"]+/g, "&quot;");
        } else if (str.indexOf("'") >= 0) {
          str = str.replace(/'/g, '&apos;');
        }
    }
  return str;
}

console.log(convert("Tommy <> Suzzy Rick"));
but I don't think that's the best way that the search and replace should be done, there is very likely a much better way of doing it
Christopher Stewart
@cjstewart13
Aug 14 2015 23:59
I'm working on bf mutations and I'm able to compare my arrays, but it looks like it is only returning the boolean on the first array item on "split2"
function mutation(arr) {

  //so search doesn't think 'a' and 'A' aren't the same
  var lowerCase1 = arr[0].toLowerCase();
  var lowerCase2 = arr[0].toLowerCase();
  //creates the arrays to compare
  var split1 = arr[0].split("");
  var split2 = arr[1].split("");
  //gives starting point for search
  var search = split1.indexOf(split2[0], 0);

  for (i = 0; i < split2.length; i++) {
    search = split1.indexOf(split2[i], 0);
    if (search === -1) {
      return false;
    }else{
      return true;
    }
  }
  return search;
}

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